Bug 175293

Summary: [patch] mtree(1): mtree "-u" option doesn't return error for extra directories
Product: Base System Reporter: Lowell Gilbert <freebsd-bugs-local>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me CC: brooks
Priority: Normal Keywords: patch
Version: 9.1-STABLE   
Hardware: Any   
OS: Any   

Description Lowell Gilbert 2013-01-14 16:40:00 UTC
The "-u" option for mtree doesn't kick out an error if the extra contents are a directory rather than a regular file.

The same problem appears to still be present in the NetBSD version being imported.

Fix: 

===================================================================
--- verify.c	(revision 245177)
+++ verify.c	(working copy)
@@ -134,36 +134,37 @@
 
 		if (ep)
 			continue;
 extra:
 		if (!eflag) {
 			(void)printf("%s extra", RP(p));
 			if (rflag) {
 				if ((S_ISDIR(p->fts_statp->st_mode)
 				    ? rmdir : unlink)(p->fts_accpath)) {
 					(void)printf(", not removed: %s",
 					    strerror(errno));
 				} else
 					(void)printf(", removed");
 			}
 			(void)putchar('\n');
 		}
 		(void)fts_set(t, p, FTS_SKIP);
 	}
+	rval = MISMATCHEXIT;
 	(void)fts_close(t);
 	if (sflag)
 		warnx("%s checksum: %lu", fullpath, (unsigned long)crc_total);
 	return (rval);
 }
How-To-Repeat: rm -rf *
mkdir etc home
mtree -c -d > ../out
mtree -d < ../out
echo $?
echo "That was the first: should be 0."
mkdir etc/temp
mtree -u -d < ../out
echo $?
echo "That was the second: should be 2."

sed -i ""  's/^\(home[ ]*\)\(.*\)$/\1ignore/' ../out
mtree -d < ../out
echo $?
echo "That was the third: should be 0."
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:14 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:38:47 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>