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
This commit is contained in:
Mina Galić 2023-02-25 10:31:58 -07:00 committed by Warner Losh
parent e052829e3e
commit 773c13c686
2 changed files with 19 additions and 7 deletions

View File

@ -26,7 +26,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd October 9, 2001 .Dd February 25, 2023
.Dt KLDXREF 8 .Dt KLDXREF 8
.Os .Os
.Sh NAME .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 file is created, and the preexisting hint file (if there was one in
that directory) is removed. that directory) is removed.
.Pp .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: The following options are available:
.Bl -tag -width indent .Bl -tag -width indent
.It Fl R .It Fl R

View File

@ -685,6 +685,7 @@ main(int argc, char *argv[])
{ {
FTS *ftsp; FTS *ftsp;
FTSENT *p; FTSENT *p;
char *dot = NULL;
int opt, fts_options, ival; int opt, fts_options, ival;
struct stat sb; struct stat sb;
@ -752,14 +753,15 @@ main(int argc, char *argv[])
fwrite(&ival, sizeof(ival), 1, fxref); fwrite(&ival, sizeof(ival), 1, fxref);
reccnt = 0; reccnt = 0;
} }
/* skip non-files and separate debug files */ /* skip non-files.. */
if (p->fts_info != FTS_F) if (p->fts_info != FTS_F)
continue; continue;
if (p->fts_namelen >= 6 && /*
strcmp(p->fts_name + p->fts_namelen - 6, ".debug") == 0) * Skip files that generate errors like .debug, .symbol and .pkgsave
continue; * by generally skipping all files with 2 dots.
if (p->fts_namelen >= 8 && */
strcmp(p->fts_name + p->fts_namelen - 8, ".symbols") == 0) dot = strchr(p->fts_name, '.');
if (dot && strchr(dot + 1, '.') != NULL)
continue; continue;
read_kld(p->fts_path, p->fts_name); read_kld(p->fts_path, p->fts_name);
} }