Forgat to send to the list.

        -Otto
        
----- Forwarded message from Otto Moerbeek <[EMAIL PROTECTED]> -----

Date: Sat, 10 Nov 2007 10:36:20 +0100
From: Otto Moerbeek <[EMAIL PROTECTED]>
To: Richard Toohey <[EMAIL PROTECTED]>
Subject: Re: identifying sparse files and get ride of them trick available?

On Sat, Nov 10, 2007 at 09:44:46PM +1300, Richard Toohey wrote:
> 
> On 10/11/2007, at 9:32 PM, Otto Moerbeek wrote:
> 
> >yeah, look at stat(2):
> >
> > int64_t    st_blocks;  /* blocks allocated for file */
> > u_int32_t  st_blksize; /* optimal file sys I/O ops blocksize */
> >
> >actually st_blocks's unit is disk sectors, to be precise.
> >
> >I don't read perl, so I cannot comment on the script below.
> >
> >     -Otto
> 
> Thanks for the feedback.
> 
> I tried in C, but could not get past getting 0 for st_blocks every  
> time (will be my C, but I can't see (C?) what it is yet ...)

Wrong format specifier. -Wall is your friend.

        -Otto
        
> 
> # man -s 2 stat:
> [cut]
>          struct timespec st_ctimespec;  /* time of last file status  
> change */
>          off_t      st_size;   /* file size, in bytes */
>          int64_t    st_blocks; /* blocks allocated for file */
> [cut]
> 
> check.c
> -----------
> 
> #include <sys/stat.h>
> 
> int main(void) {
>         struct stat stat_stuff;
>         int result;
>         result=stat("/home/sparse-files/sparsefile",&stat_stuff);
>         printf("%d %d\n",stat_stuff.st_size,stat_stuff.st_blocks);
> }
> 
> # cc check.c -o check
> # ./check
> 10485760 0

----- End forwarded message -----

Reply via email to