svn commit: r316931 - vendor/illumos/dist/lib/libzfs/common
Andriy Gapon
avg at FreeBSD.org
Fri Apr 14 18:49:45 UTC 2017
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 at 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 <mahrens at delphix.com>
Reviewed by: Justin Gibbs <gibbs at scsiguy.com>
Approved by: Dan McDonald <danmcd at omniti.com>
Author: Joshua M. Clulow <josh at sysmgr.org>
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);
More information about the svn-src-all
mailing list