uClibc-0.9.31.1-unshare.patch 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. Backport of unshare() syscall.
  2. From uClibc git 19dd090a0f68765db87990ef8eda9bf77bb29581
  3. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
  4. ---
  5. diff -Nura uClibc-0.9.31.1.orig/libc/sysdeps/linux/common/bits/sched.h uClibc-0.9.31.1/libc/sysdeps/linux/common/bits/sched.h
  6. --- uClibc-0.9.31.1.orig/libc/sysdeps/linux/common/bits/sched.h 2011-06-08 15:58:40.000000000 -0300
  7. +++ uClibc-0.9.31.1/libc/sysdeps/linux/common/bits/sched.h 2011-12-05 08:10:02.491978849 -0300
  8. @@ -58,7 +58,13 @@
  9. force CLONE_PTRACE on this clone. */
  10. # define CLONE_CHILD_SETTID 0x01000000 /* Store TID in userlevel buffer in
  11. the child. */
  12. -# define CLONE_STOPPED 0x02000000 /* Start in stopped state. */
  13. +# define CLONE_STOPPED 0x02000000 /* Start in stopped state. */
  14. +# define CLONE_NEWUTS 0x04000000 /* New utsname group. */
  15. +# define CLONE_NEWIPC 0x08000000 /* New ipcs. */
  16. +# define CLONE_NEWUSER 0x10000000 /* New user namespace. */
  17. +# define CLONE_NEWPID 0x20000000 /* New pid namespace. */
  18. +# define CLONE_NEWNET 0x40000000 /* New network namespace. */
  19. +# define CLONE_IO 0x80000000 /* Clone I/O context. */
  20. #endif
  21. /* The official definition. */
  22. @@ -74,11 +80,9 @@
  23. extern int clone (int (*__fn) (void *__arg), void *__child_stack,
  24. int __flags, void *__arg, ...) __THROW;
  25. -#if 0
  26. /* Unshare the specified resources. */
  27. extern int unshare (int __flags) __THROW;
  28. #endif
  29. -#endif
  30. __END_DECLS
  31. diff -Nura uClibc-0.9.31.1.orig/libc/sysdeps/linux/common/Makefile.in uClibc-0.9.31.1/libc/sysdeps/linux/common/Makefile.in
  32. --- uClibc-0.9.31.1.orig/libc/sysdeps/linux/common/Makefile.in 2011-06-08 15:58:40.000000000 -0300
  33. +++ uClibc-0.9.31.1/libc/sysdeps/linux/common/Makefile.in 2011-12-05 08:23:28.353757602 -0300
  34. @@ -31,7 +31,8 @@
  35. remap_file_pages.c sched_getaffinity.c sched_setaffinity.c \
  36. sendfile64.c sendfile.c setfsgid.c setfsuid.c setresuid.c \
  37. splice.c vmsplice.c tee.c signalfd.c swapoff.c swapon.c \
  38. - sync_file_range.c sysctl.c sysinfo.c timerfd.c uselib.c vhangup.c,$(CSRC))
  39. + sync_file_range.c sysctl.c sysinfo.c timerfd.c unshare.c uselib.c \
  40. + vhangup.c,$(CSRC))
  41. endif
  42. ifneq ($(UCLIBC_BSD_SPECIFIC),y)
  43. diff -Nura uClibc-0.9.31.1.orig/libc/sysdeps/linux/common/unshare.c uClibc-0.9.31.1/libc/sysdeps/linux/common/unshare.c
  44. --- uClibc-0.9.31.1.orig/libc/sysdeps/linux/common/unshare.c 1969-12-31 21:00:00.000000000 -0300
  45. +++ uClibc-0.9.31.1/libc/sysdeps/linux/common/unshare.c 2011-12-05 08:22:45.954453512 -0300
  46. @@ -0,0 +1,21 @@
  47. +/* vi: set sw=4 ts=4: */
  48. +/*
  49. + * unshare() for uClibc
  50. + *
  51. + * Copyright (C) 2011 Henning Heinold <heinold@inf.fu-berlin.de>
  52. + *
  53. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  54. + */
  55. +
  56. +#include <sys/syscall.h>
  57. +#include <sched.h>
  58. +
  59. +#if defined __NR_unshare && defined __UCLIBC_LINUX_SPECIFIC__
  60. +_syscall1(int, unshare, int, flags)
  61. +#else
  62. +int unshare(int flags)
  63. +{
  64. + __set_errno(ENOSYS);
  65. + return -1;
  66. +}
  67. +#endif