Back to index

glibc  2.9
Defines | Functions | Variables
tst-truncate.c File Reference
#include <errno.h>
#include <error.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <test-skeleton.c>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define TRUNCATE   truncate
#define FTRUNCATE   ftruncate
#define STRINGIFY(s)   STRINGIFY2 (s)
#define STRINGIFY2(s)   #s
#define PREPARE   do_prepare
#define TIMEOUT   20 /* sec */
#define FNAME   FNAME2(TRUNCATE)
#define FNAME2(s)   "/" STRINGIFY(s) "XXXXXX"

Functions

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

Variables

char * name
int fd

Define Documentation

#define FNAME   FNAME2(TRUNCATE)
#define FNAME2 (   s)    "/" STRINGIFY(s) "XXXXXX"
#define FTRUNCATE   ftruncate

Definition at line 31 of file tst-truncate.c.

#define PREPARE   do_prepare

Definition at line 42 of file tst-truncate.c.

#define STRINGIFY (   s)    STRINGIFY2 (s)

Definition at line 34 of file tst-truncate.c.

#define STRINGIFY2 (   s)    #s

Definition at line 35 of file tst-truncate.c.

#define TIMEOUT   20 /* sec */

Definition at line 45 of file tst-truncate.c.

#define TRUNCATE   truncate

Definition at line 30 of file tst-truncate.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;
}

Variable Documentation

Definition at line 52 of file tst-truncate.c.

char* name

Definition at line 51 of file tst-truncate.c.