truncate(2) DG/UX 4.30 truncate(2)
NAME
truncate - Truncate a file to a specified length.
SYNOPSIS
int truncate (path, length)
char * path;
long length;
PARAMETERS
path Address of a pathname.
length Maximum length of file after truncation.
DESCRIPTION
Truncate causes the file named by <path> to be truncated to
at most <length> bytes in size. If <path> refers to a
symbolic link, the target of the symbolic link is truncated.
The subject file must reside on a file system device mounted
read-write. Also, it must not be a directory. If mandatory
locking is enabled on the file, truncate will wait until all
locks on the file are cleared.
If an error occurs, no changes occur. Otherwise, the
subject file is changed with the following consequences:
* For files of type `ordinary-disk-file', if the file's
size is greater than <length> bytes, it is truncated to
that length, and the file's size is updated.
* If the file's size is already less than or equal to
<length> or the file is not of type `ordinary-disk-
file', neither its contents nor its size are altered.
* The `time-last-modified' and `time-last-changed'
attributes are set to the current time. These
attributes are changed even if there is no change to
the file's contents.
ACCESS CONTROL
The calling process must have permission to resolve <path>.
The calling process must have write access to the file.
RETURN VALUE
0 The file was successfully truncated.
-1 An error occurred. Errno is set to indicate
the error.
Licensed material--property of copyright holder(s) Page 1
truncate(2) DG/UX 4.30 truncate(2)
EXCEPTIONS
Errno may be set to one of the following error codes:
EACCES Write permission is denied for the named
file.
EISDIR The named file is a directory.
EROFS The named file resides on a file system
device mounted read-only.
ETXTBSY The file is a pure procedure (shared text)
file that is being executed.
ENOENT The file the pathname resolved to does not
exist.
ENOENT A non-terminal component of the pathname does
not exist.
ENOTDIR A non-terminal component of the pathname was
not a directory or symbolic link.
ENAMETOOLONG The pathname exceeds the length limit for
pathnames.
ENAMETOOLONG A component of the pathname exceeds the
length limit for filenames.
ENOMEM There are not enough system resources to
resolve the pathname or to expand a symbolic
link.
ELOOP The number of symbolic links encountered
during pathname resolution exceeded
MAXSYMLINKS. A symbolic link cycle is
suspected.
EPERM The pathname contains a character not in the
allowed character set.
Licensed material--property of copyright holder(s) Page 2
truncate(2) DG/UX 4.30 truncate(2)
EFAULT The pathname does not completely reside in
the process's address space or the pathname
does not terminate in the process's address
space.
EINTR The truncate system call was interrupted
while waiting for a mandatory record lock to
clear.
SEE ALSO
The related manual sections: creat(2), ftruncate(2),
open(2).
STANDARDS
When using m88kbcs as the Software Development Environment
target, the truncate function will be emulated using BCS
system calls. Since this emulation uses the open system
call, a failure will occur if all file descriptors are in
use. In this case, errno will be set to EMFILE. Also,
since this is an emulation requiring several BCS system
calls, a slight performance degradation may be noticed in
comparison to using truncate in /lib/libc.a.
Licensed material--property of copyright holder(s) Page 3