summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaul Wold <Saul.Wold@windriver.com>2022-03-31 15:21:52 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-04-03 10:40:31 +0100
commit708cbdf3c9d93b8cbfb5877e16a1e3fe0e274524 (patch)
tree41daf7dab2a4c133525dc1ad3b1af2a5cb6777f6
parentd0a05c2cf9a4e3329d7bbd798415e94a3a9caa55 (diff)
downloadpoky-708cbdf3c9d93b8cbfb5877e16a1e3fe0e274524.tar.gz
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. (From OE-Core rev: 5e7d09142da82c37aeab22c34d5314187c90bd84) Signed-off-by: Saul Wold <saul.wold@windriver.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch169
-rw-r--r--meta/recipes-kernel/kmod/kmod_29.bb4
2 files changed, 173 insertions, 0 deletions
diff --git a/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch b/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
new file mode 100644
index 0000000000..18d9793533
--- /dev/null
+++ b/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
@@ -0,0 +1,169 @@
1From 01f3fe68a7a42b06eb318f3b09fa5e5ea75d46c4 Mon Sep 17 00:00:00 2001
2From: Saul Wold <saul.wold@windriver.com>
3Date: Tue, 22 Mar 2022 12:11:45 -0700
4Subject: [PATCH] depmod: Add support for excluding a directory
5
6This adds support to depmod to enable a new exclude directive in
7the depmod.d/*.conf configuration file. Currently depmod
8already excludes directories named source or build. This change
9will allow additional directories like .debug to be excluded also
10via a new exclude directive.
11
12depmod.d/exclude.conf example:
13exclude .debug
14
15Upstream-Status: Submitted
16
17Signed-off-by: Saul Wold <saul.wold@windriver.com>
18---
19 man/depmod.d.xml | 14 +++++++++++
20 tools/depmod.c | 65 +++++++++++++++++++++++++++++++++++++++++++++---
21 2 files changed, 75 insertions(+), 4 deletions(-)
22
23diff --git a/man/depmod.d.xml b/man/depmod.d.xml
24index b315e93..76548e9 100644
25--- a/man/depmod.d.xml
26+++ b/man/depmod.d.xml
27@@ -131,6 +131,20 @@
28 </para>
29 </listitem>
30 </varlistentry>
31+ <varlistentry>
32+ <term>exclude <replaceable>excludedir</replaceable>
33+ </term>
34+ <listitem>
35+ <para>
36+ This specifies the trailing directories that will be excluded
37+ during the search for kernel modules.
38+ </para>
39+ <para>
40+ The <replaceable>excludedir</replaceable> is the trailing directory
41+ to exclude
42+ </para>
43+ </listitem>
44+ </varlistentry>
45 </variablelist>
46 </refsect1>
47
48diff --git a/tools/depmod.c b/tools/depmod.c
49index eb810b8..ac365e9 100644
50--- a/tools/depmod.c
51+++ b/tools/depmod.c
52@@ -458,6 +458,11 @@ struct cfg_external {
53 char path[];
54 };
55
56+struct cfg_exclude {
57+ struct cfg_exclude *next;
58+ char exclude_dir[];
59+};
60+
61 struct cfg {
62 const char *kversion;
63 char dirname[PATH_MAX];
64@@ -469,6 +474,7 @@ struct cfg {
65 struct cfg_override *overrides;
66 struct cfg_search *searches;
67 struct cfg_external *externals;
68+ struct cfg_exclude *excludes;
69 };
70
71 static enum search_type cfg_define_search_type(const char *path)
72@@ -580,6 +586,30 @@ static void cfg_external_free(struct cfg_external *ext)
73 free(ext);
74 }
75
76+static int cfg_exclude_add(struct cfg *cfg, const char *path)
77+{
78+ struct cfg_exclude *exc;
79+ size_t len = strlen(path);
80+
81+ exc = malloc(sizeof(struct cfg_exclude) + len + 1);
82+ if (exc == NULL) {
83+ ERR("exclude add: out of memory\n");
84+ return -ENOMEM;
85+ }
86+ memcpy(exc->exclude_dir, path, len + 1);
87+
88+ DBG("exclude add: %s\n", path);
89+
90+ exc->next = cfg->excludes;
91+ cfg->excludes = exc;
92+ return 0;
93+}
94+
95+static void cfg_exclude_free(struct cfg_exclude *exc)
96+{
97+ free(exc);
98+}
99+
100 static int cfg_kernel_matches(const struct cfg *cfg, const char *pattern)
101 {
102 regex_t re;
103@@ -657,6 +687,11 @@ static int cfg_file_parse(struct cfg *cfg, const char *filename)
104 }
105
106 cfg_external_add(cfg, dir);
107+ } else if (streq(cmd, "exclude")) {
108+ const char *sp;
109+ while ((sp = strtok_r(NULL, "\t ", &saveptr)) != NULL) {
110+ cfg_exclude_add(cfg, sp);
111+ }
112 } else if (streq(cmd, "include")
113 || streq(cmd, "make_map_files")) {
114 INF("%s:%u: command %s not implemented yet\n",
115@@ -857,6 +892,12 @@ static void cfg_free(struct cfg *cfg)
116 cfg->externals = cfg->externals->next;
117 cfg_external_free(tmp);
118 }
119+
120+ while (cfg->excludes) {
121+ struct cfg_exclude *tmp = cfg->excludes;
122+ cfg->excludes = cfg->excludes->next;
123+ cfg_exclude_free(tmp);
124+ }
125 }
126
127
128@@ -1229,6 +1270,24 @@ add:
129 return 0;
130 }
131
132+static int should_exclude_dir(struct cfg *cfg, char *name)
133+{
134+ struct cfg_exclude *exc;
135+
136+ if (name[0] == '.' && (name[1] == '\0' ||
137+ (name[1] == '.' && name[2] == '\0')))
138+ return 1;
139+ if (streq(name, "build") || streq(name, "source"))
140+ return 1;
141+
142+ for (exc = cfg->excludes; exc != NULL; exc = exc->next) {
143+ if (streq(name, exc->exclude_dir)) {
144+ return 1;
145+ }
146+ }
147+ return 0;
148+}
149+
150 static int depmod_modules_search_dir(struct depmod *depmod, DIR *d, size_t baselen, struct scratchbuf *s_path)
151 {
152 struct dirent *de;
153@@ -1240,11 +1299,9 @@ static int depmod_modules_search_dir(struct depmod *depmod, DIR *d, size_t basel
154 size_t namelen;
155 uint8_t is_dir;
156
157- if (name[0] == '.' && (name[1] == '\0' ||
158- (name[1] == '.' && name[2] == '\0')))
159- continue;
160- if (streq(name, "build") || streq(name, "source"))
161+ if (should_exclude_dir(depmod->cfg, name))
162 continue;
163+
164 namelen = strlen(name);
165 if (scratchbuf_alloc(s_path, baselen + namelen + 2) < 0) {
166 err = -ENOMEM;
167--
1682.31.1
169
diff --git a/meta/recipes-kernel/kmod/kmod_29.bb b/meta/recipes-kernel/kmod/kmod_29.bb
index 91951edde1..9b66349066 100644
--- a/meta/recipes-kernel/kmod/kmod_29.bb
+++ b/meta/recipes-kernel/kmod/kmod_29.bb
@@ -20,6 +20,7 @@ SRCREV = "b6ecfc916a17eab8f93be5b09f4e4f845aabd3d1"
20SRC_URI = "git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git;branch=master \ 20SRC_URI = "git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git;branch=master \
21 file://depmod-search.conf \ 21 file://depmod-search.conf \
22 file://avoid_parallel_tests.patch \ 22 file://avoid_parallel_tests.patch \
23 file://0001-depmod-Add-support-for-excluding-a-directory.patch \
23 " 24 "
24 25
25S = "${WORKDIR}/git" 26S = "${WORKDIR}/git"
@@ -64,6 +65,9 @@ do_install:append () {
64 65
65 # install depmod.d file for search/ dir 66 # install depmod.d file for search/ dir
66 install -Dm644 "${WORKDIR}/depmod-search.conf" "${D}${nonarch_base_libdir}/depmod.d/search.conf" 67 install -Dm644 "${WORKDIR}/depmod-search.conf" "${D}${nonarch_base_libdir}/depmod.d/search.conf"
68
69 # Add .debug to the exclude path for depmod
70 echo "exclude .debug" > ${D}${nonarch_base_libdir}/depmod.d/exclude.conf
67} 71}
68 72
69ALTERNATIVE_PRIORITY = "70" 73ALTERNATIVE_PRIORITY = "70"