unistd.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #include <AK/ScopedValueRollback.h>
  27. #include <AK/String.h>
  28. #include <AK/Vector.h>
  29. #include <Kernel/Syscall.h>
  30. #include <alloca.h>
  31. #include <assert.h>
  32. #include <errno.h>
  33. #include <fcntl.h>
  34. #include <grp.h>
  35. #include <pwd.h>
  36. #include <stdarg.h>
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40. #include <sys/ioctl.h>
  41. #include <sys/types.h>
  42. #include <termios.h>
  43. #include <unistd.h>
  44. extern "C" {
  45. int systrace(pid_t pid)
  46. {
  47. int rc = syscall(SC_systrace, pid);
  48. __RETURN_WITH_ERRNO(rc, rc, -1);
  49. }
  50. int chown(const char* pathname, uid_t uid, gid_t gid)
  51. {
  52. if (!pathname) {
  53. errno = EFAULT;
  54. return -1;
  55. }
  56. Syscall::SC_chown_params params { { pathname, strlen(pathname) }, uid, gid };
  57. int rc = syscall(SC_chown, &params);
  58. __RETURN_WITH_ERRNO(rc, rc, -1);
  59. }
  60. int fchown(int fd, uid_t uid, gid_t gid)
  61. {
  62. int rc = syscall(SC_fchown, fd, uid, gid);
  63. __RETURN_WITH_ERRNO(rc, rc, -1);
  64. }
  65. pid_t fork()
  66. {
  67. int rc = syscall(SC_fork);
  68. __RETURN_WITH_ERRNO(rc, rc, -1);
  69. }
  70. int execv(const char* path, char* const argv[])
  71. {
  72. return execve(path, argv, environ);
  73. }
  74. int execve(const char* filename, char* const argv[], char* const envp[])
  75. {
  76. size_t arg_count = 0;
  77. for (size_t i = 0; argv[i]; ++i)
  78. ++arg_count;
  79. size_t env_count = 0;
  80. for (size_t i = 0; envp[i]; ++i)
  81. ++env_count;
  82. auto copy_strings = [&](auto& vec, size_t count, auto& output) {
  83. output.length = count;
  84. for (size_t i = 0; vec[i]; ++i) {
  85. output.strings[i].characters = vec[i];
  86. output.strings[i].length = strlen(vec[i]);
  87. }
  88. };
  89. Syscall::SC_execve_params params;
  90. params.arguments.strings = (Syscall::StringArgument*)alloca(arg_count * sizeof(Syscall::StringArgument));
  91. params.environment.strings = (Syscall::StringArgument*)alloca(env_count * sizeof(Syscall::StringArgument));
  92. params.path = { filename, strlen(filename) };
  93. copy_strings(argv, arg_count, params.arguments);
  94. copy_strings(envp, env_count, params.environment);
  95. int rc = syscall(SC_execve, &params);
  96. __RETURN_WITH_ERRNO(rc, rc, -1);
  97. }
  98. int execvpe(const char* filename, char* const argv[], char* const envp[])
  99. {
  100. if (strchr(filename, '/'))
  101. return execve(filename, argv, envp);
  102. ScopedValueRollback errno_rollback(errno);
  103. String path = getenv("PATH");
  104. if (path.is_empty())
  105. path = "/bin:/usr/bin";
  106. auto parts = path.split(':');
  107. for (auto& part : parts) {
  108. auto candidate = String::format("%s/%s", part.characters(), filename);
  109. int rc = execve(candidate.characters(), argv, envp);
  110. if (rc < 0 && errno != ENOENT) {
  111. errno_rollback.set_override_rollback_value(errno);
  112. dbg() << "execvpe() failed on attempt (" << candidate << ") with " << strerror(errno);
  113. return rc;
  114. }
  115. }
  116. errno_rollback.set_override_rollback_value(ENOENT);
  117. dbg() << "execvpe() leaving :(";
  118. return -1;
  119. }
  120. int execvp(const char* filename, char* const argv[])
  121. {
  122. int rc = execvpe(filename, argv, environ);
  123. dbg() << "execvp() about to return " << rc << " with errno=" << errno;
  124. return rc;
  125. }
  126. int execl(const char* filename, const char* arg0, ...)
  127. {
  128. Vector<const char*, 16> args;
  129. args.append(arg0);
  130. va_list ap;
  131. va_start(ap, arg0);
  132. for (;;) {
  133. const char* arg = va_arg(ap, const char*);
  134. if (!arg)
  135. break;
  136. args.append(arg);
  137. }
  138. va_end(ap);
  139. args.append(nullptr);
  140. return execve(filename, const_cast<char* const*>(args.data()), environ);
  141. }
  142. int execlp(const char* filename, const char* arg0, ...)
  143. {
  144. Vector<const char*, 16> args;
  145. args.append(arg0);
  146. va_list ap;
  147. va_start(ap, arg0);
  148. for (;;) {
  149. const char* arg = va_arg(ap, const char*);
  150. if (!arg)
  151. break;
  152. args.append(arg);
  153. }
  154. va_end(ap);
  155. args.append(nullptr);
  156. return execvpe(filename, const_cast<char* const*>(args.data()), environ);
  157. }
  158. uid_t getuid()
  159. {
  160. return syscall(SC_getuid);
  161. }
  162. gid_t getgid()
  163. {
  164. return syscall(SC_getgid);
  165. }
  166. uid_t geteuid()
  167. {
  168. return syscall(SC_geteuid);
  169. }
  170. gid_t getegid()
  171. {
  172. return syscall(SC_getegid);
  173. }
  174. pid_t getpid()
  175. {
  176. return syscall(SC_getpid);
  177. }
  178. pid_t getppid()
  179. {
  180. return syscall(SC_getppid);
  181. }
  182. pid_t getsid(pid_t pid)
  183. {
  184. int rc = syscall(SC_getsid, pid);
  185. __RETURN_WITH_ERRNO(rc, rc, -1);
  186. }
  187. pid_t setsid()
  188. {
  189. int rc = syscall(SC_setsid);
  190. __RETURN_WITH_ERRNO(rc, rc, -1);
  191. }
  192. pid_t tcgetpgrp(int fd)
  193. {
  194. return ioctl(fd, TIOCGPGRP);
  195. }
  196. int tcsetpgrp(int fd, pid_t pgid)
  197. {
  198. return ioctl(fd, TIOCSPGRP, pgid);
  199. }
  200. int setpgid(pid_t pid, pid_t pgid)
  201. {
  202. int rc = syscall(SC_setpgid, pid, pgid);
  203. __RETURN_WITH_ERRNO(rc, rc, -1);
  204. }
  205. pid_t getpgid(pid_t pid)
  206. {
  207. int rc = syscall(SC_getpgid, pid);
  208. __RETURN_WITH_ERRNO(rc, rc, -1);
  209. }
  210. pid_t getpgrp()
  211. {
  212. int rc = syscall(SC_getpgrp);
  213. __RETURN_WITH_ERRNO(rc, rc, -1);
  214. }
  215. ssize_t read(int fd, void* buf, size_t count)
  216. {
  217. int rc = syscall(SC_read, fd, buf, count);
  218. __RETURN_WITH_ERRNO(rc, rc, -1);
  219. }
  220. ssize_t write(int fd, const void* buf, size_t count)
  221. {
  222. int rc = syscall(SC_write, fd, buf, count);
  223. __RETURN_WITH_ERRNO(rc, rc, -1);
  224. }
  225. int ttyname_r(int fd, char* buffer, size_t size)
  226. {
  227. int rc = syscall(SC_ttyname_r, fd, buffer, size);
  228. __RETURN_WITH_ERRNO(rc, rc, -1);
  229. }
  230. static char ttyname_buf[32];
  231. char* ttyname(int fd)
  232. {
  233. if (ttyname_r(fd, ttyname_buf, sizeof(ttyname_buf)) < 0)
  234. return nullptr;
  235. return ttyname_buf;
  236. }
  237. int close(int fd)
  238. {
  239. int rc = syscall(SC_close, fd);
  240. __RETURN_WITH_ERRNO(rc, rc, -1);
  241. }
  242. static int do_stat(const char* path, struct stat* statbuf, bool follow_symlinks)
  243. {
  244. if (!path) {
  245. errno = EFAULT;
  246. return -1;
  247. }
  248. Syscall::SC_stat_params params { { path, strlen(path) }, statbuf, follow_symlinks };
  249. int rc = syscall(SC_stat, &params);
  250. __RETURN_WITH_ERRNO(rc, rc, -1);
  251. }
  252. int lstat(const char* path, struct stat* statbuf)
  253. {
  254. return do_stat(path, statbuf, false);
  255. }
  256. int stat(const char* path, struct stat* statbuf)
  257. {
  258. return do_stat(path, statbuf, true);
  259. }
  260. int fstat(int fd, struct stat* statbuf)
  261. {
  262. int rc = syscall(SC_fstat, fd, statbuf);
  263. __RETURN_WITH_ERRNO(rc, rc, -1);
  264. }
  265. int chdir(const char* path)
  266. {
  267. if (!path) {
  268. errno = EFAULT;
  269. return -1;
  270. }
  271. int rc = syscall(SC_chdir, path, strlen(path));
  272. __RETURN_WITH_ERRNO(rc, rc, -1);
  273. }
  274. int fchdir(int fd)
  275. {
  276. int rc = syscall(SC_fchdir, fd);
  277. __RETURN_WITH_ERRNO(rc, rc, -1);
  278. }
  279. char* getcwd(char* buffer, size_t size)
  280. {
  281. if (!buffer) {
  282. size = size ? size : PATH_MAX;
  283. buffer = (char*)malloc(size);
  284. }
  285. int rc = syscall(SC_getcwd, buffer, size);
  286. __RETURN_WITH_ERRNO(rc, buffer, nullptr);
  287. }
  288. char* getwd(char* buf)
  289. {
  290. auto* p = getcwd(buf, PATH_MAX);
  291. return p;
  292. }
  293. int sleep(unsigned seconds)
  294. {
  295. return syscall(SC_sleep, seconds);
  296. }
  297. int usleep(useconds_t usec)
  298. {
  299. return syscall(SC_usleep, usec);
  300. }
  301. int gethostname(char* buffer, size_t size)
  302. {
  303. int rc = syscall(SC_gethostname, buffer, size);
  304. __RETURN_WITH_ERRNO(rc, rc, -1);
  305. }
  306. ssize_t readlink(const char* path, char* buffer, size_t size)
  307. {
  308. Syscall::SC_readlink_params params { { path, strlen(path) }, { buffer, size } };
  309. int rc = syscall(SC_readlink, &params);
  310. __RETURN_WITH_ERRNO(rc, rc, -1);
  311. }
  312. off_t lseek(int fd, off_t offset, int whence)
  313. {
  314. int rc = syscall(SC_lseek, fd, offset, whence);
  315. __RETURN_WITH_ERRNO(rc, rc, -1);
  316. }
  317. int link(const char* old_path, const char* new_path)
  318. {
  319. if (!old_path || !new_path) {
  320. errno = EFAULT;
  321. return -1;
  322. }
  323. Syscall::SC_link_params params { { old_path, strlen(old_path) }, { new_path, strlen(new_path) } };
  324. int rc = syscall(SC_link, &params);
  325. __RETURN_WITH_ERRNO(rc, rc, -1);
  326. }
  327. int unlink(const char* pathname)
  328. {
  329. int rc = syscall(SC_unlink, pathname, strlen(pathname));
  330. __RETURN_WITH_ERRNO(rc, rc, -1);
  331. }
  332. int symlink(const char* target, const char* linkpath)
  333. {
  334. if (!target || !linkpath) {
  335. errno = EFAULT;
  336. return -1;
  337. }
  338. Syscall::SC_symlink_params params { { target, strlen(target) }, { linkpath, strlen(linkpath) } };
  339. int rc = syscall(SC_symlink, &params);
  340. __RETURN_WITH_ERRNO(rc, rc, -1);
  341. }
  342. int rmdir(const char* pathname)
  343. {
  344. if (!pathname) {
  345. errno = EFAULT;
  346. return -1;
  347. }
  348. int rc = syscall(SC_rmdir, pathname, strlen(pathname));
  349. __RETURN_WITH_ERRNO(rc, rc, -1);
  350. }
  351. int isatty(int fd)
  352. {
  353. struct termios dummy;
  354. return tcgetattr(fd, &dummy) == 0;
  355. }
  356. int getdtablesize()
  357. {
  358. int rc = syscall(SC_getdtablesize);
  359. __RETURN_WITH_ERRNO(rc, rc, -1);
  360. }
  361. int dup(int old_fd)
  362. {
  363. int rc = syscall(SC_dup, old_fd);
  364. __RETURN_WITH_ERRNO(rc, rc, -1);
  365. }
  366. int dup2(int old_fd, int new_fd)
  367. {
  368. int rc = syscall(SC_dup2, old_fd, new_fd);
  369. __RETURN_WITH_ERRNO(rc, rc, -1);
  370. }
  371. int setgroups(size_t size, const gid_t* list)
  372. {
  373. int rc = syscall(SC_setgroups, size, list);
  374. __RETURN_WITH_ERRNO(rc, rc, -1);
  375. }
  376. int getgroups(int size, gid_t list[])
  377. {
  378. int rc = syscall(SC_getgroups, size, list);
  379. __RETURN_WITH_ERRNO(rc, rc, -1);
  380. }
  381. int pipe(int pipefd[2])
  382. {
  383. return pipe2(pipefd, 0);
  384. }
  385. int pipe2(int pipefd[2], int flags)
  386. {
  387. int rc = syscall(SC_pipe, pipefd, flags);
  388. __RETURN_WITH_ERRNO(rc, rc, -1);
  389. }
  390. unsigned int alarm(unsigned int seconds)
  391. {
  392. return syscall(SC_alarm, seconds);
  393. }
  394. int setuid(uid_t uid)
  395. {
  396. int rc = syscall(SC_setuid, uid);
  397. __RETURN_WITH_ERRNO(rc, rc, -1);
  398. }
  399. int setgid(uid_t gid)
  400. {
  401. int rc = syscall(SC_setgid, gid);
  402. __RETURN_WITH_ERRNO(rc, rc, -1);
  403. }
  404. int access(const char* pathname, int mode)
  405. {
  406. if (!pathname) {
  407. errno = EFAULT;
  408. return -1;
  409. }
  410. int rc = syscall(SC_access, pathname, strlen(pathname), mode);
  411. __RETURN_WITH_ERRNO(rc, rc, -1);
  412. }
  413. int mknod(const char* pathname, mode_t mode, dev_t dev)
  414. {
  415. if (!pathname) {
  416. errno = EFAULT;
  417. return -1;
  418. }
  419. Syscall::SC_mknod_params params { { pathname, strlen(pathname) }, mode, dev };
  420. int rc = syscall(SC_mknod, &params);
  421. __RETURN_WITH_ERRNO(rc, rc, -1);
  422. }
  423. long fpathconf(int fd, int name)
  424. {
  425. (void)fd;
  426. (void)name;
  427. switch (name) {
  428. case _PC_PATH_MAX:
  429. return PATH_MAX;
  430. case _PC_VDISABLE:
  431. return _POSIX_VDISABLE;
  432. }
  433. ASSERT_NOT_REACHED();
  434. }
  435. long pathconf(const char* path, int name)
  436. {
  437. (void)path;
  438. switch (name) {
  439. case _PC_PATH_MAX:
  440. return PATH_MAX;
  441. case _PC_PIPE_BUF:
  442. return PIPE_BUF;
  443. }
  444. ASSERT_NOT_REACHED();
  445. }
  446. void _exit(int status)
  447. {
  448. syscall(SC_exit, status);
  449. ASSERT_NOT_REACHED();
  450. }
  451. void sync()
  452. {
  453. syscall(SC_sync);
  454. }
  455. int create_shared_buffer(int size, void** buffer)
  456. {
  457. int rc = syscall(SC_create_shared_buffer, size, buffer);
  458. __RETURN_WITH_ERRNO(rc, rc, -1);
  459. }
  460. int share_buffer_with(int shared_buffer_id, pid_t peer_pid)
  461. {
  462. int rc = syscall(SC_share_buffer_with, shared_buffer_id, peer_pid);
  463. __RETURN_WITH_ERRNO(rc, rc, -1);
  464. }
  465. int share_buffer_globally(int shared_buffer_id)
  466. {
  467. int rc = syscall(SC_share_buffer_globally, shared_buffer_id);
  468. __RETURN_WITH_ERRNO(rc, rc, -1);
  469. }
  470. int set_process_icon(int icon_id)
  471. {
  472. int rc = syscall(SC_set_process_icon, icon_id);
  473. __RETURN_WITH_ERRNO(rc, rc, -1);
  474. }
  475. void* get_shared_buffer(int shared_buffer_id)
  476. {
  477. int rc = syscall(SC_get_shared_buffer, shared_buffer_id);
  478. if (rc < 0 && -rc < EMAXERRNO) {
  479. errno = -rc;
  480. return (void*)-1;
  481. }
  482. return (void*)rc;
  483. }
  484. int release_shared_buffer(int shared_buffer_id)
  485. {
  486. int rc = syscall(SC_release_shared_buffer, shared_buffer_id);
  487. __RETURN_WITH_ERRNO(rc, rc, -1);
  488. }
  489. int get_shared_buffer_size(int shared_buffer_id)
  490. {
  491. int rc = syscall(SC_get_shared_buffer_size, shared_buffer_id);
  492. __RETURN_WITH_ERRNO(rc, rc, -1);
  493. }
  494. int seal_shared_buffer(int shared_buffer_id)
  495. {
  496. int rc = syscall(SC_seal_shared_buffer, shared_buffer_id);
  497. __RETURN_WITH_ERRNO(rc, rc, -1);
  498. }
  499. char* getlogin()
  500. {
  501. static char __getlogin_buffer[256];
  502. if (auto* passwd = getpwuid(getuid())) {
  503. strncpy(__getlogin_buffer, passwd->pw_name, sizeof(__getlogin_buffer));
  504. endpwent();
  505. return __getlogin_buffer;
  506. }
  507. endpwent();
  508. return nullptr;
  509. }
  510. int ftruncate(int fd, off_t length)
  511. {
  512. int rc = syscall(SC_ftruncate, fd, length);
  513. __RETURN_WITH_ERRNO(rc, rc, -1);
  514. }
  515. int gettid()
  516. {
  517. return syscall(SC_gettid);
  518. }
  519. int donate(int tid)
  520. {
  521. int rc = syscall(SC_donate, tid);
  522. __RETURN_WITH_ERRNO(rc, rc, -1);
  523. }
  524. void sysbeep()
  525. {
  526. syscall(SC_beep);
  527. }
  528. int fsync(int fd)
  529. {
  530. UNUSED_PARAM(fd);
  531. dbgprintf("FIXME: Implement fsync()\n");
  532. return 0;
  533. }
  534. int halt()
  535. {
  536. int rc = syscall(SC_halt);
  537. __RETURN_WITH_ERRNO(rc, rc, -1);
  538. }
  539. int reboot()
  540. {
  541. int rc = syscall(SC_reboot);
  542. __RETURN_WITH_ERRNO(rc, rc, -1);
  543. }
  544. int mount(const char* source, const char* target, const char* fs_type, int flags)
  545. {
  546. if (!source || !target || !fs_type) {
  547. errno = EFAULT;
  548. return -1;
  549. }
  550. Syscall::SC_mount_params params {
  551. { source, strlen(source) },
  552. { target, strlen(target) },
  553. { fs_type, strlen(fs_type) },
  554. flags
  555. };
  556. int rc = syscall(SC_mount, &params);
  557. __RETURN_WITH_ERRNO(rc, rc, -1);
  558. }
  559. int umount(const char* mountpoint)
  560. {
  561. int rc = syscall(SC_umount, mountpoint, strlen(mountpoint));
  562. __RETURN_WITH_ERRNO(rc, rc, -1);
  563. }
  564. void dump_backtrace()
  565. {
  566. syscall(SC_dump_backtrace);
  567. }
  568. int get_process_name(char* buffer, int buffer_size)
  569. {
  570. int rc = syscall(SC_get_process_name, buffer, buffer_size);
  571. __RETURN_WITH_ERRNO(rc, rc, -1);
  572. }
  573. int chroot(const char* path)
  574. {
  575. return chroot_with_mount_flags(path, -1);
  576. }
  577. int chroot_with_mount_flags(const char* path, int mount_flags)
  578. {
  579. if (!path) {
  580. errno = EFAULT;
  581. return -1;
  582. }
  583. int rc = syscall(SC_chroot, path, strlen(path), mount_flags);
  584. __RETURN_WITH_ERRNO(rc, rc, -1);
  585. }
  586. int pledge(const char* promises, const char* execpromises)
  587. {
  588. Syscall::SC_pledge_params params {
  589. { promises, promises ? strlen(promises) : 0 },
  590. { execpromises, execpromises ? strlen(execpromises) : 0 }
  591. };
  592. int rc = syscall(SC_pledge, &params);
  593. __RETURN_WITH_ERRNO(rc, rc, -1);
  594. }
  595. int unveil(const char* path, const char* permissions)
  596. {
  597. Syscall::SC_unveil_params params {
  598. { path, path ? strlen(path) : 0 },
  599. { permissions, permissions ? strlen(permissions) : 0 }
  600. };
  601. int rc = syscall(SC_unveil, &params);
  602. __RETURN_WITH_ERRNO(rc, rc, -1);
  603. }
  604. }