This fixes lash so it handles environment variable expansion, regardless
[oweals/busybox.git] / insmod.c
index e55d9fafb115ec5748a8799ae276795a2f3ed162..166f0fc4bdddb11f0248a4b0a85b889d90004ddd 100644 (file)
--- a/insmod.c
+++ b/insmod.c
@@ -37,7 +37,6 @@
  *
  */
 
-#include "busybox.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <stddef.h>
@@ -51,6 +50,7 @@
 #include <sys/utsname.h>
 #include <sys/syscall.h>
 #include <linux/unistd.h>
+#include "busybox.h"
 
 //----------------------------------------------------------------------------
 //--------modutils module.h, lines 45-242
@@ -81,7 +81,7 @@
 #ifndef MODUTILS_MODULE_H
 static const int MODUTILS_MODULE_H = 1;
 
-#ident "$Id: insmod.c,v 1.45 2001/01/31 19:00:21 kraai Exp $"
+#ident "$Id: insmod.c,v 1.48 2001/02/20 06:14:07 andersen Exp $"
 
 /* This file contains the structures used by the 2.0 and 2.1 kernels.
    We do not use the kernel headers directly because we do not wish
@@ -287,7 +287,7 @@ int delete_module(const char *);
 #ifndef MODUTILS_OBJ_H
 static const int MODUTILS_OBJ_H = 1;
 
-#ident "$Id: insmod.c,v 1.45 2001/01/31 19:00:21 kraai Exp $"
+#ident "$Id: insmod.c,v 1.48 2001/02/20 06:14:07 andersen Exp $"
 
 /* The relocatable object is manipulated using elfin types.  */
 
@@ -2880,6 +2880,7 @@ extern int insmod_main( int argc, char **argv)
        ElfW(Addr) m_addr;
        FILE *fp;
        struct obj_file *f;
+       struct stat st;
        char m_name[BUFSIZ + 1] = "\0";
        int exit_status = EXIT_FAILURE;
        int m_has_modinfo;
@@ -2916,12 +2917,12 @@ extern int insmod_main( int argc, char **argv)
                                 * loading the same module 50 times concurrently. */
                                break;
                        default:
-                               usage(insmod_usage);
+                               show_usage();
                }
        }
        
        if (argv[optind] == NULL) {
-               usage(insmod_usage);
+               show_usage();
        }
 
        /* Grab the module name */
@@ -2941,7 +2942,8 @@ extern int insmod_main( int argc, char **argv)
        strcat(m_fullName, ".o");
 
        /* Get a filedesc for the module */
-       if ((fp = fopen(argv[optind], "r")) == NULL) {
+       if (stat(argv[optind], &st) < 0 || !S_ISREG(st.st_mode) ||
+                       (fp = fopen(argv[optind], "r")) == NULL) {
                /* Hmpf.  Could not open it. Search through _PATH_MODULES to find a module named m_name */
                if (recursive_action(_PATH_MODULES, TRUE, FALSE, FALSE,
                                                        findNamedModule, 0, m_fullName) == FALSE)