fixed formatting
[tridge/junkcode.git] / largefiletest.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <errno.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8
9 /*
10   try to determine if the filesystem supports large files
11 */
12 static int large_file_support(const char *path)
13 {
14         int fd;
15         ssize_t ret;
16         char c;
17
18         fd = open(path, O_RDWR|O_CREAT, 0600);
19         unlink(path);
20         if (fd == -1) {
21                 /* have to assume large files are OK */
22                 return 1;
23         }
24         ret = pread(fd, &c, 1, ((unsigned long long)1)<<32);
25         close(fd);
26         return ret == 0;
27 }
28
29 int main(int argc, const char *argv[])
30 {
31         int s = large_file_support(argv[1]);
32         printf("sizeof(off_t)=%d s=%d\n", sizeof(off_t), s);
33         return 0;
34 }