blob: dac90e24baf7885a84fbc0721c20e6a5dd02369d [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 Andersenc7bda1c2004-03-15 08:29:22 +00005 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
Eric Andersenaad1a882001-03-16 22:47:14 +00006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
Eric Andersenaad1a882001-03-16 22:47:14 +000021 */
22
23#include <stdio.h>
24#include <errno.h>
Eric Andersena2a978a2001-04-05 06:08:14 +000025#include <unistd.h>
26/* Kernel headers before 2.1.mumble need this on the Alpha to get
27 _syscall* defined. */
28#define __LIBRARY__
Eric Andersena2a978a2001-04-05 06:08:14 +000029#include <sys/syscall.h>
Eric Andersenaad1a882001-03-16 22:47:14 +000030#include "libbb.h"
31
Mike Frysinger9b9e5472005-03-04 01:27:18 +000032int sysfs(int option, unsigned int fs_index, char * buf)
Eric Andersena2a978a2001-04-05 06:08:14 +000033{
34 return(syscall(__NR_sysfs, option, fs_index, buf));
35}
Eric Andersenaad1a882001-03-16 22:47:14 +000036
Eric Andersen82ab3d72003-05-26 18:48:56 +000037int pivot_root(const char * new_root,const char * put_old)
38{
Eric Andersene76c3b02001-04-05 03:14:39 +000039#ifndef __NR_pivot_root
40#warning This kernel does not support the pivot_root syscall
41#warning -> The pivot_root system call is being stubbed out...
Mike Frysinger9b9e5472005-03-04 01:27:18 +000042 /* BusyBox was compiled against a kernel that did not support
43 * the pivot_root system call. To make this application work,
44 * you will need to recompile with a kernel supporting the
45 * pivot_root system call.
46 */
47 bb_error_msg("\n\nTo make this application work, you will need to recompile\n"
48 "BusyBox with a kernel supporting the pivot_root system call.\n");
49 errno = ENOSYS;
50 return -1;
Eric Andersene76c3b02001-04-05 03:14:39 +000051#else
Mike Frysinger9b9e5472005-03-04 01:27:18 +000052 return(syscall(__NR_pivot_root, new_root, put_old));
53#endif /* __NR_pivot_root */
Eric Andersen82ab3d72003-05-26 18:48:56 +000054}
Eric Andersene76c3b02001-04-05 03:14:39 +000055
56
Mike Frysinger9b9e5472005-03-04 01:27:18 +000057/* These syscalls are not included in ancient glibc versions,
58 so we have to define them ourselves, whee ! */
Eric Andersen85e5e722003-07-22 08:56:55 +000059#if ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1))
Eric Andersen82ab3d72003-05-26 18:48:56 +000060
Eric Andersen82ab3d72003-05-26 18:48:56 +000061int bdflush(int func, int data)
62{
Mike Frysinger9b9e5472005-03-04 01:27:18 +000063 return(syscall(__NR_bdflush, func, data));
Eric Andersen82ab3d72003-05-26 18:48:56 +000064}
Eric Andersene76c3b02001-04-05 03:14:39 +000065
66#ifndef __alpha__
67# define __NR_klogctl __NR_syslog
Eric Andersen82ab3d72003-05-26 18:48:56 +000068int klogctl(int type, char *b, int len)
69{
Mike Frysinger9b9e5472005-03-04 01:27:18 +000070 return(syscall(__NR_klogctl, type, b, len));
Eric Andersen82ab3d72003-05-26 18:48:56 +000071}
Mike Frysinger9b9e5472005-03-04 01:27:18 +000072#endif /* __alpha__ */
Eric Andersenaad1a882001-03-16 22:47:14 +000073
Eric Andersen82ab3d72003-05-26 18:48:56 +000074
Eric Andersenaad1a882001-03-16 22:47:14 +000075int umount2(const char * special_file, int flags)
76{
Mike Frysingera36ac0d2005-03-04 01:34:23 +000077#ifndef __NR_umount2
Eric Andersen82ab3d72003-05-26 18:48:56 +000078#warning This kernel does not support the umount2 syscall
79#warning -> The umount2 system call is being stubbed out...
Mike Frysinger9b9e5472005-03-04 01:27:18 +000080 /* BusyBox was compiled against a kernel that did not support
81 * the umount2 system call. To make this application work,
82 * you will need to recompile with a kernel supporting the
83 * umount2 system call.
84 */
85 bb_error_msg("\n\nTo make this application work, you will need to recompile\n"
86 "BusyBox with a kernel supporting the umount2 system call.\n");
87 errno = ENOSYS;
88 return -1;
Eric Andersen82ab3d72003-05-26 18:48:56 +000089#else
Mike Frysinger9b9e5472005-03-04 01:27:18 +000090 return(syscall(__NR_umount2, special_file, flags));
91#endif /* __NR_pivot_root */
Eric Andersen82ab3d72003-05-26 18:48:56 +000092}
Eric Andersenaad1a882001-03-16 22:47:14 +000093
Mike Frysinger9b9e5472005-03-04 01:27:18 +000094#endif /* old glibc check */
Eric Andersene76c3b02001-04-05 03:14:39 +000095
96
Eric Andersenaad1a882001-03-16 22:47:14 +000097/* END CODE */
98/*
99Local Variables:
100c-file-style: "linux"
101c-basic-offset: 4
102tab-width: 4
103End:
104*/