49327a9d0a4f03ae81fdb53be0cf625d9e39c1d5
2 * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License version 2.1
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include <sys/syscall.h>
18 #include <sys/utsname.h>
22 #include <sys/syscall.h>
23 #include <sys/types.h>
35 #include <libubox/avl.h>
36 #include <libubox/avl-cmp.h>
37 #include <libubox/utils.h>
38 #include <libubox/ulog.h>
39 #include <libubox/kvlist.h>
40 #include <libubox/list.h>
42 #define DEF_MOD_PATH "/modules/%s/"
43 #define MOD_BUILTIN "modules.builtin"
44 #define MOD_BUILTIN_MODINFO "modules.builtin.modinfo"
45 /* duplicated from in-kernel include/linux/module.h */
46 #define MODULE_NAME_LEN (64 - sizeof(unsigned long))
52 struct list_head list
;
72 int refcnt
; /* number of references from module_node.m */
81 static struct avl_tree modules
;
82 static KVLIST(options
, kvlist_strlen
);
84 static char **module_folders
= NULL
;
86 static void free_module(struct module
*m
);
88 static int init_module_folders(void)
93 char *s
, *e
, *p
, path
[330], ldpath
[256];
96 s
= getenv("LD_LIBRARY_PATH");
99 e
+= snprintf(ldpath
, sizeof(ldpath
), "%s:", s
);
101 e
+= snprintf(e
, sizeof(ldpath
) - (e
- ldpath
), "/lib");
105 for (s
= p
= ldpath
; p
<= e
; p
++) {
106 if (*p
!= ':' && *p
!= '\0')
110 snprintf(path
, sizeof(path
), "%s" DEF_MOD_PATH
, s
, ver
.release
);
112 if (!stat(path
, &st
) && S_ISDIR(st
.st_mode
)) {
113 module_folders
= realloc(module_folders
, sizeof(p
) * (n
+ 2));
115 if (!module_folders
) {
116 ULOG_ERR("out of memory\n");
120 module_folders
[n
++] = strdup(path
);
126 if (!module_folders
) {
127 ULOG_ERR("no module folders for kernel version %s found\n", ver
.release
);
131 module_folders
[n
] = NULL
;
135 static struct module
*find_module(const char *name
)
137 struct module_node
*mn
;
138 mn
= avl_find_element(&modules
, name
, mn
, avl
);
145 static void free_modules(void)
147 struct module_node
*mn
, *tmp
;
149 avl_remove_all_elements(&modules
, mn
, avl
, tmp
) {
150 struct module
*m
= mn
->m
;
159 static char* get_module_path(char *name
)
162 static char path
[256];
165 if (!stat(name
, &s
) && S_ISREG(s
.st_mode
))
168 for (p
= module_folders
; *p
; p
++) {
169 snprintf(path
, sizeof(path
), "%s%s.ko", *p
, name
);
170 if (!stat(path
, &s
) && S_ISREG(s
.st_mode
))
177 static char* get_module_name(char *path
)
179 static char name
[MODULE_NAME_LEN
];
182 strncpy(name
, basename(path
), sizeof(name
) - 1);
184 t
= strstr(name
, ".ko");
191 static int elf64_find_section(char *map
, const char *section
, unsigned int *offset
, unsigned int *size
)
193 const char *secnames
;
198 e
= (Elf64_Ehdr
*) map
;
199 sh
= (Elf64_Shdr
*) (map
+ e
->e_shoff
);
201 secnames
= map
+ sh
[e
->e_shstrndx
].sh_offset
;
202 for (i
= 0; i
< e
->e_shnum
; i
++) {
203 if (!strcmp(section
, secnames
+ sh
[i
].sh_name
)) {
204 *size
= sh
[i
].sh_size
;
205 *offset
= sh
[i
].sh_offset
;
213 static int elf32_find_section(char *map
, const char *section
, unsigned int *offset
, unsigned int *size
)
215 const char *secnames
;
220 e
= (Elf32_Ehdr
*) map
;
221 sh
= (Elf32_Shdr
*) (map
+ e
->e_shoff
);
223 secnames
= map
+ sh
[e
->e_shstrndx
].sh_offset
;
224 for (i
= 0; i
< e
->e_shnum
; i
++) {
225 if (!strcmp(section
, secnames
+ sh
[i
].sh_name
)) {
226 *size
= sh
[i
].sh_size
;
227 *offset
= sh
[i
].sh_offset
;
235 static int elf_find_section(char *map
, const char *section
, unsigned int *offset
, unsigned int *size
)
237 int clazz
= map
[EI_CLASS
];
238 int endian
= map
[EI_DATA
];
240 #if __BYTE_ORDER == __LITTLE_ENDIAN
241 if (endian
!= ELFDATA2LSB
)
242 #elif __BYTE_ORDER == __BIG_ENDIAN
243 if (endian
!= ELFDATA2MSB
)
245 #error "unsupported endian"
248 ULOG_ERR("invalid endianess: %d\n", endian
);
252 if (clazz
== ELFCLASS32
)
253 return elf32_find_section(map
, section
, offset
, size
);
254 else if (clazz
== ELFCLASS64
)
255 return elf64_find_section(map
, section
, offset
, size
);
257 ULOG_ERR("unknown elf format %d\n", clazz
);
262 static struct module_node
*
263 alloc_module_node(const char *name
, struct module
*m
, bool is_alias
)
265 struct module_node
*mn
;
268 mn
= calloc_a(sizeof(*mn
),
269 &_name
, strlen(name
) + 1);
271 mn
->avl
.key
= strcpy(_name
, name
);
273 mn
->is_alias
= is_alias
;
274 avl_insert(&modules
, &mn
->avl
);
280 static struct module
*
281 alloc_module(const char *name
, const char * const *aliases
, int naliases
, const char *depends
, int size
)
287 m
= calloc_a(sizeof(*m
),
288 &_name
, strlen(name
) + 1,
289 &_dep
, depends
? strlen(depends
) + 2 : 0);
293 m
->name
= strcpy(_name
, name
);
297 m
->depends
= strcpy(_dep
, depends
);
307 alloc_module_node(m
->name
, m
, false);
308 for (i
= 0; i
< naliases
; i
++)
309 alloc_module_node(aliases
[i
], m
, true);
314 static void free_module(struct module
*m
)
321 static int scan_loaded_modules(void)
328 fp
= fopen("/proc/modules", "r");
330 ULOG_ERR("failed to open /proc/modules\n");
334 while (getline(&buf
, &buf_len
, fp
) > 0) {
338 m
.name
= strtok(buf
, " ");
339 m
.size
= atoi(strtok(NULL
, " "));
340 m
.usage
= atoi(strtok(NULL
, " "));
341 m
.depends
= strtok(NULL
, " ");
343 if (!m
.name
|| !m
.depends
)
346 n
= find_module(m
.name
);
348 /* possibly a module outside /lib/modules/<ver>/ */
349 n
= alloc_module(m
.name
, NULL
, 0, m
.depends
, m
.size
);
352 ULOG_ERR("Failed to allocate memory for module\n");
367 static struct module
* get_module_info(const char *module
, const char *name
)
369 const bool is_builtin
= (module
== NULL
);
370 unsigned int offset
, size
;
371 char *map
= MAP_FAILED
, *strings
, *dep
= NULL
;
372 const char **aliases
= NULL
;
373 const char **aliasesr
;
374 const char *mpath
= NULL
;
376 int fd
= -1, naliases
= 0;
377 struct module
*m
= NULL
;
381 for (f
= module_folders
; *f
; f
++) {
382 snprintf(path
, sizeof(path
), "%s%s", *f
, MOD_BUILTIN_MODINFO
);
383 if (!stat(path
, &s
) && S_ISREG(s
.st_mode
)) {
392 ULOG_ERR("cannot find modinfo path of module - %s\n", name
);
396 fd
= open(mpath
, O_RDONLY
);
398 ULOG_ERR("failed to open %s\n", mpath
);
402 if (fstat(fd
, &s
) == -1) {
403 ULOG_ERR("failed to stat %s\n", mpath
);
407 map
= mmap(NULL
, s
.st_size
, PROT_READ
, MAP_PRIVATE
, fd
, 0);
408 if (map
== MAP_FAILED
) {
409 ULOG_ERR("failed to mmap %s\n", mpath
);
416 } else if (elf_find_section(map
, ".modinfo", &offset
, &size
)) {
417 ULOG_ERR("failed to load the .modinfo section from %s\n", mpath
);
421 strings
= map
+ offset
;
428 if (strings
>= map
+ offset
+ size
)
431 sep
= strstr(strings
, ".");
434 if (strlen(name
) == (sep
- strings
) &&
435 !strncmp(strings
, name
, sep
- strings
))
440 sep
= strstr(strings
, "=");
445 if (!strncmp(strings
, "depends=", len
+ 1))
447 else if (!strncmp(strings
, "alias=", len
+ 1)) {
448 aliasesr
= realloc(aliases
, sizeof(sep
) * (naliases
+ 1));
450 ULOG_ERR("out of memory\n");
455 aliases
[naliases
++] = sep
;
458 strings
= &sep
[strlen(sep
)];
461 m
= alloc_module(name
, aliases
, naliases
, dep
, is_builtin
? 0 : s
.st_size
);
464 m
->state
= is_builtin
? BUILTIN
: SCANNED
;
467 if (map
!= MAP_FAILED
)
468 munmap(map
, s
.st_size
);
478 static int scan_builtin_modules(void)
487 if (!module_folders
&& init_module_folders())
489 for (p
= module_folders
; *p
; p
++) {
490 snprintf(path
, sizeof(path
), "%s%s", *p
, MOD_BUILTIN
);
491 if (!stat(path
, &st
) && S_ISREG(st
.st_mode
)) {
492 fp
= fopen(path
, "r");
498 goto out
; /* OK if modules.builtin unavailable */
500 while (getline(&buf
, &buf_len
, fp
) > 0) {
504 name
= get_module_name(buf
);
507 m
= find_module(name
);
508 if (m
&& !strcmp(m
->name
, name
)) {
509 ULOG_WARN("found duplicate builtin module %s\n", name
);
512 m
= get_module_info(NULL
, name
);
514 ULOG_ERR("failed to find info for builtin module %s\n", name
);
527 static int scan_module_folder(const char *dir
)
529 int gl_flags
= GLOB_NOESCAPE
| GLOB_MARK
;
534 path
= alloca(strlen(dir
) + sizeof("*.ko") + 1);
535 sprintf(path
, "%s*.ko", dir
);
537 if (glob(path
, gl_flags
, NULL
, &gl
) < 0)
540 for (j
= 0; j
< gl
.gl_pathc
; j
++) {
541 char *name
= get_module_name(gl
.gl_pathv
[j
]);
548 m
= find_module(name
);
552 m
= get_module_info(gl
.gl_pathv
[j
], name
);
558 opts
= kvlist_get(&options
, name
);
563 m
->state
= BLACKLISTED
;
565 m
->opts
= strdup(opts
);
573 static int scan_module_folders(void)
578 if (init_module_folders())
581 for (p
= module_folders
; *p
; p
++)
582 rv
|= scan_module_folder(*p
);
587 static int print_modinfo(const struct module
*m
)
589 const bool is_builtin
= (m
->state
== BUILTIN
);
590 unsigned int offset
, size
;
593 char *map
= MAP_FAILED
, *strings
, **f
;
594 char path
[350], *mpath
= NULL
;
600 for (f
= module_folders
; *f
; f
++) {
601 snprintf(path
, sizeof(path
), "%s%s", *f
, MOD_BUILTIN_MODINFO
);
602 if (!stat(path
, &s
) && S_ISREG(s
.st_mode
)) {
608 mpath
= get_module_path(m
->name
);
611 ULOG_ERR("cannot find modinfo path of module - %s\n", m
->name
);
615 fd
= open(mpath
, O_RDONLY
);
617 ULOG_ERR("failed to open %s\n", mpath
);
621 if (fstat(fd
, &s
) == -1) {
622 ULOG_ERR("failed to stat %s\n", mpath
);
626 map
= mmap(NULL
, s
.st_size
, PROT_READ
, MAP_PRIVATE
, fd
, 0);
627 if (map
== MAP_FAILED
) {
628 ULOG_ERR("failed to mmap %s\n", mpath
);
635 } else if (elf_find_section(map
, ".modinfo", &offset
, &size
)) {
636 ULOG_ERR("failed to load the .modinfo section from %s\n", mpath
);
640 strings
= map
+ offset
;
642 printf("name:\t\t%s\n", m
->name
);
643 printf("filename:\t%s\n", is_builtin
? "(builtin)" : mpath
);
651 if (strings
>= map
+ offset
+ size
)
654 sep
= strstr(strings
, ".");
657 if (strlen(m
->name
) == (sep
- strings
) &&
658 !strncmp(strings
, m
->name
, sep
- strings
))
663 sep
= strstr(strings
, "=");
666 dup
= strndup(strings
, sep
- strings
);
668 if (strncmp(strings
, "parm", 4)) {
670 printf("%s:\t\t%s\n", dup
, sep
);
672 printf("%s:\t%s\n", dup
, sep
);
674 sep2
= strstr(sep
, ":");
677 pname
= strndup(sep
, sep2
- sep
);
679 pdata
= strdup(sep2
);
681 list_for_each_entry(p
, ¶ms
, list
)
682 if (!strcmp(pname
, p
->name
))
685 if (list_entry_is_h(p
, ¶ms
, list
)) {
686 p
= alloca(sizeof(*p
));
688 p
->desc
= p
->type
= NULL
;
689 list_add(&p
->list
, ¶ms
);
694 if (!strcmp(dup
, "parmtype"))
700 strings
= &sep
[strlen(sep
)];
705 list_for_each_entry(p
, ¶ms
, list
) {
706 printf("parm:\t\t%s", p
->name
);
708 printf(":%s", p
->desc
);
710 printf(" (%s)", p
->type
);
720 if (map
!= MAP_FAILED
)
721 munmap(map
, s
.st_size
);
729 static int deps_available(struct module
*m
, int verbose
)
734 if (!m
->depends
|| !strcmp(m
->depends
, "-") || !strcmp(m
->depends
, ""))
740 m
= find_module(dep
);
743 ULOG_ERR("missing dependency %s\n", dep
);
744 if (verbose
&& m
&& (m
->state
!= LOADED
))
745 ULOG_ERR("dependency not loaded %s\n", dep
);
746 if (!m
|| (m
->state
!= LOADED
))
748 dep
+= strlen(dep
) + 1;
754 static int insert_module(char *path
, const char *options
)
761 ULOG_ERR("Path not specified\n");
765 if (stat(path
, &s
)) {
766 ULOG_ERR("missing module %s\n", path
);
770 fd
= open(path
, O_RDONLY
);
772 ULOG_ERR("cannot open %s\n", path
);
776 data
= malloc(s
.st_size
);
778 ULOG_ERR("out of memory\n");
782 if (read(fd
, data
, s
.st_size
) == s
.st_size
) {
783 ret
= syscall(__NR_init_module
, data
, (unsigned long) s
.st_size
, options
);
788 ULOG_ERR("failed to read full module %s\n", path
);
797 static void load_moddeps(struct module
*_m
)
802 if (!strcmp(_m
->depends
, "-") || !strcmp(_m
->depends
, ""))
808 m
= find_module(dep
);
811 ULOG_ERR("failed to find dependency %s\n", dep
);
812 if (m
&& (m
->state
!= LOADED
)) {
817 dep
= dep
+ strlen(dep
) + 1;
821 static int load_modprobe(bool allow_load_retry
)
823 int loaded
, skipped
, failed
;
824 struct module_node
*mn
;
826 bool load_retry
= false;
827 static bool first_iteration
= true;
829 avl_for_each_element(&modules
, mn
, avl
) {
833 if (m
->state
== PROBE
)
841 avl_for_each_element(&modules
, mn
, avl
) {
845 if ((m
->state
== PROBE
) && (!deps_available(m
, 0)) && (!m
->error
|| load_retry
)) {
846 if (!insert_module(get_module_path(m
->name
), (m
->opts
) ? (m
->opts
) : (""))) {
858 else if (m
->state
== PROBE
)
862 if (allow_load_retry
) {
863 /* if we can't load anything else let's try to load failed modules */
864 load_retry
= loaded
? (failed
&& !skipped
) : (failed
&& !load_retry
&& !first_iteration
);
867 first_iteration
= false;
868 } while (loaded
|| load_retry
);
870 return skipped
+ failed
;
873 static int print_insmod_usage(void)
875 ULOG_INFO("Usage:\n\tinsmod filename [args]\n");
880 static int print_modprobe_usage(void)
884 "\tmodprobe [-q] [-v] filename\n"
885 "\tmodprobe -a [-q] [-v] filename [filename...]\n"
891 static int print_usage(char *arg
)
893 ULOG_INFO("Usage:\n\t%s module\n", arg
);
898 static int main_insmod(int argc
, char **argv
)
900 char *name
, *cur
, *options
;
904 return print_insmod_usage();
906 name
= get_module_name(argv
[1]);
908 ULOG_ERR("cannot find module - %s\n", argv
[1]);
912 if (scan_loaded_modules())
915 if (find_module(name
)) {
916 ULOG_ERR("module is already loaded - %s\n", name
);
923 for (len
= 0, i
= 2; i
< argc
; i
++)
924 len
+= strlen(argv
[i
]) + 1;
926 options
= malloc(len
);
928 ULOG_ERR("out of memory\n");
935 for (i
= 2; i
< argc
; i
++) {
940 cur
+= sprintf(cur
, "%s", argv
[i
]);
943 if (init_module_folders()) {
944 fprintf(stderr
, "Failed to find the folder holding the modules\n");
949 if (get_module_path(argv
[1])) {
951 } else if (!get_module_path(name
)) {
952 fprintf(stderr
, "Failed to find %s. Maybe it is a built in module ?\n", name
);
957 ret
= insert_module(get_module_path(name
), options
);
959 ULOG_ERR("failed to insert %s\n", get_module_path(name
));
966 static int main_rmmod(int argc
, char **argv
)
973 return print_usage("rmmod");
975 if (scan_loaded_modules())
978 if (scan_builtin_modules())
981 name
= get_module_name(argv
[1]);
982 m
= find_module(name
);
984 ULOG_ERR("module is not loaded\n");
987 if (m
->state
== BUILTIN
) {
988 ULOG_ERR("module is builtin\n");
991 ret
= syscall(__NR_delete_module
, m
->name
, 0);
994 ULOG_ERR("unloading the module failed\n");
1001 static int main_lsmod(int argc
, char **argv
)
1003 struct module_node
*mn
;
1007 if (scan_loaded_modules())
1010 avl_for_each_element(&modules
, mn
, avl
) {
1014 if (m
->state
== LOADED
) {
1015 printf("%-20s%8d%3d ",
1016 m
->name
, m
->size
, m
->usage
);
1017 if (m
->depends
&& strcmp(m
->depends
, "-") && strcmp(m
->depends
, "")) {
1021 dep
= dep
+ strlen(dep
) + 1;
1035 static int main_modinfo(int argc
, char **argv
)
1041 return print_usage("modinfo");
1043 if (scan_module_folders())
1046 if (scan_builtin_modules())
1049 name
= get_module_name(argv
[1]);
1050 m
= find_module(name
);
1052 ULOG_ERR("cannot find module - %s\n", argv
[1]);
1061 static int main_modprobe(int argc
, char **argv
)
1063 struct module_node
*mn
;
1067 int log_level
= LOG_WARNING
;
1070 bool use_all
= false;
1072 while ((opt
= getopt(argc
, argv
, "aqv")) != -1 ) {
1077 case 'q': /* shhhh! */
1081 log_level
= LOG_DEBUG
;
1084 return print_modprobe_usage();
1090 return print_modprobe_usage(); /* expected module after options */
1092 /* after print_modprobe_usage() so it won't be filtered out */
1093 ulog_threshold(log_level
);
1095 if (scan_module_folders())
1098 if (scan_loaded_modules())
1101 if (scan_builtin_modules())
1107 name
= get_module_name(argv
[optind
]);
1108 m
= find_module(name
);
1110 if (m
&& m
->state
== BLACKLISTED
) {
1112 ULOG_INFO("%s is blacklisted\n", name
);
1113 } else if (m
&& m
->state
== LOADED
) {
1115 ULOG_INFO("%s is already loaded\n", name
);
1116 } else if (m
&& m
->state
== BUILTIN
) {
1118 ULOG_INFO("%s is builtin\n", name
);
1121 ULOG_ERR("failed to find a module named %s\n", name
);
1128 } while (use_all
&& optind
< argc
);
1130 load_fail
= load_modprobe(true);
1132 ULOG_ERR("%d module%s could not be probed\n",
1133 load_fail
, (load_fail
== 1) ? ("") : ("s"));
1135 avl_for_each_element(&modules
, mn
, avl
) {
1139 if ((m
->state
== PROBE
) || m
->error
)
1140 ULOG_ERR("- %s\n", m
->name
);
1151 static int main_loader(int argc
, char **argv
)
1153 int gl_flags
= GLOB_NOESCAPE
| GLOB_MARK
;
1154 char *dir
= "/etc/modules.d/";
1155 struct module_node
*mn
;
1159 int ret
= 0, fail
, j
;
1164 path
= malloc(strlen(dir
) + 2);
1166 ULOG_ERR("out of memory\n");
1173 if (scan_module_folders()) {
1178 if (scan_loaded_modules()) {
1183 ULOG_INFO("loading kernel modules from %s\n", path
);
1185 if (glob(path
, gl_flags
, NULL
, &gl
) < 0)
1188 for (j
= 0; j
< gl
.gl_pathc
; j
++) {
1189 FILE *fp
= fopen(gl
.gl_pathv
[j
], "r");
1194 ULOG_ERR("failed to open %s\n", gl
.gl_pathv
[j
]);
1198 while (getline(&mod
, &mod_len
, fp
) > 0) {
1199 char *nl
= strchr(mod
, '\n');
1206 opts
= strchr(mod
, ' ');
1210 m
= find_module(get_module_name(mod
));
1211 if (!m
|| m
->state
== LOADED
|| m
->state
== BLACKLISTED
)
1216 char *prev
= m
->opts
;
1218 fail
= asprintf(&m
->opts
, "%s %s", prev
, opts
);
1221 ULOG_ERR("out of memory for opts %s\n", opts
);
1228 m
->opts
= strdup(opts
);
1232 if (basename(gl
.gl_pathv
[j
])[0] - '0' <= 9)
1233 load_modprobe(false);
1240 fail
= load_modprobe(true);
1243 ULOG_ERR("%d module%s could not be probed\n",
1244 fail
, (fail
== 1) ? ("") : ("s"));
1246 avl_for_each_element(&modules
, mn
, avl
) {
1250 if ((m
->state
== PROBE
) || (m
->error
))
1251 ULOG_ERR("- %s - %d\n", m
->name
, deps_available(m
, 1));
1254 ULOG_INFO("done loading kernel modules from %s\n", path
);
1265 static inline char weight(char c
)
1267 return c
== '_' ? '-' : c
;
1270 static int avl_modcmp(const void *k1
, const void *k2
, void *ptr
)
1272 const char *s1
= k1
;
1273 const char *s2
= k2
;
1275 while (*s1
&& (weight(*s1
) == weight(*s2
)))
1281 return (unsigned char)weight(*s1
) - (unsigned char)weight(*s2
);
1287 static char buf
[512];
1291 f
= fopen("/etc/modules.conf", "r");
1295 while ((s
= fgets(buf
, sizeof(buf
), f
)) != NULL
) {
1296 char *c
, *cmd
, *mod
;
1309 while (c
> s
&& isspace(c
[-1])) {
1314 cmd
= strsep(&s
, " \t");
1321 mod
= strsep(&s
, " \t");
1325 if (!strcmp(cmd
, "blacklist")) {
1326 kvlist_set(&options
, mod
, "\x01");
1330 if (!strcmp(cmd
, "options")) {
1331 char *prev
= kvlist_get(&options
, mod
);
1340 if (prev
&& prev
[0] == '\x01')
1344 kvlist_set(&options
, mod
, s
);
1348 if (asprintf(&val
, "%s %s", prev
, s
) < 0)
1351 kvlist_set(&options
, mod
, val
);
1360 int main(int argc
, char **argv
)
1362 char *exec
= basename(*argv
);
1364 avl_init(&modules
, avl_modcmp
, false, NULL
);
1365 if (!strcmp(exec
, "insmod"))
1366 return main_insmod(argc
, argv
);
1368 if (!strcmp(exec
, "rmmod"))
1369 return main_rmmod(argc
, argv
);
1371 if (!strcmp(exec
, "lsmod"))
1372 return main_lsmod(argc
, argv
);
1374 if (!strcmp(exec
, "modinfo"))
1375 return main_modinfo(argc
, argv
);
1379 if (!strcmp(exec
, "modprobe"))
1380 return main_modprobe(argc
, argv
);
1382 ulog_open(ULOG_KMSG
, LOG_USER
, "kmodloader");
1383 return main_loader(argc
, argv
);