• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Identifying sparse files using getattrlist()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Identifying sparse files using getattrlist()


  • Subject: Re: Identifying sparse files using getattrlist()
  • From: rohan a <email@hidden>
  • Date: Wed, 4 Nov 2009 14:11:18 +0530

Hi All,

I wrote another program to get the file stat size and its real size
using this program :

-----------------------------------------------------------------------------------------------------------------
#include<stdio.h>
#include<sys/stat.h>

int main(int argc, char *argv[])
{
        struct stat statbuf;

        if (lstat(argv[1], &statbuf) == 0)
        {
                printf("Success\n");
                printf("size = %lld\n", statbuf.st_size);
                printf("No. of blocks = %lld\n", statbuf.st_blocks);
                printf("Block Size = %d\n", S_BLKSIZE);
                printf("Real size = %lld\n", statbuf.st_blocks* S_BLKSIZE);
        }
        else
                printf("Failed\n");
        return 0;
}
-----------------------------------------------------------------------------------------------------------------

However, for a sparse file this continues to return same sizes for
stat size and real size. This is an Apple UFS partition.

Thanks

On Tue, Nov 3, 2009 at 11:02 PM, Mike Mackovitch <email@hidden> wrote:
> On Tue, Nov 03, 2009 at 09:55:05PM +0530, rohan a wrote:
>> Thanks a lot :) I will try this
>> Would st_blksize vary for every file ?
>
> That's up to each file system.
>
>> Also is there any macro I can use instead of directly using 512 ?
>
> $ grep 512 /usr/include/sys/stat.h
> #define S_BLKSIZE       512             /* block size used in the stat struct */
>
>
> --macko
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Identifying sparse files using getattrlist()
      • From: Alastair Houghton <email@hidden>
References: 
 >Identifying sparse files using getattrlist() (From: rohan a <email@hidden>)
 >Re: Identifying sparse files using getattrlist() (From: Alastair Houghton <email@hidden>)
 >Re: Identifying sparse files using getattrlist() (From: rohan a <email@hidden>)
 >Re: Identifying sparse files using getattrlist() (From: rohan a <email@hidden>)
 >Re: Identifying sparse files using getattrlist() (From: Peter O'Gorman <email@hidden>)
 >Re: Identifying sparse files using getattrlist() (From: rohan a <email@hidden>)
 >Re: Identifying sparse files using getattrlist() (From: Mike Mackovitch <email@hidden>)
 >Re: Identifying sparse files using getattrlist() (From: rohan a <email@hidden>)
 >Re: Identifying sparse files using getattrlist() (From: Mike Mackovitch <email@hidden>)

  • Prev by Date: Re: Identifying sparse files using getattrlist()
  • Next by Date: Re: Identifying sparse files using getattrlist()
  • Previous by thread: Re: Identifying sparse files using getattrlist()
  • Next by thread: Re: Identifying sparse files using getattrlist()
  • Index(es):
    • Date
    • Thread