Re: [vox-tech] files with holes in them
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vox-tech] files with holes in them
- Subject: Re: [vox-tech] files with holes in them
- From: jdnewmil@dcn.davis.caMAPS.us
- Date: Fri, 17 Nov 2000 20:23:21 -0800
- References: Pine.LNX.4.21.0011172004580.6079-100000@belial.ucdavis.edu
On Fri, 17 Nov 2000, Peter Jay Salzman wrote:
> i was playing around with creating files with holes in them:
>
> % ls -l holy_file
> -rw------- 1 p p 10000003 Nov 17 19:59 holy_file
>
> % du -k holy_file
> 24 holy_file
>
> the program i wrote to generate this file looks more or less like:
>
> if((fd = open("holy_file", O_WRONLY|O_CREAT)) < 0)
> exit(0);
>
> write(fd, string1, strlen(string1));
> lseek(fd, 99999, SEEK_SET);
> write(fd, string2, strlen(string2));
>
> ls gets its info from stat. i did an strace on du, and it also calls stat.
> i'm curious about the discrepency in file size. does anyone know why the
> two programs report different file sizes?
Because by design du looks at allocated disk space, and ls looks at the
recorded file size. From "man stat", I gather the former comes from
st_blocks and the latter comes from st_size.
But you knew this already... or you wouldn't have been playing with holey
files... right?
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Work:<JeffN@endecon.com> Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...2k
---------------------------------------------------------------------------
|