l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
November 4: Social gathering
Next Installfest:
TBD
Latest News:
Oct. 10: LUGOD Installfests coming again soon
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


  • 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
---------------------------------------------------------------------------


LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
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!