syscalls.c 49 KB

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