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?
138 Views Asked by Rik At
2
There are 2 best solutions below
3
Florian Weimer
On
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 using setrlimit, but I have no idea how reliable it is.
Related Questions in LINUX
- Is there some way to use printf to print a horizontal list of decrementing hex digits in NASM assembly on Linux
- Why does Hugo generate different taxonomy-related HTML on different OS's?
- Writes in io_uring do not advance the file offset
- Why `set -o pipefail` gives different output even though the pipe is not failing
- what really controls the permissions: UID or eUID?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Docker container unable to make HTTPS requests to external API
- Whow to use callback_query_handler in Python 3.10
- Create kea runtime directory at startup in Yocto image
- Problem on CPU scheduling algorithms in OS
- How to copy files into the singularity sandbox?
- Android kernel error: undefined reference to `get_hw_version_platform'
- Is there a need for BPF Linux namespace?
- Error when trying to execute a binary compiled in a Kali Linux machine on an Ubuntu system
- Issue with launching application after updating ElectronJs to version 28.0.0 on Windows and Linux
Related Questions in POSIX
- Is it safe to assume 8-bit char on Linux and FreeBSD, based on POSIX?
- How many senders and receivers of a notification are possible in a POSIX message queue
- Does opendir() / FindFirstFile() get a snapshot of a directory?
- Differences in behavior of kill(pid, SIGINT) between Debian and Red Hat based distros
- select() always returns 0 Serial Port (UART) vxWorks
- some questions about posix_trace_* function
- In LDAP: Differentiating via OU or via attribute?
- recvmsg returns EAGAIN after select reports file descriptor is ready
- Can close of pipe's write end fail leaving reading process blocked?
- Why, on Linux (specifically Ubuntu 20.04 LTS), a POSIX shared memory object survives reboot and then suddenly belongs to the "root" user?
- file.tell() after a write is not correct in append mode?
- Map UNIX "nobody" and "nogroup" to Win32 Accounts/SIDs?
- POSIX Message Queue - "Message too long" on send
- Does the POSIX Standard really mean that a non-thread safe function can break the thread-safety of every other function?
- awk dot in regex doesn't match space
Related Questions in POSIX-API
- Is there a way to increment a semaphore and decrement another one atomically in POSIX?
- what is the use of using shm_open and mmap together?
- Opening a semaphore return 0
- Order of declarations in Posix structs -- is it guaranteed?
- What are the possible values of _POSIX_TIMERS?
- Is there any standard way to get creation time of file or directory in FreeBSD programatically
- Azure Sphere UART no reading 0x00 from serial device
- Thread Program on Linux (Posix Thread)
- call I use mq_send or msgsnd from inside a signal handler
- POSIX API and SOLID design principles
- How can I find out which systemcall(s) that a POSIX API invoked in Linux?
- How to create a small file (size <= 2GB) file using application compiled with _FILE_OFFSET_BITS 64?
- What is timer_t at its base?
- How does shell preserve command file input line boundary?
- Getting X display variables in current running process using c++
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
No, it doesn't.
creat()always creates an empty file (or truncates an existing file).