aboutsummaryrefslogtreecommitdiff
path: root/libbb
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 /libbb
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
Diffstat (limited to 'libbb')
-rw-r--r--libbb/module_syscalls.c88
-rw-r--r--libbb/syscalls.c61
2 files changed, 113 insertions, 36 deletions
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: