Files
oldlinux-files/study/Ref-docs/syscalls/syscalls_16.html
2024-02-19 00:25:23 -05:00

48 lines
1.9 KiB
HTML

<html><!-- This HTML file has been created by texi2html 1.29
from syscalls.texi on 4 June 1994 -->
<TITLE>Syscall specifications of Linux - ftruncate</TITLE>
<P>Go to the <A HREF="syscalls_15.html" tppabs="http://www.infran.ru/TechInfo/syscalls/syscalls_15.html">previous</A>, <A HREF="syscalls_17.html" tppabs="http://www.infran.ru/TechInfo/syscalls/syscalls_17.html">next</A> section.<P>
<H2><A NAME="SEC16" HREF="syscalls_toc.html#SEC16" tppabs="http://www.infran.ru/TechInfo/syscalls/syscalls_toc.html#SEC16">ftruncate and truncate</A></H2>
<P>
<H3>SYNOPSIS</H3>
<P>
<CODE>int ftruncate(int <VAR>fd</VAR>, size_t <VAR>length</VAR>);</CODE>
<P>
<CODE>int truncate(char *<VAR>path</VAR>, size_t <VAR>length</VAR>);</CODE>
<P>
<H3>DESCRIPTION</H3>
<P>
Those calls truncate a file to a specified length. In the case of
<CODE>ftruncate</CODE>, the file must be opened for writing.
<P>
<H3>PARAMETERS</H3>
<P>
<VAR>fd</VAR>: [in] the file descriptor to truncate.
<P>
<VAR>path</VAR>: [in] points to the path of the file to truncate.
<P>
<VAR>length</VAR>: [in] the new size of the file.
<P>
<H3>RETURN VALUE</H3>
<P>
On success zero is returned. On error, -1 is returned and <CODE>errno</CODE> is
set to one of the following values:
<P>
for <CODE>ftruncate</CODE>:
<P>
<UL>
<LI><CODE>ENOENT</CODE>: the file is invalid.
<LI><CODE>EBADF</CODE>, <CODE>EACCESS</CODE>.
</UL>
<P>
for <CODE>truncate</CODE>:
<P>
<UL>
<LI><CODE>ENOTDIR</CODE>, <CODE>EINVAL</CODE>, <CODE>ENAMETOOLONG</CODE>, <CODE>ENOENT</CODE>,
<CODE>EACCESS</CODE>, <CODE>ELOOP</CODE>, <CODE>EISDIR</CODE>, <CODE>EROFS</CODE>,
<CODE>ETXTBSY</CODE>, <CODE>EIO</CODE> or <CODE>EFAULT</CODE>.
</UL>
<P>
<P>Go to the <A HREF="syscalls_15.html" tppabs="http://www.infran.ru/TechInfo/syscalls/syscalls_15.html">previous</A>, <A HREF="syscalls_17.html" tppabs="http://www.infran.ru/TechInfo/syscalls/syscalls_17.html">next</A> section.<P>