diff options
author | Roland McGrath <roland@hack.frob.com> | 2014-12-12 13:17:21 -0800 |
---|---|---|
committer | Roland McGrath <roland@hack.frob.com> | 2014-12-12 15:01:30 -0800 |
commit | e4f639e4a106d90c6f3159230788653fd6e40a26 (patch) | |
tree | 0273305e960bcb5f46e3debc523eecc312e1bba8 /nptl/sem_unlink.c | |
parent | c76d1ff5149bd03210f2bb8cd64446c51618d016 (diff) | |
download | glibc-e4f639e4a106d90c6f3159230788653fd6e40a26.tar.gz glibc-e4f639e4a106d90c6f3159230788653fd6e40a26.tar.xz glibc-e4f639e4a106d90c6f3159230788653fd6e40a26.zip |
NPTL: Refactor named semaphore code to use shm-directory.h
Diffstat (limited to 'nptl/sem_unlink.c')
-rw-r--r-- | nptl/sem_unlink.c | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/nptl/sem_unlink.c b/nptl/sem_unlink.c index 485a3b8d2a..04abd3159a 100644 --- a/nptl/sem_unlink.c +++ b/nptl/sem_unlink.c @@ -22,44 +22,16 @@ #include <string.h> #include <unistd.h> #include "semaphoreP.h" - +#include <shm-directory.h> int -sem_unlink (name) - const char *name; +sem_unlink (const char *name) { - char *fname; - size_t namelen; - - /* Determine where the shmfs is mounted. */ - __pthread_once (&__namedsem_once, __where_is_shmfs); - - /* If we don't know the mount points there is nothing we can do. Ever. */ - if (mountpoint.dir == NULL) - { - __set_errno (ENOSYS); - return -1; - } - /* Construct the filename. */ - while (name[0] == '/') - ++name; - - if (name[0] == '\0') - { - /* The name "/" is not supported. */ - __set_errno (ENOENT); - return -1; - } - namelen = strlen (name); - - /* Create the name of the file. */ - fname = (char *) alloca (mountpoint.dirlen + namelen + 1); - __mempcpy (__mempcpy (fname, mountpoint.dir, mountpoint.dirlen), - name, namelen + 1); + SHM_GET_NAME (ENOENT, -1, SEM_SHM_PREFIX); /* Now try removing it. */ - int ret = unlink (fname); + int ret = unlink (shm_name); if (ret < 0 && errno == EPERM) __set_errno (EACCES); return ret; |