Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

spt_ftruncatez(2) OSS System Calls Reference Manual
NAME
spt_ftruncatez - Changes file length (thread-aware version)
LIBRARY
H-series and J series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
#include <sys/types.h>
#include <spthread.h>
int spt_ftruncatez(
int filedes,
off_t length);
PARAMETERS
filedes Specifies the descriptor of a file that must be open for writing.
length Specifies the new length of the file in bytes.
DESCRIPTION
The spt_ftruncatez() is a thread-aware version of the ftruncate( ) function.
The spt_ftruncatez() function changes the length of a file to the size, in bytes, specified by the
length parameter.
If the new length is less than the previous length, the spt_ftruncatez() function removes all data
beyond length bytes from the specified file. All file data between the new EOF and the previous
EOF is discarded.
If the new length is greater than the previous length, zeros are added between the previous EOF
and the new EOF.
Full blocks are returned to the fileset so that they can be used again, and the file size is changed
to the value of the length parameter.
The spt_ftruncatez() function has no effect on First-in, First-out (FIFO) special files. This func-
tion does not modify the seek pointer of the file. If spt_ftruncatez() is called for a FIFO file, the
call fails, and errno is set to [EINVAL].
Upon successful completion, the spt_ftruncatez( ) function marks the st_ctime and st_mtime
fields of the file for update. If the file is a regular le, the spt_ftruncatez() function clears the
S_ISUID and S_ISGID attributes of the file.
NOTES
The spt_ftruncatez() function offers an alternative to the O_SYNC file status flag. Using
spt_ftruncatez( ) calls gives an application control over the performance tradeoffs involved in
guaranteeing data integrity. OSS file-system caching can be used for files that are protected only
by spt_ftruncatez( ) function calls.
This function is thread-aware: if this function must wait for an I/O operation to complete on an
open file, this function blocks the thread that called it (instead of the entire process), while it
waits for the I/O operation to complete.
This function serializes file operations on an open file. If a thread calls spt_ftruncatez() to
access a file that already has a file operation in progress by a different thread, this thread is
blocked until the prior file operation is complete.
7252 Hewlett-Packard Company 527186-023