syscalls.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Syscalls for uClibc
  4. *
  5. * Copyright (C) 2000 by Lineo, inc. Written by Erik Andersen
  6. * <andersen@lineo.com>, <andersee@debian.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU Library General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  16. * for more details.
  17. *
  18. * You should have received a copy of the GNU Library General Public License
  19. * along with this program; if not, write to the Free Software Foundation,
  20. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <errno.h>
  24. #include <features.h>
  25. #include <sys/types.h>
  26. #include <sys/syscall.h>
  27. #include "unified_syscall.h"
  28. //#define __NR_exit 1
  29. #ifdef L__exit
  30. /* Do not include unistd.h, so gcc doesn't whine about
  31. * _exit returning. It really doesn't return... */
  32. #define __NR__exit __NR_exit
  33. _syscall1(void, _exit, int, status);
  34. #endif
  35. //#define __NR_fork 2
  36. #ifdef L_fork
  37. #ifndef __HAS_NO_MMU__
  38. #include <unistd.h>
  39. _syscall0(pid_t, fork);
  40. #endif
  41. #endif
  42. //#define __NR_read 3
  43. #ifdef L_read
  44. #include <unistd.h>
  45. _syscall3(ssize_t, read, int, fd, __ptr_t, buf, size_t, count);
  46. #endif
  47. //#define __NR_write 4
  48. #ifdef L_write
  49. #include <unistd.h>
  50. _syscall3(ssize_t, write, int, fd, const __ptr_t, buf, size_t, count);
  51. #endif
  52. //#define __NR_open 5
  53. #ifdef L___open
  54. #include <stdarg.h>
  55. #include <fcntl.h>
  56. #define __NR___open __NR_open
  57. _syscall3(int, __open, const char *, fn, int, flags, mode_t, mode);
  58. int open(const char *file, int oflag, ...)
  59. {
  60. int mode = 0;
  61. if (oflag & O_CREAT) {
  62. va_list args;
  63. va_start(args, oflag);
  64. mode = va_arg(args, int);
  65. va_end(args);
  66. }
  67. return __open(file, oflag, mode);
  68. }
  69. #endif
  70. //#define __NR_close 6
  71. #ifdef L_close
  72. #include <unistd.h>
  73. _syscall1(int, close, int, fd);
  74. #endif
  75. //#define __NR_waitpid 7
  76. // Implemented using wait4
  77. //#define __NR_creat 8
  78. #ifdef L_creat
  79. #include <fcntl.h>
  80. _syscall2(int, creat, const char *, file, mode_t, mode);
  81. #endif
  82. //#define __NR_link 9
  83. #ifdef L_link
  84. #include <unistd.h>
  85. _syscall2(int, link, const char *, oldpath, const char *, newpath);
  86. #endif
  87. //#define __NR_unlink 10
  88. #ifdef L_unlink
  89. #include <unistd.h>
  90. _syscall1(int, unlink, const char *, pathname);
  91. #endif
  92. //#define __NR_execve 11
  93. #ifdef L_execve
  94. #include <unistd.h>
  95. _syscall3(int, execve, const char *, filename, char *const *, argv,
  96. char *const *, envp);
  97. #endif
  98. //#define __NR_chdir 12
  99. #ifdef L_chdir
  100. #include <unistd.h>
  101. _syscall1(int, chdir, const char *, path);
  102. #endif
  103. //#define __NR_time 13
  104. #ifdef L_time
  105. #include <time.h>
  106. _syscall1(time_t, time, time_t *, t);
  107. #endif
  108. //#define __NR_mknod 14
  109. #ifdef L_mknod
  110. #include <unistd.h>
  111. extern int mknod(const char *pathname, mode_t mode, dev_t dev);
  112. _syscall3(int, mknod, const char *, pathname, mode_t, mode, dev_t, dev);
  113. int _xmknod (int version, const char * path, mode_t mode, dev_t *dev)
  114. {
  115. switch(version)
  116. {
  117. case 1:
  118. return mknod (path, mode, *dev);
  119. default:
  120. errno = EINVAL;
  121. return -1;
  122. }
  123. }
  124. #endif
  125. //#define __NR_chmod 15
  126. #ifdef L_chmod
  127. #include <sys/stat.h>
  128. _syscall2(int, chmod, const char *, path, mode_t, mode);
  129. #endif
  130. /* Old kernels don't have lchown -- do chown instead. This
  131. * is sick and wrong, but at least things will compile.
  132. * They may not follow links when they should though... */
  133. #ifndef __NR_lchown
  134. #define __NR_lchown __NR_chown
  135. #endif
  136. //#define __NR_lchown 16
  137. #ifdef L_lchown
  138. #include <unistd.h>
  139. _syscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group);
  140. #endif
  141. //#define __NR_break 17
  142. //#define __NR_oldstat 18
  143. //#define __NR_lseek 19
  144. #ifdef L_lseek
  145. #include <unistd.h>
  146. _syscall3(off_t, lseek, int, fildes, off_t, offset, int, whence);
  147. #endif
  148. //#define __NR_getpid 20
  149. #ifdef L_getpid
  150. #include <unistd.h>
  151. _syscall0(pid_t, getpid);
  152. #endif
  153. //#define __NR_mount 21
  154. #ifdef L_mount
  155. #include <sys/mount.h>
  156. _syscall5(int, mount, const char *, specialfile, const char *, dir,
  157. const char *, filesystemtype, unsigned long, rwflag,
  158. const void *, data);
  159. #endif
  160. //#define __NR_umount 22
  161. #ifdef L_umount
  162. #include <sys/mount.h>
  163. _syscall1(int, umount, const char *, specialfile);
  164. #endif
  165. //#define __NR_setuid 23
  166. #ifdef L_setuid
  167. #include <unistd.h>
  168. _syscall1(int, setuid, uid_t, uid);
  169. #endif
  170. //#define __NR_getuid 24
  171. #ifdef L_getuid
  172. #include <unistd.h>
  173. _syscall0(gid_t, getuid);
  174. #endif
  175. //#define __NR_stime 25
  176. #ifdef L_stime
  177. #include <time.h>
  178. _syscall1(int, stime, time_t *, t);
  179. #endif
  180. //#define __NR_ptrace 26
  181. #ifdef L___ptrace
  182. #include <sys/ptrace.h>
  183. #define __NR___ptrace __NR_ptrace
  184. _syscall4(long, __ptrace, enum __ptrace_request, request, pid_t, pid,
  185. void*, addr, void*, data);
  186. #endif
  187. //#define __NR_alarm 27
  188. #ifdef L_alarm
  189. #include <unistd.h>
  190. _syscall1(unsigned int, alarm, unsigned int, seconds);
  191. #endif
  192. //#define __NR_oldfstat 28
  193. //#define __NR_pause 29
  194. #ifdef L_pause
  195. #include <unistd.h>
  196. _syscall0(int, pause);
  197. #endif
  198. //#define __NR_utime 30
  199. #ifdef L_utime
  200. #include <utime.h>
  201. _syscall2(int, utime, const char *, filename, struct utimbuf *, buf);
  202. #endif
  203. //#define __NR_stty 31
  204. //#define __NR_gtty 32
  205. //#define __NR_access 33
  206. #ifdef L_access
  207. #include <unistd.h>
  208. _syscall2(int, access, const char *, pathname, int, mode);
  209. #endif
  210. //#define __NR_nice 34
  211. #ifdef L_nice
  212. #include <unistd.h>
  213. _syscall1(int, nice, int, inc);
  214. #endif
  215. //#define __NR_ftime 35
  216. //#define __NR_sync 36
  217. #ifdef L_sync
  218. #include <unistd.h>
  219. _syscall0(int, sync);
  220. #endif
  221. //#define __NR_kill 37
  222. #ifdef L_kill
  223. #include <signal.h>
  224. _syscall2(int, kill, pid_t, pid, int, sig);
  225. #endif
  226. //#define __NR_rename 38
  227. #ifdef L_rename
  228. #include <stdio.h>
  229. _syscall2(int, rename, const char *, oldpath, const char *, newpath);
  230. #endif
  231. //#define __NR_mkdir 39
  232. #ifdef L_mkdir
  233. #include <sys/stat.h>
  234. _syscall2(int, mkdir, const char *, pathname, mode_t, mode);
  235. #endif
  236. //#define __NR_rmdir 40
  237. #ifdef L_rmdir
  238. #include <unistd.h>
  239. _syscall1(int, rmdir, const char *, pathname);
  240. #endif
  241. //#define __NR_dup 41
  242. #ifdef L_dup
  243. #include <unistd.h>
  244. _syscall1(int, dup, int, oldfd);
  245. #endif
  246. //#define __NR_pipe 42
  247. #ifdef L_pipe
  248. #include <unistd.h>
  249. _syscall1(int, pipe, int *, filedes);
  250. #endif
  251. //#define __NR_times 43
  252. #ifdef L_times
  253. #include <sys/times.h>
  254. _syscall1(clock_t, times, struct tms *, buf);
  255. #endif
  256. //#define __NR_prof 44
  257. //#define __NR_brk 45
  258. //#define __NR_setgid 46
  259. #ifdef L_setgid
  260. #include <unistd.h>
  261. _syscall1(int, setgid, gid_t, gid);
  262. #endif
  263. //#define __NR_getgid 47
  264. #ifdef L_getgid
  265. #include <unistd.h>
  266. _syscall0(gid_t, getgid);
  267. #endif
  268. //#define __NR_signal 48
  269. //#define __NR_geteuid 49
  270. #ifdef L_geteuid
  271. #ifdef SYS_geteuid
  272. #include <unistd.h>
  273. _syscall0(uid_t, geteuid);
  274. #else
  275. uid_t geteuid(void)
  276. {
  277. return (getuid());
  278. }
  279. #endif
  280. #endif
  281. //#define __NR_getegid 50
  282. #ifdef L_getegid
  283. #ifdef SYS_getegid
  284. #include <unistd.h>
  285. _syscall0(gid_t, getegid);
  286. #else
  287. gid_t getegid(void)
  288. {
  289. return (getgid());
  290. }
  291. #endif
  292. #endif
  293. //#define __NR_acct 51
  294. #ifdef __NR_umount2 /* Old kernels don't have umount2 */
  295. //#define __NR_umount2 52
  296. #ifdef L_umount2
  297. #include <sys/mount.h>
  298. _syscall2(int, umount2, const char *, special_file, int, flags);
  299. #endif
  300. #endif
  301. //#define __NR_lock 53
  302. //#define __NR_ioctl 54
  303. #ifdef L__ioctl
  304. #include <stdarg.h>
  305. #include <sys/ioctl.h>
  306. #define __NR__ioctl __NR_ioctl
  307. extern int _ioctl(int fd, int request, void *arg);
  308. _syscall3(int, _ioctl, int, fd, int, request, void *, arg);
  309. int ioctl(int fd, unsigned long int request, ...)
  310. {
  311. void *arg;
  312. va_list list;
  313. va_start(list, request);
  314. arg = va_arg(list, void *);
  315. va_end(list);
  316. return _ioctl(fd, request, arg);
  317. }
  318. #endif
  319. //#define __NR_fcntl 55
  320. #ifdef L__fcntl
  321. #include <stdarg.h>
  322. #include <fcntl.h>
  323. #define __NR__fcntl __NR_fcntl
  324. extern int _fcntl(int fd, int cmd, long arg);
  325. _syscall3(int, _fcntl, int, fd, int, cmd, long, arg);
  326. int fcntl(int fd, int command, ...)
  327. {
  328. long arg;
  329. va_list list;
  330. va_start(list, command);
  331. arg = va_arg(list, long);
  332. va_end(list);
  333. return _fcntl(fd, command, arg);
  334. }
  335. #endif
  336. //#define __NR_mpx 56
  337. //#define __NR_setpgid 57
  338. #ifdef L_setpgid
  339. #include <unistd.h>
  340. _syscall2(int, setpgid, pid_t, pid, pid_t, pgid);
  341. #endif
  342. //#define __NR_ulimit 58
  343. //#define __NR_oldolduname 59
  344. //#define __NR_umask 60
  345. #ifdef L_umask
  346. #include <sys/stat.h>
  347. _syscall1(mode_t, umask, mode_t, mask);
  348. #endif
  349. //#define __NR_chroot 61
  350. #ifdef L_chroot
  351. #include <unistd.h>
  352. _syscall1(int, chroot, const char *, path);
  353. #endif
  354. //#define __NR_ustat 62
  355. //#define __NR_dup2 63
  356. #ifdef L_dup2
  357. #include <unistd.h>
  358. _syscall2(int, dup2, int, oldfd, int, newfd);
  359. #endif
  360. //#define __NR_getppid 64
  361. #ifdef L_getppid
  362. #include <unistd.h>
  363. #ifdef SYS_getppid
  364. _syscall0(pid_t, getppid);
  365. #else
  366. pid_t getppid(void)
  367. {
  368. return (getpid());
  369. }
  370. #endif
  371. #endif
  372. //#define __NR_getpgrp 65
  373. #ifdef L_getpgrp
  374. #include <unistd.h>
  375. _syscall0(pid_t, getpgrp);
  376. #endif
  377. //#define __NR_setsid 66
  378. #ifdef L_setsid
  379. #include <unistd.h>
  380. _syscall0(pid_t, setsid);
  381. #endif
  382. //#define __NR_sigaction 67
  383. #ifdef L_sigaction
  384. #include <signal.h>
  385. _syscall3(int, sigaction, int, signum, const struct sigaction *, act,
  386. struct sigaction *, oldact);
  387. #endif
  388. //#define __NR_sgetmask 68
  389. //#define __NR_ssetmask 69
  390. //#define __NR_setreuid 70
  391. #ifdef L_setreuid
  392. #include <unistd.h>
  393. _syscall2(int, setreuid, uid_t, ruid, uid_t, euid);
  394. #endif
  395. //#define __NR_setregid 71
  396. #ifdef L_setregid
  397. #include <unistd.h>
  398. _syscall2(int, setregid, gid_t, rgid, gid_t, egid);
  399. #endif
  400. //#define __NR_sigsuspend 72
  401. #ifdef L_sigsuspend
  402. #include <signal.h>
  403. _syscall1(int, sigsuspend, const sigset_t *, mask);
  404. #endif
  405. //#define __NR_sigpending 73
  406. #ifdef L_sigpending
  407. #include <signal.h>
  408. _syscall1(int, sigpending, sigset_t *, set);
  409. #endif
  410. //#define __NR_sethostname 74
  411. #ifdef L_sethostname
  412. #include <unistd.h>
  413. _syscall2(int, sethostname, const char *, name, size_t, len);
  414. #endif
  415. //#define __NR_setrlimit 75
  416. #ifdef L_setrlimit
  417. #include <unistd.h>
  418. #include <sys/resource.h>
  419. _syscall2(int, setrlimit, int, resource, const struct rlimit *, rlim);
  420. #endif
  421. //#define __NR_getrlimit 76
  422. #ifdef L_getrlimit
  423. #include <unistd.h>
  424. #include <sys/resource.h>
  425. _syscall2(int, getrlimit, int, resource, struct rlimit *, rlim);
  426. #endif
  427. //#define __NR_getrusage 77
  428. #ifdef L_getrusage
  429. #include <unistd.h>
  430. #include <wait.h>
  431. _syscall2(int, getrusage, int, who, struct rusage *, usage);
  432. #endif
  433. //#define __NR_gettimeofday 78
  434. #ifdef L_gettimeofday
  435. #include <unistd.h>
  436. _syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
  437. #endif
  438. //#define __NR_settimeofday 79
  439. #ifdef L_settimeofday
  440. #include <unistd.h>
  441. _syscall2(int, settimeofday, const struct timeval *, tv,
  442. const struct timezone *, tz);
  443. #endif
  444. //#define __NR_getgroups 80
  445. #ifdef L_getgroups
  446. #include <unistd.h>
  447. _syscall2(int, getgroups, int, size, gid_t *, list);
  448. #endif
  449. //#define __NR_setgroups 81
  450. #ifdef L_setgroups
  451. #include <unistd.h>
  452. #include <grp.h>
  453. _syscall2(int, setgroups, size_t, size, const gid_t *, list);
  454. #endif
  455. //#define __NR_select 82
  456. //#define __NR_symlink 83
  457. #ifdef L_symlink
  458. #include <unistd.h>
  459. _syscall2(int, symlink, const char *, oldpath, const char *, newpath);
  460. #endif
  461. //#define __NR_oldlstat 84
  462. //#define __NR_readlink 85
  463. #ifdef L_readlink
  464. #include <unistd.h>
  465. _syscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz);
  466. #endif
  467. //#define __NR_uselib 86
  468. #ifdef L_uselib
  469. #include <unistd.h>
  470. _syscall1(int, uselib, const char *, library);
  471. #endif
  472. //#define __NR_swapon 87
  473. #ifdef L_swapon
  474. #include <sys/swap.h>
  475. _syscall2(int, swapon, const char *, path, int, swapflags);
  476. #endif
  477. //#define __NR_reboot 88
  478. #ifdef L__reboot
  479. #define __NR__reboot __NR_reboot
  480. extern int _reboot(int magic, int magic2, int flag);
  481. _syscall3(int, _reboot, int, magic, int, magic2, int, flag);
  482. int reboot(int flag)
  483. {
  484. return (_reboot((int) 0xfee1dead, 672274793, flag));
  485. }
  486. #endif
  487. //#define __NR_readdir 89
  488. //#define __NR_mmap 90
  489. #ifdef L__mmap
  490. #define __NR__mmap __NR_mmap
  491. #include <unistd.h>
  492. #include <sys/mman.h>
  493. extern __ptr_t _mmap(unsigned long *buffer);
  494. _syscall1(__ptr_t, _mmap, unsigned long *, buffer);
  495. __ptr_t mmap(__ptr_t addr, size_t len, int prot,
  496. int flags, int fd, __off_t offset)
  497. {
  498. unsigned long buffer[6];
  499. buffer[0] = (unsigned long) addr;
  500. buffer[1] = (unsigned long) len;
  501. buffer[2] = (unsigned long) prot;
  502. buffer[3] = (unsigned long) flags;
  503. buffer[4] = (unsigned long) fd;
  504. buffer[5] = (unsigned long) offset;
  505. return (__ptr_t) _mmap(buffer);
  506. }
  507. #endif
  508. //#define __NR_munmap 91
  509. #ifdef L_munmap
  510. #include <unistd.h>
  511. #include <sys/mman.h>
  512. _syscall2(int, munmap, void *, start, size_t, length);
  513. #endif
  514. //#define __NR_truncate 92
  515. #ifdef L_truncate
  516. #include <unistd.h>
  517. _syscall2(int, truncate, const char *, path, off_t, length);
  518. #endif
  519. //#define __NR_ftruncate 93
  520. #ifdef L_ftruncate
  521. #include <unistd.h>
  522. _syscall2(int, ftruncate, int, fd, off_t, length);
  523. #endif
  524. //#define __NR_fchmod 94
  525. #ifdef L_fchmod
  526. #include <sys/stat.h>
  527. _syscall2(int, fchmod, int, fildes, mode_t, mode);
  528. #endif
  529. //#define __NR_fchown 95
  530. #ifdef L_fchown
  531. #include <unistd.h>
  532. _syscall3(int, fchown, int, fd, uid_t, owner, gid_t, group);
  533. #endif
  534. //#define __NR_getpriority 96
  535. #ifdef L_getpriority
  536. #include <sys/resource.h>
  537. _syscall2(int, getpriority, int, which, int, who);
  538. #endif
  539. //#define __NR_setpriority 97
  540. #ifdef L_setpriority
  541. #include <sys/resource.h>
  542. _syscall3(int, setpriority, int, which, int, who, int, prio);
  543. #endif
  544. //#define __NR_profil 98
  545. //#define __NR_statfs 99
  546. #ifdef L_statfs
  547. #include <sys/vfs.h>
  548. _syscall2(int, statfs, const char *, path, struct statfs *, buf);
  549. #endif
  550. //#define __NR_fstatfs 100
  551. #ifdef L_fstatfs
  552. #include <sys/vfs.h>
  553. _syscall2(int, fstatfs, int, fd, struct statfs *, buf);
  554. #endif
  555. #ifndef __HAS_NO_MMU__
  556. //#define __NR_ioperm 101
  557. #ifdef L_ioperm
  558. #include <sys/io.h>
  559. _syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on);
  560. #endif
  561. #endif
  562. //#define __NR_socketcall 102
  563. #ifdef L_socketcall
  564. _syscall2(int, socketcall, int, call, unsigned long *, args);
  565. #endif
  566. //#define __NR_syslog 103
  567. #ifdef L__syslog
  568. #include <unistd.h>
  569. #define __NR__syslog __NR_syslog
  570. extern int _syslog(int type, char *buf, int len);
  571. _syscall3(int, _syslog, int, type, char *, buf, int, len);
  572. int klogctl(int type, char *buf, int len)
  573. {
  574. return (_syslog(type, buf, len));
  575. }
  576. #endif
  577. //#define __NR_setitimer 104
  578. #ifdef L_setitimer
  579. #include <sys/time.h>
  580. _syscall3(int, setitimer, enum __itimer_which, which,
  581. const struct itimerval *, new, struct itimerval *, old);
  582. #endif
  583. //#define __NR_getitimer 105
  584. #ifdef L_getitimer
  585. #include <sys/time.h>
  586. _syscall2(int, getitimer, enum __itimer_which, which, struct itimerval *, value);
  587. #endif
  588. //#define __NR_stat 106
  589. #ifdef L___stat
  590. #include <unistd.h>
  591. #include "statfix.h"
  592. #define __NR___stat __NR_stat
  593. extern int __stat(const char *file_name, struct kernel_stat *buf);
  594. _syscall2(int, __stat, const char *, file_name, struct kernel_stat *, buf);
  595. int _xstat(int version, const char * file_name, struct libc_stat * cstat)
  596. {
  597. struct kernel_stat kstat;
  598. int result = __stat(file_name, &kstat);
  599. if (result == 0) {
  600. statfix(cstat, &kstat);
  601. }
  602. return result;
  603. }
  604. int stat(const char *file_name, struct libc_stat *buf)
  605. {
  606. return(_xstat(0, file_name, buf));
  607. }
  608. #endif
  609. //#define __NR_lstat 107
  610. #ifdef L___lstat
  611. #include <unistd.h>
  612. #include "statfix.h"
  613. #define __NR___lstat __NR_lstat
  614. extern int __lstat(const char *file_name, struct kernel_stat *buf);
  615. _syscall2(int, __lstat, const char *, file_name, struct kernel_stat *, buf);
  616. int _lxstat(int version, const char * file_name, struct libc_stat * cstat)
  617. {
  618. struct kernel_stat kstat;
  619. int result = __lstat(file_name, &kstat);
  620. if (result == 0) {
  621. statfix(cstat, &kstat);
  622. }
  623. return result;
  624. }
  625. int lstat(const char *file_name, struct libc_stat *buf)
  626. {
  627. return(_lxstat(0, file_name, buf));
  628. }
  629. #endif
  630. //#define __NR_fstat 108
  631. #ifdef L___fstat
  632. #include <unistd.h>
  633. #include "statfix.h"
  634. #define __NR___fstat __NR_fstat
  635. extern int __fstat(int filedes, struct kernel_stat *buf);
  636. _syscall2(int, __fstat, int, filedes, struct kernel_stat *, buf);
  637. int _fxstat(int version, int fd, struct libc_stat * cstat)
  638. {
  639. struct kernel_stat kstat;
  640. int result = __fstat(fd, &kstat);
  641. if (result == 0) {
  642. statfix(cstat, &kstat);
  643. }
  644. return result;
  645. }
  646. int fstat(int filedes, struct libc_stat *buf)
  647. {
  648. return(_fxstat(0, filedes, buf));
  649. }
  650. #endif
  651. //#define __NR_olduname 109
  652. #ifndef __HAS_NO_MMU__
  653. //#define __NR_iopl 110
  654. #ifdef L_iopl
  655. #include <sys/io.h>
  656. _syscall1(int, iopl, int, level);
  657. #endif
  658. #endif
  659. //#define __NR_vhangup 111
  660. #ifdef L_vhangup
  661. #include <unistd.h>
  662. _syscall0(int, vhangup);
  663. #endif
  664. //#define __NR_idle 112
  665. //int idle(void);
  666. //#define __NR_vm86old 113
  667. //#define __NR_wait4 114
  668. #ifdef L_wait4
  669. _syscall4(int, wait4, pid_t, pid, int *, status, int, opts, void *, rusage);
  670. #endif
  671. //#define __NR_swapoff 115
  672. #ifdef L_swapoff
  673. #include <sys/swap.h>
  674. _syscall1(int, swapoff, const char *, path);
  675. #endif
  676. //#define __NR_sysinfo 116
  677. #ifdef L_sysinfo
  678. #include <sys/sysinfo.h>
  679. _syscall1(int, sysinfo, struct sysinfo *, info);
  680. #endif
  681. //#define __NR_ipc 117
  682. #ifdef L___ipc
  683. #define __NR___ipc __NR_ipc
  684. _syscall5(int, __ipc, unsigned int, call, int, first, int, second, int, third, void *, ptr);
  685. #endif
  686. //#define __NR_fsync 118
  687. #ifdef L_fsync
  688. #include <unistd.h>
  689. _syscall1(int, fsync, int, fd);
  690. #endif
  691. //#define __NR_sigreturn 119
  692. //int sigreturn(unsigned long __unused);
  693. //#define __NR_clone 120
  694. //See architecture specific implementation...
  695. //#define __NR_setdomainname 121
  696. #ifdef L_setdomainname
  697. #include <unistd.h>
  698. _syscall2(int, setdomainname, const char *, name, size_t, len);
  699. #endif
  700. //#define __NR_uname 122
  701. #ifdef L_uname
  702. #include <sys/utsname.h>
  703. _syscall1(int, uname, struct utsname *, buf);
  704. #endif
  705. //#define __NR_modify_ldt 123
  706. //#define __NR_adjtimex 124
  707. #ifdef L_adjtimex
  708. #include <sys/timex.h>
  709. _syscall1(int, adjtimex, struct timex *, buf);
  710. #endif
  711. //#define __NR_mprotect 125
  712. #ifdef L_mprotect
  713. #include <sys/mman.h>
  714. _syscall3(int, mprotect, const void *, addr, size_t, len, int, prot);
  715. #endif
  716. //#define __NR_sigprocmask 126
  717. #ifdef L_sigprocmask
  718. #include <signal.h>
  719. _syscall3(int, sigprocmask, int, how, const sigset_t *, set, sigset_t *,
  720. oldset);
  721. #endif
  722. //#define __NR_create_module 127
  723. //#define __NR_init_module 128
  724. //#define __NR_delete_module 129
  725. //#define __NR_get_kernel_syms 130
  726. //#define __NR_quotactl 131
  727. //#define __NR_getpgid 132
  728. #ifdef L_getpgid
  729. _syscall1(pid_t, getpgid, pid_t, pid);
  730. #endif
  731. //#define __NR_fchdir 133
  732. #ifdef L_fchdir
  733. #include <unistd.h>
  734. _syscall1(int, fchdir, int, fd);
  735. #endif
  736. //#define __NR_bdflush 134
  737. #ifdef L_bdflush
  738. #include <sys/kdaemon.h>
  739. _syscall2(int, bdflush, int, __func, long int, __data);
  740. #endif
  741. //#define __NR_sysfs 135
  742. //#define __NR_personality 136
  743. //#define __NR_afs_syscall 137
  744. //#define __NR_setfsuid 138
  745. //#define __NR_setfsgid 139
  746. //#define __NR__llseek 140
  747. #ifdef L__llseek
  748. extern int _llseek(int fd, off_t hoff, off_t loff, loff_t *res, int whence);
  749. _syscall5(int, _llseek, int, fd, off_t, hoff, off_t, loff, loff_t *, res,
  750. int, whence);
  751. loff_t llseek(int fd, loff_t offset, int whence)
  752. {
  753. int ret;
  754. loff_t result;
  755. ret = _llseek(fd, (off_t) (offset >> 32),
  756. (off_t) (offset & 0xffffffff), &result, whence);
  757. return ret ? (loff_t) ret : result;
  758. }
  759. #endif
  760. //#define __NR_getdents 141
  761. #ifdef L__getdents
  762. #define __NR__getdents __NR_getdents
  763. #include <unistd.h>
  764. #include <dirent.h>
  765. _syscall3(int, _getdents, int, fd, char *, dirp, size_t, count);
  766. #endif
  767. //#define __NR__newselect 142
  768. #ifdef L__newselect
  769. #include <unistd.h>
  770. extern int _newselect(int n, fd_set *readfds, fd_set *writefds,
  771. fd_set *exceptfds, struct timeval *timeout);
  772. _syscall5(int, _newselect, int, n, fd_set *, readfds, fd_set *, writefds,
  773. fd_set *, exceptfds, struct timeval *, timeout);
  774. int select(int n, fd_set * readfds, fd_set * writefds, fd_set * exceptfds,
  775. struct timeval *timeout)
  776. {
  777. return (_newselect(n, readfds, writefds, exceptfds, timeout));
  778. }
  779. #endif
  780. //#define __NR_flock 143
  781. #ifdef L_flock
  782. #include <sys/file.h>
  783. _syscall2(int,flock,int,fd, int,operation);
  784. #endif
  785. //#define __NR_msync 144
  786. //#define __NR_readv 145
  787. #ifdef L_readv
  788. #include <sys/uio.h>
  789. _syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector, int,
  790. count);
  791. #endif
  792. //#define __NR_writev 146
  793. #ifdef L_writev
  794. #include <sys/uio.h>
  795. _syscall3(ssize_t, writev, int, filedes, const struct iovec *, vector, int,
  796. count);
  797. #endif
  798. //#define __NR_getsid 147
  799. #ifdef L_getsid
  800. #include <unistd.h>
  801. _syscall1(pid_t, getsid, pid_t, pid);
  802. #endif
  803. //#define __NR_fdatasync 148
  804. //#define __NR__sysctl 149
  805. //#define __NR_mlock 150
  806. //#define __NR_munlock 151
  807. //#define __NR_mlockall 152
  808. //#define __NR_munlockall 153
  809. //#define __NR_sched_setparam 154
  810. //#define __NR_sched_getparam 155
  811. //#define __NR_sched_setscheduler 156
  812. //#define __NR_sched_getscheduler 157
  813. //#define __NR_sched_yield 158
  814. //#define __NR_sched_get_priority_max 159
  815. //#define __NR_sched_get_priority_min 160
  816. //#define __NR_sched_rr_get_interval 161
  817. //#define __NR_nanosleep 162
  818. #ifdef L_nanosleep
  819. #include <time.h>
  820. _syscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem);
  821. #endif
  822. //#define __NR_mremap 163
  823. #ifdef L_mremap
  824. #include <unistd.h>
  825. #include <sys/mman.h>
  826. _syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t,
  827. new_size, int, may_move);
  828. #endif
  829. //#define __NR_setresuid 164
  830. //#define __NR_getresuid 165
  831. //#define __NR_vm86 166
  832. //#define __NR_query_module 167
  833. #ifdef L_query_module
  834. # ifdef __NR_query_module
  835. _syscall5(int, query_module, const char *, name, int, which,
  836. void *, buf, size_t, bufsize, size_t*, ret);
  837. # endif
  838. #endif
  839. //#define __NR_poll 168
  840. #if defined(L_poll) && defined(__NR_poll) /* uClinux 2.0 doesn't have poll */
  841. #include <sys/poll.h>
  842. _syscall3(int, poll, struct pollfd *, fds, unsigned long int, nfds, int, timeout);
  843. #endif
  844. //#define __NR_nfsservctl 169
  845. //#define __NR_setresgid 170
  846. //#define __NR_getresgid 171
  847. //#define __NR_prctl 172
  848. //#define __NR_rt_sigreturn 173
  849. //#define __NR_rt_sigaction 174
  850. //#define __NR_rt_sigprocmask 175
  851. //#define __NR_rt_sigpending 176
  852. //#define __NR_rt_sigtimedwait 177
  853. //#define __NR_rt_sigqueueinfo 178
  854. //#define __NR_rt_sigsuspend 179
  855. //#define __NR_pread 180
  856. //#define __NR_pwrite 181
  857. //#define __NR_chown 182
  858. #ifdef L_chown
  859. #include <unistd.h>
  860. _syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
  861. #endif
  862. //#define __NR_getcwd 183
  863. // See unistd/getcwd.c -- we don't use the syscall, even when it is available...
  864. //#define __NR_capget 184
  865. //#define __NR_capset 185
  866. //#define __NR_sigaltstack 186
  867. //#define __NR_sendfile 187
  868. //#define __NR_getpmsg 188
  869. //#define __NR_putpmsg 189
  870. //#define __NR_vfork 190
  871. //See sysdeps/linux/<arch>vfork.[cS] for architecture specific implementation...