Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ftruncate(3C) — svr4 — mips UMIPS RISC/os 5.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fcntl(2)

open(2)



TRUNCATE(3C-SVR4)   RISC/os Reference Manual    TRUNCATE(3C-SVR4)



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

SYNOPSIS
     #include <unistd.h>

     int truncate (const char *path, offt length);

     int ftruncate (int fildes, offt length);

DESCRIPTION
     The file whose name is given by path or referenced by the
     descriptor fildes has its size set to length bytes.

     If the file was previously longer than length, bytes past
     length will no longer be accessible.  If it was shorter,
     bytes from the EOF before the call to the EOF after the call
     will be read in as zeros.  The effective user ID of the pro-
     cess must have write permission for the file, and for ftrun-
     cate the file must be open for writing.

     truncate fails if one or more of the following are true:

     EACCES            Search permission is denied on a component
                       of the path prefix.

     EACCES            Write permission is denied for the file
                       referred to by path.

     EFAULT            path points outside the process's allo-
                       cated address space.

     EINTR             A signal was caught during execution of
                       the truncate routine.

     EINVAL            path is not an ordinary file.

     EIO               An I/O error occurred while reading from
                       or writing to the file system.

     EISDIR            The file referred to by path is a direc-
                       tory.

     ELOOP             Too many symbolic links were encountered
                       in translating path.

     EMFILE            The maximum number of file descriptors
                       available to the process has been reached.

     EMULTIHOP         Components of path require hopping to mul-
                       tiple remote machines and file system type
                       does not allow it.



                        Printed 11/19/92                   Page 1





TRUNCATE(3C-SVR4)   RISC/os Reference Manual    TRUNCATE(3C-SVR4)



     ENAMETOOLONG      The length of a path component exceeds
                       {NAME_MAX} characters, or the length of
                       path exceeds {PATH_MAX} characters.

     ENFILE            Could not allocate any more space for the
                       system file table.

     ENOENT            Either a component of the path prefix or
                       the file referred to by path does not
                       exist.

     ENOLINK           path points to a remote machine and the
                       link to that machine is no longer active.

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

     EROFS             The file referred to by path resides on a
                       read-only file system.

     ETXTBSY           The file referred to by path is a pure
                       procedure (shared text) file that is being
                       executed.

     ftruncate fails if one or more of the following are true:

     EAGAIN            The file exists, mandatory file/record
                       locking is set, and there are outstanding
                       record locks on the file [see chmod(2)].

     EBADF             fildes is not a file descriptor open for
                       writing.

     EINTR             A signal was caught during execution of
                       the ftruncate routine.

     EIO               An I/O error occurred while reading from
                       or writing to the file system.

     ENOLINK           fildes points to a remote machine and the
                       link to that machine is no longer active.

     EINVAL            fildes does not correspond to an ordinary
                       file.

SEE ALSO
     fcntl(2), open(2)

DIAGNOSTICS
     Upon successful completion, a value of 0 is returned.  Oth-
     erwise, a value of -1 is returned and errno is set to indi-
     cate the error.



 Page 2                 Printed 11/19/92



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