When an application is compiled with _FILE_OFFSET_BITS 64 feature test macro, then all old 32-bit interface system calls (like creat/open/lseek, etc) will be replaced with new 64-bit interface system calls (like creat64/open64/lseek64,etc). So, the creat() call in my application creates a large file (size > 2GB). But, is it possible to create the small file (size <= 2GB) using same application compiled with _FILE_OFFSET_BITS 64?.
How to create a small file (size <= 2GB) file using application compiled with _FILE_OFFSET_BITS 64?
103 Views Asked by Rik At
2
You could write a
creat
wrapper function which is specifically compiled with-D_FILE_OFFSET_BITS=32
. This would give you a file descriptor which is limited to 32-bit file sizes. However, this only works with certain 32-bit environments.There is also
RLIMIT_FSIZE
, which can be set usingsetrlimit
, but I have no idea how reliable it is.