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:content-type :content-transfer-encoding; bh=AADQG2kQu0Nk4BB6O4ujbotmxlYR8Tdp1qFuVLIqsww=; b=vhzcb9Zcl7uWJq3d7BFHdR/pUtE1pDUjAERCL3PBvuekUuRbtwaO85Yx+rJxhcD1Ig i1MKmSBF3/wid++RYfrq4be5N63pIgzMIDrXLuVHvBXFAl34nZo7Vg6hLYzweR7pfT8A vPFiNrVNguPXbN5UgVEDZ80fiGsnrMp+WwZis= 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 :content-type:content-transfer-encoding; b=aHvCAqU8f3YZ48ss8Xa60VNCnWZDmfFZ1sboeDjIlbL62McfwmUcTvhPGTAjBZU3mB 0xa+9iihuwI8PxNLIwnqWxm5eENQcGYQXTjOWKhPHBcWz6rf5WC9NyhN8g4PBDlPjuh3 5IyM8K6qctY6KakCb8yz9JWDM2AWyLgVIeSJQ= Hello All, This is the program : #include<stdio.h> #include <sys/attr.h> #include <unistd.h> #include <string.h> typedef struct FileAttributes { unsigned long length; off_t TotalSize; off_t AllocSize; }FileAttributes; int main(int argc, char *argv[]) { struct attrlist attrList; FileAttributes FileBuffer; memset(&attrList, 0, sizeof(attrList)); memset(&FileBuffer, 0, sizeof(FileBuffer)); attrList.bitmapcount = ATTR_BIT_MAP_COUNT; attrList.fileattr = ATTR_FILE_TOTALSIZE | ATTR_FILE_ALLOCSIZE; if (getattrlist(argv[1], &attrList, &FileBuffer, sizeof(FileBuffer),FSOPT_NOFOLLOW) == 0) { printf("Alloc Size = %lld\n", FileBuffer.AllocSize); printf("Total Size = %lld\n", FileBuffer.TotalSize); } return 0; } On Mon, Nov 2, 2009 at 7:07 PM, rohan a <info1686@gmail.com> wrote:
Hello All,
I am trying to identify if a particular file is a sparse file using getattrlist()
I am using this : attrList.fileattr = ATTR_FILE_TOTALSIZE | ATTR_FILE_ALLOCSIZE;
According to the man page if ATTR_FILE_ALLOCSIZE < ATTR_FILE_TOTALSIZE the file is a sparse file.
I created the sparse file using dd #dd if=/dev/zero of=sparse-file bs=1 count=0 seek=3g
However, both AllocSize and TotalSize are returning the same size while actually AllocSize < TotalSize
I am using UFS
Thanks, Rohan
_______________________________________________ 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