FTRUNCATE(2,L) AIX Technical Reference FTRUNCATE(2,L)
-------------------------------------------------------------------------------
ftruncate, truncate
PURPOSE
Makes a file shorter.
SYNTAX
int ftruncate (fildes, length) int truncate (path,length)
int fildes; char *path;
off_t length; off_t length;
DESCRIPTION
The ftruncate and truncate system calls remove all data beyond length bytes
from the beginning of the file. The truncate system call operates on the file
specified in the path parameter. The ftruncate operates on the open file
specified by the fildes parameter. Full blocks are returned to the file system
so that they can be used again, and the file size is changed to the value of
the length parameter. For ftruncate, however, if the file was opened with
O_DEFERC, changes can be undone with fabort.
The ftruncate system call does not modify the seek pointer of the file.
If the length parameter is greater than the size of the file, the file size is
not changed. Successful completion of the ftruncate or truncate system call
clears the set-user-ID and set-group-ID attributes of the file.
RETURN VALUE
Upon successful completion, ftruncate and truncate return a value of 0. If
ftruncate or truncate fails, a value of -1 is returned and errno is set to
indicate the error.
ERROR CONDITIONS
The ftruncate and truncate system calls fail if one or more of the following
are true:
EIO I/O error.
EINVAL The file is a directory, FIFO, or special file.
EAGAIN The write operation in ftruncate failed due to an enforced write lock
on the file.
Processed November 7, 1990 FTRUNCATE(2,L) 1
FTRUNCATE(2,L) AIX Technical Reference FTRUNCATE(2,L)
The ftruncate system call fails if the following are true:
EBADF fildes is not a valid file descriptor open for writing.
The truncate system call fails if the following are true:
ENOTDIR A component of the path prefix is not a directory.
ENOENT The named file does not exist.
EACCES A component of the path prefix denies search permission.
EACCES Write permission is denied for the named file.
EISDIR The named file is a directory.
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.
EFAULT The path parameter points to a location outside of the process's
allocated address space.
ENFILE The system file table or inode table is full.
ENAMETOOLONG
A component of the path parameter exceeded NAME_MAX characters or the
entire path parameter exceeded PATH_MAX characters.
ENOENT A directory in the path prefix does not exist.
ENOENT A hidden directory was named, but no component inside it matched the
process's current site path list.
ENOENT A symbolic link was named, but the file to which it refers does not
exist.
ELOOP A loop of symbolic links was detected.
If the Transparent Computing Facility is installed on your system, ftruncate
can also fail if one or more of the following are true:
ESITEDN1 The storage site is down or in the case of ftruncate, has gone down
since this file descriptor was issued.
ESITEDN2 The operation was terminated because a site failed.
If the Transparent Computing Facility is installed on your system, truncate can
also fail if one or more of the following are true:
Processed November 7, 1990 FTRUNCATE(2,L) 2
FTRUNCATE(2,L) AIX Technical Reference FTRUNCATE(2,L)
ENOSTORE path is a name relative to the working directory, but no site which
stores this directory is currently up.
ENOSTORE A component of path is replicated but not stored on any site which is
currently up.
EROFS Write access is requested for a file on a replicated file system in
which the primary copy is unavailable.
ENLDEV The named file is a non-tty character special file which corresponds
to a device physically attached to another site in the cluster.
EINTR A signal was caught during the truncate system call.
RELATED INFORMATION
In this book: "fclear."
Processed November 7, 1990 FTRUNCATE(2,L) 3