Magellan Linux

Annotation of /trunk/mkinitrd-magellan/busybox/modutils/rmmod.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 984 - (hide annotations) (download)
Sun May 30 11:32:42 2010 UTC (13 years, 11 months ago) by niro
File MIME type: text/plain
File size: 1345 byte(s)
-updated to busybox-1.16.1 and enabled blkid/uuid support in default config
1 niro 532 /* vi: set sw=4 ts=4: */
2     /*
3     * Mini rmmod implementation for busybox
4     *
5     * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 niro 816 * Copyright (C) 2008 Timo Teras <timo.teras@iki.fi>
7 niro 532 *
8     * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
9     */
10    
11 niro 816 #include "libbb.h"
12     #include "modutils.h"
13 niro 532
14 niro 816 int rmmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
15     int rmmod_main(int argc UNUSED_PARAM, char **argv)
16 niro 532 {
17 niro 816 int n;
18 niro 984 unsigned flags = O_NONBLOCK | O_EXCL;
19 niro 532
20     /* Parse command line. */
21 niro 816 n = getopt32(argv, "wfas"); // -s ignored
22     argv += optind;
23     if (n & 1) // --wait
24 niro 532 flags &= ~O_NONBLOCK;
25 niro 816 if (n & 2) // --force
26 niro 532 flags |= O_TRUNC;
27 niro 816 if (n & 4) {
28 niro 532 /* Unload _all_ unused modules via NULL delete_module() call */
29 niro 816 if (bb_delete_module(NULL, flags) != 0 && errno != EFAULT)
30     bb_perror_msg_and_die("rmmod");
31 niro 532 return EXIT_SUCCESS;
32     }
33    
34 niro 816 if (!*argv)
35 niro 532 bb_show_usage();
36    
37 niro 984 n = ENABLE_FEATURE_2_4_MODULES && get_linux_version_code() < KERNEL_VERSION(2,6,0);
38 niro 816 while (*argv) {
39     char modname[MODULE_NAME_LEN];
40 niro 984 const char *bname;
41    
42     bname = bb_basename(*argv++);
43     if (n)
44     safe_strncpy(modname, bname, MODULE_NAME_LEN);
45     else
46     filename2modname(bname, modname);
47 niro 816 if (bb_delete_module(modname, flags))
48 niro 984 bb_error_msg_and_die("can't unload '%s': %s",
49 niro 816 modname, moderror(errno));
50 niro 532 }
51    
52 niro 816 return EXIT_SUCCESS;
53 niro 532 }