OSDN Git Service

Revert the following change to correct the mail address of the committer
[linuxjm/jm.git] / manual / LDP_man-pages / original / man2 / truncate.2
index bb261fa..64b8288 100644 (file)
@@ -1,6 +1,7 @@
 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
 .\" All rights reserved.
 .\"
+.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
 .\" are met:
@@ -28,6 +29,7 @@
 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
+.\" %%%LICENSE_END
 .\"
 .\"     @(#)truncate.2 6.9 (Berkeley) 3/10/91
 .\"
@@ -38,7 +40,7 @@
 .\" Modified 2002-04-06 by Andries Brouwer <aeb@cwi.nl>
 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
 .\"
-.TH TRUNCATE 2 2009-02-28 "Linux" "Linux Programmer's Manual"
+.TH TRUNCATE 2 2013-04-01 "Linux" "Linux Programmer's Manual"
 .SH NAME
 truncate, ftruncate \- truncate a file to a specified length
 .SH SYNOPSIS
@@ -55,12 +57,24 @@ Feature Test Macro Requirements for glibc (see
 .BR feature_test_macros (7)):
 .in
 .ad l
+.PD 0
 .sp
 .BR truncate ():
-_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
+.RS 4
+_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
+_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
 .br
+|| /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
+.RE
+.sp
 .BR ftruncate ():
-_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _POSIX_C_SOURCE\ >=\ 200112L
+.RS 4
+_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
+_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
+.br
+|| /* Since glibc 2.3.5: */ _POSIX_C_SOURCE\ >=\ 200112L
+.RE
+.PD
 .ad b
 .SH DESCRIPTION
 The
@@ -93,7 +107,7 @@ With
 the file must be open for writing; with
 .BR truncate (),
 the file must be writable.
-.SH "RETURN VALUE"
+.SH RETURN VALUE
 On success, zero is returned.
 On error, \-1 is returned, and
 .I errno
@@ -118,7 +132,11 @@ The argument
 is larger than the maximum file size. (XSI)
 .TP
 .B EINTR
-A signal was caught during execution.
+While blocked waiting to complete,
+the call was interrupted by a signal handler; see
+.BR fcntl (2)
+and
+.BR signal (7).
 .TP
 .B EINVAL
 The argument
@@ -128,13 +146,6 @@ is negative or larger than the maximum file size.
 .B EIO
 An I/O error occurred updating the inode.
 .TP
-.B EINTR
-While blocked waiting to complete,
-the call was interrupted by a signal handler; see
-.BR fcntl (2)
-and
-.BR signal (7).
-.TP
 .B EISDIR
 The named file is a directory.
 .TP
@@ -181,7 +192,7 @@ is not open for writing.
 .B EINVAL
 .I fd
 does not reference a regular file.
-.SH "CONFORMING TO"
+.SH CONFORMING TO
 4.4BSD, SVr4, POSIX.1-2001 (these calls first appeared in 4.2BSD).
 .\" POSIX.1-1996 has
 .\" .BR ftruncate ().
@@ -195,7 +206,7 @@ does not reference a regular file.
 .\" .BR ftruncate ()
 .\" an additional EAGAIN error condition.
 .SH NOTES
-The above description is for XSI-compliant systems.
+The details in DESCRIPTION are for XSI-compliant systems.
 For non-XSI-compliant systems, the POSIX standard allows
 two behaviors for
 .BR ftruncate ()
@@ -206,7 +217,7 @@ exceeds the file length
 .BR truncate ()
 is not specified at all in such an environment):
 either returning an error, or extending the file.
-Like most Unix implementations, Linux follows the XSI requirement
+Like most UNIX implementations, Linux follows the XSI requirement
 when dealing with native file systems.
 However, some nonnative file systems do not permit
 .BR truncate ()
@@ -215,7 +226,34 @@ and
 to be used to extend a file beyond its current length:
 a notable example on Linux is VFAT.
 .\" At the very least: OSF/1, Solaris 7, and FreeBSD conform, mtk, Jan 2002
-.SH "SEE ALSO"
+
+The original Linux
+.BR truncate ()
+and
+.BR ftruncate ()
+system calls were not designed to handle large file offsets.
+Consequently, Linux 2.4 added
+.BR truncate64 ()
+and
+.BR ftruncate64 ()
+system calls that handle large files.
+However, these details can be ignored by applications using glibc, whose
+wrapper functions transparently employ the more recent system calls
+where they are available.
+
+On some 32-bit architectures,
+the calling signature for these system calls differ,
+for the reasons described in
+.BR syscall (2).
+.SH BUGS
+A header file bug in glibc 2.12 meant that the minimum value of
+.\" http://sourceware.org/bugzilla/show_bug.cgi?id=12037
+.BR _POSIX_C_SOURCE
+required to expose the declaration of
+.BR ftruncate ()
+was 200809L instead of 200112L.
+This has been fixed in later glibc versions.
+.SH SEE ALSO
 .BR open (2),
 .BR stat (2),
 .BR path_resolution (7)