summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2000-07-21 21:52:15 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2000-07-21 21:52:15 +0000
commit39c455f83b974f9e4f0be2aaad7aa3bb469d0961 (patch)
treef2d704300d4300e3a9c9b0a72c1e2d8cd9bb6739
parenta1054c50dbb8e1fea66aa4efd7937ddf0643b0ff (diff)
Document that truncate() can also be used to extend the size of a file.
From FreeBSD; ok deraadt@
-rw-r--r--lib/libc/sys/truncate.215
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libc/sys/truncate.2 b/lib/libc/sys/truncate.2
index 5c7128553d0..e07a0a353f1 100644
--- a/lib/libc/sys/truncate.2
+++ b/lib/libc/sys/truncate.2
@@ -1,4 +1,4 @@
-.\" $OpenBSD: truncate.2,v 1.7 2000/04/15 11:46:04 aaron Exp $
+.\" $OpenBSD: truncate.2,v 1.8 2000/07/21 21:52:14 naddy Exp $
.\" $NetBSD: truncate.2,v 1.7 1995/02/27 12:39:00 cgd Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
@@ -40,7 +40,7 @@
.Sh NAME
.Nm truncate ,
.Nm ftruncate
-.Nd truncate a file to a specified length
+.Nd truncate or extend a file to a specified length
.Sh SYNOPSIS
.Fd #include <unistd.h>
.Ft int
@@ -53,11 +53,14 @@ causes the file named by
.Fa path
or referenced by
.Fa fd
-to be truncated to at most
+to be truncated or extended to
.Fa length
-bytes in size. If the file previously
+bytes in size. If the file
was larger than this size, the extra data
is lost.
+If the file was smaller than this size,
+it will be extended as if by writing bytes
+with the value zero.
With
.Fn ftruncate ,
the file must be open for writing.
@@ -123,6 +126,10 @@ is not open for writing.
.Sh BUGS
These calls should be generalized to allow ranges
of bytes in a file to be discarded.
+.Pp
+Use of
+.Fn truncate
+to extend a file is not portable.
.Sh HISTORY
The
.Fn truncate