4 #ifndef TST_POSIX_FALLOCATE64
9 # error no O_LARGEFILE but you want to test with LFS enabled
13 static void do_prepare (void);
14 #define PREPARE(argc, argv) do_prepare ()
15 static int do_test (void);
16 #define TEST_FUNCTION do_test ()
17 #include <test-skeleton.c>
23 fd = create_temp_file ("tst-posix_fallocate.", NULL);
26 printf ("cannot create temporary file: %m\n");
37 if (fstat64 (fd, &st) != 0)
39 puts ("1st fstat failed");
45 puts ("file not created with size 0");
49 if (posix_fallocate (fd, 512, 768) != 0)
51 puts ("1st posix_fallocate call failed");
55 if (fstat64 (fd, &st) != 0)
57 puts ("2nd fstat failed");
61 if (st.st_size != 512 + 768)
63 printf ("file size after 1st posix_fallocate call is %llu, expected %u\n",
64 (unsigned long long int) st.st_size, 512u + 768u);
68 if (posix_fallocate (fd, 0, 1024) != 0)
70 puts ("2nd posix_fallocate call failed");
74 if (fstat64 (fd, &st) != 0)
76 puts ("3rd fstat failed");
80 if (st.st_size != 512 + 768)
82 puts ("file size changed in 2nd posix_fallocate");
86 if (posix_fallocate (fd, 2048, 64) != 0)
88 puts ("3rd posix_fallocate call failed");
92 if (fstat64 (fd, &st) != 0)
94 puts ("4th fstat failed");
98 if (st.st_size != 2048 + 64)
100 printf ("file size after 3rd posix_fallocate call is %llu, expected %u\n",
101 (unsigned long long int) st.st_size, 2048u + 64u);
104 #ifdef TST_POSIX_FALLOCATE64
105 if (posix_fallocate64 (fd, 4097ULL, 4294967295ULL + 2ULL) != 0)
107 puts ("4th posix_fallocate call failed");
111 if (fstat64 (fd, &st) != 0)
113 puts ("5th fstat failed");
117 if (st.st_size != 4097ULL + 4294967295ULL + 2ULL)
119 printf ("file size after 4th posix_fallocate call is %llu, expected %llu\n",
120 (unsigned long long int) st.st_size, 4097ULL + 4294967295ULL + 2ULL);