From owner-svn-src-all@freebsd.org Fri Apr 14 18:49:45 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B6214D3EE02; Fri, 14 Apr 2017 18:49:45 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 74793A34; Fri, 14 Apr 2017 18:49:45 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3EInigF080545; Fri, 14 Apr 2017 18:49:44 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3EIniuO080544; Fri, 14 Apr 2017 18:49:44 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201704141849.v3EIniuO080544@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 14 Apr 2017 18:49:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r316931 - vendor/illumos/dist/lib/libzfs/common X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 14 Apr 2017 18:49:45 -0000 Author: avg Date: Fri Apr 14 18:49:44 2017 New Revision: 316931 URL: https://svnweb.freebsd.org/changeset/base/316931 Log: 6268 zfs diff confused by moving a file to another directory illumos/illumos-gate@aab04418a72c0a29040a5da7eec08efe19dbef04 https://github.com/illumos/illumos-gate/commit/aab04418a72c0a29040a5da7eec08efe19dbef04 https://www.illumos.org/issues/6268 The zfs diff command presents a description of the changes that have occurred to files within a filesystem between two snapshots. If a file is renamed, the tool is capable of reporting this, e.g.: cd /some/zfs/dataset/subdir mv file0 file1 Will result in a diff record like: R /some/zfs/dataset/subdir/file0 -> /some/zfs/dataset/subdir/file1 Unfortunately, it seems that rename detection only uses the base filename to determine if a file has been renamed or simply modified. This leads to misreporting only the original filename, omitting the more relevant destination filename entirely. For example: cd /some/zfs/dataset/subdir mv file0 ../otherdir/file0 Will result in a diff entry: M /some/zfs/dataset/subdir/file0 But it should really emit: R /some/zfs/dataset/subdir/file0 -> /some/zfs/dataset/otherdir/file0 Reviewed by: Matthew Ahrens Reviewed by: Justin Gibbs Approved by: Dan McDonald Author: Joshua M. Clulow Modified: vendor/illumos/dist/lib/libzfs/common/libzfs_diff.c Modified: vendor/illumos/dist/lib/libzfs/common/libzfs_diff.c ============================================================================== --- vendor/illumos/dist/lib/libzfs/common/libzfs_diff.c Fri Apr 14 18:43:10 2017 (r316930) +++ vendor/illumos/dist/lib/libzfs/common/libzfs_diff.c Fri Apr 14 18:49:44 2017 (r316931) @@ -57,15 +57,6 @@ #define ZDIFF_REMOVED '-' #define ZDIFF_RENAMED 'R' -static boolean_t -do_name_cmp(const char *fpath, const char *tpath) -{ - char *fname, *tname; - fname = strrchr(fpath, '/') + 1; - tname = strrchr(tpath, '/') + 1; - return (strcmp(fname, tname) == 0); -} - typedef struct differ_info { zfs_handle_t *zhp; char *fromsnap; @@ -260,7 +251,6 @@ static int write_inuse_diffs_one(FILE *fp, differ_info_t *di, uint64_t dobj) { struct zfs_stat fsb, tsb; - boolean_t same_name; mode_t fmode, tmode; char fobjname[MAXPATHLEN], tobjname[MAXPATHLEN]; int fobjerr, tobjerr; @@ -321,7 +311,6 @@ write_inuse_diffs_one(FILE *fp, differ_i if (fmode != tmode && fsb.zs_gen == tsb.zs_gen) tsb.zs_gen++; /* Force a generational difference */ - same_name = do_name_cmp(fobjname, tobjname); /* Simple modification or no change */ if (fsb.zs_gen == tsb.zs_gen) { @@ -332,7 +321,7 @@ write_inuse_diffs_one(FILE *fp, differ_i if (change) { print_link_change(fp, di, change, change > 0 ? fobjname : tobjname, &tsb); - } else if (same_name) { + } else if (strcmp(fobjname, tobjname) == 0) { print_file(fp, di, ZDIFF_MODIFIED, fobjname, &tsb); } else { print_rename(fp, di, fobjname, tobjname, &tsb);