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
i'm not sure i follow.
so du -k returns allocated disk space in kilobyte blocks.
10000.003 kb of data can't fit in 24 kb of allocated disk space. what am
i missing?
if anything, i'd expect st_blocks (in kb) >= st_size (in kb).
pete
On Fri, 17 Nov 2000 jdnewmil@dcn.davis.ca.us wrote:
> 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.
|