syscalls.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598
  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. #endif
  824. //#define __NR_mprotect 125
  825. #ifdef L_mprotect
  826. #include <sys/mman.h>
  827. _syscall3(int, mprotect, void *, addr, size_t, len, int, prot);
  828. #endif
  829. //#define __NR_sigprocmask 126
  830. #ifndef __NR_rt_sigprocmask
  831. #ifdef L_sigprocmask
  832. #include <signal.h>
  833. #undef sigprocmask
  834. _syscall3(int, sigprocmask, int, how, const sigset_t *, set,
  835. sigset_t *, oldset);
  836. #endif
  837. #endif
  838. //#define __NR_create_module 127
  839. //See sysdeps/linux/commom/create_module.c
  840. //#define __NR_init_module 128
  841. #ifdef L_init_module
  842. /* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
  843. * (for 2.2 and 2.4 kernels). Use the greatest common denominator,
  844. * and let the kernel cope with whatever it gets. It's good at that. */
  845. _syscall5(int, init_module, void *, first, void *, second, void *, third,
  846. void *, fourth, void *, fifth);
  847. #endif
  848. //#define __NR_delete_module 129
  849. #ifdef L_delete_module
  850. # ifdef __NR_delete_module
  851. _syscall1(int, delete_module, const char *, name);
  852. # else
  853. int delete_module(const char * name)
  854. {
  855. __set_errno(ENOSYS);
  856. return -1;
  857. }
  858. # endif
  859. #endif
  860. //#define __NR_get_kernel_syms 130
  861. #ifdef L_get_kernel_syms
  862. struct kernel_sym;
  863. _syscall1(int, get_kernel_syms, struct kernel_sym *, table);
  864. #endif
  865. //#define __NR_quotactl 131
  866. #ifdef __NR_quotactl
  867. #ifdef L_quotactl
  868. #include <sys/quota.h>
  869. _syscall4(int, quotactl, int, cmd, const char *, special , int, id, caddr_t, addr);
  870. #endif
  871. #endif
  872. //#define __NR_getpgid 132
  873. #ifdef L_getpgid
  874. _syscall1(pid_t, getpgid, pid_t, pid);
  875. #endif
  876. //#define __NR_fchdir 133
  877. #ifdef L_fchdir
  878. #include <unistd.h>
  879. _syscall1(int, fchdir, int, fd);
  880. #endif
  881. //#define __NR_bdflush 134
  882. #ifdef L_bdflush
  883. #include <sys/kdaemon.h>
  884. _syscall2(int, bdflush, int, __func, long int, __data);
  885. #endif
  886. //#define __NR_sysfs 135
  887. //#define __NR_personality 136
  888. //#define __NR_afs_syscall 137
  889. //#define __NR_setfsuid 138
  890. #ifdef __NR_setfsuid
  891. #ifdef L_setfsuid
  892. #include <sys/fsuid.h>
  893. _syscall1(int, setfsuid, uid_t, uid);
  894. #endif
  895. #endif
  896. //#define __NR_setfsgid 139
  897. #ifdef __NR_setfsgid
  898. #ifdef L_setfsgid
  899. #include <sys/fsuid.h>
  900. _syscall1(int, setfsgid, gid_t, gid);
  901. #endif
  902. #endif
  903. //#define __NR__llseek 140
  904. #ifdef L__llseek
  905. extern int _llseek(int fd, off_t hoff, off_t loff, loff_t *res, int whence);
  906. _syscall5(int, _llseek, int, fd, off_t, hoff, off_t, loff, loff_t *, res,
  907. int, whence);
  908. loff_t llseek(int fd, loff_t offset, int whence)
  909. {
  910. int ret;
  911. loff_t result;
  912. ret = _llseek(fd, (off_t) (offset >> 32),
  913. (off_t) (offset & 0xffffffff), &result, whence);
  914. return ret ? (loff_t) ret : result;
  915. }
  916. #ifdef __UCLIBC_HAVE_LFS__
  917. weak_alias(llseek, lseek64);
  918. #endif
  919. #endif
  920. //#define __NR_getdents 141
  921. #ifdef L_getdents
  922. #include <unistd.h>
  923. #include <dirent.h>
  924. _syscall3(int, getdents, int, fd, char *, dirp, size_t, count);
  925. #endif
  926. //#define __NR__newselect 142
  927. #ifdef L__newselect
  928. #include <unistd.h>
  929. extern int _newselect(int n, fd_set *readfds, fd_set *writefds,
  930. fd_set *exceptfds, struct timeval *timeout);
  931. _syscall5(int, _newselect, int, n, fd_set *, readfds, fd_set *, writefds,
  932. fd_set *, exceptfds, struct timeval *, timeout);
  933. weak_alias(_newselect, select);
  934. #endif
  935. //#define __NR_flock 143
  936. #ifdef L_flock
  937. #include <sys/file.h>
  938. _syscall2(int,flock,int,fd, int,operation);
  939. #endif
  940. //#define __NR_msync 144
  941. //#define __NR_readv 145
  942. #ifdef L_readv
  943. #include <sys/uio.h>
  944. _syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector, int,
  945. count);
  946. #endif
  947. //#define __NR_writev 146
  948. #ifdef L_writev
  949. #include <sys/uio.h>
  950. _syscall3(ssize_t, writev, int, filedes, const struct iovec *, vector, int,
  951. count);
  952. #endif
  953. //#define __NR_getsid 147
  954. #ifdef L_getsid
  955. #include <unistd.h>
  956. _syscall1(pid_t, getsid, pid_t, pid);
  957. #endif
  958. //#define __NR_fdatasync 148
  959. #ifdef __NR_fdatasync
  960. #ifdef L_fdatasync
  961. #include <unistd.h>
  962. _syscall1(int, fdatasync, int, fd);
  963. #endif
  964. #endif
  965. //#define __NR__sysctl 149
  966. //#define __NR_mlock 150
  967. #ifdef L_mlock
  968. #include <sys/mman.h>
  969. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlock
  970. _syscall2(int, mlock, const void *, addr, size_t, len);
  971. # endif
  972. #endif
  973. //#define __NR_munlock 151
  974. #ifdef L_munlock
  975. #include <sys/mman.h>
  976. # if defined __UCLIBC_HAS_MMU__ && defined __NR_munlock
  977. _syscall2(int, munlock, const void *, addr, size_t, len);
  978. # endif
  979. #endif
  980. //#define __NR_mlockall 152
  981. #ifdef L_mlockall
  982. #include <sys/mman.h>
  983. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlockall
  984. _syscall1(int, mlockall, int, flags);
  985. # endif
  986. #endif
  987. //#define __NR_munlockall 153
  988. #ifdef L_munlockall
  989. #include <sys/mman.h>
  990. # if defined __UCLIBC_HAS_MMU__ && defined L_munlockall
  991. _syscall0(int, munlockall);
  992. # endif
  993. #endif
  994. //#define __NR_sched_setparam 154
  995. #ifdef __NR_sched_setparam
  996. #ifdef L_sched_setparam
  997. #include <sched.h>
  998. _syscall2(int, sched_setparam, pid_t, pid, const struct sched_param *, p);
  999. #endif
  1000. #endif
  1001. //#define __NR_sched_getparam 155
  1002. #ifdef __NR_sched_getparam
  1003. #ifdef L_sched_getparam
  1004. #include <sched.h>
  1005. _syscall2(int, sched_getparam, pid_t, pid, struct sched_param *, p);
  1006. #endif
  1007. #endif
  1008. //#define __NR_sched_setscheduler 156
  1009. #ifdef __NR_sched_setscheduler
  1010. #ifdef L_sched_setscheduler
  1011. #include <sched.h>
  1012. _syscall3(int, sched_setscheduler, pid_t, pid, int, policy, const struct sched_param *, p);
  1013. #endif
  1014. #endif
  1015. //#define __NR_sched_getscheduler 157
  1016. #ifdef __NR_sched_getscheduler
  1017. #ifdef L_sched_getscheduler
  1018. #include <sched.h>
  1019. _syscall1(int, sched_getscheduler, pid_t, pid);
  1020. #endif
  1021. #endif
  1022. //#define __NR_sched_yield 158
  1023. #ifdef __NR_sched_yield
  1024. #ifdef L_sched_yield
  1025. #include <sched.h>
  1026. _syscall0(int, sched_yield);
  1027. #endif
  1028. #endif
  1029. //#define __NR_sched_get_priority_max 159
  1030. #ifdef __NR_sched_get_priority_max
  1031. #ifdef L_sched_get_priority_max
  1032. #include <sched.h>
  1033. _syscall1(int, sched_get_priority_max, int, policy);
  1034. #endif
  1035. #endif
  1036. //#define __NR_sched_get_priority_min 160
  1037. #ifdef __NR_sched_get_priority_min
  1038. #ifdef L_sched_get_priority_min
  1039. #include <sched.h>
  1040. _syscall1(int, sched_get_priority_min, int, policy);
  1041. #endif
  1042. #endif
  1043. //#define __NR_sched_rr_get_interval 161
  1044. #ifdef __NR_sched_rr_get_interval
  1045. #ifdef L_sched_rr_get_interval
  1046. #include <sched.h>
  1047. _syscall2(int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp);
  1048. #endif
  1049. #endif
  1050. //#define __NR_nanosleep 162
  1051. #ifdef L_nanosleep
  1052. #include <time.h>
  1053. _syscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem);
  1054. #endif
  1055. //#define __NR_mremap 163
  1056. #ifdef L_mremap
  1057. #include <unistd.h>
  1058. #include <sys/mman.h>
  1059. _syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t,
  1060. new_size, int, may_move);
  1061. #endif
  1062. //#define __NR_setresuid 164
  1063. //#define __NR_getresuid 165
  1064. //#define __NR_vm86 166
  1065. //#define __NR_query_module 167
  1066. #ifdef L_query_module
  1067. # ifdef __NR_query_module
  1068. _syscall5(int, query_module, const char *, name, int, which,
  1069. void *, buf, size_t, bufsize, size_t*, ret);
  1070. # else
  1071. int query_module(const char * name, int which,
  1072. void * buf, size_t bufsize, size_t* ret)
  1073. {
  1074. __set_errno(ENOSYS);
  1075. return -1;
  1076. }
  1077. # endif
  1078. #endif
  1079. //#define __NR_poll 168
  1080. #if defined(L_poll) && defined(__NR_poll) /* uClinux 2.0 doesn't have poll */
  1081. #include <sys/poll.h>
  1082. _syscall3(int, poll, struct pollfd *, fds, unsigned long int, nfds, int, timeout);
  1083. #endif
  1084. //#define __NR_nfsservctl 169
  1085. //nfsservctl EXTRA nfsservctl i:ipp nfsservctl
  1086. //#define __NR_setresgid 170
  1087. //#define __NR_getresgid 171
  1088. //#define __NR_prctl 172
  1089. //#define __NR_rt_sigreturn 173
  1090. //#define __NR_rt_sigaction 174
  1091. #ifdef __NR_rt_sigaction
  1092. #define __NR___rt_sigaction __NR_rt_sigaction
  1093. #ifdef L___rt_sigaction
  1094. #include <signal.h>
  1095. #undef sigaction
  1096. _syscall4(int, __rt_sigaction, int, signum, const struct sigaction *, act,
  1097. struct sigaction *, oldact, size_t, size);
  1098. #endif
  1099. #endif
  1100. //#define __NR_rt_sigprocmask 175
  1101. #ifdef __NR_rt_sigprocmask
  1102. #define __NR___rt_sigprocmask __NR_rt_sigprocmask
  1103. #ifdef L___rt_sigprocmask
  1104. #include <signal.h>
  1105. #undef sigprocmask
  1106. _syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
  1107. sigset_t *, oldset, size_t, size);
  1108. int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
  1109. {
  1110. return __rt_sigprocmask(how, set, oldset, _NSIG/8);
  1111. }
  1112. #endif
  1113. #endif
  1114. //#define __NR_rt_sigpending 176
  1115. #ifdef __NR_rt_sigpending
  1116. #define __NR___rt_sigpending __NR_rt_sigpending
  1117. #ifdef L___rt_sigpending
  1118. #include <signal.h>
  1119. #undef sigpending
  1120. _syscall2(int, __rt_sigpending, sigset_t *, set, size_t, size);
  1121. int sigpending(sigset_t *set)
  1122. {
  1123. return __rt_sigpending(set, _NSIG/8);
  1124. }
  1125. #endif
  1126. #endif
  1127. //#define __NR_rt_sigtimedwait 177
  1128. //#define __NR_rt_sigqueueinfo 178
  1129. //#define __NR_rt_sigsuspend 179
  1130. #ifdef __NR_rt_sigsuspend
  1131. #define __NR___rt_sigsuspend __NR_rt_sigsuspend
  1132. #ifdef L___rt_sigsuspend
  1133. #include <signal.h>
  1134. #undef _sigsuspend
  1135. _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size);
  1136. int sigsuspend (const sigset_t *mask)
  1137. {
  1138. return __rt_sigsuspend(mask, _NSIG/8);
  1139. }
  1140. #endif
  1141. #endif
  1142. //#define __NR_pread 180
  1143. //#define __NR_pwrite 181
  1144. //#define __NR_chown 182
  1145. #ifdef L_chown
  1146. #include <unistd.h>
  1147. _syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
  1148. #endif
  1149. //#define __NR_getcwd 183
  1150. // See unistd/getcwd.c -- we don't use this syscall, even when it is available...
  1151. //#define __NR_capget 184
  1152. #ifdef L_capget
  1153. # ifdef __NR_capget
  1154. _syscall2(int, capget, void*, header, void*, data);
  1155. # else
  1156. int capget(void* header, void* data)
  1157. {
  1158. __set_errno(ENOSYS);
  1159. return -1;
  1160. }
  1161. # endif
  1162. #endif
  1163. //#define __NR_capset 185
  1164. #ifdef L_capset
  1165. # ifdef __NR_capset
  1166. _syscall2(int, capset, void*, header, const void*, data);
  1167. # else
  1168. int capset(void* header, const void* data)
  1169. {
  1170. __set_errno(ENOSYS);
  1171. return -1;
  1172. }
  1173. # endif
  1174. #endif
  1175. //#define __NR_sigaltstack 186
  1176. #ifdef __NR_sigaltstack
  1177. #ifdef L_sigaltstack
  1178. #include <signal.h>
  1179. _syscall2(int, sigaltstack, const struct sigaltstack *, ss, struct sigaltstack *, oss);
  1180. #endif
  1181. #endif
  1182. //#define __NR_sendfile 187
  1183. #ifdef __NR_sendfile
  1184. #ifdef L_sendfile
  1185. #include <unistd.h>
  1186. #include <sys/sendfile.h>
  1187. _syscall4(ssize_t,sendfile, int, out_fd, int, in_fd, off_t *, offset, size_t, count)
  1188. #endif
  1189. #endif
  1190. //#define __NR_getpmsg 188
  1191. //#define __NR_putpmsg 189
  1192. //#define __NR_vfork 190
  1193. //See sysdeps/linux/<arch>vfork.[cS] for architecture specific implementation...
  1194. //#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
  1195. //#define __NR_mmap2 192
  1196. //#define __NR_truncate64 193
  1197. #ifdef __UCLIBC_HAVE_LFS__
  1198. #ifdef L_truncate64
  1199. #include <unistd.h>
  1200. _syscall2(int, truncate64, const char *, path, __off64_t, length);
  1201. #endif
  1202. #endif /* __UCLIBC_HAVE_LFS__ */
  1203. //#define __NR_ftruncate64 194
  1204. #ifdef __UCLIBC_HAVE_LFS__
  1205. #ifdef L_ftruncate64
  1206. #include <unistd.h>
  1207. _syscall2(int, ftruncate64, int, fd, __off64_t, length);
  1208. #endif
  1209. #endif /* __UCLIBC_HAVE_LFS__ */
  1210. //#define __NR_stat64 195
  1211. #ifdef __UCLIBC_HAVE_LFS__
  1212. #ifdef L___stat64
  1213. #include <unistd.h>
  1214. #include "statfix64.h"
  1215. #define __NR___stat64 __NR_stat64
  1216. #ifdef __STR_NR_stat64
  1217. #define __STR_NR___stat64 __STR_NR_stat64
  1218. #endif
  1219. extern int __stat64(const char *file_name, struct kernel_stat64 *buf);
  1220. _syscall2(int, __stat64, const char *, file_name, struct kernel_stat64 *, buf);
  1221. int __xstat64(int version, const char * file_name, struct libc_stat64 * cstat)
  1222. {
  1223. struct kernel_stat64 kstat;
  1224. int result = __stat64(file_name, &kstat);
  1225. if (result == 0) {
  1226. statfix64(cstat, &kstat);
  1227. }
  1228. return result;
  1229. }
  1230. int stat64(const char *file_name, struct libc_stat64 *buf)
  1231. {
  1232. return(__xstat64(0, file_name, buf));
  1233. }
  1234. #endif
  1235. #endif /* __UCLIBC_HAVE_LFS__ */
  1236. //#define __NR_lstat64 196
  1237. #ifdef __UCLIBC_HAVE_LFS__
  1238. #ifdef L___lstat64
  1239. #include <unistd.h>
  1240. #include "statfix64.h"
  1241. #define __NR___lstat64 __NR_lstat64
  1242. #ifdef __STR_NR_lstat64
  1243. #define __STR_NR___lstat64 __STR_NR_lstat64
  1244. #endif
  1245. extern int __lstat64(const char *file_name, struct kernel_stat64 *buf);
  1246. _syscall2(int, __lstat64, const char *, file_name, struct kernel_stat64 *, buf);
  1247. int __lxstat64(int version, const char * file_name, struct libc_stat64 * cstat)
  1248. {
  1249. struct kernel_stat64 kstat;
  1250. int result = __lstat64(file_name, &kstat);
  1251. if (result == 0) {
  1252. statfix64(cstat, &kstat);
  1253. }
  1254. return result;
  1255. }
  1256. int lstat64(const char *file_name, struct libc_stat64 *buf)
  1257. {
  1258. return(__lxstat64(0, file_name, buf));
  1259. }
  1260. #endif
  1261. #endif /* __UCLIBC_HAVE_LFS__ */
  1262. //#define __NR_fstat64 197
  1263. #ifdef __UCLIBC_HAVE_LFS__
  1264. #ifdef L___fstat64
  1265. #include <unistd.h>
  1266. #include "statfix64.h"
  1267. #define __NR___fstat64 __NR_fstat64
  1268. #ifdef __STR_NR_fstat64
  1269. #define __STR_NR___fstat64 __STR_NR_fstat64
  1270. #endif
  1271. extern int __fstat64(int filedes, struct kernel_stat64 *buf);
  1272. _syscall2(int, __fstat64, int, filedes, struct kernel_stat64 *, buf);
  1273. int __fxstat64(int version, int fd, struct libc_stat64 * cstat)
  1274. {
  1275. struct kernel_stat64 kstat;
  1276. int result = __fstat64(fd, &kstat);
  1277. if (result == 0) {
  1278. statfix64(cstat, &kstat);
  1279. }
  1280. return result;
  1281. }
  1282. int fstat64(int filedes, struct libc_stat64 *buf)
  1283. {
  1284. return(__fxstat64(0, filedes, buf));
  1285. }
  1286. #endif
  1287. #endif /* __UCLIBC_HAVE_LFS__ */
  1288. //#define __NR_lchown32 198
  1289. //#define __NR_getuid32 199
  1290. //#define __NR_getgid32 200
  1291. //#define __NR_geteuid32 201
  1292. //#define __NR_getegid32 202
  1293. //#define __NR_setreuid32 203
  1294. //#define __NR_setregid32 204
  1295. //#define __NR_getgroups32 205
  1296. //#define __NR_setgroups32 206
  1297. //#define __NR_fchown32 207
  1298. //#define __NR_setresuid32 208
  1299. //#define __NR_getresuid32 209
  1300. //#define __NR_setresgid32 210
  1301. //#define __NR_getresgid32 211
  1302. //#define __NR_chown32 212
  1303. //#define __NR_setuid32 213
  1304. //#define __NR_setgid32 214
  1305. //#define __NR_setfsuid32 215
  1306. //#define __NR_setfsgid32 216
  1307. //#define __NR_pivot_root 217
  1308. #ifdef __NR_pivot_root
  1309. #ifdef L_pivot_root
  1310. _syscall2(int, pivot_root, const char *, new_root, const char *, put_old)
  1311. #endif
  1312. #endif
  1313. //#define __NR_mincore 218
  1314. //#define __NR_madvise 219
  1315. //#define __NR_madvise1 219 /* delete when C lib stub is removed */
  1316. //#define __NR_getdents64 220
  1317. #ifdef __UCLIBC_HAVE_LFS__
  1318. #ifdef L_getdents64
  1319. #include <unistd.h>
  1320. #include <dirent.h>
  1321. _syscall3(int, getdents64, int, fd, char *, dirp, size_t, count);
  1322. #endif
  1323. #endif /* __UCLIBC_HAVE_LFS__ */
  1324. //#define __NR_fcntl64 221
  1325. #ifdef __UCLIBC_HAVE_LFS__
  1326. #define __NR__fcntl64 __NR_fcntl64
  1327. #ifdef L__fcntl64
  1328. #include <stdarg.h>
  1329. #include <fcntl.h>
  1330. extern int _fcntl64(int fd, int cmd, long arg);
  1331. _syscall3(int, _fcntl64, int, fd, int, cmd, long, arg);
  1332. int fcntl64(int fd, int command, ...)
  1333. {
  1334. long arg;
  1335. va_list list;
  1336. va_start(list, command);
  1337. arg = va_arg(list, long);
  1338. va_end(list);
  1339. return _fcntl64(fd, command, arg);
  1340. }
  1341. #endif
  1342. #endif
  1343. //#define __NR_security 223 /* syscall for security modules */
  1344. //#define __NR_gettid 224
  1345. //#define __NR_readahead 225