kmod: Add an exclude directive to depmod
PATCH 1/2 kmod: Add an exclude directive to depmod
This adds a new configuration directive to depmod that causes depmod to exclude a give path entry like .debug.
kernel-dbg provides the modules .debug/<module>.ko files and when installed either directly or when dbg-pkgs are selected this can cause depmod to fail.
This patch will be submitted to upstream kmod.
--- .../kmod/depmodwrapper-cross_1.0.bb | 3 + ...dd-support-for-excluding-a-directory.patch | 158 ++++++++++++++++++ meta/recipes-kernel/kmod/kmod_29.bb | 4 + 3 files changed, 165 insertions(+) create mode 100644 meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +3 -0
@@ -16,6 +16,9 @@ do_populate_sysroot[depends] = "" do_install() { install -d ${D}${bindir_crossscripts}/ + install -d ${D}${sysconfdir}/depmod.d/ + + echo "exclude .debug" > ${D}${sysconfdir}/depmod.d/exclude.conf cat > ${D}${bindir_crossscripts}/depmodwrapper << EOF #!/bin/sh
meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch new file +158 -0
158 lines not on this page · raw message
meta/recipes-kernel/kmod/kmod_29.bb +4 -0
@@ -20,6 +20,7 @@ SRCREV = "b6ecfc916a17eab8f93be5b09f4e4f845aabd3d1" SRC_URI = "git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git;branch=master \ file://depmod-search.conf \ file://avoid_parallel_tests.patch \ + file://0001-depmod-Add-support-for-excluding-a-directory.patch \ " S = "${WORKDIR}/git"
@@ -64,6 +65,9 @@ do_install:append () { # install depmod.d file for search/ dir install -Dm644 "${WORKDIR}/depmod-search.conf" "${D}${nonarch_base_libdir}/depmod.d/search.conf" + + # Add .debug to the exclude path for depmod + echo "exclude .debug" > ${D}${nonarch_base_libdir}/depmod.d/exclude.conf } ALTERNATIVE_PRIORITY = "70"
Signature · 1 line
2.31.1
PATCH 2/2 depmodwrapper: Use native staging dir
Use the native staging dir so that we can get the correct depmod.d configuration files. When depmod runs we want to ensure that the newly supported exclude.conf is read so that .debug/<module>.ko files are excluded.
--- meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +2 -2
@@ -35,9 +35,9 @@ fi if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [ "\$kernelabi" != "\$4" ]; then echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-\$4" >&2 - exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" "\$4" + exec env depmod -C "\${STAGING_BASE_LIBDIR_NATIVE}/depmod.d" "\$1" "\$2" "\$3" "\$4" else - exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4" + exec env depmod -C "\${STAGING_BASE_LIBDIR_NATIVE}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4" fi EOF chmod +x ${D}${bindir_crossscripts}/depmodwrapper
Signature · 1 line
2.31.1
Re: [OE-core] [PATCH 2/2] depmodwrapper: Use native staging dir
Quoted 15 lines · Saul Wold
Use the native staging dir so that we can get the correct depmod.d configuration files. When depmod runs we want to ensure that the newly supported exclude.conf is read so that .debug/<module>.ko files are excluded.
Signed-off-by Saul Wold <[email protected]>--- meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +0
-0@@ -35,9 +35,9 @@ fi
meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb fi · line 43
Quoted 10 lines
meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +2
-2if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [ "\$kernelabi" != "\$4" ]; then echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-\$4" >&2 - exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" "\$4" + exec env depmod -C "\${STAGING_BASE_LIBDIR_NATIVE}/depmod.d" "\$1" "\$2" "\$3" "\$4" else - exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4" + exec env depmod -C "\${STAGING_BASE_LIBDIR_NATIVE}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4" fi EOF chmod +x ${D}${bindir_crossscripts}/depmodwrapper
This doesn't look/feel right to me. Shouldn't we be putting this configuration into the target depmod.d directories and using it from there? What happens if the depmod configuration is machine/target specific?
Cheers,
Richard
Hi Saul,
Saul Wold <[email protected]> escreveu no dia quarta, 30/03/2022 à(s) 23:12:
Quoted 52 lines
This adds a new configuration directive to depmod that causes depmod to exclude a give path entry like .debug.
kernel-dbg provides the modules .debug/<module>.ko files and when installed either directly or when dbg-pkgs are selected this can cause depmod to fail.
This patch will be submitted to upstream kmod.
Signed-off-by Saul Wold <[email protected]>--- .../kmod/depmodwrapper-cross_1.0.bb | 3 + ...dd-support-for-excluding-a-directory.patch | 158 ++++++++++++++++++ meta/recipes-kernel/kmod/kmod_29.bb | 4 + 3 files changed, 165 insertions(+) create mode 100644
meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patchmeta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +3
-0@@ -16,6 +16,9 @@ do_populate_sysroot[depends] = "" do_install() { install -d ${D}${bindir_crossscripts}/ + install -d ${D}${sysconfdir}/depmod.d/ + + echo "exclude .debug" > ${D}${sysconfdir}/depmod.d/exclude.conf cat > ${D}${bindir_crossscripts}/depmodwrapper << EOF #!/bin/shdiff --git
a/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patchb/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patchnew file mode 100644
index 00000000000..3f16cdf0574
---/dev/null
+++b/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patchmeta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +9
-0@@ -0,0 +1,158 @@ +From 8bc07c3ba3a412bd6bb94ad8bad0d76801ec2c9f Mon Sep 17 00:00:00 2001 +From: Saul Wold <[email protected]> +Date: Tue, 22 Mar 2022 12:11:45 -0700 +Subject: [PATCH] depmod: Add support for excluding a directory + +This adds support to depmod to enable a new exclude directive in +the depmod.d/exclude.conf configuration file. Currently depmod +already excludes directories named source or build. This change +will allow additional directories like .debug to be excluded also
meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb line 19
Quoted 10 lines
meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +10
-0+via a new exclude directive. + +depmod.d/exclude.conf example: +exclude .debug + +Upstream-Status: Submitted + +Signed-off-by: Saul Wold <[email protected]> + +%% original patch: 0001-depmod-Add-support-for-excluding-a-directory.patch
This line comes from devtool but is not needed.
Jose
Quoted 188 lines
meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +23
-0+--- + man/depmod.d.xml | 14 +++++++++++++ + tools/depmod.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 68 insertions(+) + +diff --git a/man/depmod.d.xml b/man/depmod.d.xml +index b315e93..9ab790a 100644 +--- a/man/depmod.d.xml ++++ b/man/depmod.d.xml +@@ -131,6 +131,20 @@ + </para> + </listitem> + </varlistentry> ++ <varlistentry> ++ <term>external <replaceable>excludedir</replaceable> ++ </term> ++ <listitem> ++ <para> ++ This specifies the trailing directories that will be excluded ++ during the search for kernel modules. ++ </para> ++ <para> ++ The <replaceable>excludedir</replaceable> the trailingdirectory
++ to exclude
++ </para>
++ </listitem>
++ </varlistentry>meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +29
-0+ </variablelist> + </refsect1> + +diff --git a/tools/depmod.c b/tools/depmod.c +index eb810b8..8b19ab6 100644 +--- a/tools/depmod.c ++++ b/tools/depmod.c +@@ -458,6 +458,12 @@ struct cfg_external { + char path[]; + }; + ++struct cfg_exclude { ++ struct cfg_exclude *next; ++ size_t len; ++ char exclude_dir[]; ++}; ++ + struct cfg { + const char *kversion; + char dirname[PATH_MAX]; +@@ -469,6 +475,7 @@ struct cfg { + struct cfg_override *overrides; + struct cfg_search *searches; + struct cfg_external *externals; ++ struct cfg_exclude *excludes; + }; + + static enum search_type cfg_define_search_type(const char *path) +@@ -580,6 +587,31 @@ static void cfg_external_free(struct cfg_external*ext)
meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +32
-0+ free(ext); + } + ++static int cfg_exclude_add(struct cfg *cfg, const char *path) ++{ ++ struct cfg_exclude *exc; ++ size_t len = strlen(path); ++ ++ exc = malloc(sizeof(struct cfg_exclude) + len); ++ if (exc == NULL) { ++ ERR("exclude add: out of memory\n"); ++ return -ENOMEM; ++ } ++ exc->len = len; ++ memcpy(exc->exclude_dir, path, len); ++ ++ DBG("exclude add: %s\n", path); ++ ++ exc->next = cfg->excludes; ++ cfg->excludes = exc; ++ return 0; ++} ++ ++static void cfg_exclude_free(struct cfg_exclude *exc) ++{ ++ free(exc); ++} ++ + static int cfg_kernel_matches(const struct cfg *cfg, const char *pattern) + { + regex_t re; +@@ -657,6 +689,11 @@ static int cfg_file_parse(struct cfg *cfg, constchar *filename)
meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +6
-0+ } + + cfg_external_add(cfg, dir); ++ } else if (streq(cmd, "exclude")) { ++ const char *sp; ++ while ((sp = strtok_r(NULL, "\t ", &saveptr)) !=NULL) {
++cfg_exclude_add(cfg, sp);
++ }meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +17
-0+ } else if (streq(cmd, "include") + || streq(cmd, "make_map_files")) { + INF("%s:%u: command %s not implemented yet\n", +@@ -857,6 +894,12 @@ static void cfg_free(struct cfg *cfg) + cfg->externals = cfg->externals->next; + cfg_external_free(tmp); + } ++ ++ while (cfg->excludes) { ++ struct cfg_exclude *tmp = cfg->excludes; ++ cfg->excludes = cfg->excludes->next; ++ cfg_exclude_free(tmp); ++ } + } + + +@@ -1239,12 +1282,23 @@ static int depmod_modules_search_dir(structdepmod *depmod, DIR *d,
size_tbaselmeta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +8
-0+ const char *name = de->d_name; + size_t namelen; + uint8_t is_dir; ++ struct cfg_exclude *exc; ++ int exclude = 0; + + if (name[0] == '.' && (name[1] == '\0' || + (name[1] == '.' && name[2] =='\0')))
meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +5
-0+ continue; + if (streq(name, "build") || streq(name, "source")) + continue; ++ ++ for (exc = depmod->cfg->excludes; exc != NULL; exc =
exc->next) {
++ if (streq(name, exc->exclude_dir)) {
++ exclude = 1;
++ }
++ }
++ if (exclude)
++ continue;
++meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb +6
-0+ namelen = strlen(name); + if (scratchbuf_alloc(s_path, baselen + namelen + 2) < 0) { + err = -ENOMEM; +-- +2.31.1 +meta/recipes-kernel/kmod/kmod_29.bb +1
-0@@ -20,6 +20,7 @@ SRCREV = "b6ecfc916a17eab8f93be5b09f4e4f845aabd3d1" SRC_URI = "git:// git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git;branch=master \ file://depmod-search.conf \ file://avoid_parallel_tests.patch \ + file://0001-depmod-Add-support-for-excluding-a-directory.patch \ "S = "${WORKDIR}/git"
meta/recipes-kernel/kmod/kmod_29.bb +0
-0@@ -64,6 +65,9 @@ do_install:append () { # install depmod.d file for search/ dir install -Dm644 "${WORKDIR}/depmod-search.conf""
${D}${nonarch_base_libdir}/depmod.d/search.conf"meta/recipes-kernel/kmod/kmod_29.bb +3
-0+ + # Add .debug to the exclude path for depmod + echo "exclude .debug" >
${D}${nonarch_base_libdir}/depmod.d/exclude.conf
}
ALTERNATIVE_PRIORITY= "70"
--
2.31.1-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#163795):
https://lists.openembedded.org/g/openembedded-core/message/163795
Mute This Topic: https://lists.openembedded.org/mt/90143170/5052612
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Best regards, José Quaresma