The ftruncate service changes the size of a file. The file is identified by its file descriptor.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1FTR): | 31-bit |
AMODE (BPX4FTR): | 64-bit |
ASC mode: | Primary mode |
Interrupt status: | Enabled for interrupts |
Locks: | Unlocked |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
|
AMODE 64 callers use BPX4FTR with the same parameters.
The name of a fullword that contains the file descriptor of the file whose size is to be changed.
The name of a doubleword that contains the number of bytes the file is to contain after its size has been changed.
This field is a doubleword to accommodate large files. For normal processing with a singleword value, propagate the sign bit through the second word, so that the final doubleword value has a valid sign. The ftruncate service accepts only positive values.
The name of a fullword in which the ftruncate service returns 0 if the request is successful, or -1 if it is not successful.
Return_code | Explanation |
---|---|
EBADF | The File_descriptor parameter does not specify a valid, open file. |
EINVAL | The file is not a regular file; it is opened Read Only; or the File_length specified is negative. The following reason codes can accompany the return code: JRTrNegOffset, JRTrNotRegFile, and JRTrOpenedRO. |
EROFS | The specified file is on a read-only file system. The following reason code can accompany the return code: JRTrMountedRO. |
EFBIG | The File_length parameter is greater than the maximum file size limit for the process. The following reason code can accompany the return code: JRWriteBeyondLimit. |
The name of a fullword in which the ftruncate service stores the reason code. The ftruncate service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes.
The file specified must be a regular file, open for writing.
For an example using this callable service, see BPX1FTR (ftruncate) example.