syscalls.c 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Syscalls for uClibc
  4. *
  5. * Copyright (C) 2000 by Lineo, inc
  6. * Copyright (C) 2001 by Erik Andersen
  7. * Written by Erik Andersen <andersen@codpoet.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Library General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  17. * for more details.
  18. *
  19. * You should have received a copy of the GNU Library General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #include <errno.h>
  25. #include <features.h>
  26. #include <sys/types.h>
  27. #include <sys/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. #ifdef __STR_NR_exit
  34. #define __STR_NR__exit __STR_NR_exit
  35. #endif
  36. _syscall1(void, _exit, int, status);
  37. #endif
  38. //#define __NR_fork 2
  39. #ifdef L_fork
  40. #include <unistd.h>
  41. # ifdef __UCLIBC_HAS_MMU__
  42. _syscall0(pid_t, fork);
  43. # else
  44. pid_t fork(void)
  45. {
  46. __set_errno(ENOSYS);
  47. return -1;
  48. }
  49. # endif
  50. #endif
  51. //#define __NR_read 3
  52. #ifdef L_read
  53. #include <unistd.h>
  54. _syscall3(ssize_t, read, int, fd, __ptr_t, buf, size_t, count);
  55. #endif
  56. //#define __NR_write 4
  57. #ifdef L_write
  58. #include <unistd.h>
  59. _syscall3(ssize_t, write, int, fd, const __ptr_t, buf, size_t, count);
  60. weak_alias(write, __write);
  61. #endif
  62. //#define __NR_open 5
  63. #ifdef L___open
  64. #include <stdarg.h>
  65. #include <fcntl.h>
  66. #define __NR___open __NR_open
  67. #ifdef __STR_NR_open
  68. #define __STR_NR___open __STR_NR_open
  69. #endif
  70. _syscall3(int, __open, const char *, fn, int, flags, mode_t, mode);
  71. int open(const char *file, int oflag, ...)
  72. {
  73. int mode = 0;
  74. if (oflag & O_CREAT) {
  75. va_list args;
  76. va_start(args, oflag);
  77. mode = va_arg(args, int);
  78. va_end(args);
  79. }
  80. return __open(file, oflag, mode);
  81. }
  82. #endif
  83. //#define __NR_close 6
  84. #ifdef L_close
  85. #include <unistd.h>
  86. _syscall1(int, close, int, fd);
  87. #endif
  88. //#define __NR_waitpid 7
  89. // Implemented using wait4
  90. //#define __NR_creat 8
  91. #ifdef L_creat
  92. #include <fcntl.h>
  93. _syscall2(int, creat, const char *, file, mode_t, mode);
  94. #endif
  95. //#define __NR_link 9
  96. #ifdef L_link
  97. #include <unistd.h>
  98. _syscall2(int, link, const char *, oldpath, const char *, newpath);
  99. #endif
  100. //#define __NR_unlink 10
  101. #ifdef L_unlink
  102. #include <unistd.h>
  103. _syscall1(int, unlink, const char *, pathname);
  104. #endif
  105. //#define __NR_execve 11
  106. #ifdef L_execve
  107. #include <unistd.h>
  108. _syscall3(int, execve, const char *, filename, char *const *, argv,
  109. char *const *, envp);
  110. #endif
  111. //#define __NR_chdir 12
  112. #ifdef L_chdir
  113. #include <unistd.h>
  114. _syscall1(int, chdir, const char *, path);
  115. #endif
  116. //#define __NR_time 13
  117. #ifdef L_time
  118. #include <time.h>
  119. _syscall1(time_t, time, time_t *, t);
  120. #endif
  121. //#define __NR_mknod 14
  122. #ifdef L_mknod
  123. #include <unistd.h>
  124. extern int mknod(const char *pathname, mode_t mode, dev_t dev);
  125. _syscall3(int, mknod, const char *, pathname, mode_t, mode, dev_t, dev);
  126. int __xmknod (int version, const char * path, mode_t mode, dev_t *dev)
  127. {
  128. switch(version)
  129. {
  130. case 1:
  131. return mknod (path, mode, *dev);
  132. default:
  133. __set_errno(EINVAL);
  134. return -1;
  135. }
  136. }
  137. #endif
  138. //#define __NR_chmod 15
  139. #ifdef L_chmod
  140. #include <sys/stat.h>
  141. _syscall2(int, chmod, const char *, path, mode_t, mode);
  142. #endif
  143. /* Old kernels don't have lchown -- do chown instead. This
  144. * is sick and wrong, but at least things will compile.
  145. * They may not follow links when they should though... */
  146. #ifndef __NR_lchown
  147. #define __NR_lchown __NR_chown
  148. #endif
  149. //#define __NR_lchown 16
  150. #ifdef L_lchown
  151. #include <unistd.h>
  152. _syscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group);
  153. #endif
  154. //#define __NR_break 17
  155. //#define __NR_oldstat 18
  156. //#define __NR_lseek 19
  157. #ifdef L_lseek
  158. #include <unistd.h>
  159. _syscall3(off_t, lseek, int, fildes, off_t, offset, int, whence);
  160. #endif
  161. //#define __NR_getpid 20
  162. #ifdef L_getpid
  163. #include <unistd.h>
  164. _syscall0(pid_t, getpid);
  165. #endif
  166. //#define __NR_mount 21
  167. #ifdef L_mount
  168. #include <sys/mount.h>
  169. _syscall5(int, mount, const char *, specialfile, const char *, dir,
  170. const char *, filesystemtype, unsigned long, rwflag,
  171. const void *, data);
  172. #endif
  173. //#define __NR_umount 22
  174. #ifdef L_umount
  175. #include <sys/mount.h>
  176. _syscall1(int, umount, const char *, specialfile);
  177. #endif
  178. //#define __NR_setuid 23
  179. #ifdef L___setuid
  180. #define __NR___setuid __NR_setuid
  181. #include <unistd.h>
  182. static inline
  183. _syscall1(int, __setuid, uid_t, uid);
  184. int setuid(uid_t uid)
  185. {
  186. if (uid == (uid_t) ~0) {
  187. __set_errno (EINVAL);
  188. return -1;
  189. }
  190. return(__setuid(uid));
  191. }
  192. #endif
  193. //#define __NR_getuid 24
  194. #ifdef L_getuid
  195. #include <unistd.h>
  196. _syscall0(gid_t, getuid);
  197. #endif
  198. //#define __NR_stime 25
  199. #ifdef L_stime
  200. #include <time.h>
  201. _syscall1(int, stime, const time_t *, t);
  202. #endif
  203. //#define __NR_ptrace 26
  204. #ifdef L___ptrace
  205. #include <sys/ptrace.h>
  206. #define __NR___ptrace __NR_ptrace
  207. #ifdef __STR_NR_ptrace
  208. #define __STR_NR___ptrace __STR_NR_ptrace
  209. #endif
  210. _syscall4(long, __ptrace, enum __ptrace_request, request, pid_t, pid,
  211. void*, addr, void*, data);
  212. #endif
  213. //#define __NR_alarm 27
  214. #ifdef L_alarm
  215. #include <unistd.h>
  216. _syscall1(unsigned int, alarm, unsigned int, seconds);
  217. #endif
  218. //#define __NR_oldfstat 28
  219. //#define __NR_pause 29
  220. #ifdef L_pause
  221. #include <unistd.h>
  222. _syscall0(int, pause);
  223. #endif
  224. //#define __NR_utime 30
  225. #ifdef L_utime
  226. #include <utime.h>
  227. _syscall2(int, utime, const char *, filename, const struct utimbuf *, buf);
  228. #endif
  229. //#define __NR_stty 31
  230. #ifdef L_stty
  231. #include <sgtty.h>
  232. int stty (int __fd, __const struct sgttyb *__params);
  233. {
  234. __set_errno(ENOSYS);
  235. return -1;
  236. }
  237. #endif
  238. //#define __NR_gtty 32
  239. #ifdef L_gtty
  240. #include <sgtty.h>
  241. int gtty (int __fd, struct sgttyb *__params)
  242. {
  243. __set_errno(ENOSYS);
  244. return -1;
  245. }
  246. #endif
  247. //#define __NR_access 33
  248. #ifdef L_access
  249. #include <unistd.h>
  250. _syscall2(int, access, const char *, pathname, int, mode);
  251. #endif
  252. //#define __NR_nice 34
  253. #ifdef L_nice
  254. #include <unistd.h>
  255. _syscall1(int, nice, int, inc);
  256. #endif
  257. //#define __NR_ftime 35
  258. //#define __NR_sync 36
  259. #ifdef L_sync
  260. #include <unistd.h>
  261. _syscall0(void, sync);
  262. #endif
  263. //#define __NR_kill 37
  264. #ifdef L_kill
  265. #include <signal.h>
  266. #undef kill
  267. _syscall2(int, kill, pid_t, pid, int, sig);
  268. #endif
  269. //#define __NR_rename 38
  270. #ifdef L_rename
  271. #include <stdio.h>
  272. _syscall2(int, rename, const char *, oldpath, const char *, newpath);
  273. #endif
  274. //#define __NR_mkdir 39
  275. #ifdef L_mkdir
  276. #include <sys/stat.h>
  277. _syscall2(int, mkdir, const char *, pathname, mode_t, mode);
  278. #endif
  279. //#define __NR_rmdir 40
  280. #ifdef L_rmdir
  281. #include <unistd.h>
  282. _syscall1(int, rmdir, const char *, pathname);
  283. #endif
  284. //#define __NR_dup 41
  285. #ifdef L_dup
  286. #include <unistd.h>
  287. _syscall1(int, dup, int, oldfd);
  288. #endif
  289. //#define __NR_pipe 42
  290. #ifdef L_pipe
  291. #include <unistd.h>
  292. /*
  293. * SH has a weird register calling mechanism for pipe, see pipe.c
  294. */
  295. #if !defined(__sh__)
  296. _syscall1(int, pipe, int *, filedes);
  297. #endif
  298. #endif
  299. //#define __NR_times 43
  300. #ifdef L_times
  301. #include <sys/times.h>
  302. _syscall1(clock_t, times, struct tms *, buf);
  303. #endif
  304. //#define __NR_prof 44
  305. //#define __NR_brk 45
  306. //#define __NR_setgid 46
  307. #ifdef L_setgid
  308. #include <unistd.h>
  309. _syscall1(int, setgid, gid_t, gid);
  310. #endif
  311. //#define __NR_getgid 47
  312. #ifdef L_getgid
  313. #include <unistd.h>
  314. _syscall0(gid_t, getgid);
  315. #endif
  316. //#define __NR_signal 48
  317. //#define __NR_geteuid 49
  318. #ifdef L_geteuid
  319. # ifdef __NR_geteuid
  320. # include <unistd.h>
  321. _syscall0(uid_t, geteuid);
  322. # else
  323. uid_t geteuid(void)
  324. {
  325. return (getuid());
  326. }
  327. # endif
  328. #endif
  329. //#define __NR_getegid 50
  330. #ifdef L_getegid
  331. # ifdef __NR_getegid
  332. # include <unistd.h>
  333. _syscall0(gid_t, getegid);
  334. # else
  335. gid_t getegid(void)
  336. {
  337. return (getgid());
  338. }
  339. # endif
  340. #endif
  341. //#define __NR_acct 51
  342. #ifdef L_acct
  343. #include <unistd.h>
  344. _syscall1(int, acct, const char *, filename);
  345. #endif
  346. //#define __NR_umount2 52
  347. #ifdef L_umount2
  348. # ifdef __NR_umount2 /* Old kernels don't have umount2 */
  349. # include <sys/mount.h>
  350. _syscall2(int, umount2, const char *, special_file, int, flags);
  351. # else
  352. int umount2(const char * special_file, int flags)
  353. {
  354. __set_errno(ENOSYS);
  355. return -1;
  356. }
  357. # endif
  358. #endif
  359. //#define __NR_lock 53
  360. //#define __NR_ioctl 54
  361. #ifdef L__ioctl
  362. #include <stdarg.h>
  363. #include <sys/ioctl.h>
  364. #define __NR__ioctl __NR_ioctl
  365. #ifdef __STR_NR_ioctl
  366. #define __STR_NR__ioctl __STR_NR_ioctl
  367. #endif
  368. extern int _ioctl(int fd, int request, void *arg);
  369. _syscall3(int, _ioctl, int, fd, int, request, void *, arg);
  370. int ioctl(int fd, unsigned long int request, ...)
  371. {
  372. void *arg;
  373. va_list list;
  374. va_start(list, request);
  375. arg = va_arg(list, void *);
  376. va_end(list);
  377. return _ioctl(fd, request, arg);
  378. }
  379. #endif
  380. //#define __NR_fcntl 55
  381. #ifdef L__fcntl
  382. #include <stdarg.h>
  383. #include <fcntl.h>
  384. #define __NR__fcntl __NR_fcntl
  385. #ifdef __STR_NR_fcntl
  386. #define __STR_NR__fcntl __STR_NR_fcntl
  387. #endif
  388. extern int _fcntl(int fd, int cmd, long arg);
  389. _syscall3(int, _fcntl, int, fd, int, cmd, long, arg);
  390. int fcntl(int fd, int command, ...)
  391. {
  392. long arg;
  393. va_list list;
  394. va_start(list, command);
  395. arg = va_arg(list, long);
  396. va_end(list);
  397. return _fcntl(fd, command, arg);
  398. }
  399. #endif
  400. //#define __NR_mpx 56
  401. //#define __NR_setpgid 57
  402. #ifdef L_setpgid
  403. #include <unistd.h>
  404. _syscall2(int, setpgid, pid_t, pid, pid_t, pgid);
  405. #endif
  406. //#define __NR_ulimit 58
  407. //#define __NR_oldolduname 59
  408. //#define __NR_umask 60
  409. #ifdef L_umask
  410. #include <sys/stat.h>
  411. _syscall1(mode_t, umask, mode_t, mask);
  412. #endif
  413. //#define __NR_chroot 61
  414. #ifdef L_chroot
  415. #include <unistd.h>
  416. _syscall1(int, chroot, const char *, path);
  417. #endif
  418. //#define __NR_ustat 62
  419. //#define __NR_dup2 63
  420. #ifdef L_dup2
  421. #include <unistd.h>
  422. _syscall2(int, dup2, int, oldfd, int, newfd);
  423. #endif
  424. //#define __NR_getppid 64
  425. #ifdef L_getppid
  426. # include <unistd.h>
  427. # ifdef __NR_getppid
  428. _syscall0(pid_t, getppid);
  429. # else
  430. pid_t getppid(void)
  431. {
  432. return (getpid());
  433. }
  434. # endif
  435. #endif
  436. //#define __NR_getpgrp 65
  437. #ifdef L_getpgrp
  438. #include <unistd.h>
  439. _syscall0(pid_t, getpgrp);
  440. #endif
  441. //#define __NR_setsid 66
  442. #ifdef L_setsid
  443. #include <unistd.h>
  444. _syscall0(pid_t, setsid);
  445. #endif
  446. //#define __NR_sigaction 67
  447. #ifndef __NR_rt_sigaction
  448. #define __NR___sigaction __NR_sigaction
  449. #ifdef L___sigaction
  450. #include <signal.h>
  451. #undef sigaction
  452. _syscall3(int, __sigaction, int, signum, const struct sigaction *, act,
  453. struct sigaction *, oldact);
  454. #endif
  455. #endif
  456. //#define __NR_sgetmask 68
  457. //#define __NR_ssetmask 69
  458. //#define __NR_setreuid 70
  459. #ifdef L_setreuid
  460. #include <unistd.h>
  461. _syscall2(int, setreuid, uid_t, ruid, uid_t, euid);
  462. #endif
  463. //#define __NR_setregid 71
  464. #ifdef L_setregid
  465. #include <unistd.h>
  466. _syscall2(int, setregid, gid_t, rgid, gid_t, egid);
  467. #endif
  468. //#define __NR_sigsuspend 72
  469. #ifndef __NR_rt_sigsuspend
  470. #define __NR___sigsuspend __NR_sigsuspend
  471. #ifdef L___sigsuspend
  472. #include <signal.h>
  473. #undef sigsuspend
  474. _syscall3(int, __sigsuspend, int, a, unsigned long int, b, unsigned long int, c);
  475. int sigsuspend (const sigset_t *set)
  476. {
  477. return __sigsuspend(0, 0, set->__val[0]);
  478. }
  479. #endif
  480. #endif
  481. //#define __NR_sigpending 73
  482. #ifndef __NR_rt_sigpending
  483. #ifdef L_sigpending
  484. #include <signal.h>
  485. #undef sigpending
  486. _syscall1(int, sigpending, sigset_t *, set);
  487. #endif
  488. #endif
  489. //#define __NR_sethostname 74
  490. #ifdef L_sethostname
  491. #include <unistd.h>
  492. _syscall2(int, sethostname, const char *, name, size_t, len);
  493. #endif
  494. //#define __NR_setrlimit 75
  495. #ifdef L_setrlimit
  496. #include <unistd.h>
  497. #include <sys/resource.h>
  498. _syscall2(int, setrlimit, int, resource, const struct rlimit *, rlim);
  499. #endif
  500. //#define __NR_getrlimit 76
  501. #ifdef L_getrlimit
  502. #include <unistd.h>
  503. #include <sys/resource.h>
  504. _syscall2(int, getrlimit, int, resource, struct rlimit *, rlim);
  505. #endif
  506. //#define __NR_getrusage 77
  507. #ifdef L_getrusage
  508. #include <unistd.h>
  509. #include <wait.h>
  510. _syscall2(int, getrusage, int, who, struct rusage *, usage);
  511. #endif
  512. //#define __NR_gettimeofday 78
  513. #ifdef L_gettimeofday
  514. #include <sys/time.h>
  515. _syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
  516. #endif
  517. //#define __NR_settimeofday 79
  518. #ifdef L_settimeofday
  519. #include <sys/time.h>
  520. _syscall2(int, settimeofday, const struct timeval *, tv,
  521. const struct timezone *, tz);
  522. #endif
  523. //#define __NR_getgroups 80
  524. #ifdef L_getgroups
  525. #include <unistd.h>
  526. _syscall2(int, getgroups, int, size, gid_t *, list);
  527. #endif
  528. //#define __NR_setgroups 81
  529. #ifdef L_setgroups
  530. #include <unistd.h>
  531. #include <grp.h>
  532. _syscall2(int, setgroups, size_t, size, const gid_t *, list);
  533. #endif
  534. //#define __NR_select 82
  535. //#define __NR_symlink 83
  536. #ifdef L_symlink
  537. #include <unistd.h>
  538. _syscall2(int, symlink, const char *, oldpath, const char *, newpath);
  539. #endif
  540. //#define __NR_oldlstat 84
  541. //#define __NR_readlink 85
  542. #ifdef L_readlink
  543. #include <unistd.h>
  544. _syscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz);
  545. #endif
  546. //#define __NR_uselib 86
  547. #ifdef L_uselib
  548. #include <unistd.h>
  549. _syscall1(int, uselib, const char *, library);
  550. #endif
  551. //#define __NR_swapon 87
  552. #ifdef L_swapon
  553. #include <sys/swap.h>
  554. _syscall2(int, swapon, const char *, path, int, swapflags);
  555. #endif
  556. //#define __NR_reboot 88
  557. #ifdef L__reboot
  558. #define __NR__reboot __NR_reboot
  559. #ifdef __STR_NR_reboot
  560. #define __STR_NR__reboot __STR_NR_reboot
  561. #endif
  562. extern int _reboot(int magic, int magic2, int flag);
  563. _syscall3(int, _reboot, int, magic, int, magic2, int, flag);
  564. int reboot(int flag)
  565. {
  566. return (_reboot((int) 0xfee1dead, 672274793, flag));
  567. }
  568. #endif
  569. //#define __NR_readdir 89
  570. //#define __NR_mmap 90
  571. #ifdef L__mmap
  572. #define __NR__mmap __NR_mmap
  573. #ifdef __STR_NR_mmap
  574. #define __STR_NR__mmap __STR_NR_mmap
  575. #endif
  576. #include <unistd.h>
  577. #include <sys/mman.h>
  578. extern __ptr_t _mmap(unsigned long *buffer);
  579. _syscall1(__ptr_t, _mmap, unsigned long *, buffer);
  580. __ptr_t mmap(__ptr_t addr, size_t len, int prot,
  581. int flags, int fd, __off_t offset)
  582. {
  583. unsigned long buffer[6];
  584. buffer[0] = (unsigned long) addr;
  585. buffer[1] = (unsigned long) len;
  586. buffer[2] = (unsigned long) prot;
  587. buffer[3] = (unsigned long) flags;
  588. buffer[4] = (unsigned long) fd;
  589. buffer[5] = (unsigned long) offset;
  590. return (__ptr_t) _mmap(buffer);
  591. }
  592. #endif
  593. //#define __NR_munmap 91
  594. #ifdef L_munmap
  595. #include <unistd.h>
  596. #include <sys/mman.h>
  597. _syscall2(int, munmap, void *, start, size_t, length);
  598. #endif
  599. //#define __NR_truncate 92
  600. #ifdef L_truncate
  601. #include <unistd.h>
  602. _syscall2(int, truncate, const char *, path, off_t, length);
  603. #endif
  604. //#define __NR_ftruncate 93
  605. #ifdef L_ftruncate
  606. #include <unistd.h>
  607. _syscall2(int, ftruncate, int, fd, off_t, length);
  608. #endif
  609. //#define __NR_fchmod 94
  610. #ifdef L_fchmod
  611. #include <sys/stat.h>
  612. _syscall2(int, fchmod, int, fildes, mode_t, mode);
  613. #endif
  614. //#define __NR_fchown 95
  615. #ifdef L_fchown
  616. #include <unistd.h>
  617. _syscall3(int, fchown, int, fd, uid_t, owner, gid_t, group);
  618. #endif
  619. //#define __NR_getpriority 96
  620. #ifdef L_getpriority
  621. #include <sys/resource.h>
  622. _syscall2(int, getpriority, __priority_which_t, which, id_t, who);
  623. #endif
  624. //#define __NR_setpriority 97
  625. #ifdef L_setpriority
  626. #include <sys/resource.h>
  627. _syscall3(int, setpriority, __priority_which_t, which, id_t, who, int, prio);
  628. #endif
  629. //#define __NR_profil 98
  630. //#define __NR_statfs 99
  631. #ifdef L_statfs
  632. #include <sys/vfs.h>
  633. _syscall2(int, statfs, const char *, path, struct statfs *, buf);
  634. #endif
  635. //#define __NR_fstatfs 100
  636. #ifdef L_fstatfs
  637. #include <sys/vfs.h>
  638. _syscall2(int, fstatfs, int, fd, struct statfs *, buf);
  639. #endif
  640. //#define __NR_ioperm 101
  641. #ifdef L_ioperm
  642. #include <sys/io.h>
  643. # if defined __UCLIBC_HAS_MMU__ && defined __NR_ioperm
  644. _syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on);
  645. # else
  646. int ioperm(unsigned long from, unsigned long num, int turn_on)
  647. {
  648. __set_errno(ENOSYS);
  649. return -1;
  650. }
  651. # endif
  652. #endif
  653. //#define __NR_socketcall 102
  654. #ifdef L_socketcall
  655. _syscall2(int, socketcall, int, call, unsigned long *, args);
  656. #endif
  657. //#define __NR_syslog 103
  658. #ifdef L__syslog
  659. #include <unistd.h>
  660. #define __NR__syslog __NR_syslog
  661. #ifdef __STR_NR_syslog
  662. #define __STR_NR__syslog __STR_NR_syslog
  663. #endif
  664. extern int _syslog(int type, char *buf, int len);
  665. _syscall3(int, _syslog, int, type, char *, buf, int, len);
  666. int klogctl(int type, char *buf, int len)
  667. {
  668. return (_syslog(type, buf, len));
  669. }
  670. #endif
  671. //#define __NR_setitimer 104
  672. #ifdef L_setitimer
  673. #include <sys/time.h>
  674. _syscall3(int, setitimer, __itimer_which_t, which,
  675. const struct itimerval *, new, struct itimerval *, old);
  676. #endif
  677. //#define __NR_getitimer 105
  678. #ifdef L_getitimer
  679. #include <sys/time.h>
  680. _syscall2(int, getitimer, __itimer_which_t, which, struct itimerval *, value);
  681. #endif
  682. //#define __NR_stat 106
  683. #ifdef L___stat
  684. #include <unistd.h>
  685. #include "statfix.h"
  686. #define __NR___stat __NR_stat
  687. #ifdef __STR_NR_stat
  688. #define __STR_NR___stat __STR_NR_stat
  689. #endif
  690. extern int __stat(const char *file_name, struct kernel_stat *buf);
  691. _syscall2(int, __stat, const char *, file_name, struct kernel_stat *, buf);
  692. int __xstat(int version, const char * file_name, struct libc_stat * cstat)
  693. {
  694. struct kernel_stat kstat;
  695. int result = __stat(file_name, &kstat);
  696. if (result == 0) {
  697. statfix(cstat, &kstat);
  698. }
  699. return result;
  700. }
  701. int stat(const char *file_name, struct libc_stat *buf)
  702. {
  703. return(__xstat(0, file_name, buf));
  704. }
  705. #endif
  706. //#define __NR_lstat 107
  707. #ifdef L___lstat
  708. #include <unistd.h>
  709. #include "statfix.h"
  710. #define __NR___lstat __NR_lstat
  711. #ifdef __STR_NR_lstat
  712. #define __STR_NR___lstat __STR_NR_lstat
  713. #endif
  714. extern int __lstat(const char *file_name, struct kernel_stat *buf);
  715. _syscall2(int, __lstat, const char *, file_name, struct kernel_stat *, buf);
  716. int __lxstat(int version, const char * file_name, struct libc_stat * cstat)
  717. {
  718. struct kernel_stat kstat;
  719. int result = __lstat(file_name, &kstat);
  720. if (result == 0) {
  721. statfix(cstat, &kstat);
  722. }
  723. return result;
  724. }
  725. int lstat(const char *file_name, struct libc_stat *buf)
  726. {
  727. return(__lxstat(0, file_name, buf));
  728. }
  729. #endif
  730. //#define __NR_fstat 108
  731. #ifdef L___fstat
  732. #include <unistd.h>
  733. #include "statfix.h"
  734. #define __NR___fstat __NR_fstat
  735. #ifdef __STR_NR_fstat
  736. #define __STR_NR___fstat __STR_NR_fstat
  737. #endif
  738. extern int __fstat(int filedes, struct kernel_stat *buf);
  739. _syscall2(int, __fstat, int, filedes, struct kernel_stat *, buf);
  740. int __fxstat(int version, int fd, struct libc_stat * cstat)
  741. {
  742. struct kernel_stat kstat;
  743. int result = __fstat(fd, &kstat);
  744. if (result == 0) {
  745. statfix(cstat, &kstat);
  746. }
  747. return result;
  748. }
  749. int fstat(int filedes, struct libc_stat *buf)
  750. {
  751. return(__fxstat(0, filedes, buf));
  752. }
  753. #endif
  754. //#define __NR_olduname 109
  755. //#define __NR_iopl 110
  756. #ifdef L_iopl
  757. #include <sys/io.h>
  758. /* Tuns out the m68k unistd.h kernel header is broken */
  759. # if defined __UCLIBC_HAS_MMU__ && defined __NR_iopl && ! defined(__mc68000__)
  760. _syscall1(int, iopl, int, level);
  761. # else
  762. int iopl(int level)
  763. {
  764. __set_errno(ENOSYS);
  765. return -1;
  766. }
  767. # endif
  768. #endif
  769. //#define __NR_vhangup 111
  770. #ifdef L_vhangup
  771. #include <unistd.h>
  772. _syscall0(int, vhangup);
  773. #endif
  774. //#define __NR_idle 112
  775. //int idle(void);
  776. //#define __NR_vm86old 113
  777. //#define __NR_wait4 114
  778. #ifdef L_wait4
  779. _syscall4(int, wait4, pid_t, pid, int *, status, int, opts, void *, rusage);
  780. #endif
  781. //#define __NR_swapoff 115
  782. #ifdef L_swapoff
  783. #include <sys/swap.h>
  784. _syscall1(int, swapoff, const char *, path);
  785. #endif
  786. //#define __NR_sysinfo 116
  787. #ifdef L_sysinfo
  788. #include <sys/sysinfo.h>
  789. _syscall1(int, sysinfo, struct sysinfo *, info);
  790. #endif
  791. //#define __NR_ipc 117
  792. #ifdef L___ipc
  793. #define __NR___ipc __NR_ipc
  794. #ifdef __STR_NR_ipc
  795. #define __STR_NR___ipc __STR_NR_ipc
  796. #endif
  797. _syscall5(int, __ipc, unsigned int, call, int, first, int, second, int, third, void *, ptr);
  798. #endif
  799. //#define __NR_fsync 118
  800. #ifdef L_fsync
  801. #include <unistd.h>
  802. _syscall1(int, fsync, int, fd);
  803. #endif
  804. //#define __NR_sigreturn 119
  805. //int sigreturn(unsigned long __unused);
  806. //#define __NR_clone 120
  807. //See architecture specific implementation...
  808. //#define __NR_setdomainname 121
  809. #ifdef L_setdomainname
  810. #include <unistd.h>
  811. _syscall2(int, setdomainname, const char *, name, size_t, len);
  812. #endif
  813. //#define __NR_uname 122
  814. #ifdef L_uname
  815. #include <sys/utsname.h>
  816. _syscall1(int, uname, struct utsname *, buf);
  817. #endif
  818. //#define __NR_modify_ldt 123
  819. //#define __NR_adjtimex 124
  820. #ifdef L_adjtimex
  821. #include <sys/timex.h>
  822. _syscall1(int, adjtimex, struct timex *, buf);
  823. weak_alias(adjtimex, __adjtimex);
  824. #endif
  825. //#define __NR_mprotect 125
  826. #ifdef L_mprotect
  827. #include <sys/mman.h>
  828. _syscall3(int, mprotect, void *, addr, size_t, len, int, prot);
  829. #endif
  830. //#define __NR_sigprocmask 126
  831. #ifndef __NR_rt_sigprocmask
  832. #ifdef L_sigprocmask
  833. #include <signal.h>
  834. #undef sigprocmask
  835. _syscall3(int, sigprocmask, int, how, const sigset_t *, set,
  836. sigset_t *, oldset);
  837. #endif
  838. #endif
  839. //#define __NR_create_module 127
  840. //See sysdeps/linux/commom/create_module.c
  841. //#define __NR_init_module 128
  842. #ifdef L_init_module
  843. /* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
  844. * (for 2.2 and 2.4 kernels). Use the greatest common denominator,
  845. * and let the kernel cope with whatever it gets. It's good at that. */
  846. _syscall5(int, init_module, void *, first, void *, second, void *, third,
  847. void *, fourth, void *, fifth);
  848. #endif
  849. //#define __NR_delete_module 129
  850. #ifdef L_delete_module
  851. # ifdef __NR_delete_module
  852. _syscall1(int, delete_module, const char *, name);
  853. # else
  854. int delete_module(const char * name)
  855. {
  856. __set_errno(ENOSYS);
  857. return -1;
  858. }
  859. # endif
  860. #endif
  861. //#define __NR_get_kernel_syms 130
  862. #ifdef L_get_kernel_syms
  863. struct kernel_sym;
  864. _syscall1(int, get_kernel_syms, struct kernel_sym *, table);
  865. #endif
  866. //#define __NR_quotactl 131
  867. #ifdef __NR_quotactl
  868. #ifdef L_quotactl
  869. #include <sys/quota.h>
  870. _syscall4(int, quotactl, int, cmd, const char *, special , int, id, caddr_t, addr);
  871. #endif
  872. #endif
  873. //#define __NR_getpgid 132
  874. #ifdef L_getpgid
  875. _syscall1(pid_t, getpgid, pid_t, pid);
  876. #endif
  877. //#define __NR_fchdir 133
  878. #ifdef L_fchdir
  879. #include <unistd.h>
  880. _syscall1(int, fchdir, int, fd);
  881. #endif
  882. //#define __NR_bdflush 134
  883. #ifdef L_bdflush
  884. #include <sys/kdaemon.h>
  885. _syscall2(int, bdflush, int, __func, long int, __data);
  886. #endif
  887. //#define __NR_sysfs 135
  888. //#define __NR_personality 136
  889. //#define __NR_afs_syscall 137
  890. //#define __NR_setfsuid 138
  891. #ifdef __NR_setfsuid
  892. #ifdef L_setfsuid
  893. #include <sys/fsuid.h>
  894. _syscall1(int, setfsuid, uid_t, uid);
  895. #endif
  896. #endif
  897. //#define __NR_setfsgid 139
  898. #ifdef __NR_setfsgid
  899. #ifdef L_setfsgid
  900. #include <sys/fsuid.h>
  901. _syscall1(int, setfsgid, gid_t, gid);
  902. #endif
  903. #endif
  904. //#define __NR__llseek 140
  905. #ifdef L__llseek
  906. extern int _llseek(int fd, off_t hoff, off_t loff, loff_t *res, int whence);
  907. _syscall5(int, _llseek, int, fd, off_t, hoff, off_t, loff, loff_t *, res,
  908. int, whence);
  909. loff_t llseek(int fd, loff_t offset, int whence)
  910. {
  911. int ret;
  912. loff_t result;
  913. ret = _llseek(fd, (off_t) (offset >> 32),
  914. (off_t) (offset & 0xffffffff), &result, whence);
  915. return ret ? (loff_t) ret : result;
  916. }
  917. #ifdef __UCLIBC_HAVE_LFS__
  918. weak_alias(llseek, lseek64);
  919. #endif
  920. #endif
  921. //#define __NR_getdents 141
  922. #ifdef L_getdents
  923. #include <unistd.h>
  924. #include <dirent.h>
  925. _syscall3(int, getdents, int, fd, char *, dirp, size_t, count);
  926. #endif
  927. //#define __NR__newselect 142
  928. #ifdef L__newselect
  929. #include <unistd.h>
  930. extern int _newselect(int n, fd_set *readfds, fd_set *writefds,
  931. fd_set *exceptfds, struct timeval *timeout);
  932. _syscall5(int, _newselect, int, n, fd_set *, readfds, fd_set *, writefds,
  933. fd_set *, exceptfds, struct timeval *, timeout);
  934. weak_alias(_newselect, select);
  935. #endif
  936. //#define __NR_flock 143
  937. #ifdef L_flock
  938. #include <sys/file.h>
  939. _syscall2(int,flock,int,fd, int,operation);
  940. #endif
  941. //#define __NR_msync 144
  942. //#define __NR_readv 145
  943. #ifdef L_readv
  944. #include <sys/uio.h>
  945. _syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector, int,
  946. count);
  947. #endif
  948. //#define __NR_writev 146
  949. #ifdef L_writev
  950. #include <sys/uio.h>
  951. _syscall3(ssize_t, writev, int, filedes, const struct iovec *, vector, int,
  952. count);
  953. #endif
  954. //#define __NR_getsid 147
  955. #ifdef L_getsid
  956. #include <unistd.h>
  957. _syscall1(pid_t, getsid, pid_t, pid);
  958. #endif
  959. //#define __NR_fdatasync 148
  960. #ifdef __NR_fdatasync
  961. #ifdef L_fdatasync
  962. #include <unistd.h>
  963. _syscall1(int, fdatasync, int, fd);
  964. #endif
  965. #endif
  966. //#define __NR__sysctl 149
  967. //#define __NR_mlock 150
  968. #ifdef L_mlock
  969. #include <sys/mman.h>
  970. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlock
  971. _syscall2(int, mlock, const void *, addr, size_t, len);
  972. # endif
  973. #endif
  974. //#define __NR_munlock 151
  975. #ifdef L_munlock
  976. #include <sys/mman.h>
  977. # if defined __UCLIBC_HAS_MMU__ && defined __NR_munlock
  978. _syscall2(int, munlock, const void *, addr, size_t, len);
  979. # endif
  980. #endif
  981. //#define __NR_mlockall 152
  982. #ifdef L_mlockall
  983. #include <sys/mman.h>
  984. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlockall
  985. _syscall1(int, mlockall, int, flags);
  986. # endif
  987. #endif
  988. //#define __NR_munlockall 153
  989. #ifdef L_munlockall
  990. #include <sys/mman.h>
  991. # if defined __UCLIBC_HAS_MMU__ && defined L_munlockall
  992. _syscall0(int, munlockall);
  993. # endif
  994. #endif
  995. //#define __NR_sched_setparam 154
  996. #ifdef __NR_sched_setparam
  997. #ifdef L_sched_setparam
  998. #include <sched.h>
  999. _syscall2(int, sched_setparam, pid_t, pid, const struct sched_param *, p);
  1000. #endif
  1001. #endif
  1002. //#define __NR_sched_getparam 155
  1003. #ifdef __NR_sched_getparam
  1004. #ifdef L_sched_getparam
  1005. #include <sched.h>
  1006. _syscall2(int, sched_getparam, pid_t, pid, struct sched_param *, p);
  1007. #endif
  1008. #endif
  1009. //#define __NR_sched_setscheduler 156
  1010. #ifdef __NR_sched_setscheduler
  1011. #ifdef L_sched_setscheduler
  1012. #include <sched.h>
  1013. _syscall3(int, sched_setscheduler, pid_t, pid, int, policy, const struct sched_param *, p);
  1014. #endif
  1015. #endif
  1016. //#define __NR_sched_getscheduler 157
  1017. #ifdef __NR_sched_getscheduler
  1018. #ifdef L_sched_getscheduler
  1019. #include <sched.h>
  1020. _syscall1(int, sched_getscheduler, pid_t, pid);
  1021. #endif
  1022. #endif
  1023. //#define __NR_sched_yield 158
  1024. #ifdef __NR_sched_yield
  1025. #ifdef L_sched_yield
  1026. #include <sched.h>
  1027. _syscall0(int, sched_yield);
  1028. #endif
  1029. #endif
  1030. //#define __NR_sched_get_priority_max 159
  1031. #ifdef __NR_sched_get_priority_max
  1032. #ifdef L_sched_get_priority_max
  1033. #include <sched.h>
  1034. _syscall1(int, sched_get_priority_max, int, policy);
  1035. #endif
  1036. #endif
  1037. //#define __NR_sched_get_priority_min 160
  1038. #ifdef __NR_sched_get_priority_min
  1039. #ifdef L_sched_get_priority_min
  1040. #include <sched.h>
  1041. _syscall1(int, sched_get_priority_min, int, policy);
  1042. #endif
  1043. #endif
  1044. //#define __NR_sched_rr_get_interval 161
  1045. #ifdef __NR_sched_rr_get_interval
  1046. #ifdef L_sched_rr_get_interval
  1047. #include <sched.h>
  1048. _syscall2(int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp);
  1049. #endif
  1050. #endif
  1051. //#define __NR_nanosleep 162
  1052. #ifdef L_nanosleep
  1053. #include <time.h>
  1054. _syscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem);
  1055. #endif
  1056. //#define __NR_mremap 163
  1057. #ifdef L_mremap
  1058. #include <unistd.h>
  1059. #include <sys/mman.h>
  1060. _syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t,
  1061. new_size, int, may_move);
  1062. #endif
  1063. //#define __NR_setresuid 164
  1064. //#define __NR_getresuid 165
  1065. //#define __NR_vm86 166
  1066. //#define __NR_query_module 167
  1067. #ifdef L_query_module
  1068. # ifdef __NR_query_module
  1069. _syscall5(int, query_module, const char *, name, int, which,
  1070. void *, buf, size_t, bufsize, size_t*, ret);
  1071. # else
  1072. int query_module(const char * name, int which,
  1073. void * buf, size_t bufsize, size_t* ret)
  1074. {
  1075. __set_errno(ENOSYS);
  1076. return -1;
  1077. }
  1078. # endif
  1079. #endif
  1080. //#define __NR_poll 168
  1081. #if defined(L_poll) && defined(__NR_poll) /* uClinux 2.0 doesn't have poll */
  1082. #include <sys/poll.h>
  1083. _syscall3(int, poll, struct pollfd *, fds, unsigned long int, nfds, int, timeout);
  1084. #endif
  1085. //#define __NR_nfsservctl 169
  1086. //nfsservctl EXTRA nfsservctl i:ipp nfsservctl
  1087. //#define __NR_setresgid 170
  1088. //#define __NR_getresgid 171
  1089. //#define __NR_prctl 172
  1090. //#define __NR_rt_sigreturn 173
  1091. //#define __NR_rt_sigaction 174
  1092. #ifdef __NR_rt_sigaction
  1093. #define __NR___rt_sigaction __NR_rt_sigaction
  1094. #ifdef L___rt_sigaction
  1095. #include <signal.h>
  1096. #undef sigaction
  1097. _syscall4(int, __rt_sigaction, int, signum, const struct sigaction *, act,
  1098. struct sigaction *, oldact, size_t, size);
  1099. #endif
  1100. #endif
  1101. //#define __NR_rt_sigprocmask 175
  1102. #ifdef __NR_rt_sigprocmask
  1103. #define __NR___rt_sigprocmask __NR_rt_sigprocmask
  1104. #ifdef L___rt_sigprocmask
  1105. #include <signal.h>
  1106. #undef sigprocmask
  1107. _syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
  1108. sigset_t *, oldset, size_t, size);
  1109. int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
  1110. {
  1111. return __rt_sigprocmask(how, set, oldset, _NSIG/8);
  1112. }
  1113. #endif
  1114. #endif
  1115. //#define __NR_rt_sigpending 176
  1116. #ifdef __NR_rt_sigpending
  1117. #define __NR___rt_sigpending __NR_rt_sigpending
  1118. #ifdef L___rt_sigpending
  1119. #include <signal.h>
  1120. #undef sigpending
  1121. _syscall2(int, __rt_sigpending, sigset_t *, set, size_t, size);
  1122. int sigpending(sigset_t *set)
  1123. {
  1124. return __rt_sigpending(set, _NSIG/8);
  1125. }
  1126. #endif
  1127. #endif
  1128. //#define __NR_rt_sigtimedwait 177
  1129. //#define __NR_rt_sigqueueinfo 178
  1130. //#define __NR_rt_sigsuspend 179
  1131. #ifdef __NR_rt_sigsuspend
  1132. #define __NR___rt_sigsuspend __NR_rt_sigsuspend
  1133. #ifdef L___rt_sigsuspend
  1134. #include <signal.h>
  1135. #undef _sigsuspend
  1136. _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size);
  1137. int sigsuspend (const sigset_t *mask)
  1138. {
  1139. return __rt_sigsuspend(mask, _NSIG/8);
  1140. }
  1141. #endif
  1142. #endif
  1143. //#define __NR_pread 180
  1144. //#define __NR_pwrite 181
  1145. //#define __NR_chown 182
  1146. #ifdef L_chown
  1147. #include <unistd.h>
  1148. _syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
  1149. #endif
  1150. //#define __NR_getcwd 183
  1151. // See unistd/getcwd.c -- we don't use this syscall, even when it is available...
  1152. //#define __NR_capget 184
  1153. #ifdef L_capget
  1154. # ifdef __NR_capget
  1155. _syscall2(int, capget, void*, header, void*, data);
  1156. # else
  1157. int capget(void* header, void* data)
  1158. {
  1159. __set_errno(ENOSYS);
  1160. return -1;
  1161. }
  1162. # endif
  1163. #endif
  1164. //#define __NR_capset 185
  1165. #ifdef L_capset
  1166. # ifdef __NR_capset
  1167. _syscall2(int, capset, void*, header, const void*, data);
  1168. # else
  1169. int capset(void* header, const void* data)
  1170. {
  1171. __set_errno(ENOSYS);
  1172. return -1;
  1173. }
  1174. # endif
  1175. #endif
  1176. //#define __NR_sigaltstack 186
  1177. #ifdef __NR_sigaltstack
  1178. #ifdef L_sigaltstack
  1179. #include <signal.h>
  1180. _syscall2(int, sigaltstack, const struct sigaltstack *, ss, struct sigaltstack *, oss);
  1181. #endif
  1182. #endif
  1183. //#define __NR_sendfile 187
  1184. #ifdef __NR_sendfile
  1185. #ifdef L_sendfile
  1186. #include <unistd.h>
  1187. #include <sys/sendfile.h>
  1188. _syscall4(ssize_t,sendfile, int, out_fd, int, in_fd, off_t *, offset, size_t, count)
  1189. #endif
  1190. #endif
  1191. //#define __NR_getpmsg 188
  1192. //#define __NR_putpmsg 189
  1193. //#define __NR_vfork 190
  1194. //See sysdeps/linux/<arch>vfork.[cS] for architecture specific implementation...
  1195. //#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
  1196. //#define __NR_mmap2 192
  1197. //#define __NR_truncate64 193
  1198. #ifdef __UCLIBC_HAVE_LFS__
  1199. #ifdef L_truncate64
  1200. #include <unistd.h>
  1201. _syscall2(int, truncate64, const char *, path, __off64_t, length);
  1202. #endif
  1203. #endif /* __UCLIBC_HAVE_LFS__ */
  1204. //#define __NR_ftruncate64 194
  1205. #ifdef __UCLIBC_HAVE_LFS__
  1206. #ifdef L_ftruncate64
  1207. #include <unistd.h>
  1208. _syscall2(int, ftruncate64, int, fd, __off64_t, length);
  1209. #endif
  1210. #endif /* __UCLIBC_HAVE_LFS__ */
  1211. //#define __NR_stat64 195
  1212. #ifdef __UCLIBC_HAVE_LFS__
  1213. #ifdef L___stat64
  1214. #include <unistd.h>
  1215. #include "statfix64.h"
  1216. #define __NR___stat64 __NR_stat64
  1217. #ifdef __STR_NR_stat64
  1218. #define __STR_NR___stat64 __STR_NR_stat64
  1219. #endif
  1220. extern int __stat64(const char *file_name, struct kernel_stat64 *buf);
  1221. _syscall2(int, __stat64, const char *, file_name, struct kernel_stat64 *, buf);
  1222. int __xstat64(int version, const char * file_name, struct libc_stat64 * cstat)
  1223. {
  1224. struct kernel_stat64 kstat;
  1225. int result = __stat64(file_name, &kstat);
  1226. if (result == 0) {
  1227. statfix64(cstat, &kstat);
  1228. }
  1229. return result;
  1230. }
  1231. int stat64(const char *file_name, struct libc_stat64 *buf)
  1232. {
  1233. return(__xstat64(0, file_name, buf));
  1234. }
  1235. #endif
  1236. #endif /* __UCLIBC_HAVE_LFS__ */
  1237. //#define __NR_lstat64 196
  1238. #ifdef __UCLIBC_HAVE_LFS__
  1239. #ifdef L___lstat64
  1240. #include <unistd.h>
  1241. #include "statfix64.h"
  1242. #define __NR___lstat64 __NR_lstat64
  1243. #ifdef __STR_NR_lstat64
  1244. #define __STR_NR___lstat64 __STR_NR_lstat64
  1245. #endif
  1246. extern int __lstat64(const char *file_name, struct kernel_stat64 *buf);
  1247. _syscall2(int, __lstat64, const char *, file_name, struct kernel_stat64 *, buf);
  1248. int __lxstat64(int version, const char * file_name, struct libc_stat64 * cstat)
  1249. {
  1250. struct kernel_stat64 kstat;
  1251. int result = __lstat64(file_name, &kstat);
  1252. if (result == 0) {
  1253. statfix64(cstat, &kstat);
  1254. }
  1255. return result;
  1256. }
  1257. int lstat64(const char *file_name, struct libc_stat64 *buf)
  1258. {
  1259. return(__lxstat64(0, file_name, buf));
  1260. }
  1261. #endif
  1262. #endif /* __UCLIBC_HAVE_LFS__ */
  1263. //#define __NR_fstat64 197
  1264. #ifdef __UCLIBC_HAVE_LFS__
  1265. #ifdef L___fstat64
  1266. #include <unistd.h>
  1267. #include "statfix64.h"
  1268. #define __NR___fstat64 __NR_fstat64
  1269. #ifdef __STR_NR_fstat64
  1270. #define __STR_NR___fstat64 __STR_NR_fstat64
  1271. #endif
  1272. extern int __fstat64(int filedes, struct kernel_stat64 *buf);
  1273. _syscall2(int, __fstat64, int, filedes, struct kernel_stat64 *, buf);
  1274. int __fxstat64(int version, int fd, struct libc_stat64 * cstat)
  1275. {
  1276. struct kernel_stat64 kstat;
  1277. int result = __fstat64(fd, &kstat);
  1278. if (result == 0) {
  1279. statfix64(cstat, &kstat);
  1280. }
  1281. return result;
  1282. }
  1283. int fstat64(int filedes, struct libc_stat64 *buf)
  1284. {
  1285. return(__fxstat64(0, filedes, buf));
  1286. }
  1287. #endif
  1288. #endif /* __UCLIBC_HAVE_LFS__ */
  1289. //#define __NR_lchown32 198
  1290. //#define __NR_getuid32 199
  1291. //#define __NR_getgid32 200
  1292. //#define __NR_geteuid32 201
  1293. //#define __NR_getegid32 202
  1294. //#define __NR_setreuid32 203
  1295. //#define __NR_setregid32 204
  1296. //#define __NR_getgroups32 205
  1297. //#define __NR_setgroups32 206
  1298. //#define __NR_fchown32 207
  1299. //#define __NR_setresuid32 208
  1300. //#define __NR_getresuid32 209
  1301. //#define __NR_setresgid32 210
  1302. //#define __NR_getresgid32 211
  1303. //#define __NR_chown32 212
  1304. //#define __NR_setuid32 213
  1305. //#define __NR_setgid32 214
  1306. //#define __NR_setfsuid32 215
  1307. //#define __NR_setfsgid32 216
  1308. //#define __NR_pivot_root 217
  1309. #ifdef __NR_pivot_root
  1310. #ifdef L_pivot_root
  1311. _syscall2(int, pivot_root, const char *, new_root, const char *, put_old)
  1312. #endif
  1313. #endif
  1314. //#define __NR_mincore 218
  1315. //#define __NR_madvise 219
  1316. //#define __NR_madvise1 219 /* delete when C lib stub is removed */
  1317. //#define __NR_getdents64 220
  1318. #ifdef __UCLIBC_HAVE_LFS__
  1319. #ifdef L_getdents64
  1320. #include <unistd.h>
  1321. #include <dirent.h>
  1322. _syscall3(int, getdents64, int, fd, char *, dirp, size_t, count);
  1323. #endif
  1324. #endif /* __UCLIBC_HAVE_LFS__ */
  1325. //#define __NR_fcntl64 221
  1326. #ifdef __UCLIBC_HAVE_LFS__
  1327. #define __NR__fcntl64 __NR_fcntl64
  1328. #ifdef L__fcntl64
  1329. #include <stdarg.h>
  1330. #include <fcntl.h>
  1331. extern int _fcntl64(int fd, int cmd, long arg);
  1332. _syscall3(int, _fcntl64, int, fd, int, cmd, long, arg);
  1333. int fcntl64(int fd, int command, ...)
  1334. {
  1335. long arg;
  1336. va_list list;
  1337. va_start(list, command);
  1338. arg = va_arg(list, long);
  1339. va_end(list);
  1340. return _fcntl64(fd, command, arg);
  1341. }
  1342. #endif
  1343. #endif
  1344. //#define __NR_security 223 /* syscall for security modules */
  1345. //#define __NR_gettid 224
  1346. //#define __NR_readahead 225