mirror of
https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
synced 2024-11-23 02:43:54 +08:00
depmod: Fix handling relative moduledir
Make sure moduledir is always relative to the basedir and document it as such. Note: scdoc 1.11.3 produces a strange result when trying to render the man page for the 2 examples. Workaround that by ending with an explicit newline, which produces another stranger behavior (but visually correct) of indenting the next line. Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/243
This commit is contained in:
parent
263ab7243c
commit
a9e69c02d6
@ -56,6 +56,9 @@ rather than the current kernel version (as returned by *uname -r*).
|
||||
distribution vendor who needs to pre-generate the meta-data files rather
|
||||
than running *depmod* again later.
|
||||
|
||||
If a relative path is given, it's relative to the current working
|
||||
directory.
|
||||
|
||||
Example:
|
||||
depmod -b /my/build/staging/dir/
|
||||
|
||||
@ -69,13 +72,27 @@ rather than the current kernel version (as returned by *uname -r*).
|
||||
building *modules.dep* file in _basedir_ for a system that uses a
|
||||
different prefix, e.g. _/usr/lib/modules_ vs _/lib/modules_.
|
||||
|
||||
Example:
|
||||
depmod -b /tmp/build -m /kernel-modules
|
||||
Relative and absolute paths are accepted, but they are always relative
|
||||
to the _basedir_.
|
||||
|
||||
Examples:
|
||||
depmod -b /tmp/build -m /kernel-modules++
|
||||
depmod -b /tmp/build -m kernel-modules
|
||||
|
||||
This expects all input files under
|
||||
_/tmp/build/kernel-modules/$(uname -r)_ and generates index files under
|
||||
that same directory.
|
||||
|
||||
Without an accompanying *-b* argument, the moduledir is relative to _/_.
|
||||
Example:
|
||||
|
||||
depmod -m foo/bar
|
||||
|
||||
This expects all input files under _/foo/bar/$(uname -r)_ and generates
|
||||
index files under the same directory. Unless libkmod is prepared to
|
||||
handle that arbitrary location, it won't work in runtime.
|
||||
|
||||
|
||||
*-o* _outdir_, *--outdir* _outdir_
|
||||
Set the output directory where *depmod* will store any generated file.
|
||||
_outdir_ serves as a root to that location, similar to how _basedir_ is
|
||||
@ -83,6 +100,9 @@ rather than the current kernel version (as returned by *uname -r*).
|
||||
_basedir_ it will result in the input being that directory, but the output
|
||||
being the one set by _outdir_.
|
||||
|
||||
If a relative path is given, it's relative to the current working
|
||||
directory.
|
||||
|
||||
Example:
|
||||
depmod -o /my/build/staging/dir/
|
||||
|
||||
|
@ -36,7 +36,6 @@
|
||||
#define DEFAULT_VERBOSE LOG_WARNING
|
||||
static int verbose = DEFAULT_VERBOSE;
|
||||
|
||||
static const char *module_directory = MODULE_DIRECTORY;
|
||||
static const char CFG_BUILTIN_KEY[] = "built-in";
|
||||
static const char CFG_EXTERNAL_KEY[] = "external";
|
||||
static const char *const default_cfg_paths[] = {
|
||||
@ -2924,6 +2923,7 @@ static int do_depmod(int argc, char *argv[])
|
||||
const char *module_symvers = NULL;
|
||||
const char *null_kmod_config = NULL;
|
||||
const char *root = "";
|
||||
const char *module_directory = MODULE_DIRECTORY;
|
||||
struct utsname un;
|
||||
struct kmod_ctx *ctx = NULL;
|
||||
struct cfg cfg;
|
||||
@ -3033,19 +3033,22 @@ static int do_depmod(int argc, char *argv[])
|
||||
cfg.kversion = un.release;
|
||||
}
|
||||
|
||||
cfg.dirnamelen = snprintf(cfg.dirname, PATH_MAX, "%s%s/%s", root,
|
||||
/* module directory is always relative to basedir/outdir */
|
||||
while (module_directory[0] == '/')
|
||||
module_directory++;
|
||||
|
||||
cfg.dirnamelen = snprintf(cfg.dirname, PATH_MAX, "%s/%s/%s", root,
|
||||
module_directory, cfg.kversion);
|
||||
if (cfg.dirnamelen >= PATH_MAX) {
|
||||
ERR("Bad directory %s%s/%s: path too long\n", root,
|
||||
module_directory, cfg.kversion);
|
||||
ERR("Bad directory %s/%s/%s: path too long\n", root, module_directory,
|
||||
cfg.kversion);
|
||||
goto cmdline_failed;
|
||||
}
|
||||
|
||||
cfg.outdirnamelen = snprintf(cfg.outdirname, PATH_MAX, "%s%s/%s",
|
||||
out_root ?: root, module_directory,
|
||||
cfg.kversion);
|
||||
cfg.outdirnamelen = snprintf(cfg.outdirname, PATH_MAX, "%s/%s/%s",
|
||||
out_root ?: root, module_directory, cfg.kversion);
|
||||
if (cfg.outdirnamelen >= PATH_MAX) {
|
||||
ERR("Bad directory %s%s/%s: path too long\n", out_root ?: root,
|
||||
ERR("Bad directory %s/%s/%s: path too long\n", out_root ?: root,
|
||||
module_directory, cfg.kversion);
|
||||
goto cmdline_failed;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user