Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ftruncate(2) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open(2)



truncate(2)                   4 BSD                   truncate(2)



NAME
     truncate, ftruncate - truncate a file to a specified length

SYNOPSIS
     int truncate (path, length)
     char *path;
     int length;

     int ftruncate (fd, length)
     int fd, length;

DESCRIPTION
     truncate or ftruncate causes the file named by path or
     referenced by fd to be truncated to at most length bytes in
     size.  If the file previously was larger than this size, the
     extra data is lost.  With ftruncate, the file must be open
     for writing.  If fd references a memory object, ftruncate
     sets the size of the memory object to length.

RETURN VALUES
     A value of 0 is returned if the call succeeds.  If the call
     fails a -1 is returned, and the global variable errno speci-
     fies the error.

ERRORS
     truncate succeeds unless:

     [ENOENT]       The pathname was too long.

     [ENOTDIR]      A component of the path prefix of path is not
                    a directory.

     [ENOENT]       The named file does not exist.

     [EACCES]       A component of the path prefix denies search
                    permission.

     [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]       Name points outside the process's allocated
                    address space.

     Ftruncate succeeds unless:

     [EBADF]        The fd is not a valid descriptor.




Page 1                        CX/UX Programmer's Reference Manual





truncate(2)                   4 BSD                   truncate(2)



     [EINVAL]       The fd references a socket, not a file.

SEE ALSO
     open(2), shmopen(3P4)

BUGS
     Partial blocks discarded as the result of truncation are not
     zero filled; this can result in holes in files which do not
     read as zero.

     These calls should be generalized to allow ranges of bytes
     in a file to be discarded.











































Page 2                        CX/UX Programmer's Reference Manual



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026