setsebool: new applet (Yuichi Nakamura <ynakam@hitachisoft.jp>)
[oweals/busybox.git] / modutils / insmod.c
index 8a6cc05ddff42866ea8cb2d7294ef711fa7399a0..6f3b7d0f46383441d086129e19481bc1515cf6b2 100644 (file)
@@ -72,7 +72,7 @@
 #endif
 
 #if ENABLE_FEATURE_2_6_MODULES
-extern int insmod_ng_main( int argc, char **argv);
+extern int insmod_ng_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 #endif
 
 
@@ -806,7 +806,7 @@ static int check_module_name_match(const char *filename, struct stat *statbuf,
                return FALSE;
        else {
                char *tmp, *tmp1 = xstrdup(filename);
-               tmp = bb_get_last_path_component(tmp1);
+               tmp = bb_get_last_path_component_nostrip(tmp1);
                if (strcmp(tmp, fullname) == 0) {
                        free(tmp1);
                        /* Stop searching if we find a match */
@@ -3613,12 +3613,12 @@ static int obj_gpl_license(struct obj_file *f, const char **license)
         * linux/include/linux/module.h.  Checking for leading "GPL" will not
         * work, somebody will use "GPL sucks, this is proprietary".
         */
-       static const char * const gpl_licenses[] = {
+       static const char *const gpl_licenses[] = {
                "GPL",
                "GPL v2",
                "GPL and additional rights",
                "Dual BSD/GPL",
-               "Dual MPL/GPL",
+               "Dual MPL/GPL"
        };
 
        sec = obj_find_section(f, ".modinfo");
@@ -3681,7 +3681,8 @@ static void set_tainted(struct obj_file *f, int fd, char *m_name,
 /* Check if loading this module will taint the kernel. */
 static void check_tainted_module(struct obj_file *f, char *m_name)
 {
-       static const char tainted_file[] = TAINT_FILENAME;
+       static const char tainted_file[] ALIGN1 = TAINT_FILENAME;
+
        int fd, kernel_has_tainted;
        const char *ptr;
 
@@ -3750,7 +3751,8 @@ static void
 add_ksymoops_symbols(struct obj_file *f, const char *filename,
                                 const char *m_name)
 {
-       static const char symprefix[] = "__insmod_";
+       static const char symprefix[] ALIGN1 = "__insmod_";
+
        struct obj_section *sec;
        struct obj_symbol *sym;
        char *name, *absolute_filename;
@@ -3950,8 +3952,8 @@ static void print_load_map(struct obj_file *f)
 void print_load_map(struct obj_file *f);
 #endif
 
-int insmod_main( int argc, char **argv);
-int insmod_main( int argc, char **argv)
+int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int insmod_main(int argc, char **argv)
 {
        char *opt_o, *arg1;
        int len;
@@ -3970,7 +3972,7 @@ int insmod_main( int argc, char **argv)
        int m_version, m_crcs;
 #endif
 #if ENABLE_FEATURE_CLEAN_UP
-       FILE *fp = 0;
+       FILE *fp = NULL;
 #else
        FILE *fp;
 #endif
@@ -3978,7 +3980,7 @@ int insmod_main( int argc, char **argv)
        struct utsname myuname;
 
        /* Parse any options */
-       getopt32(argc, argv, OPTION_STR, &opt_o);
+       getopt32(argv, OPTION_STR, &opt_o);
        arg1 = argv[optind];
        if (option_mask32 & OPT_o) { // -o /* name the output module */
                free(m_name);
@@ -4028,7 +4030,7 @@ int insmod_main( int argc, char **argv)
                tmp1 = 0;       /* flag for free(m_name) before exit() */
        }
 
-       /* Get a filedesc for the module.  Check we we have a complete path */
+       /* Get a filedesc for the module.  Check that we have a complete path */
        if (stat(arg1, &st) < 0 || !S_ISREG(st.st_mode)
         || (fp = fopen(arg1, "r")) == NULL
        ) {
@@ -4055,12 +4057,12 @@ int insmod_main( int argc, char **argv)
                }
 
                /* Check if we have found anything yet */
-               if (m_filename == 0 || ((fp = fopen(m_filename, "r")) == NULL)) {
+               if (!m_filename || ((fp = fopen(m_filename, "r")) == NULL)) {
                        char module_dir[FILENAME_MAX];
 
                        free(m_filename);
-                       m_filename = 0;
-                       if (realpath (_PATH_MODULES, module_dir) == NULL)
+                       m_filename = NULL;
+                       if (realpath(_PATH_MODULES, module_dir) == NULL)
                                strcpy(module_dir, _PATH_MODULES);
                        /* No module found under /lib/modules/`uname -r`, this
                         * time cast the net a bit wider.  Search /lib/modules/ */
@@ -4070,11 +4072,11 @@ int insmod_main( int argc, char **argv)
                                if (m_filename == 0
                                 || ((fp = fopen(m_filename, "r")) == NULL)
                                ) {
-                                       bb_error_msg("%s: no module by that name found", m_fullName);
+                                       bb_error_msg("%s: module not found", m_fullName);
                                        goto out;
                                }
                        } else
-                               bb_error_msg_and_die("%s: no module by that name found", m_fullName);
+                               bb_error_msg_and_die("%s: module not found", m_fullName);
                }
        } else
                m_filename = xstrdup(arg1);
@@ -4259,7 +4261,7 @@ static const char *moderror(int err)
        }
 }
 
-int insmod_ng_main(int argc, char **argv);
+int insmod_ng_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int insmod_ng_main(int argc, char **argv)
 {
        long ret;