Esempio n. 1
0
int
do_test (int argc, char *argv[])
{
  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;
}
Esempio n. 2
0
int
do_test (int argc, char *argv[])
{
  int ret, fd2;
  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);
    }
  off64_t offset64 = lseek64 (fd, 0, SEEK_CUR);
  if (offset64 != TWO_GB + 100)
    {
      error (0, 0, "lseek64 did not return expected offset");
      exit (EXIT_FAILURE);
    }
  off_t offset = lseek (fd, 0, SEEK_CUR);
  if (sizeof (off_t) < sizeof (off64_t))
    {
      if (offset != -1 || errno != EOVERFLOW)
	{
	  error (0, 0, "lseek did not fail with EOVERFLOW");
	  exit (EXIT_FAILURE);
	}
    }
  else
    if (offset != TWO_GB + 100)
      {
	error (0, 0, "lseek did not return expected offset");
	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));

  fd2 = openat64 (AT_FDCWD, name, O_RDWR);
  if (fd2 == -1)
    {
      if (errno == ENOSYS)
	{
	  /* Silently ignore this test.  */
	  error (0, 0, "openat64 is not supported");
	}
      else
	error (EXIT_FAILURE, errno, "openat64 failed to open big file");
    }
  else
    {
      ret = close (fd2);

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

  test_ftello ();

  return 0;
}