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/
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
_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/
#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[] = {
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;
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;
}