* Syscall to unlink a message queue. */
| 2138 | * Syscall to unlink a message queue. |
| 2139 | */ |
| 2140 | int |
| 2141 | sys_kmq_unlink(struct thread *td, struct kmq_unlink_args *uap) |
| 2142 | { |
| 2143 | char path[MQFS_NAMELEN+1]; |
| 2144 | struct mqfs_node *pn; |
| 2145 | int error, len; |
| 2146 | |
| 2147 | error = copyinstr(uap->path, path, MQFS_NAMELEN + 1, NULL); |
| 2148 | if (error) |
| 2149 | return (error); |
| 2150 | |
| 2151 | len = strlen(path); |
| 2152 | if (len < 2 || path[0] != '/' || strchr(path + 1, '/') != NULL) |
| 2153 | return (EINVAL); |
| 2154 | if (strcmp(path, "/.") == 0 || strcmp(path, "/..") == 0) |
| 2155 | return (EINVAL); |
| 2156 | AUDIT_ARG_UPATH1_CANON(path); |
| 2157 | |
| 2158 | sx_xlock(&mqfs_data.mi_lock); |
| 2159 | pn = mqfs_search(mqfs_data.mi_root, path + 1, len - 1, td->td_ucred); |
| 2160 | if (pn != NULL) |
| 2161 | error = do_unlink(pn, td->td_ucred); |
| 2162 | else |
| 2163 | error = ENOENT; |
| 2164 | sx_xunlock(&mqfs_data.mi_lock); |
| 2165 | return (error); |
| 2166 | } |
| 2167 | |
| 2168 | typedef int (*_fgetf)(struct thread *, int, cap_rights_t *, struct file **); |
| 2169 |
no test coverage detected