Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ truncate(2) — HP-UX 7.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open(2)

TRUNCATE(2)

NAME

truncate, ftruncate − truncate a file to a specified length

SYNOPSIS

truncate(path, length)
char *path;
unsigned long length;

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

DESCRIPTION

Truncate 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; for truncate the user must have write permission for the file. 

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 specifies the error. 

ERRORS

Truncate succeeds unless:

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

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

[EACCES] Write permission is denied on the 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] Path points outside the process’s allocated address space.  The reliable detection of this error will be implementation dependent. 

[ELOOP] Too many symbolic links were encountered in translating the path name. 

[ENAMETOOLONG]
The length of the specified path name exceeds PATH_MAX bytes, or the length of a component of the path name exceeds NAME_MAX bytes while _POSIX_NO_TRUNC is in effect. 

Ftruncate succeeds unless:

[EBADF] The fd is not a valid descriptor. 

[EINVAL] The fd references a file that was opened without write permission. 

AUTHOR

Truncate was developed by the University of California, Berkeley California, Computer Science Division, Department of Electrical Engineering and Computer Science. 

SEE ALSO

open(2). 

Hewlett-Packard Company  —  HP-UX Release 7.0: Sept 1989

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