/* * Compile: * cc -m32 test.c -o test * * Prepare testfile: * fallocate -l 4294967297 large-file * * Test: * ./test large-file * * Result: * Correct: open() fails, exit code 2 * Incorrect: Prints an incorrect file size * * Observation: * Correct on ext4/btrfs * Incorrect on NFS/tmpfs */ #include #include #include #include #include static_assert(sizeof(void *) == 4, "This test only makes sense on 32bit"); static_assert(sizeof(off_t) == 4, "Large file support has to be disabled"); int main(int argc, char **argv) { if (argc != 2) return 1; int fd = open(argv[1], O_RDONLY); if (fd == -1) return 2; off_t fsize = lseek(fd, 0, SEEK_END); printf("file size=%lu\n", fsize); }