Back to index

glibc  2.9
Defines | Functions | Variables
tst-aio64.c File Reference
#include <aio.h>
#include <errno.h>
#include <error.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <test-skeleton.c>

Go to the source code of this file.

Defines

#define _LARGEFILE_SOURCE   1
#define PREPARE   do_prepare
#define TIMEOUT   20 /* sec */

Functions

void do_prepare (int argc, char *argv[])
int do_test (int argc, char *argv[])
static int test_file (const void *buf, size_t size, int fd, const char *msg)
static int do_wait (struct aiocb64 **cbp, size_t nent, int allowed_err)

Variables

char * name
int fd

Define Documentation

#define _LARGEFILE_SOURCE   1

Definition at line 21 of file tst-aio64.c.

#define PREPARE   do_prepare

Definition at line 36 of file tst-aio64.c.

#define TIMEOUT   20 /* sec */

Definition at line 39 of file tst-aio64.c.


Function Documentation

void do_prepare ( int  argc,
char *  argv[] 
)
int do_test ( int  argc,
char *  argv[] 
)

Definition at line 146 of file test-lfs.c.

{
  int ret;
  struct stat64 statbuf;

  ret = lseek64 (fd, TWO_GB+100, SEEK_SET);
  if (ret == -1 && errno == ENOSYS)
    {
      error (0, 0, "lseek64 is not supported.");
      exit (EXIT_SUCCESS);
    }
  if (ret == -1 && errno == EINVAL)
    {
      error (0, 0, "LFS seems not to be supported.");
      exit (EXIT_SUCCESS);
    }
  if (ret == -1)
    {
      error (0, errno, "lseek64 failed with error");
      exit (EXIT_FAILURE);
    }

  ret = write (fd, "Hello", 5);
  if (ret == -1 && errno == EFBIG)
    {
      error (0, 0, "LFS seems not to be supported.");
      exit (EXIT_SUCCESS);
    }

  if (ret == -1 && errno == ENOSPC)
    {
      error (0, 0, "Not enough space to write file.");
      exit (EXIT_SUCCESS);
    }

  if (ret != 5)
    error (EXIT_FAILURE, errno, "cannot write test string to large file");

  ret = close (fd);

  if (ret == -1)
    error (EXIT_FAILURE, errno, "error closing file");

  ret = stat64 (name, &statbuf);

  if (ret == -1 && (errno == ENOSYS || errno == EOVERFLOW))
    error (0, 0, "stat64 is not supported.");
  else if (ret == -1)
    error (EXIT_FAILURE, errno, "cannot stat file `%s'", name);
  else if (statbuf.st_size != (TWO_GB + 100 + 5))
    error (EXIT_FAILURE, 0, "stat reported size %lld instead of %lld.",
          (long long int) statbuf.st_size, (TWO_GB + 100 + 5));

  test_ftello ();

  return 0;
}
static int do_wait ( struct aiocb64 **  cbp,
size_t  nent,
int  allowed_err 
) [static]

Definition at line 106 of file tst-aio64.c.

{
  int go_on;
  size_t cnt;
  int result = 0;

  do
    {
      aio_suspend64 ((const struct aiocb64 *const *) cbp, nent, NULL);
      go_on = 0;
      for (cnt = 0; cnt < nent; ++cnt)
       if (cbp[cnt] != NULL)
         {
           if (aio_error64 (cbp[cnt]) == EINPROGRESS)
             go_on = 1;
           else
             {
              if (aio_return64 (cbp[cnt]) == -1
                  && (allowed_err == 0
                     || aio_error64 (cbp[cnt]) != allowed_err))
                {
                  error (0, aio_error64 (cbp[cnt]), "Operation failed\n");
                  result = 1;
                }
              cbp[cnt] = NULL;
             }
         }
    }
  while (go_on);

  return result;
}
static int test_file ( const void *  buf,
size_t  size,
int  fd,
const char *  msg 
) [static]

Definition at line 68 of file tst-aio64.c.

{
  struct stat st;
  char tmp[size];

  errno = 0;
  if (fstat (fd, &st) < 0)
    {
      error (0, errno, "%s: failed stat", msg);
      return 1;
    }

  if (st.st_size != (off_t) size)
    {
      error (0, errno, "%s: wrong size: %lu, should be %lu",
            msg, (unsigned long int) st.st_size, (unsigned long int) size);
      return 1;
    }

  if (pread (fd, tmp, size, 0) != (ssize_t) size)
    {
      error (0, errno, "%s: failed pread", msg);
      return 1;
    }

  if (memcmp (buf, tmp, size) != 0)
    {
      error (0, errno, "%s: failed comparison", msg);
      return 1;
    }

  printf ("%s test ok\n", msg);

  return 0;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 47 of file tst-aio64.c.

char* name

Definition at line 46 of file tst-aio64.c.