TRUNCATE(2) 1990 TRUNCATE(2) NNAAMMEE truncate - truncate a file to a specified length SSYYNNOOPPSSIISS ttrruunnccaattee((ppaatthh,, lleennggtthh)) cchhaarr **ppaatthh;; ooffff__tt lleennggtthh;; ffttrruunnccaattee((ffdd,, lleennggtthh)) iinntt ffdd;; ooffff__tt lleennggtthh;; DDEESSCCRRIIPPTTIIOONN _T_r_u_n_c_a_t_e causes the file named by _p_a_t_h or referenced by _f_d to be truncated to at most _l_e_n_g_t_h bytes in size. If the file previously was larger than this size, the extra data is lost. With _f_t_r_u_n_c_a_t_e, the file must be open for writing. RREETTUURRNN VVAALLUUEESS A value of 0 is returned if the call succeeds. If the call fails a -1 is returned, and the global variable _e_r_r_n_o speci- fies the error. EERRRROORRSS _T_r_u_n_c_a_t_e succeeds unless: [ENOTDIR] A component of the path prefix is not a directory. [EINVAL] The pathname contains a character with the high-order bit set. [ENAMETOOLONG] A component of a pathname exceeded 255 char- acters, or an entire path name exceeded 1023 characters. [ENOENT] The named file does not exist. [EACCES] Search permission is denied for a component of the path prefix. [EACCES] The named file is not writable by the user. [ELOOP] Too many symbolic links were encountered in translating the pathname. [EISDIR] The named file is a directory. [EROFS] The named file resides on a read-only file system. [ETXTBSY] The file is a pure procedure (shared text) Printed 7/27/90 June 1 TRUNCATE(2) 1990 TRUNCATE(2) file that is being executed. [EIO] An I/O error occurred updating the inode. [EFAULT] _P_a_t_h points outside the process's allocated address space. _F_t_r_u_n_c_a_t_e succeeds unless: [EBADF] The _f_d is not a valid descriptor. [EINVAL] The _f_d references a socket, not a file. [EINVAL] The _f_d is not open for writing. SSEEEE AALLSSOO open(2) BBUUGGSS These calls should be generalized to allow ranges of bytes in a file to be discarded. Printed 7/27/90 June 2