l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2001 Dec 30 16:58

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
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).


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.

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!