From 0fe82aa40bd9a5765843fc2e0d2115adc4e842f8 Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 8 May 2024 15:57:56 +0000 Subject: [PATCH] Add an option to warn and error out for mtree missing entries. --- usr.sbin/makefs/makefs.8 | 8 ++++++-- usr.sbin/makefs/makefs.c | 6 +++--- usr.sbin/makefs/walk.c | 13 +++++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8 index 83934adb08e6..aefb7d97ac12 100644 --- a/usr.sbin/makefs/makefs.8 +++ b/usr.sbin/makefs/makefs.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: makefs.8,v 1.71 2022/11/17 06:40:41 chs Exp $ +.\" $NetBSD: makefs.8,v 1.72 2024/05/08 15:57:56 christos Exp $ .\" .\" Copyright (c) 2001-2003 Wasabi Systems, Inc. .\" All rights reserved. @@ -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 April 4, 2021 +.Dd May 8, 2024 .Dt MAKEFS 8 .Os .Sh NAME @@ -260,6 +260,10 @@ ISO/Ecma UDF file system. .El .It Fl x Exclude file system nodes not explicitly listed in the specfile. +Repeating this flag causes +.Nm +to print a warning for each missing system nodes and exit with an error code +if there are any missing. .It Fl Z Create a sparse file for .Sy ffs . diff --git a/usr.sbin/makefs/makefs.c b/usr.sbin/makefs/makefs.c index 5ef249ad4e0f..3c89cb8e8a32 100644 --- a/usr.sbin/makefs/makefs.c +++ b/usr.sbin/makefs/makefs.c @@ -1,4 +1,4 @@ -/* $NetBSD: makefs.c,v 1.57 2024/02/18 16:59:16 christos Exp $ */ +/* $NetBSD: makefs.c,v 1.58 2024/05/08 15:57:56 christos Exp $ */ /* * Copyright (c) 2001-2003 Wasabi Systems, Inc. @@ -41,7 +41,7 @@ #include #if defined(__RCSID) && !defined(__lint) -__RCSID("$NetBSD: makefs.c,v 1.57 2024/02/18 16:59:16 christos Exp $"); +__RCSID("$NetBSD: makefs.c,v 1.58 2024/05/08 15:57:56 christos Exp $"); #endif /* !__lint */ #include @@ -261,7 +261,7 @@ main(int argc, char *argv[]) break; case 'x': - fsoptions.onlyspec = 1; + fsoptions.onlyspec++; break; case 'Z': diff --git a/usr.sbin/makefs/walk.c b/usr.sbin/makefs/walk.c index 27d43231ef0e..731e92180fcb 100644 --- a/usr.sbin/makefs/walk.c +++ b/usr.sbin/makefs/walk.c @@ -1,4 +1,4 @@ -/* $NetBSD: walk.c,v 1.39 2024/04/24 21:59:39 rillig Exp $ */ +/* $NetBSD: walk.c,v 1.40 2024/05/08 15:57:56 christos Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -41,7 +41,7 @@ #include #if defined(__RCSID) && !defined(__lint) -__RCSID("$NetBSD: walk.c,v 1.39 2024/04/24 21:59:39 rillig Exp $"); +__RCSID("$NetBSD: walk.c,v 1.40 2024/05/08 15:57:56 christos Exp $"); #endif /* !__lint */ #include @@ -65,6 +65,7 @@ static void apply_specentry(const char *, NODE *, fsnode *); static fsnode *create_fsnode(const char *, const char *, const char *, struct stat *); static fsinode *link_check(fsinode *); +static size_t missing = 0; /* * fsnode_cmp -- @@ -429,6 +430,9 @@ apply_specfile(const char *specfile, const char *dir, fsnode *parent, int specon apply_specdir(dir, root, parent, speconly); free_nodes(root); + if (missing) + errx(EXIT_FAILURE, "Add %zu missing entries in `%s'", + missing, specfile); } static void @@ -469,6 +473,11 @@ apply_specdir(const char *dir, NODE *specnode, fsnode *dirnode, int speconly) break; } if (curnode == NULL) { + if (speconly > 1) { + warnx("missing specfile entry for %s/%s", + dir, curfsnode->name); + missing++; + } if (debug & DEBUG_APPLY_SPECONLY) { printf("%s: trimming %s/%s %p\n", __func__, dir, curfsnode->name,