1 /* 2 * mq_unlink.c - remove a message queue. 3 */ 4 5 #include <errno.h> 6 #include <sys/syscall.h> 7 8 #include <mqueue.h> 9 10 #ifdef __NR_mq_unlink 11 12 #define __NR___syscall_mq_unlink __NR_mq_unlink 13 static __inline__ _syscall1(int, __syscall_mq_unlink, const char *, name); 14 15 /* Remove message queue */ mq_unlink(const char * name)16int mq_unlink(const char *name) 17 { 18 int ret; 19 20 if (name[0] != '/') { 21 __set_errno(EINVAL); 22 return -1; 23 } 24 25 ret = __syscall_mq_unlink(name + 1); 26 27 /* While unlink can return either EPERM or EACCES, mq_unlink should return just EACCES. */ 28 if (ret < 0) { 29 ret = errno; 30 if (ret == EPERM) 31 ret = EACCES; 32 __set_errno(ret); 33 ret = -1; 34 } 35 36 return ret; 37 } 38 39 #endif 40