From 79020cf23f23ffcbf059d9cf408f58befa84c08d Mon Sep 17 00:00:00 2001 From: Alexander Langer Date: Fri, 7 Jun 1996 01:34:47 +0000 Subject: [PATCH] Document that truncate can also be used to extend the size of a file, but doing so is not truly portable. --- lib/libc/sys/truncate.2 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/libc/sys/truncate.2 b/lib/libc/sys/truncate.2 index 2a5f3a67a136..b9c039a766bc 100644 --- a/lib/libc/sys/truncate.2 +++ b/lib/libc/sys/truncate.2 @@ -37,7 +37,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 .Ft int @@ -50,11 +50,13 @@ 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 was larger than this size, the extra data is lost. +If the file was smaller than this size, +extra zeros are appended. With .Fn ftruncate , the file must be open for writing. @@ -116,6 +118,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 .Nm