truncate(2) System Calls Manual truncate(2) truncate, ftruncate - C (libc, -lc) #include int truncate(const char *path, off_t length); int ftruncate(int fd, off_t length); glibc (. feature_test_macros(7)): truncate(): _XOPEN_SOURCE >= 500 || /* glibc 2.12: */ _POSIX_C_SOURCE >= 200809L || /* glibc <= 2.19: */ _BSD_SOURCE ftruncate(): _XOPEN_SOURCE >= 500 || /* Since glibc 2.3.5: */ _POSIX_C_SOURCE >= 200112L || /* glibc <= 2.19: */ _BSD_SOURCE truncate() ftruncate() , path fd, , length ( ). If the file previously was larger than this size, the extra data is lost. If the file previously was shorter, it is extended, and the extended part reads as null bytes ('\0'). . , st_ctime st_mtime ( , ; inode(7)) , set-user-ID set-group-ID . ftruncate() ; truncate() . 0. -1, errno . truncate(): EACCES , ( path_resolution(7)). EFAULT path , . EFBIG The argument length is larger than the maximum file size. (XSI) ENOSPC There is not enough space left on the device for extending the file size to the given length. EINTR ; fcntl(2) signal(7). EINVAL length . EIO (inode) /. EISDIR . ELOOP pathname . ENAMETOOLONG 255 , 1023 . ENOENT . ENOTDIR . EPERM . EPERM (file seal); fcntl(2). EROFS , . ETXTBSY , . ftruncate() , , , path, , fd: EBADF fd . EBADF EINVAL fd . EINVAL fd POSIX. EINVAL EBADF fd . POSIX (Linux EINVAL). XSI- . XSI- POSIX ftruncate(), length (, truncate() ): , . UNIX, Linux XSI, . , truncate() ftruncate() : , Linux VFAT. 32- , syscall(2). POSIX.1-2024. POSIX.1-2001, SVr4, 4.2BSD. truncate() ftruncate() Linux . , Linux 2.4 truncate64() ftruncate64() . , glibc, , . ftruncate() POSIX; shm_open(3). - glibc 2.12 _POSIX_C_SOURCE, ftruncate(), 200809L 200112L. glibc . truncate(1), open(2), stat(2), path_resolution(7) () Azamat Hackimov , Dmitry Bolkhovskikh , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () . Linux man-pages 6.18 12 2026 . truncate(2)