Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Feb 2023 17:37:02 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 773c13c686e4 - main - kldxref: skip .pkgsave files
Message-ID:  <202302251737.31PHb2R8072300@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

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

commit 773c13c686e4b6ae9dbbc150b342b82c3f47d73a
Author:     Mina Galić <freebsd@igalic.co>
AuthorDate: 2023-02-25 17:31:58 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-02-25 17:35:43 +0000

    kldxref: skip .pkgsave files
    
    This should help people transitioning from traditional setups to pkgbase
    experience a lot less friction.
    
    We do this by skipping all files containing two dots.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/661
    Differential Revision: https://reviews.freebsd.org/D27959
---
 usr.sbin/kldxref/kldxref.8 | 12 +++++++++++-
 usr.sbin/kldxref/kldxref.c | 14 ++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/usr.sbin/kldxref/kldxref.8 b/usr.sbin/kldxref/kldxref.8
index 1a3b9118dd5c..38db9d6922ce 100644
--- a/usr.sbin/kldxref/kldxref.8
+++ b/usr.sbin/kldxref/kldxref.8
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 9, 2001
+.Dd February 25, 2023
 .Dt KLDXREF 8
 .Os
 .Sh NAME
@@ -51,6 +51,16 @@ If no hint records are generated for a particular directory, no hint
 file is created, and the preexisting hint file (if there was one in
 that directory) is removed.
 .Pp
+.Nm
+ignores files with at least two "."s in the filename, such as
+.Pa foo.ko.debug
+or
+.Pa bar.ko.pkgsave .
+Note that this means that modules cannot have names such as
+.Pa foo.bar.ko .
+This limitation however, has been lived practice since the beginning of
+FreeBSD's kernel modules.
+.Pp
 The following options are available:
 .Bl -tag -width indent
 .It Fl R
diff --git a/usr.sbin/kldxref/kldxref.c b/usr.sbin/kldxref/kldxref.c
index 7a4d704356b8..933de4991e62 100644
--- a/usr.sbin/kldxref/kldxref.c
+++ b/usr.sbin/kldxref/kldxref.c
@@ -685,6 +685,7 @@ main(int argc, char *argv[])
 {
 	FTS *ftsp;
 	FTSENT *p;
+	char *dot = NULL;
 	int opt, fts_options, ival;
 	struct stat sb;
 
@@ -752,14 +753,15 @@ main(int argc, char *argv[])
 			fwrite(&ival, sizeof(ival), 1, fxref);
 			reccnt = 0;
 		}
-		/* skip non-files and separate debug files */
+		/* skip non-files.. */
 		if (p->fts_info != FTS_F)
 			continue;
-		if (p->fts_namelen >= 6 &&
-		    strcmp(p->fts_name + p->fts_namelen - 6, ".debug") == 0)
-			continue;
-		if (p->fts_namelen >= 8 &&
-		    strcmp(p->fts_name + p->fts_namelen - 8, ".symbols") == 0)
+		/*
+		 * Skip files that generate errors like .debug, .symbol and .pkgsave
+		 * by generally skipping all files with 2 dots.
+		 */
+		dot = strchr(p->fts_name, '.');
+		if (dot && strchr(dot + 1, '.') != NULL)
 			continue;
 		read_kld(p->fts_path, p->fts_name);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302251737.31PHb2R8072300>