uClibc-0.9.32.1-unshare.patch 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.32.orig/libc/sysdeps/linux/common/bits/sched.h uClibc-0.9.32/libc/sysdeps/linux/common/bits/sched.h
  6. --- uClibc-0.9.32.orig/libc/sysdeps/linux/common/bits/sched.h 2011-12-02 23:54:30.571841170 -0300
  7. +++ uClibc-0.9.32/libc/sysdeps/linux/common/bits/sched.h 2011-12-02 23:57:45.874205079 -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.32.orig/libc/sysdeps/linux/common/Makefile.in uClibc-0.9.32/libc/sysdeps/linux/common/Makefile.in
  32. --- uClibc-0.9.32.orig/libc/sysdeps/linux/common/Makefile.in 2011-12-02 23:54:30.577841215 -0300
  33. +++ uClibc-0.9.32/libc/sysdeps/linux/common/Makefile.in 2011-12-02 23:56:08.801527166 -0300
  34. @@ -24,7 +24,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
  39. + sync_file_range.c sysctl.c sysinfo.c timerfd.c unshare.c uselib.c \
  40. + vhangup.c
  41. # NPTL needs these internally: madvise.c
  42. CSRC-$(findstring y,$(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_THREADS_NATIVE)) += madvise.c
  43. ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
  44. diff -Nura uClibc-0.9.32.orig/libc/sysdeps/linux/common/stubs.c uClibc-0.9.32/libc/sysdeps/linux/common/stubs.c
  45. --- uClibc-0.9.32.orig/libc/sysdeps/linux/common/stubs.c 2011-12-02 23:54:30.577841215 -0300
  46. +++ uClibc-0.9.32/libc/sysdeps/linux/common/stubs.c 2011-12-02 23:58:18.803435042 -0300
  47. @@ -278,6 +278,10 @@
  48. make_stub(umount2)
  49. #endif
  50. +#if !defined __NR_unshare && defined __UCLIBC_LINUX_SPECIFIC__
  51. +make_stub(unshare)
  52. +#endif
  53. +
  54. #ifndef __NR_utimensat
  55. make_stub(futimens)
  56. make_stub(utimensat)
  57. diff -Nura uClibc-0.9.32.orig/libc/sysdeps/linux/common/unshare.c uClibc-0.9.32/libc/sysdeps/linux/common/unshare.c
  58. --- uClibc-0.9.32.orig/libc/sysdeps/linux/common/unshare.c 1969-12-31 21:00:00.000000000 -0300
  59. +++ uClibc-0.9.32/libc/sysdeps/linux/common/unshare.c 2011-12-02 23:58:42.693601880 -0300
  60. @@ -0,0 +1,15 @@
  61. +/* vi: set sw=4 ts=4: */
  62. +/*
  63. + * unshare() for uClibc
  64. + *
  65. + * Copyright (C) 2011 Henning Heinold <heinold@inf.fu-berlin.de>
  66. + *
  67. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  68. + */
  69. +
  70. +#include <sys/syscall.h>
  71. +#include <sched.h>
  72. +
  73. +#if defined __NR_unshare
  74. +_syscall1(int, unshare, int, flags)
  75. +#endif