Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
truncate(2)							   truncate(2)

Name
       truncate, ftruncate - truncate a	file to	a specified length

Syntax
       truncate(path, length)
       char *path;
       int length;

       ftruncate(fd, length)
       int fd, length;

Description
       The system call causes the file named by	path or	referenced by fd to be
       truncated to, at	most, length bytes in size.  If	 the  file  previously
       was  larger than	this size, the extra data is lost.  With the file must
       be open for writing.

Return Values
       A value of zero (0) is returned if the  call  succeeds.	 If  the  call
       fails,  a  -1  is returned, and the global variable errno specifies the
       error.

Restrictions
       Partial blocks discarded	as the result  of  truncation  are  not	 zero-
       filled. This can	result in holes	in files that do not read as zero.

Diagnostics
       The system call succeeds	unless:

       [ENOTDIR]      A	component of the path prefix is	not a directory.

       [ENOENT]	      The named	file does not exist.

       [EACCES]	      Search  permission is denied for a component of the path
		      prefix.

       [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) file that  is
		      being executed.

       [EFAULT]	      The  path	points outside the process's allocated address
		      space.

       [ENAMETOOLONG] A	component of a pathname	exceeded 255 characters, or an
		      entire path name exceeded	1023 characters.

       [ELOOP]	      Too  many	symbolic links were encountered	in translating
		      the pathname.

       [EIO]	      An I/O error occurred updating the inode.

       The system call succeeds	unless:

       [EBADF]	      The fd is	not a valid descriptor.

       [EINVAL]	      The fd references	a socket, not a	file.

       [ETIMEDOUT]    A	connect	 request  or  remote  file  operation  failed,
		      because  the  connected  party  did not properly respond
		      after a period of	time that is dependent on the communi-
		      cations protocol.

See Also
       open(2)

								   truncate(2)

Name | Syntax | Description | Return Values | Restrictions | Diagnostics | See Also

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=truncate&sektion=2&manpath=ULTRIX+4.2>

home | help