⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syscalls.c

📁 linux下用PCMCIA无线网卡虚拟无线AP的程序源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* vi: set sw=4 ts=4: *//* * Syscalls for uClibc * * Copyright (C) 2000, 2001 by Lineo, inc.  Written by Erik Andersen * <andersen@lineo.com>, <andersee@debian.org> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Library General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License * for more details. * * You should have received a copy of the GNU Library General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */#include <errno.h>#include <features.h>#include <sys/types.h>#include <sys/syscall.h>//#define __NR_exit             1#ifdef L__exit/* Do not include unistd.h, so gcc doesn't whine about  * _exit returning.  It really doesn't return... */#define __NR__exit __NR_exit#ifdef __STR_NR_exit#define __STR_NR__exit __STR_NR_exit#endif_syscall1(void, _exit, int, status);#endif//#define __NR_fork             2#ifdef L_fork#include <unistd.h>#	ifdef __UCLIBC_HAS_MMU__		_syscall0(pid_t, fork);#	else		pid_t fork(void)		{			__set_errno(ENOSYS);			return -1;		}#	endif#endif//#define __NR_read             3#ifdef L_read#include <unistd.h>_syscall3(ssize_t, read, int, fd, __ptr_t, buf, size_t, count);#endif//#define __NR_write            4#ifdef L_write#include <unistd.h>_syscall3(ssize_t, write, int, fd, const __ptr_t, buf, size_t, count);weak_alias(write, __write);#endif//#define __NR_open             5#ifdef L___open#include <stdarg.h>#include <fcntl.h>#define __NR___open __NR_open#ifdef __STR_NR_open#define __STR_NR___open __STR_NR_open#endif_syscall3(int, __open, const char *, fn, int, flags, mode_t, mode);int open(const char *file, int oflag, ...){	int mode = 0;	if (oflag & O_CREAT) {		va_list args;		va_start(args, oflag);		mode = va_arg(args, int);		va_end(args);	}	return __open(file, oflag, mode);}#endif//#define __NR_close            6#ifdef L_close#include <unistd.h>_syscall1(int, close, int, fd);#endif//#define __NR_waitpid          7// Implemented using wait4 //#define __NR_creat            8#ifdef L_creat#include <fcntl.h>_syscall2(int, creat, const char *, file, mode_t, mode);#endif//#define __NR_link             9#ifdef L_link#include <unistd.h>_syscall2(int, link, const char *, oldpath, const char *, newpath);#endif//#define __NR_unlink           10#ifdef L_unlink#include <unistd.h>_syscall1(int, unlink, const char *, pathname);#endif//#define __NR_execve           11#ifdef L_execve#include <unistd.h>_syscall3(int, execve, const char *, filename, char *const *, argv,		  char *const *, envp);#endif//#define __NR_chdir            12#ifdef L_chdir#include <unistd.h>_syscall1(int, chdir, const char *, path);#endif//#define __NR_time             13#ifdef L_time#include <time.h>_syscall1(time_t, time, time_t *, t);#endif//#define __NR_mknod            14#ifdef L_mknod#include <unistd.h>extern int mknod(const char *pathname, mode_t mode, dev_t dev);_syscall3(int, mknod, const char *, pathname, mode_t, mode, dev_t, dev);int __xmknod (int version, const char * path, mode_t mode, dev_t *dev){	switch(version)	{		case 1:			return mknod (path, mode, *dev);		default:			__set_errno(EINVAL);			return -1;	}}#endif//#define __NR_chmod            15#ifdef L_chmod#include <sys/stat.h>_syscall2(int, chmod, const char *, path, mode_t, mode);#endif/* Old kernels don't have lchown -- do chown instead.  This * is sick and wrong, but at least things will compile.   * They may not follow links when they should though... */#ifndef __NR_lchown #define __NR_lchown __NR_chown#endif//#define __NR_lchown           16#ifdef L_lchown#include <unistd.h>_syscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group);#endif//#define __NR_break            17//#define __NR_oldstat          18//#define __NR_lseek            19#ifdef L_lseek#include <unistd.h>_syscall3(off_t, lseek, int, fildes, off_t, offset, int, whence);#endif//#define __NR_getpid           20#ifdef L_getpid#include <unistd.h>_syscall0(pid_t, getpid);#endif//#define __NR_mount            21#ifdef L_mount#include <sys/mount.h>_syscall5(int, mount, const char *, specialfile, const char *, dir,		  const char *, filesystemtype, unsigned long, rwflag,		  const void *, data);#endif//#define __NR_umount           22#ifdef L_umount#include <sys/mount.h>_syscall1(int, umount, const char *, specialfile);#endif//#define __NR_setuid           23#ifdef L_setuid#include <unistd.h>_syscall1(int, setuid, uid_t, uid);#endif//#define __NR_getuid           24#ifdef L_getuid#include <unistd.h>_syscall0(gid_t, getuid);#endif//#define __NR_stime            25#ifdef L_stime#include <time.h>_syscall1(int, stime, const time_t *, t);#endif//#define __NR_ptrace           26#ifdef L___ptrace#include <sys/ptrace.h>#define __NR___ptrace __NR_ptrace#ifdef __STR_NR_ptrace#define __STR_NR___ptrace __STR_NR_ptrace#endif_syscall4(long, __ptrace, enum __ptrace_request, request, pid_t, pid,		void*, addr, void*, data);#endif//#define __NR_alarm            27#ifdef L_alarm#include <unistd.h>_syscall1(unsigned int, alarm, unsigned int, seconds);#endif//#define __NR_oldfstat         28//#define __NR_pause            29#ifdef L_pause#include <unistd.h>_syscall0(int, pause);#endif//#define __NR_utime            30#ifdef L_utime#include <utime.h>_syscall2(int, utime, const char *, filename, const struct utimbuf *, buf);#endif//#define __NR_stty             31//#define __NR_gtty             32//#define __NR_access           33#ifdef L_access#include <unistd.h>_syscall2(int, access, const char *, pathname, int, mode);#endif//#define __NR_nice             34#ifdef L_nice#include <unistd.h>_syscall1(int, nice, int, inc);#endif//#define __NR_ftime            35//#define __NR_sync             36#ifdef L_sync#include <unistd.h>_syscall0(void, sync);#endif//#define __NR_kill             37#ifdef L_kill#include <signal.h>#undef kill_syscall2(int, kill, pid_t, pid, int, sig);#endif//#define __NR_rename           38#ifdef L_rename#include <stdio.h>_syscall2(int, rename, const char *, oldpath, const char *, newpath);#endif//#define __NR_mkdir            39#ifdef L_mkdir#include <sys/stat.h>_syscall2(int, mkdir, const char *, pathname, mode_t, mode);#endif//#define __NR_rmdir            40#ifdef L_rmdir#include <unistd.h>_syscall1(int, rmdir, const char *, pathname);#endif//#define __NR_dup              41#ifdef L_dup#include <unistd.h>_syscall1(int, dup, int, oldfd);#endif//#define __NR_pipe             42#ifdef L_pipe#include <unistd.h>/* * SH has a weird register calling mechanism for pipe, see pipe.c */#if !defined(__sh__)_syscall1(int, pipe, int *, filedes);#endif#endif//#define __NR_times            43#ifdef L_times#include <sys/times.h>_syscall1(clock_t, times, struct tms *, buf);#endif//#define __NR_prof             44//#define __NR_brk              45//#define __NR_setgid           46#ifdef L_setgid#include <unistd.h>_syscall1(int, setgid, gid_t, gid);#endif//#define __NR_getgid           47#ifdef L_getgid#include <unistd.h>_syscall0(gid_t, getgid);#endif//#define __NR_signal           48//#define __NR_geteuid          49#ifdef	L_geteuid#	ifdef	__NR_geteuid#	include <unistd.h>	_syscall0(uid_t, geteuid);#	else	uid_t geteuid(void)	{		return (getuid());	}#	endif#endif//#define __NR_getegid          50#ifdef	L_getegid#	ifdef	__NR_getegid#	include <unistd.h>	_syscall0(gid_t, getegid);#	else	gid_t getegid(void)	{		return (getgid());	}#	endif#endif//#define __NR_acct             51//#define __NR_umount2          52#ifdef L_umount2#	ifdef __NR_umount2 /* Old kernels don't have umount2 */ #		include <sys/mount.h>		_syscall2(int, umount2, const char *, special_file, int, flags);#	else		int umount2(const char * special_file, int flags)		{			__set_errno(ENOSYS);			return -1;		}#	endif#endif//#define __NR_lock             53//#define __NR_ioctl            54#ifdef L__ioctl#include <stdarg.h>#include <sys/ioctl.h>#define __NR__ioctl __NR_ioctl#ifdef __STR_NR_ioctl#define __STR_NR__ioctl __STR_NR_ioctl#endifextern int _ioctl(int fd, int request, void *arg);_syscall3(int, _ioctl, int, fd, int, request, void *, arg);int ioctl(int fd, unsigned long int request, ...){	void *arg;	va_list list;	va_start(list, request);	arg = va_arg(list, void *);	va_end(list);	return _ioctl(fd, request, arg);}#endif//#define __NR_fcntl            55#ifdef L__fcntl#include <stdarg.h>#include <fcntl.h>#define __NR__fcntl __NR_fcntl#ifdef __STR_NR_fcntl#define __STR_NR__fcntl __STR_NR_fcntl#endifextern int _fcntl(int fd, int cmd, long arg);_syscall3(int, _fcntl, int, fd, int, cmd, long, arg);int fcntl(int fd, int command, ...){	long arg;	va_list list;	va_start(list, command);	arg = va_arg(list, long);	va_end(list);	return _fcntl(fd, command, arg);}#endif//#define __NR_mpx              56//#define __NR_setpgid          57#ifdef L_setpgid#include <unistd.h>_syscall2(int, setpgid, pid_t, pid, pid_t, pgid);#endif//#define __NR_ulimit           58//#define __NR_oldolduname      59//#define __NR_umask            60#ifdef L_umask#include <sys/stat.h>_syscall1(mode_t, umask, mode_t, mask);#endif//#define __NR_chroot           61#ifdef L_chroot#include <unistd.h>_syscall1(int, chroot, const char *, path);#endif//#define __NR_ustat            62//#define __NR_dup2             63#ifdef L_dup2#include <unistd.h>_syscall2(int, dup2, int, oldfd, int, newfd);#endif//#define __NR_getppid          64#ifdef	L_getppid#	include <unistd.h>#	ifdef	__NR_getppid	_syscall0(pid_t, getppid);#	else	pid_t getppid(void)	{		return (getpid());	}#	endif#endif//#define __NR_getpgrp          65#ifdef L_getpgrp#include <unistd.h>_syscall0(pid_t, getpgrp);#endif//#define __NR_setsid           66#ifdef L_setsid#include <unistd.h>_syscall0(pid_t, setsid);#endif//#define __NR_sigaction        67#ifdef L_sigaction#include <signal.h>#undef sigaction_syscall3(int, sigaction, int, signum, const struct sigaction *, act,		  struct sigaction *, oldact);#endif//#define __NR_sgetmask         68//#define __NR_ssetmask         69//#define __NR_setreuid         70#ifdef L_setreuid#include <unistd.h>_syscall2(int, setreuid, uid_t, ruid, uid_t, euid);#endif//#define __NR_setregid         71#ifdef L_setregid#include <unistd.h>_syscall2(int, setregid, gid_t, rgid, gid_t, egid);#endif//#define __NR_sigsuspend       72#ifdef L_sigsuspend#include <signal.h>#undef sigsuspend_syscall1(int, sigsuspend, const sigset_t *, mask);#endif//#define __NR_sigpending       73#ifdef L_sigpending#include <signal.h>#undef sigpending_syscall1(int, sigpending, sigset_t *, set);#endif//#define __NR_sethostname      74#ifdef L_sethostname#include <unistd.h>_syscall2(int, sethostname, const char *, name, size_t, len);#endif//#define __NR_setrlimit        75#ifdef L_setrlimit#include <unistd.h>#include <sys/resource.h>_syscall2(int, setrlimit, int, resource, const struct rlimit *, rlim);#endif//#define __NR_getrlimit        76#ifdef L_getrlimit#include <unistd.h>#include <sys/resource.h>_syscall2(int, getrlimit, int, resource, struct rlimit *, rlim);#endif//#define __NR_getrusage        77#ifdef L_getrusage#include <unistd.h>#include <wait.h>_syscall2(int, getrusage, int, who, struct rusage *, usage);#endif//#define __NR_gettimeofday     78#ifdef L_gettimeofday#include <sys/time.h>_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);#endif//#define __NR_settimeofday     79#ifdef L_settimeofday#include <sys/time.h>_syscall2(int, settimeofday, const struct timeval *, tv,		  const struct timezone *, tz);#endif//#define __NR_getgroups        80#ifdef L_getgroups#include <unistd.h>_syscall2(int, getgroups, int, size, gid_t *, list);#endif//#define __NR_setgroups        81#ifdef L_setgroups#include <unistd.h>#include <grp.h>_syscall2(int, setgroups, size_t, size, const gid_t *, list);#endif//#define __NR_select           82//#define __NR_symlink          83#ifdef L_symlink#include <unistd.h>_syscall2(int, symlink, const char *, oldpath, const char *, newpath);#endif//#define __NR_oldlstat         84//#define __NR_readlink         85#ifdef L_readlink#include <unistd.h>_syscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz);#endif//#define __NR_uselib           86#ifdef L_uselib#include <unistd.h>_syscall1(int, uselib, const char *, library);#endif//#define __NR_swapon           87#ifdef L_swapon#include <sys/swap.h>_syscall2(int, swapon, const char *, path, int, swapflags);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -