syscalls.c 36 KB

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