svn commit: trunk/busybox/modutils

aldot at busybox.net aldot at busybox.net
Tue May 27 03:13:54 PDT 2008


Author: aldot
Date: 2008-05-27 03:13:54 -0700 (Tue, 27 May 2008)
New Revision: 22090

Log:
- use (uC)libc functions. Saves a dozen bytes.


Modified:
   trunk/busybox/modutils/insmod.c
   trunk/busybox/modutils/rmmod.c


Changeset:
Modified: trunk/busybox/modutils/insmod.c
===================================================================
--- trunk/busybox/modutils/insmod.c	2008-05-27 09:06:05 UTC (rev 22089)
+++ trunk/busybox/modutils/insmod.c	2008-05-27 10:13:54 UTC (rev 22090)
@@ -4184,8 +4184,14 @@
 #if ENABLE_FEATURE_2_6_MODULES
 
 #include <sys/mman.h>
+
+#ifdef __UCLIBC__
+extern int init_module(void *module, unsigned long len, const char *options);
+#else
 #include <asm/unistd.h>
 #include <sys/syscall.h>
+#define init_module(mod, len, opts) syscall(__NR_init_module, mod, len, opts)
+#endif
 
 /* We use error numbers in a loose translation... */
 static const char *moderror(int err)
@@ -4257,10 +4263,9 @@
 	map = xmalloc_open_read_close(filename, &len);
 #endif
 
-	if (syscall(__NR_init_module, map, len, options) != 0)
+	if (init_module(map, len, options) != 0)
 		bb_error_msg_and_die("cannot insert '%s': %s",
 				filename, moderror(errno));
-
 	return 0;
 }
 

Modified: trunk/busybox/modutils/rmmod.c
===================================================================
--- trunk/busybox/modutils/rmmod.c	2008-05-27 09:06:05 UTC (rev 22089)
+++ trunk/busybox/modutils/rmmod.c	2008-05-27 10:13:54 UTC (rev 22090)
@@ -8,8 +8,14 @@
  */
 
 #include "libbb.h"
-#include <sys/syscall.h>
 
+#ifdef __UCLIBC__
+extern int delete_module(const char *module, unsigned int flags);
+#else
+# include <sys/syscall.h>
+# define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags)
+#endif
+
 #if ENABLE_FEATURE_2_6_MODULES
 static inline void filename2modname(char *modname, const char *afterslash)
 {
@@ -59,7 +65,7 @@
 		size_t pnmod = -1; /* previous number of modules */
 
 		while (nmod != pnmod) {
-			if (syscall(__NR_delete_module, NULL, flags) != 0) {
+			if (delete_module(NULL, flags) != 0) {
 				if (errno == EFAULT)
 					return ret;
 				bb_perror_msg_and_die("rmmod");
@@ -84,7 +90,7 @@
 			filename2modname(misc_buf, bb_basename(argv[n]));
 		}
 
-		if (syscall(__NR_delete_module, ENABLE_FEATURE_2_6_MODULES ? misc_buf : argv[n], flags)) {
+		if (delete_module(ENABLE_FEATURE_2_6_MODULES ? misc_buf : argv[n], flags)) {
 			bb_simple_perror_msg(argv[n]);
 			ret = EXIT_FAILURE;
 		}



More information about the busybox-cvs mailing list