cchhssiizzee() -- System Call (libc)

Change the size of a file
iinntt cchhssiizzee(_f_d, _s_i_z_e);
iinntt _f_d; lloonngg _s_i_z_e;

The COHERENT  system call cchhssiizzee() changes the size  of the file associated
with the  file descriptor  _f_d to  be exactly _s_i_z_e  bytes long.  If  _s_i_z_e is
larger than the  file's initial size, then cchhssiizzee() pads  the file with the
appropriate number  of extra  bytes.  If _s_i_z_e  is smaller than  the initial
size, then  _c_h_s_i_z_e() frees all  allocated disk blocks between  _s_i_z_e and the
initial size.   The maximum file  size as set  by uulliimmiitt() is  in force for
calls to cchhssiizzee().

With a  successful call, cchhssiizzee()  returns 0; otherwise, it  returns -1 and
sets eerrrrnnoo to an appropriate value.

_S_e_e _A_l_s_o
lliibbcc, ooppeenn(), uulliimmiitt()

_N_o_t_e_s
When you  use cchhssiizzee() to  shorten a file,  COHERENT frees all  disk blocks
beyond the new  end-of-file mark.  However, it does not  zero out the bytes
beyond the new  end-of-file in the last allocated disk  block.  If you wish
to obliterate a file, simply using  cchhssiizzee() to reset its size to zero will
_n_o_t do the trick.

When you use cchhssiizzee() to lengthen  a file, the new bytes beyond the initial
size are  simply those bytes that  were in the final  disk block beyond the
original end-of-file  marker.  All additional  bytes beyond that  point are
zeroes.   The file  system will  not actually allocate  new disk  blocks to
accomodate the  new file size,  but rather will  create one or  more sparse
blocks.

The term _s_p_a_r_s_e _b_l_o_c_k refers to  the fact that in the COHERENT file system,
a disk  block that  would be all  zeroes need not  take up a  physical disk
block.  Rather, COHERENT marks the i-node to indicate that the block is all
zeroes, but  does not allocate a  physical block.  This saves  space on the
disk.

A _s_p_a_r_s_e _f_i_l_e, is a file that contains one or more sparse blocks.  The file
system handles sparse files correctly; however, the command ffsscckk may return
the error message

    Possible File Size Error

for them.

If you lengthen  a file with cchhssiizzee(), you may  create a sparse file, which
may in turn cause ffsscckk to complain.
