Hi, how can I do the following in a shell script: - check whether my file system supports cp --reflink? - check whether two files share the same data on disk, i.e. one has been created by cp --reflink of the other? Thank you! Thomas Koch -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sat, Aug 24, 2013 at 06:09:58PM +0200, Thomas Koch wrote:> Hi, > > how can I do the following in a shell script: > > - check whether my file system supports cp --reflink?touch foo; if cp --reflink=always foo bar; then ...; fi; rm -f foo bar> - check whether two files share the same data on disk, i.e. one has been > created by cp --reflink of the other?You can''t, using simple userspace tools. I think the only way would be to use the tree search ioctl to inspect the extents for each file, and see whether any of them overlap. Why do you need to know this? Hugo. -- === Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk == PGP key: 65E74AC0 from wwwkeys.eu.pgp.net or http://www.carfax.org.uk --- Someone''s been throwing dead sheep down my Fun Well ---
On Sat, August 24, 2013 at 18:20 (+0200), Hugo Mills wrote:> On Sat, Aug 24, 2013 at 06:09:58PM +0200, Thomas Koch wrote: >> Hi, >> >> how can I do the following in a shell script: >> >> - check whether my file system supports cp --reflink? > > touch foo; if cp --reflink=always foo bar; then ...; fi; rm -f foo bar > >> - check whether two files share the same data on disk, i.e. one has been >> created by cp --reflink of the other? > > You can''t, using simple userspace tools. I think the only way would > be to use the tree search ioctl to inspect the extents for each file, > and see whether any of them overlap. Why do you need to know this?It should work with fiemap to a file in question and btrfs inspect logical to what ever extents fiemap reported as "physical". -Jan -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sat, Aug 24, 2013 at 06:09:58PM +0200, Thomas Koch wrote:> Hi, > > how can I do the following in a shell script: > > - check whether my file system supports cp --reflink? > - check whether two files share the same data on disk, i.e. one has been > created by cp --reflink of the other?Someone has proposed to teach ''du(1)'' to show this, ie. ''du --shared''[1]. It''s written for ocfs2 originally, besides btrfs, ocfs2 also can share data between two files. [1]: https://oss.oracle.com/pipermail/ocfs2-devel/2010-September/007287.html -liubo -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Sat, Aug 24, 2013 at 12:09 PM, Thomas Koch <thomas@koch.ro> wrote:> - check whether two files share the same data on disk, i.e. one has been > created by cp --reflink of the other?How about inspecting the output of filefrag -v $filename? For example, you could filter out with grep all lines except the ones that contain information about the extents. Then you could hash the lines left and use that single hash to compare the two files. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Apparently Analagous Threads
- Btrfs balance invalid argument error
- The state of btrfs RAID6 as of kernel 3.13-rc1
- Btrfs questions
- Two identical copies of an image mounted result in changes to both images if only one is modified
- btrfs-convert won't convert ext* - No valid Btrfs found on /dev/sdb1