truncate(2)
_________________________________________________________________
truncate System Call
Truncate a file to a specified length.
_________________________________________________________________
SYNTAX
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>.
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
truncate(2)
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.
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
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)
truncate(2)
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.
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).
DG/UX 4.00 Page 3
Licensed material--property of copyright holder(s)