git: d139062ffb01 - stable/14 - makefs: Make it possible to silence warnings about duplicate paths

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Sat, 03 Feb 2024 19:11:38 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=d139062ffb01cdce1145d1a95c530da0e792d559

commit d139062ffb01cdce1145d1a95c530da0e792d559
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-01-19 19:06:16 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-02-03 19:10:43 +0000

    makefs: Make it possible to silence warnings about duplicate paths
    
    When generating a VM image from an installworld mtree manifest, makefs
    spits out several thousand warnings about duplicate paths in the
    manifest.  These are harmless and have been around for a long time (see
    the phabricator revision for some more details), so let's at least have
    a way to make makefs quieter.
    
    Reviewed by:    brooks, imp, emaste
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D43513
    
    (cherry picked from commit e0deb85065efbcd2123d65f65eb54bd1dcf0588c)
---
 usr.sbin/makefs/makefs.8 | 4 +++-
 usr.sbin/makefs/makefs.c | 2 +-
 usr.sbin/makefs/mtree.c  | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8
index a5e15a045ec6..c6aeae961196 100644
--- a/usr.sbin/makefs/makefs.8
+++ b/usr.sbin/makefs/makefs.8
@@ -33,7 +33,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 2, 2024
+.Dd January 19, 2024
 
 .Dt MAKEFS 8
 .Os
@@ -110,6 +110,8 @@ suffix may be provided to indicate that
 indicates a percentage of the calculated image size.
 .It Fl D
 Treat duplicate paths in an mtree manifest as warnings not error.
+If this flag is specified more than once, warnings about duplicate paths
+are not printed at all.
 .It Fl d Ar debug-mask
 Enable various levels of debugging, depending upon which bits are
 set in
diff --git a/usr.sbin/makefs/makefs.c b/usr.sbin/makefs/makefs.c
index 8c8e03b9d59f..e02571f42997 100644
--- a/usr.sbin/makefs/makefs.c
+++ b/usr.sbin/makefs/makefs.c
@@ -165,7 +165,7 @@ main(int argc, char *argv[])
 			break;
 
 		case 'D':
-			dupsok = 1;
+			dupsok++;
 			break;
 
 		case 'd':
diff --git a/usr.sbin/makefs/mtree.c b/usr.sbin/makefs/mtree.c
index 3e62afbc1137..dabc9f787f88 100644
--- a/usr.sbin/makefs/mtree.c
+++ b/usr.sbin/makefs/mtree.c
@@ -895,11 +895,11 @@ read_mtree_spec1(FILE *fp, bool def, const char *name)
 
 		if (strcmp(name, node->name) == 0) {
 			if (def == true) {
-				if (!dupsok)
+				if (dupsok == 0)
 					mtree_error(
 					    "duplicate definition of %s",
 					    name);
-				else
+				else if (dupsok == 1)
 					mtree_warning(
 					    "duplicate definition of %s",
 					    name);