Index: asf.8 =================================================================== RCS file: /usr/cvs/src/usr.sbin/asf/asf.8,v retrieving revision 1.9 diff -u -r1.9 asf.8 --- asf.8 29 Sep 2006 17:57:01 -0000 1.9 +++ asf.8 4 Dec 2006 20:24:16 -0000 @@ -63,6 +63,11 @@ .Pa /usr/src and .Pa /usr/obj ) . +The +.Ar modules-path +argument accepts a semicolon-separated list of paths, like the +.Pa kern.module_path +sysctl. Each path in the list will be searched in turn for modules. .Pp If .Ar outfile Index: asf.c =================================================================== RCS file: /usr/cvs/src/usr.sbin/asf/asf.c,v retrieving revision 1.11 diff -u -r1.11 asf.c --- asf.c 29 Sep 2006 16:10:28 -0000 1.11 +++ asf.c 4 Dec 2006 19:54:04 -0000 @@ -185,10 +185,12 @@ } } +#define MAXPATHS 16 static void findmodules(const char *modules_path, const char *sfx[], FILE *out) { - char *path_argv[2]; + char *path_argv[MAXPATHS + 1]; + char *path_copy; char *p; FTS *fts; FTSENT *ftsent; @@ -197,9 +199,14 @@ int sl; /* Have to copy modules_path here because it's const */ - if ((path_argv[0] = strdup(modules_path)) == NULL) + if ((p = path_copy = strdup(modules_path)) == NULL) errx(2, "out of memory"); - path_argv[1] = NULL; + i = 0; + while (i < MAXPATHS && (path_argv[i] = strsep(&p, ";")) != NULL) { + if (path_argv[i] != '\0') + i++; + } + path_argv[i] = NULL; /* Have to fts once per suffix to find preferred suffixes first */ do { @@ -245,7 +252,7 @@ fts_close(fts); } while (*sfx++); done: - free(path_argv[0]); + free(path_copy); } static void @@ -287,6 +294,9 @@ char path[PATH_MAX]; const char *filemode = "w"; /* mode for outfile */ const char *modules_path = "modules"; /* path to kernel build directory */ + char *path_copy; + char *path_p; + char *p; const char *outfile = ".asf"; /* and where to write the output */ const char *corefile = NULL; /* for kvm(3) */ const char *sysfile = NULL; /* for kvm(3) */ @@ -301,6 +311,7 @@ int runprog = 0; int i; const int sl = strlen(KLDSUFFIX); + int module_found; while ((i = getopt(argc, argv, "afKkM:N:o:sVX:x")) != -1) switch (i) { @@ -384,6 +395,9 @@ if (!dofind) STAILQ_FOREACH(kfp, &kfile_head, link) { + module_found = 0; + if ((path_p = path_copy = strdup(modules_path)) == NULL) + errx(2, "out of memory"); if (!nosubdir) { /* prepare basename of KLD, w/o suffix */ strlcpy(basename, kfp->name, sizeof(basename) - 1); @@ -393,21 +407,30 @@ basename[i] = '/'; basename[i + 1] = '\0'; } - for (sfx = suffixes;; sfx++) { - snprintf(path, sizeof(path), + while ((p = strsep(&path_p, ";")) != NULL && *p != '\0') { + for (sfx = suffixes;; sfx++) { + snprintf(path, sizeof(path), "%s/%s%s%s", - modules_path, + p, nosubdir ? "" : basename, kfp->name, *sfx ? *sfx : ""); - if (*sfx == NULL || stat(path, &st) == 0) { - doobj(path, kfp->addr, out); - break; + if (stat(path, &st) == 0) { + module_found = 1; + doobj(path, kfp->addr, out); + break; + } + if (*sfx == NULL) + break; } + if (module_found) + break; } + free(path_copy); + if (!module_found) + warnx("module %s not found in search path\n", kfp->name); } else findmodules(modules_path, suffixes, out); - return (0); }