Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jun 1998 13:03:54 +0200 (CEST)
From:      Oliver Fromme <olli@dorifer.heim3.tu-clausthal.de>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Unexpected lseek(2) non-feature
Message-ID:  <199806301103.NAA07478@dorifer.heim3.tu-clausthal.de>

next in thread | raw e-mail | index | archive | help
In list.freebsd-questions you wrote (30 Jun 1998 01:40:07 +0200):
 > Is there some sort of an obscure rule somewhere that says that you cannot
 > use lseek to pre-extend a file that you have just now opened/created via
 > a call to open(2) with the O_CREAT option?

Use truncate() to pre-extend a file, not lseek().  See the
manual page on truncate() for details.

Note, however, that it will create a so-called "sparse" file,
i.e. it does not contain empty data, but holes.  Reading from
that area of the file will give zeroes, but there's nothing
physically stored on the disk, and no space allocated.  If you
want this, then you have to write() data to the file (zeroes
or whatever).

Regards
   Oliver

-- 
Oliver Fromme, Leibnizstr. 18-61, 38678 Clausthal, Germany
(Info: finger userinfo:olli@dorifer.heim3.tu-clausthal.de)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806301103.NAA07478>