blob: 426a14aa18999c7e79e157433829fbf32887a5b8 [file] [log] [blame]
Eric Andersenaad1a882001-03-16 22:47:14 +00001/* vi: set sw=4 ts=4: */
2/*
Eric Andersena2a978a2001-04-05 06:08:14 +00003 * some system calls possibly missing from libc
Eric Andersenaad1a882001-03-16 22:47:14 +00004 *
Eric Andersena2a978a2001-04-05 06:08:14 +00005 * Copyright (C) 1999,2000,2001 by Lineo, inc.
6 * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
Eric Andersenaad1a882001-03-16 22:47:14 +00007 *
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 *
Eric Andersenaad1a882001-03-16 22:47:14 +000022 */
23
24#include <stdio.h>
25#include <errno.h>
Eric Andersena2a978a2001-04-05 06:08:14 +000026#include <unistd.h>
27/* Kernel headers before 2.1.mumble need this on the Alpha to get
28 _syscall* defined. */
29#define __LIBRARY__
Eric Andersenaad1a882001-03-16 22:47:14 +000030
Eric Andersena2a978a2001-04-05 06:08:14 +000031
32#include <sys/syscall.h>
Manuel Novoa III a2949aa2001-06-29 18:59:32 +000033#ifndef __UCLIBC__
Eric Andersena2a978a2001-04-05 06:08:14 +000034#include <asm/unistd.h>
Manuel Novoa III a2949aa2001-06-29 18:59:32 +000035#endif
Eric Andersenaad1a882001-03-16 22:47:14 +000036#include "libbb.h"
37
Eric Andersena2a978a2001-04-05 06:08:14 +000038#if defined(__ia64__)
39int sysfs( int option, unsigned int fs_index, char * buf)
40{
41 return(syscall(__NR_sysfs, option, fs_index, buf));
42}
43#else
Eric Andersene76c3b02001-04-05 03:14:39 +000044_syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf);
Eric Andersena2a978a2001-04-05 06:08:14 +000045#endif
Eric Andersenaad1a882001-03-16 22:47:14 +000046
Eric Andersene76c3b02001-04-05 03:14:39 +000047#ifndef __NR_pivot_root
48#warning This kernel does not support the pivot_root syscall
49#warning -> The pivot_root system call is being stubbed out...
50int pivot_root(const char * new_root,const char * put_old)
51{
52 /* BusyBox was compiled against a kernel that did not support
53 * the pivot_root system call. To make this application work,
54 * you will need to recompile with a kernel supporting the
55 * pivot_root system call.
56 */
57 fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
58 fprintf(stderr, "with a kernel supporting the pivot_root system call. -Erik\n\n");
59 errno=ENOSYS;
60 return -1;
61}
62#else
Eric Andersena2a978a2001-04-05 06:08:14 +000063# if defined(__ia64__)
64 int pivot_root(const char * new_root,const char * put_old)
65 {
66 return(syscall(__NR_pivot_root, new_root, put_old));
67 }
68# else
69 _syscall2(int,pivot_root,const char *,new_root,const char *,put_old);
70# endif
Eric Andersene76c3b02001-04-05 03:14:39 +000071#endif
Eric Andersenaad1a882001-03-16 22:47:14 +000072
Eric Andersene76c3b02001-04-05 03:14:39 +000073
74
75
Eric Andersen831ed162001-04-05 22:38:32 +000076#if __GNU_LIBRARY__ < 5 || ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1))
Eric Andersene76c3b02001-04-05 03:14:39 +000077/* These syscalls are not included as part of libc5 */
78_syscall2(int, bdflush, int, func, int, data);
Eric Andersene76c3b02001-04-05 03:14:39 +000079
80#ifndef __alpha__
81# define __NR_klogctl __NR_syslog
82 _syscall3(int, klogctl, int, type, char *, b, int, len);
83#endif
Eric Andersenaad1a882001-03-16 22:47:14 +000084
85#ifndef __NR_umount2
86# warning This kernel does not support the umount2 syscall
Eric Andersene76c3b02001-04-05 03:14:39 +000087# warning -> The umount2 system call is being stubbed out...
Eric Andersenaad1a882001-03-16 22:47:14 +000088int umount2(const char * special_file, int flags)
89{
90 /* BusyBox was compiled against a kernel that did not support
91 * the umount2 system call. To make this application work,
92 * you will need to recompile with a kernel supporting the
93 * umount2 system call.
94 */
95 fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
96 fprintf(stderr, "with a kernel supporting the umount2 system call. -Erik\n\n");
97 errno=ENOSYS;
98 return -1;
99}
100# else
Eric Andersene76c3b02001-04-05 03:14:39 +0000101_syscall2(int, umount2, const char *, special_file, int, flags);
Eric Andersenaad1a882001-03-16 22:47:14 +0000102#endif
103
Eric Andersene76c3b02001-04-05 03:14:39 +0000104
105#endif /* __GNU_LIBRARY__ < 5 */
106
107
Eric Andersenaad1a882001-03-16 22:47:14 +0000108/* END CODE */
109/*
110Local Variables:
111c-file-style: "linux"
112c-basic-offset: 4
113tab-width: 4
114End:
115*/