From owner-svn-src-all@FreeBSD.ORG Sun Feb 7 01:22:56 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0AA9F106566C; Sun, 7 Feb 2010 01:22:56 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D5C2F8FC12; Sun, 7 Feb 2010 01:22:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o171MtHq096119; Sun, 7 Feb 2010 01:22:55 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o171Mt43096117; Sun, 7 Feb 2010 01:22:55 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <201002070122.o171Mt43096117@svn.freebsd.org> From: Tim Kientzle Date: Sun, 7 Feb 2010 01:22:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203588 - head/usr.bin/tar X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Feb 2010 01:22:56 -0000 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. + */ } /*