Date: Sun, 7 Feb 2010 01:22:55 +0000 (UTC) From: Tim Kientzle <kientzle@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r203588 - head/usr.bin/tar Message-ID: <201002070122.o171Mt43096117@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kientzle Date: Sun Feb 7 01:22:55 2010 New Revision: 203588 URL: http://svn.freebsd.org/changeset/base/203588 Log: 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. Modified: head/usr.bin/tar/write.c Modified: head/usr.bin/tar/write.c ============================================================================== --- head/usr.bin/tar/write.c Sun Feb 7 01:16:05 2010 (r203587) +++ head/usr.bin/tar/write.c Sun Feb 7 01:22:55 2010 (r203588) @@ -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, s } /* - * 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. + */ } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002070122.o171Mt43096117>