Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ truncate(3C) — UnixWare 2.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fcntl(2)

open(2)






       truncate(3C)                                            truncate(3C)


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

       SYNOPSIS
             #include <unistd.h>
             int truncate (const char *path, off_t length);
             int ftruncate (int fildes, off_t 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 process must
             have write permission for the file, and for ftruncate the file
             must be open for writing.

          Return Values
             Upon successful completion, a value of 0 is returned.
             Otherwise, a value of -1 is returned and errno is set to
             indicate the error.

          Errors
             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 allocated
                               address space.

             EFBIG             An attempt is made to write a file that
                               exceeds the process's file size limit or the
                               maximum file size [see getrlimit(2) and
                               ulimit(2)].

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





                           Copyright 1994 Novell, Inc.               Page 1













      truncate(3C)                                            truncate(3C)


            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 directory.

            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
                              multiple remote machines and file system
                              type does not allow it.

            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)].



                          Copyright 1994 Novell, Inc.               Page 2













       truncate(3C)                                            truncate(3C)


             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.

       REFERENCES
             fcntl(2), open(2)































                           Copyright 1994 Novell, Inc.               Page 3








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