Re: Identifying sparse files using getattrlist()
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=3bbRFaEXhyWnvyFkcBM2JdUwQaKnI0iSPwJJ/1/0Bz0=; b=qp3GDC+o4cObB4aiCG8+6ElAgzE87RjTgzRG9G7FZwzdJNKTvAG9O8A0rNYX1qhup/ OHAQ8xZDAOqjN83m2pY9gxo3rzlPtvdEpyMUTN6TSMTo9wHeZxpNxv0vGy/t089efNiw upjgNS0LvLYYuWj8I9RfGJaOwpmiOWJW6TL/c= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=oPDteRV04Q+X8vfa2tiKJ02TcmY47LkWhNOX5U83gPaJ4j4HS7xI1ekAHADHsozU+D /dkMBUzTDeJb/HpPYJeb7tnz/aiP/8mCM4PxnFkXZZ0BYkzXgmpzNYQTA7MDgvxWAYrE HuhOFvJggtTwUYanLY+AO+/o0WoGTUAuceuRk= 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 <macko@apple.com> 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
rohan a