syscalls.c 23 KB

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