syscalls.c 35 KB

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