diff options
author | kientzle <kientzle@FreeBSD.org> | 2010-02-07 01:22:55 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2010-02-07 01:22:55 +0000 |
commit | 38d0db1832302c0148a1cfd04ba1e24bd89a61c7 (patch) | |
tree | 126cb02975d770273ffdbd5a7e57233cf6bc03b0 /usr.bin | |
parent | 15e360bfc834824f4c43293908d12903cd7b5338 (diff) | |
download | FreeBSD-src-38d0db1832302c0148a1cfd04ba1e24bd89a61c7.zip FreeBSD-src-38d0db1832302c0148a1cfd04ba1e24bd89a61c7.tar.gz |
Restructure the logic that determines when we're crossing a mount
point. In particular, this carves out a place for detecting and
excluding synthetic or network filesystems.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tar/write.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c index e17bd93..37d2de6 100644 --- a/usr.bin/tar/write.c +++ b/usr.bin/tar/write.c @@ -82,8 +82,8 @@ __FBSDID("$FreeBSD$"); #endif #include "bsdtar.h" -#include "tree.h" #include "err.h" +#include "tree.h" /* Size of buffer for holding file data prior to writing. */ #define FILEDATABUFLEN 65536 @@ -733,17 +733,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. + */ } /* |