>>-ftrunc--fd--file_size---------------------------------------><
Function
ftrunc invokes the ftrunc callable service to change the
size of the file identified by the file descriptor.
Parameters
- fd
- The file descriptor (a number) for the file.
- file_size
- The new size of the file, in bytes.
Usage notes
- The ftrunc service changes the file size to file_size bytes,
beginning at the first byte of the file. If the file was previously
larger than file_size, all data from file_size to
the original end of the file is removed. If the file was previously
shorter than file_size, bytes between the old and new lengths
are read as zeros.
- Full blocks are returned to the file system so that they can be
used again, and the file size is changed to the lesser of file_size or
the current length of the file.
- The file offset is not changed.
Example
In the following example, assume that
fd was assigned
a value earlier in the exec. To truncate
fd to
0 bytes:
"ftrunc" fd 0