]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod, depmod: prefer -ENODATA over -ENOENT if no section found
authorDmitry Antipov <dmantipov@yandex.ru>
Fri, 19 May 2023 09:36:30 +0000 (12:36 +0300)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 30 May 2023 19:54:12 +0000 (12:54 -0700)
When the module is definitely present but CONFIG_MODVERSIONS is
disabled, the following error message may be somewhat confusing:

modprobe --dump-modversions /path/to/module.ko.xz
modprobe: FATAL: could not get modversions of /path/to/module.ko.xz: No such file or directory

Choosing among the convenient errno values, I would suggest to use
ENODATA when the module lacks a particular ELF section (and vermagic
as well). So now it is expected to be:

modprobe: FATAL: could not get modversions of /path/to/module.ko.xz: No data available

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Link: https://lore.kernel.org/r/20230519093630.474185-1-dmantipov@yandex.ru
libkmod/libkmod-elf.c
tools/depmod.c

index ef4a8a3142a1f48dbbe913b9c8a16ac41d205bf8..fb2e3d9293c04bc03bd8c53e2c0c7feb82f1010a 100644 (file)
@@ -392,7 +392,7 @@ static int elf_find_section(const struct kmod_elf *elf, const char *section)
                return i;
        }
 
-       return -ENOENT;
+       return -ENODATA;
 }
 
 int kmod_elf_get_section(const struct kmod_elf *elf, const char *section, const void **buf, uint64_t *buf_size)
@@ -422,7 +422,7 @@ int kmod_elf_get_section(const struct kmod_elf *elf, const char *section, const
                return 0;
        }
 
-       return -ENOENT;
+       return -ENODATA;
 }
 
 /* array will be allocated with strings in a single malloc, just free *array */
@@ -653,7 +653,7 @@ int kmod_elf_strip_vermagic(struct kmod_elf *elf)
        }
 
        ELFDBG(elf, "no vermagic found in .modinfo\n");
-       return -ENOENT;
+       return -ENODATA;
 }
 
 
index a2c39b3f3b1bcb4adae0d6c878c6eaf67ee7dbbc..1d1d41db860ffa699264042eef194bbee735345a 100644 (file)
@@ -1586,7 +1586,7 @@ static int depmod_load_modules(struct depmod *depmod)
                struct kmod_list *l, *list = NULL;
                int err = kmod_module_get_symbols(mod->kmod, &list);
                if (err < 0) {
-                       if (err == -ENOENT)
+                       if (err == -ENODATA)
                                DBG("ignoring %s: no symbols\n", mod->path);
                        else
                                ERR("failed to load symbols from %s: %s\n",