Bug 28430

Summary: mtree does not correctly compare files when one of which have flags set
Product: Base System Reporter: Voradesh Yenbut <yenbut>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Voradesh Yenbut 2001-06-27 00:30:06 UTC
Mtree does not correctly compare files against their specs if
one of the files has flags such as nodump set.  The files not
having the flags set show errors like the following:

za:     flags ("nodump" is not "none")
za/z:   flags ("nodump" is not "none")
za/z/a: flags ("nodump" is not "none")

Fix: 

The patch below on spec.c corrects the problem.  The patch
on create.c is a patch to what looks like another bug.  It
is unclear what the bug does.

--- spec.c      2001/06/26 21:59:06     1.1
+++ spec.c      2001/06/26 22:13:49
@@ -113,6 +113,7 @@
                        case 's':
                                if (strcmp(p + 1, "set"))
                                        break;
+                               bzero(&ginfo, sizeof(ginfo));
                                set(NULL, &ginfo);
                                continue;
                        case 'u':
--- create.c    2001/06/26 21:00:13     1.1
+++ create.c    2001/06/26 21:08:54
@@ -337,7 +337,7 @@
                        if (FLAGS2IDX(sflags) < MAXFLAGS &&
                            ++f[FLAGS2IDX(sflags)] > maxflags) {
                                saveflags = sflags;
-                               maxflags = u[FLAGS2IDX(sflags)];
+                               maxflags = f[FLAGS2IDX(sflags)];
                        }
                }
        }
How-To-Repeat: Running the following commands:
------
rm -rf /tmp/test

mkdir /tmp/test
mkdir /tmp/test/x
mkdir /tmp/test/x/y
mkdir /tmp/test/x/z
touch /tmp/test/x/z/b

touch /tmp/test/y
chflags nodump /tmp/test/y

ln -s /tmp/test/y /tmp/test/x/y/a

rm -rf /tmp/test/za
mkdir /tmp/test/za
mkdir /tmp/test/za/z
touch /tmp/test/za/z/a

mtree -cnxiK sha1digest -p /tmp/test > spec
mtree -xp /tmp/test < spec
Comment 1 Jonathan Chen freebsd_committer freebsd_triage 2001-08-03 00:16:06 UTC
State Changed
From-To: open->closed

The problem and the "other bug" has since been corrected. 
4.3-RELEASE contains the fixed version.