Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ chsize(S) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

creat(S)

dup(S)

lseek(S)

open(S)

pipe(S)

ulimit(S)


 chsize(S)                      6 January 1993                      chsize(S)


 Name

    chsize - changes the size of a file

 Syntax


    cc  . . .  -lx


    int chsize (fildes, size)
    int fildes;
    long size;


 Description

    fildes is a file descriptor obtained from a creat, open, dup, fcntl, or
    pipe system call.  chsize changes the size of the file associated with
    the file descriptor fildes to be exactly size bytes in length.  The rou-
    tine either truncates the file, or pads it with an appropriate number of
    bytes.  If size is less than the initial size of the file, then all allo-
    cated disk blocks between size and the initial file size are freed.

    The maximum file size as set by ulimit(S) is enforced when chsize is
    called, rather than on subsequent writes.  Thus chsize fails, and the
    file size remains unchanged if the new changed file size would exceed the
    ulimit.

 Return value

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

 Notes

    In general if chsize is used to expand the size of a file, when data is
    written to the end of the file, intervening blocks are filled with zeros.
    In a few rare cases, reducing the file size may not remove the data
    beyond the new end-of-file.  This routine must be linked with the linker
    option -lx.

 See also

    creat(S), dup(S), lseek(S), open(S), pipe(S), ulimit(S)

 Standards conformance

    chsize is an extension of AT&T System V provided by the Santa Cruz Opera-
    tion.


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