sys_truncate  [fs/open.c]


Truncates a file to the specified length.

Arguments

eax 92
ebx Pointer to a null-terminated string specifying the name of the file to truncate. The file must be writable.
ecx Number of bytes to truncate. If the file size is smaller that this value, it will be extended by this number of bytes.

Return values

If the system call succeeds the return value is 0.
If the system call fails the return value is one of the following errno values:

-EACCES Search permission is denied for a component of the path prefix, or the named file is not writable by the user.
-EFAULT ebx points outside the process's allocated address space.
-EFBIG The argument ecx is larger than the maximum file size. (XSI)
-EINTR A signal was caught during execution.
-EINVAL The argument ecx is negative or larger than the maximum file size.
-EIO An I/O error occurred updating the inode.
-EISDIR The named file is a directory.
-ELOOP Too many symbolic links were encountered in translating the pathname.
-ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire pathname exceeded 1023 characters.
-ENOENT The named file does not exist.
-ENOTDIR A component of the path prefix is not a directory.
-EPERM The underlying file system does not support extending a file beyond its current size.
-EROFS The named file resides on a read-only file system.
-ETXTBSY The file is a pure procedure (shared text) file that is being executed.

Remarks

The file offset is not changed.

Some non-native file systems do not permit sys_truncate to be used to extend a file beyond its current length: a notable example on Linux is VFAT.

Compatibility

n/a