syscalls.c 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Syscalls for uClibc
  4. *
  5. * Copyright (C) 2001-2003 by Erik Andersen
  6. * Written by Erik Andersen <andersen@codpoet.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU Library General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  16. * for more details.
  17. *
  18. * You should have received a copy of the GNU Library General Public License
  19. * along with this program; if not, write to the Free Software Foundation,
  20. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #define _GNU_SOURCE
  24. #define _LARGEFILE64_SOURCE
  25. #include <features.h>
  26. #undef __OPTIMIZE__
  27. /* We absolutely do _NOT_ want interfaces silently
  28. * * * renamed under us or very bad things will happen... */
  29. #ifdef __USE_FILE_OFFSET64
  30. # undef __USE_FILE_OFFSET64
  31. #endif
  32. #include <errno.h>
  33. #include <sys/types.h>
  34. #include <sys/syscall.h>
  35. #include <endian.h>
  36. //#define __NR_exit 1
  37. //See _exit.c
  38. //#define __NR_fork 2
  39. #ifdef L___libc_fork
  40. #include <unistd.h>
  41. # ifdef __UCLIBC_HAS_MMU__
  42. #define __NR___libc_fork __NR_fork
  43. _syscall0(pid_t, __libc_fork);
  44. # else
  45. pid_t __libc_fork(void)
  46. {
  47. __set_errno(ENOSYS);
  48. return -1;
  49. }
  50. # endif
  51. weak_alias (__libc_fork, fork)
  52. #endif
  53. //#define __NR_read 3
  54. #ifdef L___libc_read
  55. #include <unistd.h>
  56. #define __NR___libc_read __NR_read
  57. _syscall3(ssize_t, __libc_read, int, fd, __ptr_t, buf, size_t, count);
  58. weak_alias(__libc_read, read)
  59. #endif
  60. //#define __NR_write 4
  61. #ifdef L___libc_write
  62. #include <unistd.h>
  63. #define __NR___libc_write __NR_write
  64. _syscall3(ssize_t, __libc_write, int, fd, const __ptr_t, buf, size_t, count);
  65. weak_alias(__libc_write, write)
  66. /* Stupid libgcc.a from gcc 2.95.x uses __write in pure.o
  67. * which is a blatent GNU libc-ism... */
  68. weak_alias (__libc_write, __write)
  69. #endif
  70. //#define __NR_open 5
  71. #ifdef L___syscall_open
  72. #define __NR___syscall_open __NR_open
  73. #include <stdarg.h>
  74. #include <fcntl.h>
  75. static inline
  76. _syscall3(int, __syscall_open, const char *, fn, int, flags, __kernel_mode_t, mode);
  77. int __libc_open (const char * fn, int flags, ...)
  78. {
  79. va_list ap;
  80. mode_t mode;
  81. va_start(ap, flags);
  82. mode = va_arg(ap, mode_t);
  83. va_end(ap);
  84. return __syscall_open(fn, flags, mode);
  85. }
  86. weak_alias(__libc_open, open)
  87. #endif
  88. //#define __NR_close 6
  89. #ifdef L___libc_close
  90. #include <unistd.h>
  91. #define __NR___libc_close __NR_close
  92. _syscall1(int, __libc_close, int, fd);
  93. weak_alias(__libc_close, close)
  94. #endif
  95. //#define __NR_waitpid 7
  96. // Implemented using wait4
  97. //#define __NR_creat 8
  98. #ifdef L___syscall_creat
  99. #include <fcntl.h>
  100. #ifdef __NR_creat
  101. #define __NR___syscall_creat __NR_creat
  102. _syscall2(int, __syscall_creat, const char *, file, __kernel_mode_t, mode);
  103. int creat (const char *file, mode_t mode)
  104. {
  105. return __syscall_creat (file, mode);
  106. }
  107. #else
  108. extern int __libc_open (const char *file, int flags, mode_t mode);
  109. int creat (const char *file, mode_t mode)
  110. {
  111. return __libc_open (file, O_WRONLY|O_CREAT|O_TRUNC, mode);
  112. }
  113. #endif
  114. #endif
  115. //#define __NR_link 9
  116. #ifdef L_link
  117. #include <unistd.h>
  118. _syscall2(int, link, const char *, oldpath, const char *, newpath);
  119. #endif
  120. //#define __NR_unlink 10
  121. #ifdef L_unlink
  122. #include <unistd.h>
  123. _syscall1(int, unlink, const char *, pathname);
  124. #endif
  125. //#define __NR_execve 11
  126. #ifdef L_execve
  127. #include <unistd.h>
  128. _syscall3(int, execve, const char *, filename, char *const *, argv,
  129. char *const *, envp);
  130. #endif
  131. //#define __NR_chdir 12
  132. #ifdef L_chdir
  133. #include <unistd.h>
  134. _syscall1(int, chdir, const char *, path);
  135. #endif
  136. //#define __NR_time 13
  137. #ifdef L_time
  138. #include <time.h>
  139. #include <sys/time.h>
  140. #ifdef __NR_time
  141. _syscall1(time_t, time, time_t *, t);
  142. #else
  143. time_t time (time_t *t)
  144. {
  145. time_t result;
  146. struct timeval tv;
  147. if (gettimeofday (&tv, (struct timezone *) NULL)) {
  148. result = (time_t) -1;
  149. } else { result = (time_t) tv.tv_sec; }
  150. if (t != NULL) { *t = result; }
  151. return result;
  152. }
  153. #endif
  154. #endif
  155. //#define __NR_mknod 14
  156. #ifdef L___syscall_mknod
  157. #define __NR___syscall_mknod __NR_mknod
  158. #include <sys/stat.h>
  159. _syscall3(int, __syscall_mknod, const char *, path, __kernel_mode_t, mode, __kernel_dev_t, dev);
  160. int mknod(const char *path, mode_t mode, dev_t dev)
  161. {
  162. __kernel_dev_t k_dev;
  163. /* We must convert the dev_t value to a __kernel_dev_t */
  164. k_dev = ((major(dev) & 0xff) << 8) | (minor(dev) & 0xff);
  165. return __syscall_mknod(path, mode, k_dev);
  166. }
  167. #endif
  168. //#define __NR_chmod 15
  169. #ifdef L___syscall_chmod
  170. #include <sys/stat.h>
  171. #define __NR___syscall_chmod __NR_chmod
  172. static inline
  173. _syscall2(int, __syscall_chmod, const char *, path, __kernel_mode_t, mode);
  174. int chmod(const char *path, mode_t mode)
  175. {
  176. return __syscall_chmod(path, mode);
  177. }
  178. #endif
  179. /* Old kernels don't have lchown -- do chown instead. This
  180. * is sick and wrong, but at least things will compile.
  181. * They may not follow links when they should though... */
  182. #ifndef __NR_lchown
  183. #define __NR_lchown __NR_chown
  184. #endif
  185. //#define __NR_lchown 16
  186. #ifdef L___syscall_lchown
  187. #include <unistd.h>
  188. #define __NR___syscall_lchown __NR_lchown
  189. static inline
  190. _syscall3(int, __syscall_lchown, const char *, path, __kernel_uid_t, owner, __kernel_gid_t, group);
  191. int lchown(const char *path, uid_t owner, gid_t group)
  192. {
  193. return __syscall_lchown(path, owner, group);
  194. }
  195. #endif
  196. //#define __NR_break 17
  197. //#define __NR_oldstat 18
  198. //#define __NR_lseek 19
  199. #ifdef L___libc_lseek
  200. #include <unistd.h>
  201. #define __NR___libc_lseek __NR_lseek
  202. _syscall3(__off_t, __libc_lseek, int, fildes, __off_t, offset, int, whence);
  203. weak_alias(__libc_lseek, lseek)
  204. #endif
  205. //#define __NR_getpid 20
  206. #ifdef L___libc_getpid
  207. #include <unistd.h>
  208. #if defined (__alpha__)
  209. #define __NR_getpid __NR_getxpid
  210. #endif
  211. #define __NR___libc_getpid __NR_getpid
  212. _syscall0(pid_t, __libc_getpid);
  213. weak_alias(__libc_getpid, getpid)
  214. weak_alias(__libc_getpid, __getpid)
  215. #endif
  216. //#define __NR_mount 21
  217. #ifdef L_mount
  218. #include <sys/mount.h>
  219. _syscall5(int, mount, const char *, specialfile, const char *, dir,
  220. const char *, filesystemtype, unsigned long, rwflag,
  221. const void *, data);
  222. #endif
  223. //#define __NR_umount 22
  224. #ifdef L_umount
  225. #include <sys/mount.h>
  226. _syscall1(int, umount, const char *, specialfile);
  227. #endif
  228. //#define __NR_setuid 23
  229. #ifdef L___syscall_setuid
  230. #define __NR___syscall_setuid __NR_setuid
  231. #include <unistd.h>
  232. static inline
  233. _syscall1(int, __syscall_setuid, __kernel_uid_t, uid);
  234. int setuid(uid_t uid)
  235. {
  236. if (uid == (uid_t) ~0 || uid != (uid_t) ((int) uid)) {
  237. __set_errno (EINVAL);
  238. return -1;
  239. }
  240. return(__syscall_setuid(uid));
  241. }
  242. #endif
  243. //#define __NR_getuid 24
  244. #ifdef L___syscall_getuid
  245. #include <unistd.h>
  246. #if defined (__alpha__)
  247. #define __NR_getuid __NR_getxuid
  248. #endif
  249. #define __NR___syscall_getuid __NR_getuid
  250. static inline
  251. _syscall0(int, __syscall_getuid);
  252. uid_t getuid(void)
  253. {
  254. return(__syscall_getuid());
  255. }
  256. #endif
  257. //#define __NR_stime 25
  258. #ifdef L_stime
  259. #include <time.h>
  260. #include <sys/time.h>
  261. #ifdef __NR_stime
  262. _syscall1(int, stime, const time_t *, t);
  263. #else
  264. int stime(const time_t *when)
  265. {
  266. struct timeval tv;
  267. if (when == NULL) { __set_errno (EINVAL); return -1; }
  268. tv.tv_sec = *when;
  269. tv.tv_usec = 0;
  270. return settimeofday (&tv, (struct timezone *) 0);
  271. }
  272. #endif
  273. #endif
  274. //#define __NR_ptrace 26
  275. #ifdef L___ptrace
  276. #include <sys/ptrace.h>
  277. #define __NR___ptrace __NR_ptrace
  278. _syscall4(long, __ptrace, enum __ptrace_request, request, __kernel_pid_t, pid,
  279. void*, addr, void*, data);
  280. #endif
  281. //#define __NR_alarm 27
  282. #ifdef L_alarm
  283. #include <unistd.h>
  284. #ifdef __NR_alarm
  285. _syscall1(unsigned int, alarm, unsigned int, seconds);
  286. #else
  287. #include <sys/time.h>
  288. unsigned int alarm (unsigned int seconds)
  289. {
  290. struct itimerval old, new;
  291. unsigned int retval;
  292. new.it_value.tv_usec = 0;
  293. new.it_interval.tv_sec = 0;
  294. new.it_interval.tv_usec = 0;
  295. new.it_value.tv_sec = (long int) seconds;
  296. if (setitimer (ITIMER_REAL, &new, &old) < 0) { return 0; }
  297. retval = old.it_value.tv_sec;
  298. if (old.it_value.tv_usec) { ++retval; }
  299. return retval;
  300. }
  301. #endif
  302. #endif
  303. //#define __NR_oldfstat 28
  304. //#define __NR_pause 29
  305. #ifdef L___libc_pause
  306. #include <unistd.h>
  307. #ifdef __NR_pause
  308. #define __NR___libc_pause __NR_pause
  309. _syscall0(int, __libc_pause);
  310. weak_alias(__libc_pause, pause)
  311. #else
  312. #include <signal.h>
  313. int __libc_pause (void)
  314. {
  315. return(__sigpause(sigblock(0), 0));
  316. }
  317. weak_alias(__libc_pause, pause)
  318. #endif
  319. #endif
  320. //#define __NR_utime 30
  321. #ifdef L_utime
  322. #include <utime.h>
  323. #ifdef __NR_utime
  324. _syscall2(int, utime, const char *, file, const struct utimbuf *, times);
  325. #else
  326. #include <stdlib.h>
  327. #include <sys/time.h>
  328. int utime(const char *file, const struct utimbuf *times)
  329. {
  330. struct timeval timevals[2];
  331. if (times != NULL) {
  332. timevals[0].tv_usec = 0L;
  333. timevals[1].tv_usec = 0L;
  334. timevals[0].tv_sec = (long int) times->actime;
  335. timevals[1].tv_sec = (long int) times->modtime;
  336. } else {
  337. if (gettimeofday (&timevals[0], NULL) < 0) { return -1; }
  338. timevals[1] = timevals[0];
  339. }
  340. return utimes(file, timevals);
  341. }
  342. #endif
  343. #endif
  344. //#define __NR_utimed
  345. #ifdef L_utimes
  346. #include <utime.h>
  347. #ifdef __NR_utimes
  348. _syscall2(int, utimes, const char *, file, const struct timeval *, tvp);
  349. #else
  350. #include <stdlib.h>
  351. #include <sys/time.h>
  352. int utimes (const char *file, const struct timeval tvp[2])
  353. {
  354. struct utimbuf buf, *times;
  355. if (tvp) {
  356. times = &buf;
  357. times->actime = tvp[0].tv_sec;
  358. times->modtime = tvp[1].tv_sec;
  359. } else { times = NULL; }
  360. return utime(file, times);
  361. }
  362. #endif
  363. #endif
  364. //#define __NR_stty 31
  365. #ifdef L_stty
  366. #include <sgtty.h>
  367. int stty (int __fd, __const struct sgttyb *__params);
  368. {
  369. __set_errno(ENOSYS);
  370. return -1;
  371. }
  372. #endif
  373. //#define __NR_gtty 32
  374. #ifdef L_gtty
  375. #include <sgtty.h>
  376. int gtty (int __fd, struct sgttyb *__params)
  377. {
  378. __set_errno(ENOSYS);
  379. return -1;
  380. }
  381. #endif
  382. //#define __NR_access 33
  383. #ifdef L_access
  384. #include <unistd.h>
  385. _syscall2(int, access, const char *, pathname, int, mode);
  386. #endif
  387. //#define __NR_nice 34
  388. #ifdef L_nice
  389. #include <unistd.h>
  390. #ifdef __NR_nice
  391. _syscall1(int, nice, int, inc);
  392. #else
  393. #include <sys/resource.h>
  394. int nice (int incr)
  395. {
  396. int save, prio, result;
  397. save = errno;
  398. __set_errno (0);
  399. prio = getpriority (PRIO_PROCESS, 0);
  400. if (prio == -1) {
  401. if (errno != 0) { return -1; }
  402. else { __set_errno (save); }
  403. }
  404. result = setpriority (PRIO_PROCESS, 0, prio + incr);
  405. if (result != -1) { return prio + incr; } else { return -1; }
  406. }
  407. #endif
  408. #endif
  409. //#define __NR_ftime 35
  410. //#define __NR_sync 36
  411. //See sync.c
  412. //#define __NR_kill 37
  413. #ifdef L___syscall_kill
  414. #include <signal.h>
  415. #undef kill
  416. #define __NR___syscall_kill __NR_kill
  417. static inline
  418. _syscall2(int, __syscall_kill, __kernel_pid_t, pid, int, sig);
  419. int kill(pid_t pid, int sig)
  420. {
  421. return(__syscall_kill(pid, sig));
  422. }
  423. #endif
  424. //#define __NR_rename 38
  425. #ifdef L_rename
  426. #include <stdio.h>
  427. _syscall2(int, rename, const char *, oldpath, const char *, newpath);
  428. #endif
  429. //#define __NR_mkdir 39
  430. #ifdef L___syscall_mkdir
  431. #include <sys/stat.h>
  432. #define __NR___syscall_mkdir __NR_mkdir
  433. static inline
  434. _syscall2(int, __syscall_mkdir, const char *, pathname, __kernel_mode_t, mode);
  435. int mkdir(const char * pathname, mode_t mode)
  436. {
  437. return(__syscall_mkdir(pathname, mode));
  438. }
  439. #endif
  440. //#define __NR_rmdir 40
  441. #ifdef L_rmdir
  442. #include <unistd.h>
  443. _syscall1(int, rmdir, const char *, pathname);
  444. #endif
  445. //#define __NR_dup 41
  446. #ifdef L_dup
  447. #include <unistd.h>
  448. _syscall1(int, dup, int, oldfd);
  449. #endif
  450. //#define __NR_pipe 42
  451. #ifdef L_pipe
  452. #include <unistd.h>
  453. _syscall1(int, pipe, int *, filedes);
  454. #endif
  455. //#define __NR_times 43
  456. #ifdef L_times
  457. #include <sys/times.h>
  458. _syscall1(clock_t, times, struct tms *, buf);
  459. #endif
  460. //#define __NR_prof 44
  461. //#define __NR_brk 45
  462. //#define __NR_setgid 46
  463. #ifdef L___syscall_setgid
  464. #include <unistd.h>
  465. #define __NR___syscall_setgid __NR_setgid
  466. static inline
  467. _syscall1(int, __syscall_setgid, __kernel_gid_t, gid);
  468. int setgid(gid_t gid)
  469. {
  470. return(__syscall_setgid(gid));
  471. }
  472. #endif
  473. //#define __NR_getgid 47
  474. #ifdef L___syscall_getgid
  475. #include <unistd.h>
  476. #define __NR___syscall_getgid __NR_getgid
  477. #if defined (__alpha__)
  478. #define __NR_getgid __NR_getxgid
  479. #endif
  480. static inline
  481. _syscall0(int, __syscall_getgid);
  482. gid_t getgid(void)
  483. {
  484. return(__syscall_getgid());
  485. }
  486. #endif
  487. //#define __NR_signal 48
  488. //#define __NR_geteuid 49
  489. #ifdef L___syscall_geteuid
  490. #include <unistd.h>
  491. # ifdef __NR_geteuid
  492. #define __NR___syscall_geteuid __NR_geteuid
  493. static inline
  494. _syscall0(int, __syscall_geteuid);
  495. uid_t geteuid(void)
  496. {
  497. return(__syscall_geteuid());
  498. }
  499. # else
  500. uid_t geteuid(void)
  501. {
  502. return (getuid());
  503. }
  504. # endif
  505. #endif
  506. //#define __NR_getegid 50
  507. #ifdef L___syscall_getegid
  508. #include <unistd.h>
  509. # ifdef __NR_getegid
  510. #define __NR___syscall_getegid __NR_getegid
  511. static inline
  512. _syscall0(int, __syscall_getegid);
  513. gid_t getegid(void)
  514. {
  515. return(__syscall_getegid());
  516. }
  517. # else
  518. gid_t getegid(void)
  519. {
  520. return (getgid());
  521. }
  522. # endif
  523. #endif
  524. //#define __NR_acct 51
  525. #ifdef L_acct
  526. #include <unistd.h>
  527. _syscall1(int, acct, const char *, filename);
  528. #endif
  529. //#define __NR_umount2 52
  530. #ifdef L_umount2
  531. # ifdef __NR_umount2 /* Old kernels don't have umount2 */
  532. # include <sys/mount.h>
  533. _syscall2(int, umount2, const char *, special_file, int, flags);
  534. # else
  535. int umount2(const char * special_file, int flags)
  536. {
  537. __set_errno(ENOSYS);
  538. return -1;
  539. }
  540. # endif
  541. #endif
  542. //#define __NR_lock 53
  543. //#define __NR_ioctl 54
  544. #ifdef L___syscall_ioctl
  545. #include <stdarg.h>
  546. #include <sys/ioctl.h>
  547. #define __NR___syscall_ioctl __NR_ioctl
  548. extern int __syscall_ioctl(int fd, int request, void *arg);
  549. _syscall3(int, __syscall_ioctl, int, fd, int, request, void *, arg);
  550. #if !defined (__powerpc__)
  551. #include "ioctl.c"
  552. /* Also see ioctl.c and powerpc/ioctl.c */
  553. #endif
  554. #endif
  555. //#define __NR_fcntl 55
  556. #ifdef L___syscall_fcntl
  557. #include <stdarg.h>
  558. #include <fcntl.h>
  559. #define __NR___syscall_fcntl __NR_fcntl
  560. #ifdef __UCLIBC_HAS_LFS__
  561. static inline
  562. #endif
  563. _syscall3(int, __syscall_fcntl, int, fd, int, cmd, long, arg);
  564. int __libc_fcntl(int fd, int cmd, ...)
  565. {
  566. long arg;
  567. va_list list;
  568. if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64)
  569. {
  570. __set_errno(ENOSYS);
  571. return -1;
  572. }
  573. va_start(list, cmd);
  574. arg = va_arg(list, long);
  575. va_end(list);
  576. return(__syscall_fcntl(fd, cmd, arg));
  577. }
  578. weak_alias(__libc_fcntl, fcntl)
  579. #endif
  580. //#define __NR_mpx 56
  581. //#define __NR_setpgid 57
  582. #ifdef L___syscall_setpgid
  583. #include <unistd.h>
  584. #define __NR___syscall_setpgid __NR_setpgid
  585. static inline
  586. _syscall2(int, __syscall_setpgid, __kernel_pid_t, pid, __kernel_pid_t, pgid);
  587. int setpgid(pid_t pid, pid_t pgid)
  588. {
  589. return(__syscall_setpgid(pid, pgid));
  590. }
  591. #endif
  592. //#define __NR_ulimit 58
  593. //See ulimit.c
  594. //#define __NR_oldolduname 59
  595. //#define __NR_umask 60
  596. #ifdef L___syscall_umask
  597. #include <sys/stat.h>
  598. #define __NR___syscall_umask __NR_umask
  599. static inline
  600. _syscall1(__kernel_mode_t, __syscall_umask, __kernel_mode_t, mask);
  601. mode_t umask(mode_t mask)
  602. {
  603. return(__syscall_umask(mask));
  604. }
  605. #endif
  606. //#define __NR_chroot 61
  607. #ifdef L_chroot
  608. #include <unistd.h>
  609. _syscall1(int, chroot, const char *, path);
  610. #endif
  611. //#define __NR_ustat 62
  612. #ifdef L___syscall_ustat
  613. #define __NR___syscall_ustat __NR_ustat
  614. #include <sys/ustat.h>
  615. static inline
  616. _syscall2(int, __syscall_ustat, unsigned short int, kdev_t, struct ustat *, ubuf);
  617. int ustat(dev_t dev, struct ustat *ubuf)
  618. {
  619. __kernel_dev_t k_dev;
  620. /* We must convert the dev_t value to a __kernel_dev_t */
  621. k_dev = ((major(dev) & 0xff) << 8) | (minor(dev) & 0xff);
  622. return __syscall_ustat(k_dev, ubuf);
  623. }
  624. #endif
  625. //#define __NR_dup2 63
  626. #ifdef L_dup2
  627. #include <unistd.h>
  628. _syscall2(int, dup2, int, oldfd, int, newfd);
  629. #endif
  630. //#define __NR_getppid 64
  631. #ifdef L_getppid
  632. # include <unistd.h>
  633. # ifdef __NR_getppid
  634. _syscall0(pid_t, getppid);
  635. # else
  636. pid_t getppid(void)
  637. {
  638. return (getpid());
  639. }
  640. # endif
  641. #endif
  642. //#define __NR_getpgrp 65
  643. #ifdef L_getpgrp
  644. #include <unistd.h>
  645. _syscall0(pid_t, getpgrp);
  646. #endif
  647. //#define __NR_setsid 66
  648. #ifdef L_setsid
  649. #include <unistd.h>
  650. _syscall0(pid_t, setsid);
  651. #endif
  652. //#define __NR_sigaction 67
  653. #ifndef __NR_rt_sigaction
  654. #ifdef L___syscall_sigaction
  655. #define __NR___syscall_sigaction __NR_sigaction
  656. #include <signal.h>
  657. #undef sigaction
  658. _syscall3(int, __syscall_sigaction, int, signum, const struct sigaction *, act,
  659. struct sigaction *, oldact);
  660. #endif
  661. #endif
  662. //#define __NR_sgetmask 68
  663. //#define __NR_ssetmask 69
  664. //#define __NR_setreuid 70
  665. #ifdef L___syscall_setreuid
  666. #include <unistd.h>
  667. #define __NR___syscall_setreuid __NR_setreuid
  668. static inline
  669. _syscall2(int, __syscall_setreuid, __kernel_uid_t, ruid, __kernel_uid_t, euid);
  670. int setreuid(uid_t ruid, uid_t euid)
  671. {
  672. return(__syscall_setreuid(ruid, euid));
  673. }
  674. #endif
  675. //#define __NR_setregid 71
  676. #ifdef L___syscall_setregid
  677. #include <unistd.h>
  678. #define __NR___syscall_setregid __NR_setregid
  679. static inline
  680. _syscall2(int, __syscall_setregid, __kernel_gid_t, rgid, __kernel_gid_t, egid);
  681. int setregid(gid_t rgid, gid_t egid)
  682. {
  683. return(__syscall_setregid(rgid, egid));
  684. }
  685. #endif
  686. //#define __NR_sigsuspend 72
  687. #ifndef __NR_rt_sigsuspend
  688. #define __NR___sigsuspend __NR_sigsuspend
  689. #ifdef L___sigsuspend
  690. #include <signal.h>
  691. #undef sigsuspend
  692. _syscall3(int, __sigsuspend, int, a, unsigned long int, b, unsigned long int, c);
  693. int sigsuspend (const sigset_t *set)
  694. {
  695. return __sigsuspend(0, 0, set->__val[0]);
  696. }
  697. #endif
  698. #endif
  699. //#define __NR_sigpending 73
  700. #ifndef __NR_rt_sigpending
  701. #ifdef L_sigpending
  702. #include <signal.h>
  703. #undef sigpending
  704. _syscall1(int, sigpending, sigset_t *, set);
  705. #endif
  706. #endif
  707. //#define __NR_sethostname 74
  708. #ifdef L_sethostname
  709. #include <unistd.h>
  710. _syscall2(int, sethostname, const char *, name, size_t, len);
  711. #endif
  712. //#define __NR_setrlimit 75
  713. #ifndef __NR_ugetrlimit
  714. /* Only wrap setrlimit if the new ugetrlimit is not present */
  715. #ifdef L___setrlimit
  716. #define __NR___setrlimit __NR_setrlimit
  717. #include <unistd.h>
  718. #include <sys/resource.h>
  719. #define RMIN(x, y) ((x) < (y) ? (x) : (y))
  720. _syscall2(int, __setrlimit, int, resource, const struct rlimit *, rlim);
  721. int setrlimit (__rlimit_resource_t resource, const struct rlimit *rlimits)
  722. {
  723. struct rlimit rlimits_small;
  724. /* We might have to correct the limits values. Since the old values
  725. * were signed the new values might be too large. */
  726. rlimits_small.rlim_cur = RMIN ((unsigned long int) rlimits->rlim_cur,
  727. RLIM_INFINITY >> 1);
  728. rlimits_small.rlim_max = RMIN ((unsigned long int) rlimits->rlim_max,
  729. RLIM_INFINITY >> 1);
  730. return(__setrlimit(resource, &rlimits_small));
  731. }
  732. #undef RMIN
  733. #endif
  734. #else /* We don't need to wrap setrlimit */
  735. #ifdef L_setrlimit
  736. #include <unistd.h>
  737. struct rlimit;
  738. _syscall2(int, setrlimit, unsigned int, resource, const struct rlimit *, rlim);
  739. #endif
  740. #endif /* __NR_setrlimit */
  741. //#define __NR_getrlimit 76
  742. #ifdef L___getrlimit
  743. /* Only include the old getrlimit if the new one (ugetrlimit) is not around */
  744. #ifndef __NR_ugetrlimit
  745. #define __NR___getrlimit __NR_getrlimit
  746. #include <unistd.h>
  747. #include <sys/resource.h>
  748. _syscall2(int, __getrlimit, int, resource, struct rlimit *, rlim);
  749. int getrlimit (__rlimit_resource_t resource, struct rlimit *rlimits)
  750. {
  751. int result;
  752. result = __getrlimit(resource, rlimits);
  753. if (result == -1)
  754. return result;
  755. /* We might have to correct the limits values. Since the old values
  756. * were signed the infinity value is too small. */
  757. if (rlimits->rlim_cur == RLIM_INFINITY >> 1)
  758. rlimits->rlim_cur = RLIM_INFINITY;
  759. if (rlimits->rlim_max == RLIM_INFINITY >> 1)
  760. rlimits->rlim_max = RLIM_INFINITY;
  761. return result;
  762. }
  763. #endif
  764. #endif /* __NR_getrlimit */
  765. //#define __NR_getrusage 77
  766. #ifdef L_getrusage
  767. #include <unistd.h>
  768. #include <wait.h>
  769. _syscall2(int, getrusage, int, who, struct rusage *, usage);
  770. #endif
  771. //#define __NR_gettimeofday 78
  772. #ifdef L_gettimeofday
  773. #include <sys/time.h>
  774. _syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
  775. #endif
  776. //#define __NR_settimeofday 79
  777. #ifdef L_settimeofday
  778. #include <sys/time.h>
  779. _syscall2(int, settimeofday, const struct timeval *, tv,
  780. const struct timezone *, tz);
  781. #endif
  782. //#define __NR_getgroups 80
  783. #ifdef L___syscall_getgroups
  784. #include <unistd.h>
  785. #define __NR___syscall_getgroups __NR_getgroups
  786. static inline
  787. _syscall2(int, __syscall_getgroups, int, size, __kernel_gid_t *, list);
  788. #define MIN(a,b) (((a)<(b))?(a):(b))
  789. int getgroups(int n, gid_t *groups)
  790. {
  791. if (unlikely(n < 0)) {
  792. __set_errno(EINVAL);
  793. return -1;
  794. } else {
  795. int i, ngids;
  796. __kernel_gid_t kernel_groups[n = MIN(n, sysconf(_SC_NGROUPS_MAX))];
  797. ngids = __syscall_getgroups(n, kernel_groups);
  798. if (n != 0 && ngids > 0) {
  799. for (i = 0; i < ngids; i++) {
  800. groups[i] = kernel_groups[i];
  801. }
  802. }
  803. return ngids;
  804. }
  805. }
  806. #endif
  807. //#define __NR_setgroups 81
  808. #ifdef L___syscall_setgroups
  809. #include <unistd.h>
  810. #include <grp.h>
  811. #define __NR___syscall_setgroups __NR_setgroups
  812. static inline
  813. _syscall2(int, __syscall_setgroups, size_t, size, const __kernel_gid_t *, list);
  814. int setgroups (size_t n, const gid_t *groups)
  815. {
  816. if (n > (size_t)sysconf(_SC_NGROUPS_MAX)) {
  817. __set_errno (EINVAL);
  818. return -1;
  819. } else {
  820. size_t i;
  821. __kernel_gid_t kernel_groups[n];
  822. for (i = 0; i < n; i++) {
  823. kernel_groups[i] = (groups)[i];
  824. if (groups[i] != (gid_t) ((__kernel_gid_t)groups[i])) {
  825. __set_errno (EINVAL);
  826. return -1;
  827. }
  828. }
  829. return(__syscall_setgroups(n, kernel_groups));
  830. }
  831. }
  832. #endif
  833. //#define __NR_select 82
  834. #ifdef L_select
  835. //Used as a fallback if _newselect isn't available...
  836. #ifndef __NR__newselect
  837. #include <unistd.h>
  838. extern int select(int n, fd_set *readfds, fd_set *writefds,
  839. fd_set *exceptfds, struct timeval *timeout);
  840. _syscall5(int, select, int, n, fd_set *, readfds, fd_set *, writefds,
  841. fd_set *, exceptfds, struct timeval *, timeout);
  842. #endif
  843. #endif
  844. //#define __NR_symlink 83
  845. #ifdef L_symlink
  846. #include <unistd.h>
  847. _syscall2(int, symlink, const char *, oldpath, const char *, newpath);
  848. #endif
  849. //#define __NR_oldlstat 84
  850. //#define __NR_readlink 85
  851. #ifdef L_readlink
  852. #include <unistd.h>
  853. _syscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz);
  854. #endif
  855. //#define __NR_uselib 86
  856. #ifdef L_uselib
  857. #include <unistd.h>
  858. _syscall1(int, uselib, const char *, library);
  859. #endif
  860. //#define __NR_swapon 87
  861. #ifdef L_swapon
  862. #include <sys/swap.h>
  863. _syscall2(int, swapon, const char *, path, int, swapflags);
  864. #endif
  865. //#define __NR_reboot 88
  866. #ifdef L__reboot
  867. #define __NR__reboot __NR_reboot
  868. extern int _reboot(int magic, int magic2, int flag);
  869. _syscall3(int, _reboot, int, magic, int, magic2, int, flag);
  870. int reboot(int flag)
  871. {
  872. return (_reboot((int) 0xfee1dead, 672274793, flag));
  873. }
  874. #endif
  875. //#define __NR_readdir 89
  876. //#define __NR_mmap 90
  877. #ifdef L__mmap
  878. #define __NR__mmap __NR_mmap
  879. #include <unistd.h>
  880. #include <sys/mman.h>
  881. extern __ptr_t _mmap(unsigned long *buffer);
  882. _syscall1(__ptr_t, _mmap, unsigned long *, buffer);
  883. __ptr_t mmap(__ptr_t addr, size_t len, int prot,
  884. int flags, int fd, __off_t offset)
  885. {
  886. unsigned long buffer[6];
  887. buffer[0] = (unsigned long) addr;
  888. buffer[1] = (unsigned long) len;
  889. buffer[2] = (unsigned long) prot;
  890. buffer[3] = (unsigned long) flags;
  891. buffer[4] = (unsigned long) fd;
  892. buffer[5] = (unsigned long) offset;
  893. return (__ptr_t) _mmap(buffer);
  894. }
  895. #endif
  896. //#define __NR_munmap 91
  897. #ifdef L_munmap
  898. #include <unistd.h>
  899. #include <sys/mman.h>
  900. _syscall2(int, munmap, void *, start, size_t, length);
  901. #endif
  902. //#define __NR_truncate 92
  903. #ifdef L_truncate
  904. #include <unistd.h>
  905. _syscall2(int, truncate, const char *, path, __off_t, length);
  906. #endif
  907. //#define __NR_ftruncate 93
  908. #ifdef L_ftruncate
  909. #include <unistd.h>
  910. _syscall2(int, ftruncate, int, fd, __off_t, length);
  911. #endif
  912. //#define __NR_fchmod 94
  913. #ifdef L___syscall_fchmod
  914. #include <sys/stat.h>
  915. #define __NR___syscall_fchmod __NR_fchmod
  916. static inline
  917. _syscall2(int, __syscall_fchmod, int, fildes, __kernel_mode_t, mode);
  918. int fchmod(int fildes, mode_t mode)
  919. {
  920. return(__syscall_fchmod(fildes, mode));
  921. }
  922. #endif
  923. //#define __NR_fchown 95
  924. #ifdef L___syscall_fchown
  925. #include <unistd.h>
  926. #define __NR___syscall_fchown __NR_fchown
  927. static inline
  928. _syscall3(int, __syscall_fchown, int, fd, __kernel_uid_t, owner, __kernel_gid_t, group);
  929. int fchown(int fd, uid_t owner, gid_t group)
  930. {
  931. return(__syscall_fchown(fd, owner, group));
  932. }
  933. #endif
  934. //#define __NR_getpriority 96
  935. #ifdef L___syscall_getpriority
  936. #include <sys/resource.h>
  937. #define __NR___syscall_getpriority __NR_getpriority
  938. _syscall2(int, __syscall_getpriority, __priority_which_t, which, id_t, who);
  939. /* The return value of __syscall_getpriority is biased by this value
  940. * to avoid returning negative values. */
  941. #define PZERO 20
  942. int getpriority (enum __priority_which which, id_t who)
  943. {
  944. int res;
  945. res = __syscall_getpriority(which, who);
  946. if (res >= 0)
  947. res = PZERO - res;
  948. return res;
  949. }
  950. #endif
  951. //#define __NR_setpriority 97
  952. #ifdef L_setpriority
  953. #include <sys/resource.h>
  954. _syscall3(int, setpriority, __priority_which_t, which, id_t, who, int, prio);
  955. #endif
  956. //#define __NR_profil 98
  957. //#define __NR_statfs 99
  958. #ifdef L_statfs
  959. #include <sys/vfs.h>
  960. _syscall2(int, statfs, const char *, path, struct statfs *, buf);
  961. #endif
  962. //#define __NR_fstatfs 100
  963. #ifdef L_fstatfs
  964. #include <sys/vfs.h>
  965. _syscall2(int, fstatfs, int, fd, struct statfs *, buf);
  966. #endif
  967. //#define __NR_ioperm 101
  968. #ifdef L_ioperm
  969. # if defined __UCLIBC_HAS_MMU__ && defined __NR_ioperm
  970. _syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on);
  971. # else
  972. int ioperm(unsigned long from, unsigned long num, int turn_on)
  973. {
  974. __set_errno(ENOSYS);
  975. return -1;
  976. }
  977. # endif
  978. #endif
  979. //#define __NR_socketcall 102
  980. #ifdef L___socketcall
  981. #ifdef __NR_socketcall
  982. #define __NR___socketcall __NR_socketcall
  983. _syscall2(int, __socketcall, int, call, unsigned long *, args);
  984. #endif
  985. #endif
  986. //#define __NR_syslog 103
  987. #ifdef L__syslog
  988. #include <unistd.h>
  989. #define __NR__syslog __NR_syslog
  990. extern int _syslog(int type, char *buf, int len);
  991. _syscall3(int, _syslog, int, type, char *, buf, int, len);
  992. int klogctl(int type, char *buf, int len)
  993. {
  994. return (_syslog(type, buf, len));
  995. }
  996. #endif
  997. //#define __NR_setitimer 104
  998. #ifdef L_setitimer
  999. #include <sys/time.h>
  1000. _syscall3(int, setitimer, __itimer_which_t, which,
  1001. const struct itimerval *, new, struct itimerval *, old);
  1002. #endif
  1003. //#define __NR_getitimer 105
  1004. #ifdef L_getitimer
  1005. #include <sys/time.h>
  1006. _syscall2(int, getitimer, __itimer_which_t, which, struct itimerval *, value);
  1007. #endif
  1008. //#define __NR_stat 106
  1009. #ifdef L___syscall_stat
  1010. #define __NR___syscall_stat __NR_stat
  1011. #include <unistd.h>
  1012. #define _SYS_STAT_H
  1013. #include <bits/stat.h>
  1014. #include "xstatconv.h"
  1015. _syscall2(int, __syscall_stat, const char *, file_name, struct kernel_stat *, buf);
  1016. int stat(const char * file_name, struct stat * buf)
  1017. {
  1018. int result;
  1019. struct kernel_stat kbuf;
  1020. result = __syscall_stat(file_name, &kbuf);
  1021. if (result == 0) {
  1022. __xstat_conv(&kbuf, buf);
  1023. }
  1024. return result;
  1025. }
  1026. #if ! defined __NR_stat64 && defined __UCLIBC_HAS_LFS__
  1027. weak_alias(stat, stat64);
  1028. #endif
  1029. #endif
  1030. //#define __NR_lstat 107
  1031. #ifdef L___syscall_lstat
  1032. #define __NR___syscall_lstat __NR_lstat
  1033. #include <unistd.h>
  1034. #define _SYS_STAT_H
  1035. #include <bits/stat.h>
  1036. #include <bits/kernel_stat.h>
  1037. #include "xstatconv.h"
  1038. _syscall2(int, __syscall_lstat, const char *, file_name, struct kernel_stat *, buf);
  1039. int lstat(const char * file_name, struct stat * buf)
  1040. {
  1041. int result;
  1042. struct kernel_stat kbuf;
  1043. result = __syscall_lstat(file_name, &kbuf);
  1044. if (result == 0) {
  1045. __xstat_conv(&kbuf, buf);
  1046. }
  1047. return result;
  1048. }
  1049. #if ! defined __NR_lstat64 && defined __UCLIBC_HAS_LFS__
  1050. weak_alias(lstat, lstat64);
  1051. #endif
  1052. #endif
  1053. //#define __NR_fstat 108
  1054. #ifdef L___syscall_fstat
  1055. #define __NR___syscall_fstat __NR_fstat
  1056. #include <unistd.h>
  1057. #define _SYS_STAT_H
  1058. #include <bits/stat.h>
  1059. #include <bits/kernel_stat.h>
  1060. #include "xstatconv.h"
  1061. _syscall2(int, __syscall_fstat, int, fd, struct kernel_stat *, buf);
  1062. int fstat(int fd, struct stat * buf)
  1063. {
  1064. int result;
  1065. struct kernel_stat kbuf;
  1066. result = __syscall_fstat(fd, &kbuf);
  1067. if (result == 0) {
  1068. __xstat_conv(&kbuf, buf);
  1069. }
  1070. return result;
  1071. }
  1072. #if ! defined __NR_fstat64 && defined __UCLIBC_HAS_LFS__
  1073. weak_alias(fstat, fstat64);
  1074. #endif
  1075. #endif
  1076. //#define __NR_olduname 109
  1077. //#define __NR_iopl 110
  1078. #ifdef L_iopl
  1079. /* For arm there is a totally different implementation */
  1080. #if !defined(__arm__)
  1081. /* Tuns out the m68k unistd.h kernel header is broken */
  1082. # if defined __UCLIBC_HAS_MMU__ && defined __NR_iopl && ( !defined(__mc68000__))
  1083. _syscall1(int, iopl, int, level);
  1084. # else
  1085. int iopl(int level)
  1086. {
  1087. __set_errno(ENOSYS);
  1088. return -1;
  1089. }
  1090. # endif
  1091. # endif
  1092. #endif
  1093. //#define __NR_vhangup 111
  1094. #ifdef L_vhangup
  1095. #include <unistd.h>
  1096. _syscall0(int, vhangup);
  1097. #endif
  1098. //#define __NR_idle 112
  1099. //int idle(void);
  1100. //#define __NR_vm86old 113
  1101. //#define __NR_wait4 114
  1102. #ifdef L___syscall_wait4
  1103. #define __NR___syscall_wait4 __NR_wait4
  1104. static inline
  1105. _syscall4(int, __syscall_wait4, __kernel_pid_t, pid, int *, status, int, opts, void *, rusage);
  1106. int wait4(pid_t pid, int * status, int opts, void * rusage)
  1107. {
  1108. return(__syscall_wait4(pid, status, opts, rusage));
  1109. }
  1110. #endif
  1111. //#define __NR_swapoff 115
  1112. #ifdef L_swapoff
  1113. #include <sys/swap.h>
  1114. _syscall1(int, swapoff, const char *, path);
  1115. #endif
  1116. //#define __NR_sysinfo 116
  1117. #ifdef L_sysinfo
  1118. #include <sys/sysinfo.h>
  1119. _syscall1(int, sysinfo, struct sysinfo *, info);
  1120. #endif
  1121. //#define __NR_ipc 117
  1122. #ifdef L___ipc
  1123. #ifdef __NR_ipc
  1124. #define __NR___ipc __NR_ipc
  1125. _syscall5(int, __ipc, unsigned int, call, int, first, int, second, int, third, void *, ptr);
  1126. #endif
  1127. #endif
  1128. //#define __NR_fsync 118
  1129. #ifdef L___libc_fsync
  1130. #include <unistd.h>
  1131. #define __NR___libc_fsync __NR_fsync
  1132. _syscall1(int, __libc_fsync, int, fd);
  1133. weak_alias(__libc_fsync, fsync)
  1134. #endif
  1135. //#define __NR_sigreturn 119
  1136. //int sigreturn(unsigned long __unused);
  1137. //#define __NR_clone 120
  1138. //See architecture specific implementation...
  1139. //#define __NR_setdomainname 121
  1140. #ifdef L_setdomainname
  1141. #include <unistd.h>
  1142. _syscall2(int, setdomainname, const char *, name, size_t, len);
  1143. #endif
  1144. //#define __NR_uname 122
  1145. #ifdef L_uname
  1146. #include <sys/utsname.h>
  1147. _syscall1(int, uname, struct utsname *, buf);
  1148. #endif
  1149. //#define __NR_modify_ldt 123
  1150. #ifdef __NR_modify_ldt
  1151. #ifdef L_modify_ldt
  1152. _syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount);
  1153. weak_alias(modify_ldt, __modify_ldt);
  1154. #endif
  1155. #endif
  1156. //#define __NR_adjtimex 124
  1157. #ifdef L_adjtimex
  1158. #include <sys/timex.h>
  1159. _syscall1(int, adjtimex, struct timex *, buf);
  1160. weak_alias(adjtimex, __adjtimex);
  1161. #endif
  1162. //#define __NR_mprotect 125
  1163. #ifdef L_mprotect
  1164. #include <sys/mman.h>
  1165. _syscall3(int, mprotect, void *, addr, size_t, len, int, prot);
  1166. #endif
  1167. //#define __NR_sigprocmask 126
  1168. #ifndef __NR_rt_sigprocmask
  1169. #ifdef L_sigprocmask
  1170. #include <signal.h>
  1171. #undef sigprocmask
  1172. _syscall3(int, sigprocmask, int, how, const sigset_t *, set,
  1173. sigset_t *, oldset);
  1174. #endif
  1175. #endif
  1176. //#define __NR_create_module 127
  1177. //See sysdeps/linux/commom/create_module.c
  1178. //#define __NR_init_module 128
  1179. #ifdef L_init_module
  1180. /* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
  1181. * (for 2.2 and 2.4 kernels). Use the greatest common denominator,
  1182. * and let the kernel cope with whatever it gets. It's good at that. */
  1183. _syscall5(int, init_module, void *, first, void *, second, void *, third,
  1184. void *, fourth, void *, fifth);
  1185. #endif
  1186. //#define __NR_delete_module 129
  1187. #ifdef L_delete_module
  1188. # ifdef __NR_delete_module
  1189. _syscall1(int, delete_module, const char *, name);
  1190. # else
  1191. int delete_module(const char * name)
  1192. {
  1193. __set_errno(ENOSYS);
  1194. return -1;
  1195. }
  1196. # endif
  1197. #endif
  1198. //#define __NR_get_kernel_syms 130
  1199. #ifdef L_get_kernel_syms
  1200. struct kernel_sym;
  1201. _syscall1(int, get_kernel_syms, struct kernel_sym *, table);
  1202. #endif
  1203. //#define __NR_quotactl 131
  1204. #ifdef __NR_quotactl
  1205. #ifdef L_quotactl
  1206. #include <sys/quota.h>
  1207. _syscall4(int, quotactl, int, cmd, const char *, special , int, id, caddr_t, addr);
  1208. #endif
  1209. #endif
  1210. //#define __NR_getpgid 132
  1211. #ifdef L___syscall_getpgid
  1212. #define __NR___syscall_getpgid __NR_getpgid
  1213. static inline
  1214. _syscall1(__kernel_pid_t, __syscall_getpgid, __kernel_pid_t, pid);
  1215. pid_t getpgid(pid_t pid)
  1216. {
  1217. return(__syscall_getpgid(pid));
  1218. }
  1219. #endif
  1220. //#define __NR_fchdir 133
  1221. #ifdef L_fchdir
  1222. #include <unistd.h>
  1223. _syscall1(int, fchdir, int, fd);
  1224. #endif
  1225. //#define __NR_bdflush 134
  1226. #ifdef L_bdflush
  1227. #include <sys/kdaemon.h>
  1228. _syscall2(int, bdflush, int, __func, long int, __data);
  1229. #endif
  1230. //#define __NR_sysfs 135
  1231. //#define __NR_personality 136
  1232. #ifdef __NR_personality
  1233. #ifdef L_personality
  1234. #include <sys/personality.h>
  1235. _syscall1(int, personality, unsigned long int, __persona);
  1236. #endif
  1237. #endif
  1238. //#define __NR_afs_syscall 137
  1239. //#define __NR_setfsuid 138
  1240. #ifdef __NR_setfsuid
  1241. #ifdef L___syscall_setfsuid
  1242. #include <sys/fsuid.h>
  1243. #define __NR___syscall_setfsuid __NR_setfsuid
  1244. static inline
  1245. _syscall1(int, __syscall_setfsuid, __kernel_uid_t, uid);
  1246. int setfsuid(uid_t uid)
  1247. {
  1248. return(__syscall_setfsuid(uid));
  1249. }
  1250. #endif
  1251. #endif
  1252. //#define __NR_setfsgid 139
  1253. #ifdef __NR_setfsgid
  1254. #ifdef L___syscall_setfsgid
  1255. #include <sys/fsuid.h>
  1256. #define __NR___syscall_setfsgid __NR_setfsgid
  1257. static inline
  1258. _syscall1(int, __syscall_setfsgid, __kernel_gid_t, gid);
  1259. int setfsgid(gid_t gid)
  1260. {
  1261. return(__syscall_setfsgid(gid));
  1262. }
  1263. #endif
  1264. #endif
  1265. //#define __NR__llseek 140
  1266. //See llseek.c
  1267. //#define __NR_getdents 141
  1268. // See getdents.c
  1269. //#define __NR__newselect 142
  1270. #ifdef L__newselect
  1271. //Used in preference to select when available...
  1272. #ifdef __NR__newselect
  1273. #include <unistd.h>
  1274. extern int _newselect(int n, fd_set *readfds, fd_set *writefds,
  1275. fd_set *exceptfds, struct timeval *timeout);
  1276. _syscall5(int, _newselect, int, n, fd_set *, readfds, fd_set *, writefds,
  1277. fd_set *, exceptfds, struct timeval *, timeout);
  1278. weak_alias(_newselect, select);
  1279. #endif
  1280. #endif
  1281. //#define __NR_flock 143
  1282. #ifdef L___syscall_flock
  1283. #include <sys/file.h>
  1284. #define __NR___syscall_flock __NR_flock
  1285. static inline
  1286. _syscall2(int, __syscall_flock, int, fd, int, operation);
  1287. int flock(int fd, int operation)
  1288. {
  1289. return(__syscall_flock(fd, operation));
  1290. }
  1291. #endif
  1292. //#define __NR_msync 144
  1293. #ifdef L___libc_msync
  1294. #include <unistd.h>
  1295. #include <sys/mman.h>
  1296. #define __NR___libc_msync __NR_msync
  1297. _syscall3(int, __libc_msync, void *, addr, size_t, length, int, flags);
  1298. weak_alias(__libc_msync, msync);
  1299. #endif
  1300. //#define __NR_readv 145
  1301. #ifdef L_readv
  1302. #include <sys/uio.h>
  1303. _syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector, int,
  1304. count);
  1305. #endif
  1306. //#define __NR_writev 146
  1307. #ifdef L_writev
  1308. #include <sys/uio.h>
  1309. _syscall3(ssize_t, writev, int, filedes, const struct iovec *, vector, int,
  1310. count);
  1311. #endif
  1312. //#define __NR_getsid 147
  1313. #ifdef L___syscall_getsid
  1314. #include <unistd.h>
  1315. #define __NR___syscall_getsid __NR_getsid
  1316. static inline
  1317. _syscall1(__kernel_pid_t, __syscall_getsid, __kernel_pid_t, pid);
  1318. pid_t getsid(pid_t pid)
  1319. {
  1320. return(__syscall_getsid(pid));
  1321. }
  1322. #endif
  1323. //#define __NR_fdatasync 148
  1324. #ifdef __NR_fdatasync
  1325. #ifdef L_fdatasync
  1326. #include <unistd.h>
  1327. _syscall1(int, fdatasync, int, fd);
  1328. #endif
  1329. #endif
  1330. //#define __NR__sysctl 149
  1331. #ifdef __NR__sysctl
  1332. #ifdef L__sysctl
  1333. struct __sysctl_args {
  1334. int *name;
  1335. int nlen;
  1336. void *oldval;
  1337. size_t *oldlenp;
  1338. void *newval;
  1339. size_t newlen;
  1340. unsigned long __unused[4];
  1341. };
  1342. _syscall1(int, _sysctl, struct __sysctl_args *, args);
  1343. int sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
  1344. void *newval, size_t newlen)
  1345. {
  1346. struct __sysctl_args args =
  1347. {
  1348. name: name,
  1349. nlen: nlen,
  1350. oldval: oldval,
  1351. oldlenp: oldlenp,
  1352. newval: newval,
  1353. newlen: newlen
  1354. };
  1355. return _sysctl(&args);
  1356. }
  1357. #endif
  1358. #endif
  1359. //#define __NR_mlock 150
  1360. #ifdef L_mlock
  1361. #include <sys/mman.h>
  1362. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlock
  1363. _syscall2(int, mlock, const void *, addr, size_t, len);
  1364. # endif
  1365. #endif
  1366. //#define __NR_munlock 151
  1367. #ifdef L_munlock
  1368. #include <sys/mman.h>
  1369. # if defined __UCLIBC_HAS_MMU__ && defined __NR_munlock
  1370. _syscall2(int, munlock, const void *, addr, size_t, len);
  1371. # endif
  1372. #endif
  1373. //#define __NR_mlockall 152
  1374. #ifdef L_mlockall
  1375. #include <sys/mman.h>
  1376. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlockall
  1377. _syscall1(int, mlockall, int, flags);
  1378. # endif
  1379. #endif
  1380. //#define __NR_munlockall 153
  1381. #ifdef L_munlockall
  1382. #include <sys/mman.h>
  1383. # if defined __UCLIBC_HAS_MMU__ && defined L_munlockall
  1384. _syscall0(int, munlockall);
  1385. # endif
  1386. #endif
  1387. //#define __NR_sched_setparam 154
  1388. #ifdef __NR_sched_setparam
  1389. #ifdef L___syscall_sched_setparam
  1390. #include <sched.h>
  1391. #define __NR___syscall_sched_setparam __NR_sched_setparam
  1392. static inline
  1393. _syscall2(int, __syscall_sched_setparam, __kernel_pid_t, pid, const struct sched_param *, p);
  1394. int sched_setparam(pid_t pid, const struct sched_param * p)
  1395. {
  1396. return(__syscall_sched_setparam(pid, p));
  1397. }
  1398. #endif
  1399. #endif
  1400. //#define __NR_sched_getparam 155
  1401. #ifdef __NR_sched_getparam
  1402. #ifdef L___syscall_sched_getparam
  1403. #include <sched.h>
  1404. #define __NR___syscall_sched_getparam __NR_sched_getparam
  1405. static inline
  1406. _syscall2(int, __syscall_sched_getparam, __kernel_pid_t, pid, struct sched_param *, p);
  1407. int sched_getparam(pid_t pid, struct sched_param * p)
  1408. {
  1409. return(__syscall_sched_getparam(pid, p));
  1410. }
  1411. #endif
  1412. #endif
  1413. //#define __NR_sched_setscheduler 156
  1414. #ifdef __NR_sched_setscheduler
  1415. #ifdef L___syscall_sched_setscheduler
  1416. #include <sched.h>
  1417. #define __NR___syscall_sched_setscheduler __NR_sched_setscheduler
  1418. static inline
  1419. _syscall3(int, __syscall_sched_setscheduler, __kernel_pid_t, pid, int, policy, const struct sched_param *, p);
  1420. int sched_setscheduler(pid_t pid, int policy, const struct sched_param * p)
  1421. {
  1422. return(__syscall_sched_setscheduler(pid, policy, p));
  1423. }
  1424. #endif
  1425. #endif
  1426. //#define __NR_sched_getscheduler 157
  1427. #ifdef __NR_sched_getscheduler
  1428. #ifdef L___syscall_sched_getscheduler
  1429. #include <sched.h>
  1430. #define __NR___syscall_sched_getscheduler __NR_sched_getscheduler
  1431. static inline
  1432. _syscall1(int, __syscall_sched_getscheduler, __kernel_pid_t, pid);
  1433. int sched_getscheduler(pid_t pid)
  1434. {
  1435. return(__syscall_sched_getscheduler(pid));
  1436. }
  1437. #endif
  1438. #endif
  1439. //#define __NR_sched_yield 158
  1440. #ifdef __NR_sched_yield
  1441. #ifdef L_sched_yield
  1442. #include <sched.h>
  1443. _syscall0(int, sched_yield);
  1444. #endif
  1445. #endif
  1446. //#define __NR_sched_get_priority_max 159
  1447. #ifdef __NR_sched_get_priority_max
  1448. #ifdef L_sched_get_priority_max
  1449. #include <sched.h>
  1450. _syscall1(int, sched_get_priority_max, int, policy);
  1451. #endif
  1452. #endif
  1453. //#define __NR_sched_get_priority_min 160
  1454. #ifdef __NR_sched_get_priority_min
  1455. #ifdef L_sched_get_priority_min
  1456. #include <sched.h>
  1457. _syscall1(int, sched_get_priority_min, int, policy);
  1458. #endif
  1459. #endif
  1460. //#define __NR_sched_rr_get_interval 161
  1461. #ifdef __NR_sched_rr_get_interval
  1462. #ifdef L___syscall_sched_rr_get_interval
  1463. #include <sched.h>
  1464. #define __NR___syscall_sched_rr_get_interval __NR_sched_rr_get_interval
  1465. static inline
  1466. _syscall2(int, __syscall_sched_rr_get_interval, __kernel_pid_t, pid, struct timespec *, tp);
  1467. int sched_rr_get_interval(pid_t pid, struct timespec * tp)
  1468. {
  1469. return(__syscall_sched_rr_get_interval(pid, tp));
  1470. }
  1471. #endif
  1472. #endif
  1473. //#define __NR_nanosleep 162
  1474. #ifdef L___libc_nanosleep
  1475. #include <time.h>
  1476. #define __NR___libc_nanosleep __NR_nanosleep
  1477. _syscall2(int, __libc_nanosleep, const struct timespec *, req, struct timespec *, rem);
  1478. weak_alias(__libc_nanosleep, nanosleep)
  1479. #endif
  1480. //#define __NR_mremap 163
  1481. #ifdef L_mremap
  1482. #include <unistd.h>
  1483. #include <sys/mman.h>
  1484. _syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t, new_size, int, may_move);
  1485. #endif
  1486. //#define __NR_setresuid 164
  1487. #ifdef __NR_setresuid
  1488. #ifdef L___syscall_setresuid
  1489. #define __NR___syscall_setresuid __NR_setresuid
  1490. static inline
  1491. _syscall3(int, __syscall_setresuid, __kernel_uid_t, rgid, __kernel_uid_t, egid, __kernel_uid_t, sgid);
  1492. int setresuid(uid_t ruid, uid_t euid, uid_t suid)
  1493. {
  1494. return(__syscall_setresuid(ruid, euid, suid));
  1495. }
  1496. #endif
  1497. #endif
  1498. //#define __NR_getresuid 165
  1499. #ifdef __NR_getresuid
  1500. #ifdef L___syscall_getresuid
  1501. #define __NR___syscall_getresuid __NR_getresuid
  1502. static inline
  1503. _syscall3(int, __syscall_getresuid, __kernel_uid_t *, ruid, __kernel_uid_t *, euid, __kernel_uid_t *, suid);
  1504. int getresuid (uid_t *ruid, uid_t *euid, uid_t *suid)
  1505. {
  1506. int result;
  1507. __kernel_uid_t k_ruid, k_euid, k_suid;
  1508. result = __syscall_getresuid(&k_ruid, &k_euid, &k_suid);
  1509. if (result == 0) {
  1510. *ruid = (uid_t) k_ruid;
  1511. *euid = (uid_t) k_euid;
  1512. *suid = (uid_t) k_suid;
  1513. }
  1514. return result;
  1515. }
  1516. #endif
  1517. #endif
  1518. //#define __NR_vm86 166
  1519. //#define __NR_query_module 167
  1520. #ifdef L_query_module
  1521. # ifdef __NR_query_module
  1522. _syscall5(int, query_module, const char *, name, int, which,
  1523. void *, buf, size_t, bufsize, size_t*, ret);
  1524. # else
  1525. int query_module(const char * name, int which,
  1526. void * buf, size_t bufsize, size_t* ret)
  1527. {
  1528. __set_errno(ENOSYS);
  1529. return -1;
  1530. }
  1531. # endif
  1532. #endif
  1533. //#define __NR_poll 168
  1534. #ifdef L_poll
  1535. #ifdef __NR_poll
  1536. #include <sys/poll.h>
  1537. _syscall3(int, poll, struct pollfd *, fds, unsigned long int, nfds, int, timeout);
  1538. #else
  1539. /* uClinux 2.0 doesn't have poll, emulate it using select */
  1540. #include "poll.c"
  1541. #endif
  1542. #endif
  1543. //#define __NR_nfsservctl 169
  1544. //nfsservctl EXTRA nfsservctl i:ipp nfsservctl
  1545. //#define __NR_setresgid 170
  1546. #ifdef __NR_setresgid
  1547. #ifdef L___syscall_setresgid
  1548. #define __NR___syscall_setresgid __NR_setresgid
  1549. static inline
  1550. _syscall3(int, __syscall_setresgid, __kernel_gid_t, rgid, __kernel_gid_t, egid, __kernel_gid_t, sgid);
  1551. int setresgid(gid_t rgid, gid_t egid, gid_t sgid)
  1552. {
  1553. return(__syscall_setresgid(rgid, egid, sgid));
  1554. }
  1555. #endif
  1556. #endif
  1557. //#define __NR_getresgid 171
  1558. #ifdef __NR_getresgid
  1559. #ifdef L___syscall_getresgid
  1560. #define __NR___syscall_getresgid __NR_getresgid
  1561. static inline
  1562. _syscall3(int, __syscall_getresgid, __kernel_gid_t *, egid, __kernel_gid_t *, rgid, __kernel_gid_t *, sgid);
  1563. int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid)
  1564. {
  1565. int result;
  1566. __kernel_gid_t k_rgid, k_egid, k_sgid;
  1567. result = __syscall_getresgid(&k_rgid, &k_egid, &k_sgid);
  1568. if (result == 0) {
  1569. *rgid = (gid_t) k_rgid;
  1570. *egid = (gid_t) k_egid;
  1571. *sgid = (gid_t) k_sgid;
  1572. }
  1573. return result;
  1574. }
  1575. #endif
  1576. #endif
  1577. //#define __NR_prctl 172
  1578. #ifdef __NR_prctl
  1579. #ifdef L_prctl
  1580. #include <stdarg.h>
  1581. //#include <sys/prctl.h>
  1582. _syscall5(int, prctl, int, a, int, b, int, c, int, d, int, e);
  1583. #endif
  1584. #endif
  1585. //#define __NR_rt_sigreturn 173
  1586. //#define __NR_rt_sigaction 174
  1587. #ifdef __NR_rt_sigaction
  1588. #define __NR___syscall_rt_sigaction __NR_rt_sigaction
  1589. #ifdef L___syscall_rt_sigaction
  1590. #include <signal.h>
  1591. #undef sigaction
  1592. _syscall4(int, __syscall_rt_sigaction, int, signum, const struct sigaction *, act,
  1593. struct sigaction *, oldact, size_t, size);
  1594. #endif
  1595. #endif
  1596. //#define __NR_rt_sigprocmask 175
  1597. #ifdef __NR_rt_sigprocmask
  1598. #define __NR___rt_sigprocmask __NR_rt_sigprocmask
  1599. #ifdef L___rt_sigprocmask
  1600. #include <signal.h>
  1601. #undef sigprocmask
  1602. _syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
  1603. sigset_t *, oldset, size_t, size);
  1604. int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
  1605. {
  1606. return __rt_sigprocmask(how, set, oldset, _NSIG/8);
  1607. }
  1608. #endif
  1609. #endif
  1610. //#define __NR_rt_sigpending 176
  1611. #ifdef __NR_rt_sigpending
  1612. #define __NR___rt_sigpending __NR_rt_sigpending
  1613. #ifdef L___rt_sigpending
  1614. #include <signal.h>
  1615. #undef sigpending
  1616. _syscall2(int, __rt_sigpending, sigset_t *, set, size_t, size);
  1617. int sigpending(sigset_t *set)
  1618. {
  1619. return __rt_sigpending(set, _NSIG/8);
  1620. }
  1621. #endif
  1622. #endif
  1623. //#define __NR_rt_sigtimedwait 177
  1624. #ifdef L___rt_sigtimedwait
  1625. #include <signal.h>
  1626. #define __need_NULL
  1627. #include <stddef.h>
  1628. #ifdef __NR_rt_sigtimedwait
  1629. #define __NR___rt_sigtimedwait __NR_rt_sigtimedwait
  1630. _syscall4(int, __rt_sigtimedwait, const sigset_t *, set, siginfo_t *, info,
  1631. const struct timespec *, timeout, size_t, setsize);
  1632. int sigwaitinfo(const sigset_t *set, siginfo_t *info)
  1633. {
  1634. return __rt_sigtimedwait (set, info, NULL, _NSIG/8);
  1635. }
  1636. int sigtimedwait (const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
  1637. {
  1638. return __rt_sigtimedwait (set, info, timeout, _NSIG/8);
  1639. }
  1640. #else
  1641. int sigwaitinfo(const sigset_t *set, siginfo_t *info)
  1642. {
  1643. if (set==NULL)
  1644. __set_errno (EINVAL);
  1645. else
  1646. __set_errno (ENOSYS);
  1647. return -1;
  1648. }
  1649. int sigtimedwait (const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
  1650. {
  1651. if (set==NULL)
  1652. __set_errno (EINVAL);
  1653. else
  1654. __set_errno (ENOSYS);
  1655. return -1;
  1656. }
  1657. #endif
  1658. #endif
  1659. //#define __NR_rt_sigqueueinfo 178
  1660. //#define __NR_rt_sigsuspend 179
  1661. #ifdef __NR_rt_sigsuspend
  1662. #define __NR___rt_sigsuspend __NR_rt_sigsuspend
  1663. #ifdef L___rt_sigsuspend
  1664. #include <signal.h>
  1665. #undef _sigsuspend
  1666. _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size);
  1667. int sigsuspend (const sigset_t *mask)
  1668. {
  1669. return __rt_sigsuspend(mask, _NSIG/8);
  1670. }
  1671. #endif
  1672. #endif
  1673. //#define __NR_pread 180
  1674. // See pread_write.c
  1675. //#define __NR_pwrite 181
  1676. // See pread_write.c
  1677. //#define __NR_chown 182
  1678. #ifdef L___syscall_chown
  1679. #include <unistd.h>
  1680. #define __NR___syscall_chown __NR_chown
  1681. static inline
  1682. _syscall3(int, __syscall_chown, const char *, path, __kernel_uid_t, owner, __kernel_gid_t, group);
  1683. int chown(const char * path, uid_t owner, gid_t group)
  1684. {
  1685. return(__syscall_chown(path, owner, group));
  1686. }
  1687. #endif
  1688. //#define __NR_getcwd 183
  1689. // See getcwd.c in this directory
  1690. //#define __NR_capget 184
  1691. #ifdef L_capget
  1692. # ifdef __NR_capget
  1693. _syscall2(int, capget, void*, header, void*, data);
  1694. # else
  1695. int capget(void* header, void* data)
  1696. {
  1697. __set_errno(ENOSYS);
  1698. return -1;
  1699. }
  1700. # endif
  1701. #endif
  1702. //#define __NR_capset 185
  1703. #ifdef L_capset
  1704. # ifdef __NR_capset
  1705. _syscall2(int, capset, void*, header, const void*, data);
  1706. # else
  1707. int capset(void* header, const void* data)
  1708. {
  1709. __set_errno(ENOSYS);
  1710. return -1;
  1711. }
  1712. # endif
  1713. #endif
  1714. //#define __NR_sigaltstack 186
  1715. #ifdef __NR_sigaltstack
  1716. #ifdef L_sigaltstack
  1717. #include <signal.h>
  1718. _syscall2(int, sigaltstack, const struct sigaltstack *, ss, struct sigaltstack *, oss);
  1719. #endif
  1720. #endif
  1721. //#define __NR_sendfile 187
  1722. #ifdef __NR_sendfile
  1723. #ifdef L_sendfile
  1724. #include <unistd.h>
  1725. #include <sys/sendfile.h>
  1726. _syscall4(ssize_t,sendfile, int, out_fd, int, in_fd, __off_t *, offset, size_t, count);
  1727. #endif
  1728. #endif
  1729. //#define __NR_getpmsg 188
  1730. //#define __NR_putpmsg 189
  1731. //#define __NR_vfork 190
  1732. //See sysdeps/linux/<arch>vfork.[cS] for architecture specific implementation...
  1733. //#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
  1734. #ifdef L___ugetrlimit
  1735. #ifdef __NR_ugetrlimit
  1736. #define __NR___ugetrlimit __NR_ugetrlimit
  1737. #include <unistd.h>
  1738. #include <sys/resource.h>
  1739. _syscall2(int, __ugetrlimit, enum __rlimit_resource, resource, struct rlimit *, rlim);
  1740. int getrlimit (__rlimit_resource_t resource, struct rlimit *rlimits)
  1741. {
  1742. return(__ugetrlimit(resource, rlimits));
  1743. }
  1744. #endif /* __NR_ugetrlimit */
  1745. #endif
  1746. //#define __NR_mmap2 192
  1747. //#define __NR_truncate64 193
  1748. //See libc/sysdeps/linux/common/truncate64.c
  1749. //#define __NR_ftruncate64 194
  1750. //See libc/sysdeps/linux/common/ftruncate64.c
  1751. //#define __NR_stat64 195
  1752. #ifdef L___syscall_stat64
  1753. #if defined __UCLIBC_HAS_LFS__ && defined __NR_stat64
  1754. #define __NR___syscall_stat64 __NR_stat64
  1755. #include <unistd.h>
  1756. #include <sys/stat.h>
  1757. #include <bits/kernel_stat.h>
  1758. #include "xstatconv.h"
  1759. _syscall2(int, __syscall_stat64, const char *, file_name, struct kernel_stat64 *, buf);
  1760. int stat64(const char * file_name, struct stat64 * buf)
  1761. {
  1762. int result;
  1763. struct kernel_stat64 kbuf;
  1764. result = __syscall_stat64(file_name, &kbuf);
  1765. if (result == 0) {
  1766. __xstat64_conv(&kbuf, buf);
  1767. }
  1768. return result;
  1769. }
  1770. #endif /* __UCLIBC_HAS_LFS__ */
  1771. #endif
  1772. //#define __NR_lstat64 196
  1773. #ifdef L___syscall_lstat64
  1774. #if defined __UCLIBC_HAS_LFS__ && defined __NR_lstat64
  1775. #define __NR___syscall_lstat64 __NR_lstat64
  1776. #include <unistd.h>
  1777. #include <sys/stat.h>
  1778. #include <bits/kernel_stat.h>
  1779. #include "xstatconv.h"
  1780. _syscall2(int, __syscall_lstat64, const char *, file_name, struct kernel_stat64 *, buf);
  1781. int lstat64(const char * file_name, struct stat64 * buf)
  1782. {
  1783. int result;
  1784. struct kernel_stat64 kbuf;
  1785. result = __syscall_lstat64(file_name, &kbuf);
  1786. if (result == 0) {
  1787. __xstat64_conv(&kbuf, buf);
  1788. }
  1789. return result;
  1790. }
  1791. #endif /* __UCLIBC_HAS_LFS__ */
  1792. #endif
  1793. //#define __NR_fstat64 197
  1794. #ifdef L___syscall_fstat64
  1795. #if defined __UCLIBC_HAS_LFS__ && defined __NR_fstat64
  1796. #define __NR___syscall_fstat64 __NR_fstat64
  1797. #include <unistd.h>
  1798. #include <sys/stat.h>
  1799. #include <bits/kernel_stat.h>
  1800. #include "xstatconv.h"
  1801. _syscall2(int, __syscall_fstat64, int, filedes, struct kernel_stat64 *, buf);
  1802. int fstat64(int fd, struct stat64 * buf)
  1803. {
  1804. int result;
  1805. struct kernel_stat64 kbuf;
  1806. result = __syscall_fstat64(fd, &kbuf);
  1807. if (result == 0) {
  1808. __xstat64_conv(&kbuf, buf);
  1809. }
  1810. return result;
  1811. }
  1812. #endif /* __UCLIBC_HAS_LFS__ */
  1813. #endif
  1814. //#define __NR_lchown32 198
  1815. //#define __NR_getuid32 199
  1816. //#define __NR_getgid32 200
  1817. //#define __NR_geteuid32 201
  1818. //#define __NR_getegid32 202
  1819. //#define __NR_setreuid32 203
  1820. //#define __NR_setregid32 204
  1821. //#define __NR_getgroups32 205
  1822. //#define __NR_setgroups32 206
  1823. //#define __NR_fchown32 207
  1824. //#define __NR_setresuid32 208
  1825. //#define __NR_getresuid32 209
  1826. //#define __NR_setresgid32 210
  1827. //#define __NR_getresgid32 211
  1828. //#define __NR_chown32 212
  1829. //#define __NR_setuid32 213
  1830. //#define __NR_setgid32 214
  1831. //#define __NR_setfsuid32 215
  1832. //#define __NR_setfsgid32 216
  1833. //#define __NR_pivot_root 217
  1834. #ifdef __NR_pivot_root
  1835. #ifdef L_pivot_root
  1836. _syscall2(int, pivot_root, const char *, new_root, const char *, put_old);
  1837. #endif
  1838. #endif
  1839. //#define __NR_mincore 218
  1840. //#define __NR_madvise 219
  1841. #ifdef __NR_madvise
  1842. #ifdef L_madvise
  1843. _syscall3(int, madvise, void*, __addr, size_t, __len, int, __advice);
  1844. #endif
  1845. #endif
  1846. //#define __NR_madvise1 219 /* delete when C lib stub is removed */
  1847. //#define __NR_getdents64 220
  1848. // See getdents64.c
  1849. //#define __NR_fcntl64 221
  1850. #ifdef L___syscall_fcntl64
  1851. #include <stdarg.h>
  1852. #include <fcntl.h>
  1853. #if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
  1854. #define __NR___syscall_fcntl64 __NR_fcntl64
  1855. static inline
  1856. _syscall3(int, __syscall_fcntl64, int, fd, int, cmd, long, arg);
  1857. #else
  1858. #define __syscall_fcntl64 __syscall_fcntl
  1859. extern int __syscall_fcntl(int fd, int cmd, ...);
  1860. #endif
  1861. int __libc_fcntl64(int fd, int cmd, ...)
  1862. {
  1863. long arg;
  1864. va_list list;
  1865. va_start(list, cmd);
  1866. arg = va_arg(list, long);
  1867. va_end(list);
  1868. return(__syscall_fcntl64(fd, cmd, arg));
  1869. }
  1870. weak_alias(__libc_fcntl64, fcntl64)
  1871. #endif
  1872. //#define __NR_security 223 /* syscall for security modules */
  1873. //#define __NR_gettid 224
  1874. //#define __NR_readahead 225