chsize(2xnx) (XENIX System Compatibility)
chsize --
(XENIX) change the size of a file
Synopsis
cc [flag . . . ] flag . . . -lx
int chsize(int fildes, long size);
Description
fildes is a file descriptor obtained from a create,
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 routine 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 allocated disk blocks between size
and the initial file size are freed.
The maximum file size as set by
ulimit(2)
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 values
Upon successful completion, a value of 0 is returned.
Otherwise, the value -1 is returned and errno
is set to indicate the error.
References
creat(2),
dup(2),
lseek(2),
open(2),
pipe(2),
ulimit(2)
Notices
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 some cases, reducing the file size may not remove
the data beyond the new end-of-file.
30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.