diff options
Diffstat (limited to 'rmmod.c')
-rw-r--r-- | rmmod.c | 55 |
1 files changed, 28 insertions, 27 deletions
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* | 2 | /* |
2 | * Mini rmmod implementation for busybox | 3 | * Mini rmmod implementation for busybox |
3 | * | 4 | * |
@@ -33,41 +34,41 @@ _syscall1(int, delete_module, const char *, name) | |||
33 | 34 | ||
34 | 35 | ||
35 | static const char rmmod_usage[] = | 36 | static const char rmmod_usage[] = |
36 | "rmmod [OPTION]... [MODULE]...\n\n" | 37 | "rmmod [OPTION]... [MODULE]...\n\n" |
37 | "Unloads the specified kernel modules from the kernel.\n\n" | 38 | "Unloads the specified kernel modules from the kernel.\n\n" |
38 | "Options:\n" | 39 | |
39 | "\t-a\tTry to remove all unused kernel modules.\n"; | 40 | "Options:\n" "\t-a\tTry to remove all unused kernel modules.\n"; |
40 | 41 | ||
41 | 42 | ||
42 | 43 | ||
43 | extern int rmmod_main(int argc, char **argv) | 44 | extern int rmmod_main(int argc, char **argv) |
44 | { | 45 | { |
45 | if (argc<=1) { | 46 | if (argc <= 1) { |
46 | usage(rmmod_usage); | 47 | usage(rmmod_usage); |
47 | } | 48 | } |
48 | 49 | ||
49 | /* Parse any options */ | 50 | /* Parse any options */ |
50 | while (--argc > 0 && **(++argv) == '-') { | 51 | while (--argc > 0 && **(++argv) == '-') { |
51 | while (*(++(*argv))) { | 52 | while (*(++(*argv))) { |
52 | switch (**argv) { | 53 | switch (**argv) { |
53 | case 'a': | 54 | case 'a': |
54 | /* Unload _all_ unused modules via NULL delete_module() call */ | 55 | /* Unload _all_ unused modules via NULL delete_module() call */ |
55 | if (delete_module(NULL)) { | 56 | if (delete_module(NULL)) { |
56 | perror("rmmod"); | 57 | perror("rmmod"); |
57 | exit( FALSE); | 58 | exit(FALSE); |
59 | } | ||
60 | exit(TRUE); | ||
61 | default: | ||
62 | usage(rmmod_usage); | ||
63 | } | ||
58 | } | 64 | } |
59 | exit( TRUE); | ||
60 | default: | ||
61 | usage(rmmod_usage); | ||
62 | } | ||
63 | } | 65 | } |
64 | } | ||
65 | 66 | ||
66 | while (argc-- > 0 ) { | 67 | while (argc-- > 0) { |
67 | if (delete_module(*argv) < 0) { | 68 | if (delete_module(*argv) < 0) { |
68 | perror(*argv); | 69 | perror(*argv); |
70 | } | ||
71 | argv++; | ||
69 | } | 72 | } |
70 | argv++; | 73 | exit(TRUE); |
71 | } | ||
72 | exit( TRUE); | ||
73 | } | 74 | } |