]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Refactor logic for crossing mount points. This provides a hook for
authorTim Kientzle <kientzle@gmail.com>
Sun, 10 May 2009 20:07:39 +0000 (16:07 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 10 May 2009 20:07:39 +0000 (16:07 -0400)
special handling of synthetic and non-local filesystems.

SVN-Revision: 1081

tar/write.c

index 8fb219ef325fdca1428c7816677fad1a19d52861..3ed846e8acd5fe7fa93df29ba3737e15fb576416 100644 (file)
@@ -737,17 +737,38 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
                }
 
                /*
-                * If user has asked us not to cross mount points,
-                * then don't descend into into a dir on a different
-                * device.
+                * Are we about to cross to a new filesystem?
                 */
                if (!dev_recorded) {
+                       /* This is the initial file system. */
                        first_dev = lst->st_dev;
                        dev_recorded = 1;
-               }
-               if (bsdtar->option_dont_traverse_mounts) {
-                       if (lst->st_dev != first_dev)
-                               descend = 0;
+               } else if (lst->st_dev == first_dev) {
+                       /* The starting file system is always acceptable. */
+               } else if (descend == 0) {
+                       /* We're not descending, so no need to check. */
+               } else if (bsdtar->option_dont_traverse_mounts) {
+                       /* User has asked us not to cross mount points. */
+                       descend = 0;
+               } else {
+                       /* We're prepared to cross a mount point. */
+
+                       /* XXX TODO: check whether this filesystem is
+                        * synthetic and/or local.  Add a new
+                        * --local-only option to skip non-local
+                        * filesystems.  Skip synthetic filesystems
+                        * regardless.
+                        *
+                        * The results should be cached, since
+                        * tree.c doesn't usually visit a directory
+                        * and the directory contents together.  A simple
+                        * move-to-front list should perform quite well.
+                        *
+                        * This is going to be heavily OS dependent:
+                        * FreeBSD's statfs() in conjunction with getvfsbyname()
+                        * provides all of this; NetBSD's statvfs() does
+                        * most of it; other systems will vary.
+                        */
                }
 
                /*