2 * kmod-modprobe - manage linux kernel modules using libkmod.
4 * Copyright (C) 2011-2013 ProFUSION embedded systems
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 #include <sys/types.h>
31 #include <sys/utsname.h>
34 #include <shared/array.h>
35 #include <shared/util.h>
36 #include <shared/macro.h>
38 #include <libkmod/libkmod.h>
42 static int log_priority
= LOG_CRIT
;
43 static int use_syslog
= 0;
44 #define LOG(...) log_printf(log_priority, __VA_ARGS__)
46 #define DEFAULT_VERBOSE LOG_WARNING
47 static int verbose
= DEFAULT_VERBOSE
;
48 static int do_show
= 0;
49 static int dry_run
= 0;
50 static int ignore_loaded
= 0;
51 static int lookup_only
= 0;
52 static int first_time
= 0;
53 static int ignore_commands
= 0;
54 static int use_blacklist
= 0;
56 static int strip_modversion
= 0;
57 static int strip_vermagic
= 0;
58 static int remove_holders
= 0;
59 static unsigned long long wait_msec
= 0;
60 static int quiet_inuse
= 0;
62 static const char cmdopts_s
[] = "arw:RibfDcnC:d:S:sqvVh";
63 static const struct option cmdopts
[] = {
64 {"all", no_argument
, 0, 'a'},
66 {"remove", no_argument
, 0, 'r'},
67 {"remove-dependencies", no_argument
, 0, 5},
68 {"remove-holders", no_argument
, 0, 5},
69 {"wait", required_argument
, 0, 'w'},
71 {"resolve-alias", no_argument
, 0, 'R'},
72 {"first-time", no_argument
, 0, 3},
73 {"ignore-install", no_argument
, 0, 'i'},
74 {"ignore-remove", no_argument
, 0, 'i'},
75 {"use-blacklist", no_argument
, 0, 'b'},
76 {"force", no_argument
, 0, 'f'},
77 {"force-modversion", no_argument
, 0, 2},
78 {"force-vermagic", no_argument
, 0, 1},
80 {"show-depends", no_argument
, 0, 'D'},
81 {"showconfig", no_argument
, 0, 'c'},
82 {"show-config", no_argument
, 0, 'c'},
83 {"show-modversions", no_argument
, 0, 4},
84 {"dump-modversions", no_argument
, 0, 4},
85 {"show-exports", no_argument
, 0, 6},
87 {"dry-run", no_argument
, 0, 'n'},
88 {"show", no_argument
, 0, 'n'},
90 {"config", required_argument
, 0, 'C'},
91 {"dirname", required_argument
, 0, 'd'},
92 {"set-version", required_argument
, 0, 'S'},
94 {"syslog", no_argument
, 0, 's'},
95 {"quiet", no_argument
, 0, 'q'},
96 {"verbose", no_argument
, 0, 'v'},
97 {"version", no_argument
, 0, 'V'},
98 {"help", no_argument
, 0, 'h'},
102 static void help(void)
105 "\t%s [options] [-i] [-b] modulename\n"
106 "\t%s [options] -a [-i] [-b] modulename [modulename...]\n"
107 "\t%s [options] -r [-i] modulename\n"
108 "\t%s [options] -r -a [-i] modulename [modulename...]\n"
109 "\t%s [options] -c\n"
110 "\t%s [options] --dump-modversions filename\n"
111 "Management Options:\n"
112 "\t-a, --all Consider every non-argument to\n"
113 "\t be a module name to be inserted\n"
114 "\t or removed (-r)\n"
115 "\t-r, --remove Remove modules instead of inserting\n"
116 "\t --remove-dependencies Deprecated: use --remove-holders\n"
117 "\t --remove-holders Also remove module holders (use together with -r)\n"
118 "\t-w, --wait <MSEC> When removing a module, wait up to MSEC for\n"
119 "\t module's refcount to become 0 so it can be\n"
120 "\t removed (use together with -r)\n"
121 "\t --first-time Fail if module already inserted or removed\n"
122 "\t-i, --ignore-install Ignore install commands\n"
123 "\t-i, --ignore-remove Ignore remove commands\n"
124 "\t-b, --use-blacklist Apply blacklist to resolved alias.\n"
125 "\t-f, --force Force module insertion or removal.\n"
126 "\t implies --force-modversions and\n"
127 "\t --force-vermagic\n"
128 "\t --force-modversion Ignore module's version\n"
129 "\t --force-vermagic Ignore module's version magic\n"
132 "\t-R, --resolve-alias Only lookup and print alias and exit\n"
133 "\t-D, --show-depends Only print module dependencies and exit\n"
134 "\t-c, --showconfig Print out known configuration and exit\n"
135 "\t-c, --show-config Same as --showconfig\n"
136 "\t --show-modversions Dump module symbol version and exit\n"
137 "\t --dump-modversions Same as --show-modversions\n"
138 "\t --show-exports Only print module exported symbol versions and exit\n"
141 "\t-n, --dry-run Do not execute operations, just print out\n"
142 "\t-n, --show Same as --dry-run\n"
144 "\t-C, --config=FILE Use FILE instead of default search paths\n"
145 "\t-d, --dirname=DIR Use DIR as filesystem root for " MODULE_DIRECTORY
"\n"
146 "\t-S, --set-version=VERSION Use VERSION instead of `uname -r`\n"
148 "\t-s, --syslog print to syslog, not stderr\n"
149 "\t-q, --quiet disable messages\n"
150 "\t-v, --verbose enables more messages\n"
151 "\t-V, --version show version\n"
152 "\t-h, --help show this help\n",
153 program_invocation_short_name
, program_invocation_short_name
,
154 program_invocation_short_name
, program_invocation_short_name
,
155 program_invocation_short_name
, program_invocation_short_name
);
158 _printf_format_(1, 2)
159 static inline void _show(const char *fmt
, ...)
163 if (!do_show
&& verbose
<= DEFAULT_VERBOSE
)
167 vfprintf(stdout
, fmt
, args
);
171 #define SHOW(...) _show(__VA_ARGS__)
173 static int show_config(struct kmod_ctx
*ctx
)
175 struct config_iterators
{
177 struct kmod_config_iter
*(*get_iter
)(const struct kmod_ctx
*ctx
);
179 { "blacklist", kmod_config_get_blacklists
},
180 { "install", kmod_config_get_install_commands
},
181 { "remove", kmod_config_get_remove_commands
},
182 { "alias", kmod_config_get_aliases
},
183 { "options", kmod_config_get_options
},
184 { "softdep", kmod_config_get_softdeps
},
185 { "weakdep", kmod_config_get_weakdeps
},
189 for (i
= 0; i
< ARRAY_SIZE(ci
); i
++) {
190 struct kmod_config_iter
*iter
= ci
[i
].get_iter(ctx
);
195 while (kmod_config_iter_next(iter
)) {
198 printf("%s %s", ci
[i
].name
,
199 kmod_config_iter_get_key(iter
));
200 val
= kmod_config_iter_get_value(iter
);
208 kmod_config_iter_free_iter(iter
);
211 puts("\n# End of configuration files. Dumping indexes now:\n");
214 kmod_dump_index(ctx
, KMOD_INDEX_MODULES_ALIAS
, STDOUT_FILENO
);
215 kmod_dump_index(ctx
, KMOD_INDEX_MODULES_SYMBOL
, STDOUT_FILENO
);
220 static int show_modversions(struct kmod_ctx
*ctx
, const char *filename
)
222 struct kmod_list
*l
, *list
= NULL
;
223 struct kmod_module
*mod
;
224 int err
= kmod_module_new_from_path(ctx
, filename
, &mod
);
226 LOG("Module %s not found.\n", filename
);
230 err
= kmod_module_get_versions(mod
, &list
);
232 LOG("could not get modversions of %s: %s\n",
233 filename
, strerror(-err
));
234 kmod_module_unref(mod
);
238 kmod_list_foreach(l
, list
) {
239 const char *symbol
= kmod_module_version_get_symbol(l
);
240 uint64_t crc
= kmod_module_version_get_crc(l
);
241 printf("0x%08"PRIx64
"\t%s\n", crc
, symbol
);
243 kmod_module_versions_free_list(list
);
244 kmod_module_unref(mod
);
248 static int show_exports(struct kmod_ctx
*ctx
, const char *filename
)
250 struct kmod_list
*l
, *list
= NULL
;
251 struct kmod_module
*mod
;
252 int err
= kmod_module_new_from_path(ctx
, filename
, &mod
);
254 LOG("Module %s not found.\n", filename
);
258 err
= kmod_module_get_symbols(mod
, &list
);
260 LOG("could not get symbols of %s: %s\n",
261 filename
, strerror(-err
));
262 kmod_module_unref(mod
);
266 kmod_list_foreach(l
, list
) {
267 const char *symbol
= kmod_module_symbol_get_symbol(l
);
268 uint64_t crc
= kmod_module_symbol_get_crc(l
);
269 printf("0x%08"PRIx64
"\t%s\n", crc
, symbol
);
271 kmod_module_symbols_free_list(list
);
272 kmod_module_unref(mod
);
276 static int command_do(struct kmod_module
*module
, const char *type
,
277 const char *command
, const char *cmdline_opts
)
279 const char *modname
= kmod_module_get_name(module
);
280 char *p
, *cmd
= NULL
;
281 size_t cmdlen
, cmdline_opts_len
, varlen
;
284 if (cmdline_opts
== NULL
)
286 cmdline_opts_len
= strlen(cmdline_opts
);
288 cmd
= strdup(command
);
291 cmdlen
= strlen(cmd
);
292 varlen
= sizeof("$CMDLINE_OPTS") - 1;
293 while ((p
= strstr(cmd
, "$CMDLINE_OPTS")) != NULL
) {
294 size_t prefixlen
= p
- cmd
;
295 size_t suffixlen
= cmdlen
- prefixlen
- varlen
;
296 size_t slen
= cmdlen
- varlen
+ cmdline_opts_len
;
297 char *suffix
= p
+ varlen
;
298 char *s
= malloc(slen
+ 1);
303 memcpy(s
, cmd
, p
- cmd
);
304 memcpy(s
+ prefixlen
, cmdline_opts
, cmdline_opts_len
);
305 memcpy(s
+ prefixlen
+ cmdline_opts_len
, suffix
, suffixlen
);
313 SHOW("%s %s\n", type
, cmd
);
317 setenv("MODPROBE_MODULE", modname
, 1);
319 unsetenv("MODPROBE_MODULE");
320 if (ret
== -1 || WEXITSTATUS(ret
)) {
321 LOG("Error running %s command for %s\n", type
, modname
);
323 ret
= -WEXITSTATUS(ret
);
331 static int rmmod_do_remove_module(struct kmod_module
*mod
)
333 const char *modname
= kmod_module_get_name(mod
);
334 unsigned long long interval_msec
= 0, t0_msec
= 0,
338 SHOW("rmmod %s\n", modname
);
344 flags
|= KMOD_REMOVE_FORCE
;
347 flags
|= KMOD_REMOVE_NOLOG
;
350 err
= kmod_module_remove_module(mod
, flags
);
351 if (err
== -EEXIST
) {
355 LOG("Module %s is not in kernel.\n", modname
);
357 } else if (err
== -EAGAIN
&& wait_msec
) {
358 unsigned long long until_msec
;
361 t0_msec
= now_msec();
362 tend_msec
= t0_msec
+ wait_msec
;
366 until_msec
= get_backoff_delta_msec(t0_msec
, tend_msec
,
368 err
= sleep_until_msec(until_msec
);
374 ERR("Failed to sleep: %s\n", strerror(-err
));
381 } while (interval_msec
);
383 if (err
< 0 && wait_msec
)
384 ERR("could not remove '%s': %s\n", modname
, strerror(-err
));
389 #define RMMOD_FLAG_REMOVE_HOLDERS 0x1
390 #define RMMOD_FLAG_IGNORE_BUILTIN 0x2
391 static int rmmod_do_module(struct kmod_module
*mod
, int flags
);
393 /* Remove modules in reverse order */
394 static int rmmod_do_modlist(struct kmod_list
*list
, bool stop_on_errors
)
398 kmod_list_foreach_reverse(l
, list
) {
399 struct kmod_module
*m
= kmod_module_get_module(l
);
400 int r
= rmmod_do_module(m
, RMMOD_FLAG_IGNORE_BUILTIN
);
401 kmod_module_unref(m
);
403 if (r
< 0 && stop_on_errors
)
410 static int rmmod_do_module(struct kmod_module
*mod
, int flags
)
412 const char *modname
= kmod_module_get_name(mod
);
413 struct kmod_list
*pre
= NULL
, *post
= NULL
;
414 const char *cmd
= NULL
;
417 if (!ignore_commands
) {
418 err
= kmod_module_get_softdeps(mod
, &pre
, &post
);
420 WRN("could not get softdeps of '%s': %s\n",
421 modname
, strerror(-err
));
425 cmd
= kmod_module_get_remove_commands(mod
);
428 /* Quick check if module is loaded, otherwise there's nothing to do */
429 if (!cmd
&& !ignore_loaded
) {
430 int state
= kmod_module_get_initstate(mod
);
434 LOG("Module %s is not in kernel.\n", modname
);
440 } else if (state
== KMOD_MODULE_BUILTIN
) {
441 if (flags
& RMMOD_FLAG_IGNORE_BUILTIN
) {
444 LOG("Module %s is builtin.\n", modname
);
451 /* 1. @mod's post-softdeps in reverse order */
452 rmmod_do_modlist(post
, false);
454 /* 2. Other modules holding @mod */
455 if (flags
& RMMOD_FLAG_REMOVE_HOLDERS
) {
456 struct kmod_list
*holders
= kmod_module_get_holders(mod
);
458 err
= rmmod_do_modlist(holders
, true);
459 kmod_module_unref_list(holders
);
464 /* 3. @mod itself, but check for refcnt first */
465 if (!cmd
&& !ignore_loaded
&& !wait_msec
) {
466 int usage
= kmod_module_get_refcnt(mod
);
470 LOG("Module %s is in use.\n", modname
);
478 err
= rmmod_do_remove_module(mod
);
480 err
= command_do(mod
, "remove", cmd
, NULL
);
485 /* 4. Other modules that became unused: errors are non-fatal */
487 struct kmod_list
*deps
, *itr
;
489 deps
= kmod_module_get_dependencies(mod
);
490 kmod_list_foreach(itr
, deps
) {
491 struct kmod_module
*dep
= kmod_module_get_module(itr
);
492 if (kmod_module_get_refcnt(dep
) == 0)
493 rmmod_do_remove_module(dep
);
494 kmod_module_unref(dep
);
496 kmod_module_unref_list(deps
);
499 /* 5. @mod's pre-softdeps in reverse order: errors are non-fatal */
500 rmmod_do_modlist(pre
, false);
503 kmod_module_unref_list(pre
);
504 kmod_module_unref_list(post
);
509 static int rmmod(struct kmod_ctx
*ctx
, const char *alias
)
511 struct kmod_list
*l
, *list
= NULL
;
514 err
= kmod_module_new_from_lookup(ctx
, alias
, &list
);
519 LOG("Module %s not found.\n", alias
);
523 kmod_list_foreach(l
, list
) {
524 struct kmod_module
*mod
= kmod_module_get_module(l
);
525 int flags
= remove_holders
? RMMOD_FLAG_REMOVE_HOLDERS
: 0;
527 err
= rmmod_do_module(mod
, flags
);
528 kmod_module_unref(mod
);
533 kmod_module_unref_list(list
);
537 static int rmmod_all(struct kmod_ctx
*ctx
, char **args
, int nargs
)
541 for (i
= 0; i
< nargs
; i
++) {
542 int r
= rmmod(ctx
, args
[i
]);
550 static void print_action(struct kmod_module
*m
, bool install
,
556 printf("install %s %s\n", kmod_module_get_install_commands(m
),
561 path
= kmod_module_get_path(m
);
565 * Either a builtin module, or an alias, print only for
568 if (kmod_module_get_initstate(m
) == KMOD_MODULE_BUILTIN
)
569 printf("builtin %s\n", kmod_module_get_name(m
));
571 printf("insmod %s %s\n", kmod_module_get_path(m
), options
);
574 static int insmod_insert(struct kmod_module
*mod
, int flags
,
575 const char *extra_options
)
578 void (*show
)(struct kmod_module
*m
, bool install
,
579 const char *options
) = NULL
;
581 if (do_show
|| verbose
> DEFAULT_VERBOSE
)
582 show
= &print_action
;
585 printf("%s\n", kmod_module_get_name(mod
));
587 err
= kmod_module_probe_insert_module(mod
, flags
,
588 extra_options
, NULL
, NULL
, show
);
591 /* ignore flag return values such as a mod being blacklisted */
596 ERR("could not insert '%s': Module already in kernel\n",
597 kmod_module_get_name(mod
));
600 ERR("could not insert '%s': Unknown symbol in module, "
601 "or unknown parameter (see dmesg)\n",
602 kmod_module_get_name(mod
));
605 ERR("could not insert '%s': %s\n",
606 kmod_module_get_name(mod
),
615 static int insmod(struct kmod_ctx
*ctx
, const char *alias
,
616 const char *extra_options
)
618 struct kmod_list
*l
, *list
= NULL
;
619 struct kmod_module
*mod
= NULL
;
622 if (strncmp(alias
, "/", 1) == 0 || strncmp(alias
, "./", 2) == 0) {
623 err
= kmod_module_new_from_path(ctx
, alias
, &mod
);
625 LOG("Failed to get module from path %s: %s\n", alias
,
630 err
= kmod_module_new_from_lookup(ctx
, alias
, &list
);
631 if (list
== NULL
|| err
< 0) {
632 LOG("Module %s not found in directory %s\n", alias
,
633 ctx
? kmod_get_dirname(ctx
) : "(missing)");
638 if (strip_modversion
|| force
)
639 flags
|= KMOD_PROBE_FORCE_MODVERSION
;
640 if (strip_vermagic
|| force
)
641 flags
|= KMOD_PROBE_FORCE_VERMAGIC
;
643 flags
|= KMOD_PROBE_IGNORE_COMMAND
;
645 flags
|= KMOD_PROBE_IGNORE_LOADED
;
647 flags
|= KMOD_PROBE_DRY_RUN
;
649 flags
|= KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY
;
652 flags
|= KMOD_PROBE_APPLY_BLACKLIST
;
654 flags
|= KMOD_PROBE_FAIL_ON_LOADED
;
656 /* If module is loaded from path */
658 err
= insmod_insert(mod
, flags
, extra_options
);
659 kmod_module_unref(mod
);
661 kmod_list_foreach(l
, list
) {
662 mod
= kmod_module_get_module(l
);
663 err
= insmod_insert(mod
, flags
, extra_options
);
664 kmod_module_unref(mod
);
666 kmod_module_unref_list(list
);
671 static int insmod_all(struct kmod_ctx
*ctx
, char **args
, int nargs
)
675 for (i
= 0; i
< nargs
; i
++) {
676 int r
= insmod(ctx
, args
[i
], NULL
);
684 static void env_modprobe_options_append(const char *value
)
686 const char *old
= getenv("MODPROBE_OPTIONS");
690 setenv("MODPROBE_OPTIONS", value
, 1);
694 if (asprintf(&env
, "%s %s", old
, value
) < 0) {
695 ERR("could not append value to $MODPROBE_OPTIONS\n");
699 if (setenv("MODPROBE_OPTIONS", env
, 1) < 0)
700 ERR("could not setenv(MODPROBE_OPTIONS, \"%s\")\n", env
);
704 static int options_from_array(char **args
, int nargs
, char **output
)
710 for (i
= 1; i
< nargs
; i
++) {
711 size_t len
= strlen(args
[i
]);
716 value
= strchr(args
[i
], '=');
719 if (*value
!= '"' && *value
!= '\'') {
720 if (strchr(value
, ' '))
725 tmp
= realloc(opts
, optslen
+ len
+ qlen
+ 2);
730 ERR("could not gather module options: out-of-memory\n");
739 memcpy(opts
+ optslen
, args
[i
], len
+ 1);
742 size_t keylen
= value
- args
[i
];
743 size_t valuelen
= len
- keylen
;
744 memcpy(opts
+ optslen
, args
[i
], keylen
);
748 memcpy(opts
+ optslen
, value
, valuelen
);
752 opts
[optslen
] = '\0';
760 static char **prepend_options_from_env(int *p_argc
, char **orig_argv
)
762 const char *p
, *env
= getenv("MODPROBE_OPTIONS");
763 char **new_argv
, *str_end
, *str
, *s
, *quote
;
764 int i
, argc
= *p_argc
;
765 size_t envlen
, space_count
= 0;
770 for (p
= env
; *p
!= '\0'; p
++) {
776 new_argv
= malloc(sizeof(char *) * (argc
+ space_count
+ 3 + envlen
));
777 if (new_argv
== NULL
)
780 new_argv
[0] = orig_argv
[0];
781 str
= (char *) (new_argv
+ argc
+ space_count
+ 3);
782 memcpy(str
, env
, envlen
+ 1);
784 str_end
= str
+ envlen
;
787 for (i
= 1, s
= str
; *s
!= '\0'; s
++) {
794 } else if (*s
== '"' || *s
== '\'')
799 new_argv
[i
] = str
+ 1;
805 for (it
= quote
; it
< s
- 1; it
++)
807 for (it
= s
- 1; it
< str_end
- 2; it
++)
822 memcpy(new_argv
+ i
, orig_argv
+ 1, sizeof(char *) * (argc
- 1));
823 new_argv
[i
+ argc
- 1] = NULL
;
824 *p_argc
= i
+ argc
- 1;
829 static int do_modprobe(int argc
, char **orig_argv
)
831 struct kmod_ctx
*ctx
;
832 char **args
= NULL
, **argv
;
833 const char **config_paths
= NULL
;
834 int nargs
= 0, n_config_paths
= 0;
835 char dirname_buf
[PATH_MAX
];
836 const char *dirname
= NULL
;
837 const char *root
= NULL
;
838 const char *kversion
= NULL
;
841 int do_show_config
= 0;
842 int do_show_modversions
= 0;
843 int do_show_exports
= 0;
845 struct stat stat_buf
;
847 argv
= prepend_options_from_env(&argc
, orig_argv
);
849 ERR("Could not prepend options from command line\n");
855 c
= getopt_long(argc
, argv
, cmdopts_s
, cmdopts
, &idx
);
860 log_priority
= LOG_WARNING
;
871 wait_msec
= strtoul(optarg
, &endptr
, 0);
872 if (!*optarg
|| *endptr
) {
873 ERR("unexpected wait value '%s'.\n", optarg
);
892 strip_modversion
= 1;
909 do_show_modversions
= 1;
918 size_t bytes
= sizeof(char *) * (n_config_paths
+ 2);
919 void *tmp
= realloc(config_paths
, bytes
);
921 ERR("out-of-memory\n");
926 config_paths
[n_config_paths
] = optarg
;
928 config_paths
[n_config_paths
] = NULL
;
930 env_modprobe_options_append("-C");
931 env_modprobe_options_append(optarg
);
941 env_modprobe_options_append("-s");
945 env_modprobe_options_append("-q");
949 env_modprobe_options_append("-v");
953 puts(PACKAGE
" version " VERSION
);
965 ERR("unexpected getopt_long() value '%c'.\n", c
);
971 args
= argv
+ optind
;
972 nargs
= argc
- optind
;
976 fileno(stderr
) == -1 ||
977 fstat(fileno(stderr
), &stat_buf
)))
980 log_open(use_syslog
);
982 if (!do_show_config
) {
984 ERR("missing parameters. See -h.\n");
990 if (root
!= NULL
|| kversion
!= NULL
) {
994 if (kversion
== NULL
) {
996 ERR("uname() failed: %m\n");
1000 kversion
= u
.release
;
1002 snprintf(dirname_buf
, sizeof(dirname_buf
),
1003 "%s" MODULE_DIRECTORY
"/%s", root
,
1005 dirname
= dirname_buf
;
1008 ctx
= kmod_new(dirname
, config_paths
);
1010 ERR("kmod_new() failed!\n");
1015 log_setup_kmod_log(ctx
, verbose
);
1017 kmod_load_resources(ctx
);
1020 err
= show_config(ctx
);
1021 else if (do_show_modversions
)
1022 err
= show_modversions(ctx
, args
[0]);
1023 else if (do_show_exports
)
1024 err
= show_exports(ctx
, args
[0]);
1026 err
= rmmod_all(ctx
, args
, nargs
);
1028 err
= insmod_all(ctx
, args
, nargs
);
1031 err
= options_from_array(args
, nargs
, &opts
);
1033 err
= insmod(ctx
, args
[0], opts
);
1043 if (argv
!= orig_argv
)
1048 return err
>= 0 ? EXIT_SUCCESS
: EXIT_FAILURE
;
1051 const struct kmod_cmd kmod_cmd_compat_modprobe
= {
1054 .help
= "compat modprobe command",