From bf258341b71711461ce19891674d43c135827d0e Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 30 Sep 2012 19:35:40 -0400 Subject: overhaul sem_open this function was overly complicated and not even obviously correct. avoid using openat/linkat just like in shm_open, and instead expand pathname using code shared with shm_open. remove bogus (and dangerous, with priorities) use of spinlocks. this commit also heavily streamlines the code and ensures there are no failure cases that can happen after a new semaphore has been created in the filesystem, since that case is unreportable. --- src/mman/shm_open.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mman') diff --git a/src/mman/shm_open.c b/src/mman/shm_open.c index a9be899b..b23eac7f 100644 --- a/src/mman/shm_open.c +++ b/src/mman/shm_open.c @@ -7,7 +7,7 @@ char *__strchrnul(const char *, int); -static const char *mapname(const char *name, char *buf) +char *__shm_mapname(const char *name, char *buf) { char *p; while (*name == '/') name++; @@ -28,13 +28,13 @@ static const char *mapname(const char *name, char *buf) int shm_open(const char *name, int flag, mode_t mode) { char buf[NAME_MAX+10]; - if (!(name = mapname(name, buf))) return -1; + if (!(name = __shm_mapname(name, buf))) return -1; return open(name, flag|O_NOFOLLOW|O_CLOEXEC|O_NONBLOCK, mode); } int shm_unlink(const char *name) { char buf[NAME_MAX+10]; - if (!(name = mapname(name, buf))) return -1; + if (!(name = __shm_mapname(name, buf))) return -1; return unlink(name); } -- cgit v1.2.1