blob: 2fb4cd1775affca886fdd7a84e495d0f92cb816e [file] [log] [blame]
Eric Andersena2a978a2001-04-05 06:08:14 +00001/* 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
Eric Andersenacc77572001-04-05 06:24:28 +000034
Eric Andersena2a978a2001-04-05 06:08:14 +000035#if __GNU_LIBRARY__ < 5
36/* These syscalls are not included as part of libc5 */
37_syscall1(int, delete_module, const char *, name);
Eric Andersen911af572001-04-05 07:41:51 +000038_syscall1(int, get_kernel_syms, __ptr_t, ks);
Eric Andersena2a978a2001-04-05 06:08:14 +000039
Eric Andersen64c8b172001-04-05 07:33:10 +000040/* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
41 * (for 2.2 and 2.4 kernels). Use the greatest common denominator,
42 * and let the kernel cope with whatever it gets. Its good at that. */
43_syscall5(int, init_module, void *, first, void *, second, void *, third,
44 void *, fourth, void *, fifth);
45
Eric Andersena2a978a2001-04-05 06:08:14 +000046#ifndef __NR_query_module
47#warning This kernel does not support the query_module syscall
48#warning -> The query_module system call is being stubbed out...
49int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret)
50{
51 fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
52 fprintf(stderr, "with a kernel supporting the query_module system call. -Erik\n\n");
53 errno=ENOSYS;
54 return -1;
55}
56#else
57_syscall5(int, query_module, const char *, name, int, which,
58 void *, buf, size_t, bufsize, size_t*, ret);
59#endif
60
61/* Jump through hoops to fixup error return codes */
Eric Andersen64c8b172001-04-05 07:33:10 +000062#define __NR___create_module __NR_create_module
63static inline _syscall2(long, __create_module, const char *, name, size_t, size)
Eric Andersena2a978a2001-04-05 06:08:14 +000064unsigned long create_module(const char *name, size_t size)
65{
Eric Andersen64c8b172001-04-05 07:33:10 +000066 long ret = __create_module(name, size);
Eric Andersena2a978a2001-04-05 06:08:14 +000067
68 if (ret == -1 && errno > 125) {
69 ret = -errno;
70 errno = 0;
71 }
72 return ret;
73}
74
75#endif /* __GNU_LIBRARY__ < 5 */
76
77
78/* END CODE */
79/*
80Local Variables:
81c-file-style: "linux"
82c-basic-offset: 4
83tab-width: 4
84End:
85*/
86