aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-04-05 06:08:14 +0000
committerEric Andersen <andersen@codepoet.org>2001-04-05 06:08:14 +0000
commita2a978ae23e267c24eb7b11662afdcc9ea47e789 (patch)
treef9927bd24dbc96724b1c0b89327d4c7157ed8eb4
parentfdefbbbe85b852ba6de361c8f53d025b09b9abbe (diff)
downloadbusybox-w32-a2a978ae23e267c24eb7b11662afdcc9ea47e789.tar.gz
busybox-w32-a2a978ae23e267c24eb7b11662afdcc9ea47e789.tar.bz2
busybox-w32-a2a978ae23e267c24eb7b11662afdcc9ea47e789.zip
Some further syscall adjustments. Split the module syscalls out of
insmod and into libbb. Only enable them for libc5. glibc and uClibc don't need them. -Erik
-rw-r--r--Makefile2
-rw-r--r--insmod.c43
-rw-r--r--libbb/module_syscalls.c88
-rw-r--r--libbb/syscalls.c61
-rw-r--r--modutils/insmod.c43
5 files changed, 120 insertions, 117 deletions
diff --git a/Makefile b/Makefile
index 5e7e417e0..66df84921 100644
--- a/Makefile
+++ b/Makefile
@@ -242,7 +242,7 @@ full_write.c get_console.c get_last_path_component.c get_line_from_file.c \
242human_readable.c inode_hash.c isdirectory.c kernel_version.c loop.c \ 242human_readable.c inode_hash.c isdirectory.c kernel_version.c loop.c \
243mode_string.c parse_mode.c parse_number.c print_file.c process_escape_sequence.c \ 243mode_string.c parse_mode.c parse_number.c print_file.c process_escape_sequence.c \
244my_getgrgid.c my_getpwnamegid.c my_getpwuid.c my_getgrnam.c my_getpwnam.c \ 244my_getgrgid.c my_getpwnamegid.c my_getpwuid.c my_getgrnam.c my_getpwnam.c \
245recursive_action.c safe_read.c safe_strncpy.c syscalls.c \ 245recursive_action.c safe_read.c safe_strncpy.c syscalls.c module_syscalls.c \
246syslog_msg_with_name.c time_string.c trim.c vdprintf.c wfopen.c xfuncs.c \ 246syslog_msg_with_name.c time_string.c trim.c vdprintf.c wfopen.c xfuncs.c \
247xregcomp.c error_msg_and_die.c perror_msg.c perror_msg_and_die.c \ 247xregcomp.c error_msg_and_die.c perror_msg.c perror_msg_and_die.c \
248verror_msg.c vperror_msg.c mtab.c mtab_file.c 248verror_msg.c vperror_msg.c mtab.c mtab_file.c
diff --git a/insmod.c b/insmod.c
index ad1486b7b..c2ebd2e24 100644
--- a/insmod.c
+++ b/insmod.c
@@ -60,8 +60,6 @@
60#include <string.h> 60#include <string.h>
61#include <getopt.h> 61#include <getopt.h>
62#include <sys/utsname.h> 62#include <sys/utsname.h>
63#include <sys/syscall.h>
64#include <linux/unistd.h>
65#include "busybox.h" 63#include "busybox.h"
66 64
67#if defined(__powerpc__) 65#if defined(__powerpc__)
@@ -119,7 +117,7 @@
119#ifndef MODUTILS_MODULE_H 117#ifndef MODUTILS_MODULE_H
120static const int MODUTILS_MODULE_H = 1; 118static const int MODUTILS_MODULE_H = 1;
121 119
122#ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $" 120#ident "$Id: insmod.c,v 1.55 2001/04/05 06:08:14 andersen Exp $"
123 121
124/* This file contains the structures used by the 2.0 and 2.1 kernels. 122/* This file contains the structures used by the 2.0 and 2.1 kernels.
125 We do not use the kernel headers directly because we do not wish 123 We do not use the kernel headers directly because we do not wish
@@ -325,7 +323,7 @@ int delete_module(const char *);
325#ifndef MODUTILS_OBJ_H 323#ifndef MODUTILS_OBJ_H
326static const int MODUTILS_OBJ_H = 1; 324static const int MODUTILS_OBJ_H = 1;
327 325
328#ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $" 326#ident "$Id: insmod.c,v 1.55 2001/04/05 06:08:14 andersen Exp $"
329 327
330/* The relocatable object is manipulated using elfin types. */ 328/* The relocatable object is manipulated using elfin types. */
331 329
@@ -674,20 +672,8 @@ int n_ext_modules;
674int n_ext_modules_used; 672int n_ext_modules_used;
675 673
676 674
677
678/* Some firendly syscalls to cheer everyone's day... */
679#define __NR_new_sys_init_module __NR_init_module
680_syscall2(int, new_sys_init_module, const char *, name,
681 const struct new_module *, info)
682#define __NR_old_sys_init_module __NR_init_module
683_syscall5(int, old_sys_init_module, const char *, name, char *, code,
684 unsigned, codesize, struct old_mod_routines *, routines,
685 struct old_symbol_table *, symtab)
686#ifndef BB_RMMOD
687_syscall1(int, delete_module, const char *, name)
688#else
689extern int delete_module(const char *); 675extern int delete_module(const char *);
690#endif 676
691 677
692/* This is kind of troublesome. See, we don't actually support 678/* This is kind of troublesome. See, we don't actually support
693 the m68k or the arm the same way we support i386 and (now) 679 the m68k or the arm the same way we support i386 and (now)
@@ -700,29 +686,6 @@ extern int delete_module(const char *);
700 686
701 -- Bryan Rittmeyer <bryan@ixiacom.com> */ 687 -- Bryan Rittmeyer <bryan@ixiacom.com> */
702 688
703#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
704_syscall1(int, get_kernel_syms, struct old_kernel_sym *, ks)
705#endif
706
707#if defined(__i386__) || defined(__m68k__) || defined(__arm__) \
708 || defined(__powerpc__)
709/* Jump through hoops to fixup error return codes */
710#define __NR__create_module __NR_create_module
711static inline _syscall2(long, _create_module, const char *, name, size_t,
712 size)
713unsigned long create_module(const char *name, size_t size)
714{
715 long ret = _create_module(name, size);
716
717 if (ret == -1 && errno > 125) {
718 ret = -errno;
719 errno = 0;
720 }
721 return ret;
722}
723#else
724_syscall2(unsigned long, create_module, const char *, name, size_t, size)
725#endif
726static char m_filename[BUFSIZ + 1]; 689static char m_filename[BUFSIZ + 1];
727static char m_fullName[BUFSIZ + 1]; 690static char m_fullName[BUFSIZ + 1];
728 691
diff --git a/libbb/module_syscalls.c b/libbb/module_syscalls.c
new file mode 100644
index 000000000..d0c1a36d4
--- /dev/null
+++ b/libbb/module_syscalls.c
@@ -0,0 +1,88 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * some system calls possibly missing from libc
4 *
5 * Copyright (C) 1999,2000,2001 by Lineo, inc.
6 * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <stdio.h>
25#include <errno.h>
26#include <unistd.h>
27/* Kernel headers before 2.1.mumble need this on the Alpha to get
28 _syscall* defined. */
29#define __LIBRARY__
30#include <sys/syscall.h>
31#include <asm/unistd.h>
32#include "libbb.h"
33
34#define __NR_new_sys_init_module __NR_init_module
35_syscall2(int, new_sys_init_module, const char *, name,
36 const struct new_module *, info);
37
38#define __NR_old_sys_init_module __NR_init_module
39_syscall5(int, old_sys_init_module, const char *, name, char *, code,
40 unsigned, codesize, struct old_mod_routines *, routines,
41 struct old_symbol_table *, symtab);
42
43#if __GNU_LIBRARY__ < 5
44/* These syscalls are not included as part of libc5 */
45_syscall1(int, delete_module, const char *, name);
46_syscall1(int, get_kernel_syms, struct old_kernel_sym *, ks);
47
48#ifndef __NR_query_module
49#warning This kernel does not support the query_module syscall
50#warning -> The query_module system call is being stubbed out...
51int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret)
52{
53 fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
54 fprintf(stderr, "with a kernel supporting the query_module system call. -Erik\n\n");
55 errno=ENOSYS;
56 return -1;
57}
58#else
59_syscall5(int, query_module, const char *, name, int, which,
60 void *, buf, size_t, bufsize, size_t*, ret);
61#endif
62
63/* Jump through hoops to fixup error return codes */
64#define __NR__create_module __NR_create_module
65static inline _syscall2(long, _create_module, const char *, name, size_t, size)
66unsigned long create_module(const char *name, size_t size)
67{
68 long ret = _create_module(name, size);
69
70 if (ret == -1 && errno > 125) {
71 ret = -errno;
72 errno = 0;
73 }
74 return ret;
75}
76
77#endif /* __GNU_LIBRARY__ < 5 */
78
79
80/* END CODE */
81/*
82Local Variables:
83c-file-style: "linux"
84c-basic-offset: 4
85tab-width: 4
86End:
87*/
88
diff --git a/libbb/syscalls.c b/libbb/syscalls.c
index efca39902..4a846eb00 100644
--- a/libbb/syscalls.c
+++ b/libbb/syscalls.c
@@ -1,10 +1,9 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * Utility routines. 3 * some system calls possibly missing from libc
4 * 4 *
5 * Copyright (C) tons of folks. Tracking down who wrote what 5 * Copyright (C) 1999,2000,2001 by Lineo, inc.
6 * isn't something I'm going to worry about... If you wrote something 6 * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
7 * here, please feel free to acknowledge your work.
8 * 7 *
9 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -20,19 +19,28 @@
20 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * 21 *
23 * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
24 * Permission has been granted to redistribute this code under the GPL.
25 *
26 */ 22 */
27 23
28#include <stdio.h> 24#include <stdio.h>
29#include <errno.h> 25#include <errno.h>
30#include <sys/syscall.h> 26#include <unistd.h>
31#include <linux/unistd.h> 27/* Kernel headers before 2.1.mumble need this on the Alpha to get
28 _syscall* defined. */
29#define __LIBRARY__
30
32 31
32#include <sys/syscall.h>
33#include <asm/unistd.h>
33#include "libbb.h" 34#include "libbb.h"
34 35
36#if defined(__ia64__)
37int sysfs( int option, unsigned int fs_index, char * buf)
38{
39 return(syscall(__NR_sysfs, option, fs_index, buf));
40}
41#else
35_syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf); 42_syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf);
43#endif
36 44
37#ifndef __NR_pivot_root 45#ifndef __NR_pivot_root
38#warning This kernel does not support the pivot_root syscall 46#warning This kernel does not support the pivot_root syscall
@@ -50,7 +58,14 @@ int pivot_root(const char * new_root,const char * put_old)
50 return -1; 58 return -1;
51} 59}
52#else 60#else
53_syscall2(int,pivot_root,const char *,new_root,const char *,put_old) 61# if defined(__ia64__)
62 int pivot_root(const char * new_root,const char * put_old)
63 {
64 return(syscall(__NR_pivot_root, new_root, put_old));
65 }
66# else
67 _syscall2(int,pivot_root,const char *,new_root,const char *,put_old);
68# endif
54#endif 69#endif
55 70
56 71
@@ -59,27 +74,6 @@ _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
59#if __GNU_LIBRARY__ < 5 74#if __GNU_LIBRARY__ < 5
60/* These syscalls are not included as part of libc5 */ 75/* These syscalls are not included as part of libc5 */
61_syscall2(int, bdflush, int, func, int, data); 76_syscall2(int, bdflush, int, func, int, data);
62_syscall1(int, delete_module, const char *, name)
63
64#ifndef __NR_query_module
65#warning This kernel does not support the query_module syscall
66#warning -> The query_module system call is being stubbed out...
67int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret)
68{
69 /* BusyBox was compiled against a kernel that did not support
70 * the query_module system call. To make this application work,
71 * you will need to recompile with a kernel supporting the
72 * query_module system call.
73 */
74 fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
75 fprintf(stderr, "with a kernel supporting the query_module system call. -Erik\n\n");
76 errno=ENOSYS;
77 return -1;
78}
79#else
80_syscall5(int, query_module, const char *, name, int, which,
81 void *, buf, size_t, bufsize, size_t*, ret);
82#endif
83 77
84#ifndef __alpha__ 78#ifndef __alpha__
85# define __NR_klogctl __NR_syslog 79# define __NR_klogctl __NR_syslog
@@ -109,11 +103,6 @@ _syscall2(int, umount2, const char *, special_file, int, flags);
109#endif /* __GNU_LIBRARY__ < 5 */ 103#endif /* __GNU_LIBRARY__ < 5 */
110 104
111 105
112#if 0
113_syscall1(int, sysinfo, struct sysinfo *, info);
114#endif
115
116
117/* END CODE */ 106/* END CODE */
118/* 107/*
119Local Variables: 108Local Variables:
diff --git a/modutils/insmod.c b/modutils/insmod.c
index ad1486b7b..c2ebd2e24 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -60,8 +60,6 @@
60#include <string.h> 60#include <string.h>
61#include <getopt.h> 61#include <getopt.h>
62#include <sys/utsname.h> 62#include <sys/utsname.h>
63#include <sys/syscall.h>
64#include <linux/unistd.h>
65#include "busybox.h" 63#include "busybox.h"
66 64
67#if defined(__powerpc__) 65#if defined(__powerpc__)
@@ -119,7 +117,7 @@
119#ifndef MODUTILS_MODULE_H 117#ifndef MODUTILS_MODULE_H
120static const int MODUTILS_MODULE_H = 1; 118static const int MODUTILS_MODULE_H = 1;
121 119
122#ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $" 120#ident "$Id: insmod.c,v 1.55 2001/04/05 06:08:14 andersen Exp $"
123 121
124/* This file contains the structures used by the 2.0 and 2.1 kernels. 122/* This file contains the structures used by the 2.0 and 2.1 kernels.
125 We do not use the kernel headers directly because we do not wish 123 We do not use the kernel headers directly because we do not wish
@@ -325,7 +323,7 @@ int delete_module(const char *);
325#ifndef MODUTILS_OBJ_H 323#ifndef MODUTILS_OBJ_H
326static const int MODUTILS_OBJ_H = 1; 324static const int MODUTILS_OBJ_H = 1;
327 325
328#ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $" 326#ident "$Id: insmod.c,v 1.55 2001/04/05 06:08:14 andersen Exp $"
329 327
330/* The relocatable object is manipulated using elfin types. */ 328/* The relocatable object is manipulated using elfin types. */
331 329
@@ -674,20 +672,8 @@ int n_ext_modules;
674int n_ext_modules_used; 672int n_ext_modules_used;
675 673
676 674
677
678/* Some firendly syscalls to cheer everyone's day... */
679#define __NR_new_sys_init_module __NR_init_module
680_syscall2(int, new_sys_init_module, const char *, name,
681 const struct new_module *, info)
682#define __NR_old_sys_init_module __NR_init_module
683_syscall5(int, old_sys_init_module, const char *, name, char *, code,
684 unsigned, codesize, struct old_mod_routines *, routines,
685 struct old_symbol_table *, symtab)
686#ifndef BB_RMMOD
687_syscall1(int, delete_module, const char *, name)
688#else
689extern int delete_module(const char *); 675extern int delete_module(const char *);
690#endif 676
691 677
692/* This is kind of troublesome. See, we don't actually support 678/* This is kind of troublesome. See, we don't actually support
693 the m68k or the arm the same way we support i386 and (now) 679 the m68k or the arm the same way we support i386 and (now)
@@ -700,29 +686,6 @@ extern int delete_module(const char *);
700 686
701 -- Bryan Rittmeyer <bryan@ixiacom.com> */ 687 -- Bryan Rittmeyer <bryan@ixiacom.com> */
702 688
703#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
704_syscall1(int, get_kernel_syms, struct old_kernel_sym *, ks)
705#endif
706
707#if defined(__i386__) || defined(__m68k__) || defined(__arm__) \
708 || defined(__powerpc__)
709/* Jump through hoops to fixup error return codes */
710#define __NR__create_module __NR_create_module
711static inline _syscall2(long, _create_module, const char *, name, size_t,
712 size)
713unsigned long create_module(const char *name, size_t size)
714{
715 long ret = _create_module(name, size);
716
717 if (ret == -1 && errno > 125) {
718 ret = -errno;
719 errno = 0;
720 }
721 return ret;
722}
723#else
724_syscall2(unsigned long, create_module, const char *, name, size_t, size)
725#endif
726static char m_filename[BUFSIZ + 1]; 689static char m_filename[BUFSIZ + 1];
727static char m_fullName[BUFSIZ + 1]; 690static char m_fullName[BUFSIZ + 1];
728 691