Re: Identifying reflink / CoW files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Sep 23, 2012 at 09:56:34AM +1200, Jp Wise wrote:
> >Afaik without playing with it myself fiemap can give you information
> >about the mappings of each file. If the mappings of 2 files match,
> >the data is shared.
> OK, have just done some searching on fiemap and located a code example using
> it to pull the file extent data.
> http://smackerelofopinion.blogspot.com/2010/01/using-fiemap-ioctl-to-get-file-extents.html
> Will have a play around to see if i might be able to hack it up to compare
> two files, or just parse it's output between two files to identify matches.
> Thank you for the pointer. :)
> 
> Likewise if anyone else knows of an existing utility to do a non-bytewise
> compare between two files, and just check if they share the same datablocks
> please let me know. :)

The FIEMAP is a way with stable and defined interface to show file
extents, there's the filefrag utility (from e2fsprogs). It does not
have a parser-friendly output, so you may want to call the ioctl
directly. The key information is in the (struct
fiemap_extent)->fe_physical field. If physical block ranges from two
files overlap, they're shared.

There's another way how to get the extent info, via btrfs' SEARCH_TREE
ioctl, but it's more low-level and needs basic knowledge about the
internal b-tree items and how they're linked together.

david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux