]> xenbits.xensource.com Git - freebsd.git/commitdiff
mtree: Fix -f -f not considering type changes.
authorbdrewery <bdrewery@FreeBSD.org>
Thu, 12 Sep 2019 18:44:48 +0000 (18:44 +0000)
committerbdrewery <bdrewery@FreeBSD.org>
Thu, 12 Sep 2019 18:44:48 +0000 (18:44 +0000)
This only lists the changed type and not other attributes so that it
matches the behavior of -C as done in r66747 for fmtree. The NetBSD
-ff implementation was copied from fmtree.

Reviewed by: imp
MFC after: 2 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D21623

contrib/mtree/specspec.c
contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh
usr.sbin/fmtree/specspec.c

index 466cb60bb32ce0247dbfdb08594fc60ffee73b8d..57d1e08888ac92c4d112d15adf841c3ec04196ea 100644 (file)
@@ -145,7 +145,7 @@ compare_nodes(NODE *n1, NODE *n2, char const *path)
                return (1);
        }
        if (n1->type != n2->type) {
-               differs = 0;
+               differs = F_TYPE;
                mismatch(n1, n2, differs, path);
                return (1);
        }
index 58fc7db6155bc483ca695c42a1267d3791dfefcf..5daefd84e928a82a54683d4e82274cc919b8e104 100755 (executable)
@@ -411,6 +411,41 @@ netbsd6_nonemptydir_body()
        FLAVOR=netbsd6 nonemptydir_body
 }
 
+atf_test_case mtree_specspec_type
+mtree_specspec_type_head()
+{
+       atf_set "descr" "Test that spec comparisons detect type changes"
+}
+
+mtree_specspec_type_body()
+{
+       mkdir testdir
+
+       touch testdir/bar
+       mtree -c -p testdir > mtree1.spec
+
+       if [ ! -f mtree1.spec ]; then
+               atf_fail "mtree failed"
+       fi
+
+       rm -f testdir/bar
+       ln -s foo testdir/bar
+       # uid change is expected to be ignored as done in -C
+       chown -h operator testdir/bar
+       mtree -c -p testdir > mtree2.spec
+
+       if [ ! -f mtree2.spec ]; then
+               atf_fail "mtree failed"
+       fi
+
+       atf_check -s ignore -o save:output \
+           -x "mtree -f mtree1.spec -f mtree2.spec"
+
+       if ! cut -f 3 output | egrep -q "bar file" || \
+           ! cut -f 3 output | egrep -q "bar link"; then
+               atf_fail "mtree did not detect type change"
+       fi
+}
 
 atf_init_test_cases()
 {
@@ -423,6 +458,7 @@ atf_init_test_cases()
        atf_add_test_case mtree_ignore
        atf_add_test_case mtree_merge
        atf_add_test_case mtree_nonemptydir
+       atf_add_test_case mtree_specspec_type
 
        atf_add_test_case netbsd6_create
        atf_add_test_case netbsd6_check
index ac70c2831a69e58b8653e99e84f47299ed5e8aca..c26e195fdaa60a06922f3f154780290cfacf8152 100644 (file)
@@ -132,7 +132,7 @@ compare_nodes(NODE *n1, NODE *n2, char const *path)
                return (1);
        }
        if (n1->type != n2->type) {
-               differs = 0;
+               differs = F_TYPE;
                mismatch(n1, n2, differs, path);
                return (1);
        }