Discussion:
[PATCH] Linux: Implement per-thread file system attributes
(too old to reply)
Florian Weimer
2018-11-30 12:03:20 UTC
Permalink
This commit adds the functions pthread_attr_setperthreadfs_np and
pthread_attr_getperthreadfs_np.

The implementation is based on suppressing the CLONE_FS clone flag when
creating the new thread.

2018-11-30 Florian Weimer <***@redhat.com>

Linux: Implement per-thread file system attributes.
* nptl/Makefile (routines): Add pthread_attr_setperthreadfs_np,
pthread_attr_getperthreadfs_np.
(tests): Add tst-pthread-perthreadfs,
tst-pthread-perthreadfs-chroot.
* nptl/Versions (GLIBC_2.29): Export
pthread_attr_setperthreadfs_np, pthread_attr_getperthreadfs_np.
* nptl/pthread_attr_setperthreadfs_np.c: New file
* nptl/pthread_attr_getperthreadfs_np.c: Likewise.
* nptl/tst-pthread-perthreadfs.c: Likewise.
* nptl/tst-pthread-perthreadfs-chroot.c: Likewise.
* sysdeps/nptl/internaltypes.h (ATTR_FLAG_PERTHREADFS): Define.
* sysdeps/unix/sysv/linux/createthread.c (create_thread): Use it.
* sysdeps/nptl/pthread.h (pthread_attr_setperthreadfs_np)
(pthread_attr_getperthreadfs_np): Declare.
* support/Makefile (libsupport-routines): Add xchdir, xfchdir.
* support/xunistd.h (xchdir, xfchdir): Declare.
* support/xchdir.c: New file.
* support/xfchdir.c: Likewise.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist (GLIBC_2.29): Add
pthread_attr_setperthreadfs_np, pthread_attr_getperthreadfs_np.
* sysdeps/unix/sysv/linux/alpha/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/arm/libc.abilist (GLIBC_2.29): Likewise.
* sysdeps/unix/sysv/linux/hppa/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/microblaze/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
(GLIBC_2.29): Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
(GLIBC_2.29): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
(GLIBC_2.29): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
(GLIBC_2.29): Likewise.
* sysdeps/unix/sysv/linux/nios2/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
(GLIBC_2.29): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
(GLIBC_2.29): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
(GLIBC_2.29): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
(GLIBC_2.29): Likewise.
* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/sh/libc.abilist (GLIBC_2.29): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist (GLIBC_2.29):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist (GLIBC_2.29):
Likewise.

diff --git a/NEWS b/NEWS
index 1098be1afb..6acd6e1921 100644
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,11 @@ Major new features:
different directory. This is a GNU extension and similar to the
Solaris function of the same name.

+* On Linux, it is now possible to create threads with per-thread current
+ directory, umask, and file system root. The functions
+ pthread_attr_setperthreadfs_np and pthread_attr_getperthreadfs_np have
+ been added in support of that.
+
Deprecated and removed features, and other changes affecting compatibility:

* The glibc.tune tunable namespace has been renamed to glibc.cpu and the
diff --git a/nptl/Makefile b/nptl/Makefile
index 982e43adfa..02346b2f92 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -30,7 +30,8 @@ extra-libs-others := $(extra-libs)
routines = alloca_cutoff forward libc-lowlevellock libc-cancellation \
libc-cleanup libc_pthread_init libc_multiple_threads \
register-atfork pthread_atfork pthread_self thrd_current \
- thrd_equal thrd_sleep thrd_yield
+ thrd_equal thrd_sleep thrd_yield \
+ pthread_attr_setperthreadfs_np pthread_attr_getperthreadfs_np
shared-only-routines = forward
static-only-routines = pthread_atfork

@@ -318,7 +319,8 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
tst-minstack-throw \
tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
tst-cnd-timedwait tst-thrd-detach tst-mtx-basic tst-thrd-sleep \
- tst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock
+ tst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock \
+ tst-pthread-perthreadfs tst-pthread-perthreadfs-chroot

tests-internal := tst-rwlock19 tst-rwlock20 \
tst-sem11 tst-sem12 tst-sem13 \
diff --git a/nptl/Versions b/nptl/Versions
index e7f691da7a..ba71f85411 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -32,6 +32,10 @@ libc {
GLIBC_2.28 {
thrd_current; thrd_equal; thrd_sleep; thrd_yield;
}
+ GLIBC_2.29 {
+ pthread_attr_setperthreadfs_np;
+ pthread_attr_getperthreadfs_np;
+ }
GLIBC_PRIVATE {
__libc_alloca_cutoff;
# Internal libc interface to libpthread
diff --git a/nptl/pthread_attr_getperthreadfs_np.c b/nptl/pthread_attr_getperthreadfs_np.c
new file mode 100644
index 0000000000..f285fe8516
--- /dev/null
+++ b/nptl/pthread_attr_getperthreadfs_np.c
@@ -0,0 +1,27 @@
+/* Read the private file system flag in thread attributes.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <internaltypes.h>
+
+int
+pthread_attr_getperthreadfs_np (const pthread_attr_t *attr)
+{
+ struct pthread_attr *iattr = (struct pthread_attr *) attr;
+ return (iattr->flags & ATTR_FLAG_PERTHREADFS) != 0;
+}
diff --git a/nptl/pthread_attr_setperthreadfs_np.c b/nptl/pthread_attr_setperthreadfs_np.c
new file mode 100644
index 0000000000..6ce982a8bb
--- /dev/null
+++ b/nptl/pthread_attr_setperthreadfs_np.c
@@ -0,0 +1,30 @@
+/* Change the private file system flag in thread attributes.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <internaltypes.h>
+
+void
+pthread_attr_setperthreadfs_np (pthread_attr_t *attr, int enabled)
+{
+ struct pthread_attr *iattr = (struct pthread_attr *) attr;
+ if (enabled)
+ iattr->flags |= ATTR_FLAG_PERTHREADFS;
+ else
+ iattr->flags &= ~ATTR_FLAG_PERTHREADFS;
+}
diff --git a/nptl/tst-pthread-perthreadfs-chroot.c b/nptl/tst-pthread-perthreadfs-chroot.c
new file mode 100644
index 0000000000..77494c2bcc
--- /dev/null
+++ b/nptl/tst-pthread-perthreadfs-chroot.c
@@ -0,0 +1,256 @@
+/* Test per-thread file system attributes, chroot version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+#include <support/namespace.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xthread.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+/* Paths for chroot operations. */
+static char *chroot_1;
+static char *chroot_2;
+static char *chroot_3;
+
+/* These paths are used for recognizing chroots. */
+static const char *const chroot_1_marker = "/chroot-1-marker";
+static const char *const chroot_2_marker = "/chroot-2-marker";
+
+/* Directory available in the chroot for a second chroot call. */
+static const char *const next_chroot = "/next_chroot";
+
+/* Return 0 for no chroot, 1 for first chroot, 2 for second chroot, or
+ -1 for error. */
+static int
+which_chroot (void)
+{
+ /* If the full (out-of-chroot) path is present, we are not in a
+ chroot. */
+ if (access (chroot_1, F_OK) == 0)
+ return 0;
+ if (access (chroot_1_marker, F_OK) == 0)
+ return 1;
+ if (access (chroot_2_marker, F_OK) == 0)
+ return 2;
+ return -1;
+}
+
+/* Thread attribute requesting per-thread file system attributes. */
+pthread_attr_t attr_perthreadfs;
+
+/* Used to synchronize operations among the threads. This is needed
+ so that the chroot changes happen in the expected order. */
+static pthread_barrier_t barrier;
+
+static void *
+thread_which_chroot_helper (void *closure)
+{
+ int *result = closure;
+ *result = which_chroot ();
+ return NULL;
+}
+
+static void *
+thread_which_chroot_helper_perthread (void *closure)
+{
+ int *result = closure;
+ *result = which_chroot ();
+ if (*result == 0)
+ /* No /next-chroot available without a first chroot. */
+ xchroot (chroot_3);
+ else
+ xchroot (next_chroot);
+ return NULL;
+}
+
+/* Determine the current chroot on another thread. */
+static int
+thread_which_chroot (void)
+{
+ int result1;
+ pthread_t thr = xpthread_create (NULL, thread_which_chroot_helper, &result1);
+ xpthread_join (thr);
+ /* Same using per-thread attributes. They are supposed to be equal.
+ Also change the chroot to check isolation. */
+ int result2;
+ thr = xpthread_create (&attr_perthreadfs,
+ thread_which_chroot_helper_perthread, &result2);
+ xpthread_join (thr);
+ TEST_COMPARE (result1, result2);
+ return result1;
+}
+
+/* Verify that the file system attributes for the current thread are
+ as expected. */
+static void
+check_attributes (const char *where, int expected_chroot)
+{
+ printf ("info: reading file attributes in %s\n", where);
+ TEST_COMPARE (which_chroot (), expected_chroot);
+ TEST_COMPARE (thread_which_chroot (), expected_chroot);
+}
+
+/* Thread function launched with per-thread file system
+ attributes. */
+static void *
+thread_perthreadfs (void *closure)
+{
+ puts ("info: changing file attributes in thread_perthreadfs");
+ xchroot (chroot_1);
+ check_attributes ("thread_perthreadfs", 1);
+
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in thread_sharedfs here. */
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in main thread here. */
+ pthread_barrier_wait (&barrier);
+ /* File attributes changed in thread_sharedfs here. */
+ pthread_barrier_wait (&barrier);
+
+ check_attributes ("thread_perthreadfs", 1);
+
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in main thread here. */
+ pthread_barrier_wait (&barrier);
+ return NULL;
+}
+
+/* Thread function launched with shared file system attributes. */
+static void *
+thread_sharedfs (void *closure)
+{
+ /* Wait for thread_perthreadfs to update chroot. */
+ pthread_barrier_wait (&barrier);
+
+ check_attributes ("thread_sharedfs", 0);
+
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in main thread here. */
+ pthread_barrier_wait (&barrier);
+
+ puts ("info: changing file attributes in thread_sharedfs");
+ xchroot (chroot_2);
+ check_attributes ("thread_sharedfs", 2);
+
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in thread_perthreadfs here. */
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in main thread here. */
+ pthread_barrier_wait (&barrier);
+ return NULL;
+}
+
+static int
+do_test (void)
+{
+ support_become_root ();
+ if (!support_can_chroot ())
+ FAIL_UNSUPPORTED ("chroot not supported");
+
+ /* Used to revert the effect of chroot. */
+ int original_chroot_fd = xopen ("/", O_DIRECTORY | O_RDONLY, 0);
+
+ TEST_COMPARE (access (chroot_1_marker, F_OK), -1);
+ TEST_COMPARE (access (chroot_2_marker, F_OK), -1);
+ TEST_COMPARE (access (next_chroot, F_OK), -1);
+
+ chroot_1 = support_create_temp_directory
+ ("tst-pthread-perthreadfs-chroot-1-");
+ chroot_2 = support_create_temp_directory
+ ("tst-pthread-perthreadfs-chroot-2-");
+ chroot_3 = support_create_temp_directory
+ ("tst-pthread-perthreadfs-chroot-3-");
+ {
+ char *path = xasprintf ("%s%s", chroot_1, chroot_1_marker);
+ xmkdir (path, 0777);
+ add_temp_file (path);
+ free (path);
+
+ path = xasprintf ("%s%s", chroot_1, next_chroot);
+ xmkdir (path, 0777);
+ add_temp_file (path);
+ free (path);
+
+ path = xasprintf ("%s%s", chroot_2, chroot_2_marker);
+ xmkdir (path, 0777);
+ add_temp_file (path);
+ free (path);
+
+ path = xasprintf ("%s%s", chroot_2, next_chroot);
+ xmkdir (path, 0777);
+ add_temp_file (path);
+ free (path);
+ }
+ TEST_COMPARE (which_chroot (), 0);
+
+ xpthread_barrier_init (&barrier, NULL, 3);
+ xpthread_attr_init (&attr_perthreadfs);
+ TEST_COMPARE (pthread_attr_getperthreadfs_np (&attr_perthreadfs), 0);
+ pthread_attr_setperthreadfs_np (&attr_perthreadfs, true);
+ TEST_COMPARE (pthread_attr_getperthreadfs_np (&attr_perthreadfs), 1);
+ /* The flag is normalized to 1. */
+ pthread_attr_setperthreadfs_np (&attr_perthreadfs, 2);
+ TEST_COMPARE (pthread_attr_getperthreadfs_np (&attr_perthreadfs), 1);
+
+ pthread_t thr1 = xpthread_create (&attr_perthreadfs,
+ thread_perthreadfs, NULL);
+ pthread_t thr2 = xpthread_create (NULL, thread_sharedfs, NULL);
+
+ /* Wait for thread_perthreadfs to update chroot. */
+ xpthread_barrier_wait (&barrier);
+ /* File attributes read thread_sharedfs here. */
+ xpthread_barrier_wait (&barrier);
+
+ check_attributes ("main thread", 0);
+
+ xpthread_barrier_wait (&barrier);
+ /* File attributes changed thread_sharedfs here. */
+ xpthread_barrier_wait (&barrier);
+ /* File attributes read in thread_perthreadfs here. */
+ xpthread_barrier_wait (&barrier);
+
+ check_attributes ("main thread", 2);
+
+ xpthread_barrier_wait (&barrier);
+
+ xpthread_join (thr2);
+ xpthread_join (thr1);
+
+ xpthread_attr_destroy (&attr_perthreadfs);
+ xpthread_barrier_destroy (&barrier);
+
+ free (chroot_3);
+ free (chroot_2);
+ free (chroot_1);
+
+ xfchdir (original_chroot_fd);
+ xclose (original_chroot_fd);
+ xchroot (".");
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-pthread-perthreadfs.c b/nptl/tst-pthread-perthreadfs.c
new file mode 100644
index 0000000000..d11dc63a1f
--- /dev/null
+++ b/nptl/tst-pthread-perthreadfs.c
@@ -0,0 +1,243 @@
+/* Test per-thread file system attributes.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+#include <support/temp_file.h>
+#include <support/xthread.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+/* Original values in the parent process. */
+static char *original_cwd;
+static mode_t original_umask;
+
+/* New values for the attributes, distinct from the old. */
+static char *new_cwd_1;
+static char *new_cwd_2;
+static mode_t new_umask_1;
+static mode_t new_umask_2;
+
+/* Thread attribute requesting per-thread file system attributes. */
+pthread_attr_t attr_perthreadfs;
+
+/* Used to synchronize operations among the threads. This is needed
+ so that the attribute changes happen in the expected order, and
+ that get_umask_unlocked can be used safely. */
+static pthread_barrier_t barrier;
+
+/* Linux does not have getumask, so use synchronization and the umask
+ system call to read the value. */
+static mode_t
+get_umask_unlocked (void)
+{
+ mode_t mask = umask (0);
+ TEST_COMPARE (umask (mask), 0);
+ return mask;
+}
+
+static void *
+thread_get_pwd_helper (void *closure)
+{
+ char *result = get_current_dir_name ();
+ if (closure != NULL)
+ xchdir (closure);
+ return result;
+}
+
+/* Obtain the current directory on another thread. */
+static char *
+thread_get_pwd (void)
+{
+ pthread_t thr = xpthread_create (NULL, thread_get_pwd_helper, NULL);
+ char *path1 = xpthread_join (thr);
+ /* Same using per-thread attributes. They are supposed to be equal.
+ Also change the current directory to check isolation. */
+ thr = xpthread_create (&attr_perthreadfs,
+ thread_get_pwd_helper, (char *) "/");
+ char *path2 = xpthread_join (thr);
+ TEST_COMPARE_STRING (path1, path2);
+ free (path2);
+ return path1;
+}
+
+static void *
+thread_get_umask_helper (void *closure)
+{
+ mode_t *pmask = closure;
+ *pmask = get_umask_unlocked ();
+ return NULL;
+}
+
+static void *
+thread_get_umask_helper_perthread (void *closure)
+{
+ mode_t *pmask = closure;
+ *pmask = get_umask_unlocked ();
+ /* Check isolation. This bit pattern is not used anywhere else. */
+ TEST_COMPARE (umask (*pmask ^ 0101), *pmask);
+ return NULL;
+}
+
+/* Obtain the current umask on another thread. */
+static mode_t
+thread_get_umask_unlocked (void)
+{
+ mode_t mask1;
+ pthread_t thr = xpthread_create (NULL, thread_get_umask_helper, &mask1);
+ xpthread_join (thr);
+ mode_t mask2;
+ thr = xpthread_create (&attr_perthreadfs,
+ thread_get_umask_helper_perthread, &mask2);
+ xpthread_join (thr);
+ TEST_COMPARE (mask1, mask2);
+ return mask1;
+}
+
+/* Verify that the file system attributes for the current thread are
+ as expected. */
+static void
+check_attributes (const char *where, mode_t expected_umask,
+ const char *expected_cwd)
+{
+ printf ("info: reading file attributes in %s\n", where);
+ TEST_COMPARE (get_umask_unlocked (), expected_umask);
+ TEST_COMPARE (thread_get_umask_unlocked (), expected_umask);
+ char *cwd = get_current_dir_name ();
+ TEST_COMPARE_STRING (cwd, expected_cwd);
+ free (cwd);
+ cwd = thread_get_pwd ();
+ TEST_COMPARE_STRING (cwd, expected_cwd);
+ free (cwd);
+}
+
+/* Thread function launched with per-thread file system
+ attributes. */
+static void *
+thread_perthreadfs (void *closure)
+{
+ puts ("info: changing file attributes in thread_perthreadfs");
+ xchdir (new_cwd_1);
+ TEST_COMPARE (umask (new_umask_1), original_umask);
+ check_attributes ("thread_perthreadfs", new_umask_1, new_cwd_1);
+
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in thread_sharedfs here. */
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in main thread here. */
+ pthread_barrier_wait (&barrier);
+ /* File attributes changed in thread_sharedfs here. */
+ pthread_barrier_wait (&barrier);
+
+ check_attributes ("thread_perthreadfs", new_umask_1, new_cwd_1);
+
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in main thread here. */
+ pthread_barrier_wait (&barrier);
+ return NULL;
+}
+
+/* Thread function launched with shared file system attributes. */
+static void *
+thread_sharedfs (void *closure)
+{
+ /* Wait for thread_perthreadfs to update current directory and
+ umask. */
+ pthread_barrier_wait (&barrier);
+
+ check_attributes ("thread_sharedfs", original_umask, original_cwd);
+
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in main thread here. */
+ pthread_barrier_wait (&barrier);
+
+ puts ("info: changing file attributes in thread_sharedfs");
+ TEST_COMPARE (umask (new_umask_2), original_umask);
+ xchdir (new_cwd_2);
+ check_attributes ("thread_sharedfs", new_umask_2, new_cwd_2);
+
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in thread_perthreadfs here. */
+ pthread_barrier_wait (&barrier);
+ /* File attributes read in main thread here. */
+ pthread_barrier_wait (&barrier);
+ return NULL;
+}
+
+static int
+do_test (void)
+{
+ original_cwd = get_current_dir_name ();
+ TEST_VERIFY_EXIT (original_cwd != NULL);
+ original_umask = get_umask_unlocked ();
+
+ new_cwd_1 = support_create_temp_directory ("tst-pthread-perthreadfs-1-");
+ new_cwd_2 = support_create_temp_directory ("tst-pthread-perthreadfs-2-");
+ /* Arbitrary bit pattern change to obtain distinct values, so that
+ it is possible to check for actual changes. */
+ new_umask_1 = original_umask ^ 0111;
+ new_umask_2 = original_umask ^ 0222;
+
+ xpthread_barrier_init (&barrier, NULL, 3);
+ xpthread_attr_init (&attr_perthreadfs);
+ TEST_COMPARE (pthread_attr_getperthreadfs_np (&attr_perthreadfs), 0);
+ pthread_attr_setperthreadfs_np (&attr_perthreadfs, true);
+ TEST_COMPARE (pthread_attr_getperthreadfs_np (&attr_perthreadfs), 1);
+ /* The flag is normalized to 1. */
+ pthread_attr_setperthreadfs_np (&attr_perthreadfs, 2);
+ TEST_COMPARE (pthread_attr_getperthreadfs_np (&attr_perthreadfs), 1);
+
+ pthread_t thr1 = xpthread_create (&attr_perthreadfs,
+ thread_perthreadfs, NULL);
+ pthread_t thr2 = xpthread_create (NULL, thread_sharedfs, NULL);
+
+ /* Wait for thread_perthreadfs to update current directory and
+ umask. */
+ xpthread_barrier_wait (&barrier);
+ /* File attributes read thread_sharedfs here. */
+ xpthread_barrier_wait (&barrier);
+
+ check_attributes ("main thread", original_umask, original_cwd);
+
+ xpthread_barrier_wait (&barrier);
+ /* File attributes changed thread_sharedfs here. */
+ xpthread_barrier_wait (&barrier);
+ /* File attributes read in thread_perthreadfs here. */
+ xpthread_barrier_wait (&barrier);
+
+ check_attributes ("main thread", new_umask_2, new_cwd_2);
+
+ xpthread_barrier_wait (&barrier);
+
+ xpthread_join (thr2);
+ xpthread_join (thr1);
+
+ xpthread_attr_destroy (&attr_perthreadfs);
+ xpthread_barrier_destroy (&barrier);
+
+ free (new_cwd_2);
+ free (new_cwd_1);
+ free (original_cwd);
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/support/Makefile b/support/Makefile
index a2536980d1..dd75df5cb8 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -75,12 +75,14 @@ libsupport-routines = \
xasprintf \
xbind \
xcalloc \
+ xchdir \
xchroot \
xclose \
xconnect \
xcopy_file_range \
xdlfcn \
xdup2 \
+ xfchdir \
xfclose \
xfopen \
xfork \
diff --git a/support/xchdir.c b/support/xchdir.c
new file mode 100644
index 0000000000..5f9f001ce0
--- /dev/null
+++ b/support/xchdir.c
@@ -0,0 +1,28 @@
+/* chdir with error checking.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+
+void
+xchdir (const char *path)
+{
+ if (chdir (path) != 0)
+ FAIL_EXIT1 ("chdir (\"%s\"): %m", path);
+}
diff --git a/support/xfchdir.c b/support/xfchdir.c
new file mode 100644
index 0000000000..75fadeb865
--- /dev/null
+++ b/support/xfchdir.c
@@ -0,0 +1,28 @@
+/* fchdir with error checking.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+
+void
+xfchdir (int fd)
+{
+ if (fchdir (fd) != 0)
+ FAIL_EXIT1 ("fchdir (%d): %m", fd);
+}
diff --git a/support/xunistd.h b/support/xunistd.h
index f99f362cb4..13dfa2c0e5 100644
--- a/support/xunistd.h
+++ b/support/xunistd.h
@@ -38,6 +38,8 @@ int xopen (const char *path, int flags, mode_t);
void xstat (const char *path, struct stat64 *);
void xfstat (int fd, struct stat64 *);
void xmkdir (const char *path, mode_t);
+void xchdir (const char *path);
+void xfchdir (int);
void xchroot (const char *path);
void xunlink (const char *path);
long xsysconf (int name);
diff --git a/sysdeps/nptl/internaltypes.h b/sysdeps/nptl/internaltypes.h
index b78ad99a88..30396cc448 100644
--- a/sysdeps/nptl/internaltypes.h
+++ b/sysdeps/nptl/internaltypes.h
@@ -48,6 +48,7 @@ struct pthread_attr
#define ATTR_FLAG_OLDATTR 0x0010
#define ATTR_FLAG_SCHED_SET 0x0020
#define ATTR_FLAG_POLICY_SET 0x0040
+#define ATTR_FLAG_PERTHREADFS 0x0080


/* Mutex attribute data structure. */
diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
index df049abf74..8efcff278e 100644
--- a/sysdeps/nptl/pthread.h
+++ b/sysdeps/nptl/pthread.h
@@ -406,6 +406,18 @@ extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr,
cpu_set_t *__cpuset)
__THROW __nonnull ((1, 3));

+
+/* Control the flag in ATTR whether the thread has its own current
+ directory, file system root, and umask attribute. By default, new
+ threads share these attributes with their creating thread. */
+void pthread_attr_setperthreadfs_np (pthread_attr_t *__attr, int __enabled)
+ __THROW __nonnull ((1));
+
+/* Return 1 if ATTR enables private file system attributes, or 0 if
+ not. See pthread_attr_setperthreadfs_np. */
+int pthread_attr_getperthreadfs_np (const pthread_attr_t *__attr)
+ __THROW __nonnull ((1));
+
/* Get the default attributes used by pthread_create in this process. */
extern int pthread_getattr_default_np (pthread_attr_t *__attr)
__THROW __nonnull ((1));
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index e66c741d04..59e897b59e 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2139,3 +2139,5 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 8df162fe99..4ea64a9af9 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2034,6 +2034,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist
index 43c804f9dc..1074323ac7 100644
--- a/sysdeps/unix/sysv/linux/arm/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/libc.abilist
@@ -124,6 +124,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/createthread.c b/sysdeps/unix/sysv/linux/createthread.c
index 5879e51bd2..8de97746dc 100644
--- a/sysdeps/unix/sysv/linux/createthread.c
+++ b/sysdeps/unix/sysv/linux/createthread.c
@@ -66,7 +66,9 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr,

CLONE_VM, CLONE_FS, CLONE_FILES
These flags select semantics with shared address space and
- file descriptors according to what POSIX requires.
+ file descriptors according to what POSIX requires. CLONE_FS
+ is optional; it can be using the function
+ pthread_attr_setperthreadfs_np.

CLONE_SIGHAND, CLONE_THREAD
This flag selects the POSIX signal semantics and various
@@ -90,11 +92,13 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr,

The termination signal is chosen to be zero which means no signal
is sent. */
- const int clone_flags = (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SYSVSEM
- | CLONE_SIGHAND | CLONE_THREAD
- | CLONE_SETTLS | CLONE_PARENT_SETTID
- | CLONE_CHILD_CLEARTID
- | 0);
+ int clone_flags = (CLONE_VM | CLONE_FILES | CLONE_SYSVSEM
+ | CLONE_SIGHAND | CLONE_THREAD
+ | CLONE_SETTLS | CLONE_PARENT_SETTID
+ | CLONE_CHILD_CLEARTID
+ | 0);
+ if ((attr->flags & ATTR_FLAG_PERTHREADFS) == 0)
+ clone_flags |= CLONE_FS;

TLS_DEFINE_INIT_TP (tp, pd);

diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index 88b01c2e75..3a2c85a8d8 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -1881,6 +1881,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index 6d02f31612..9896c9d9f4 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2046,6 +2046,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index 4249712611..febdc06b39 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -1915,6 +1915,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index d47b808862..61e077b7fd 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -125,6 +125,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0x98
GLIBC_2.4 _IO_2_1_stdin_ D 0x98
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index d5e38308be..807382fa46 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -1990,6 +1990,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist
index 8596b84399..313ec63271 100644
--- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist
@@ -2131,3 +2131,5 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 88e0f896d5..d277f4210e 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -1968,6 +1968,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index aff7462c34..4237bad588 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -1966,6 +1966,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index 71d82444aa..0c200c15f2 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -1974,6 +1974,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index de6c53d293..aceab1b162 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -1969,6 +1969,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index e724bab9fb..e402a05d86 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2172,3 +2172,5 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index e9ecbccb71..976fa6c45a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -1994,6 +1994,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index da83ea6028..0837cb981e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -1998,6 +1998,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
index 4535b40d15..0f696145a5 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
@@ -2229,3 +2229,5 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
index 65725de4f0..b9a2327410 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
@@ -124,6 +124,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 _Exit F
GLIBC_2.3 _IO_2_1_stderr_ D 0xe0
GLIBC_2.3 _IO_2_1_stdin_ D 0xe0
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index bbb3c4a8e7..56bbeb0572 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2101,3 +2101,5 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index e85ac2a178..f7a7cc3b7a 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2003,6 +2003,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index d56931022c..5f2bf4126f 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -1909,6 +1909,8 @@ GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 __fentry__ F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist
index ff939a15c4..46d4254812 100644
--- a/sysdeps/unix/sysv/linux/sh/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/libc.abilist
@@ -1885,6 +1885,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index 64fa9e10a5..be8189851c 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -1997,6 +1997,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index db909d1506..d29252f5b8 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -1938,6 +1938,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 3b175f104b..a4088c691c 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -1896,6 +1896,8 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
GLIBC_2.3 __ctype_b_loc F
GLIBC_2.3 __ctype_tolower_loc F
GLIBC_2.3 __ctype_toupper_loc F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 1b57710477..e11f54da10 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2147,3 +2147,5 @@ GLIBC_2.28 thrd_equal F
GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
+GLIBC_2.29 pthread_attr_getperthreadfs_np F
+GLIBC_2.29 pthread_attr_setperthreadfs_np F
Florian Weimer
2018-12-05 13:21:11 UTC
Permalink
Post by Florian Weimer
This commit adds the functions pthread_attr_setperthreadfs_np and
pthread_attr_getperthreadfs_np.
The implementation is based on suppressing the CLONE_FS clone flag when
creating the new thread.
Any comments? Do we want something like this at all?

Thanks,
Florian

Loading...