Date: Tue, 29 Jul 2003 11:53:55 -0400 From: Leo Bicknell <bicknell@ufp.org> To: freebsd-hackers@freebsd.org Subject: Re: file size different from ls to du Message-ID: <20030729155355.GA89416@ussenterprise.ufp.org> In-Reply-To: <20030729172615.N13255-100000@fw.office.icom> References: <200307291524.h6TFO3J06998@revolt.poohsticks.org> <20030729172615.N13255-100000@fw.office.icom>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
In a message written on Tue, Jul 29, 2003 at 05:27:14PM +0200, Bogdan TARU wrote:
> I have tried to create some files of myself, with 'spaces' in them
> (holes?), but they don't act like this. So could you please explain what
> 'sparse' means, and the 'trick' to create them?
% cat sparse.c
#include <sys/types.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <unistd.h>
int main(void) {
int fd;
fd = open("sparse-file", O_RDWR|O_CREAT);
lseek(fd, 1024*1024*1024, SEEK_SET);
write(fd, "0123456789", 10);
close(fd);
}
% cc -o sparse sparse.c
% ./sparse
% ls -lag sparse-file
-r-xr----- 1 bicknell bicknell 1073741834 Jul 29 11:52 sparse-file*
% du -k sparse-file
48 sparse-file
--
Leo Bicknell - bicknell@ufp.org - CCIE 3440
PGP keys at http://www.ufp.org/~bicknell/
Read TMBG List - tmbg-list-request@tmbg.org, www.tmbg.org
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)
iD8DBQE/JpiTNh6mMG5yMTYRAhpsAJ425kMhVTb6tonzZteuQxjJcqKdhgCeKQUc
6oKFtptaWQABsU92FH5KVBk=
=ng0F
-----END PGP SIGNATURE-----
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030729155355.GA89416>
