| 2220 | } |
| 2221 | |
| 2222 | static int |
| 2223 | kern_kmq_setattr(struct thread *td, int mqd, const struct mq_attr *attr, |
| 2224 | struct mq_attr *oattr) |
| 2225 | { |
| 2226 | struct mqueue *mq; |
| 2227 | struct file *fp; |
| 2228 | u_int oflag, flag; |
| 2229 | int error; |
| 2230 | |
| 2231 | AUDIT_ARG_FD(mqd); |
| 2232 | if (attr != NULL && (attr->mq_flags & ~O_NONBLOCK) != 0) |
| 2233 | return (EINVAL); |
| 2234 | error = getmq(td, mqd, &fp, NULL, &mq); |
| 2235 | if (error) |
| 2236 | return (error); |
| 2237 | oattr->mq_maxmsg = mq->mq_maxmsg; |
| 2238 | oattr->mq_msgsize = mq->mq_msgsize; |
| 2239 | oattr->mq_curmsgs = mq->mq_curmsgs; |
| 2240 | if (attr != NULL) { |
| 2241 | do { |
| 2242 | oflag = flag = fp->f_flag; |
| 2243 | flag &= ~O_NONBLOCK; |
| 2244 | flag |= (attr->mq_flags & O_NONBLOCK); |
| 2245 | } while (atomic_cmpset_int(&fp->f_flag, oflag, flag) == 0); |
| 2246 | } else |
| 2247 | oflag = fp->f_flag; |
| 2248 | oattr->mq_flags = (O_NONBLOCK & oflag); |
| 2249 | fdrop(fp, td); |
| 2250 | return (error); |
| 2251 | } |
| 2252 | |
| 2253 | int |
| 2254 | sys_kmq_setattr(struct thread *td, struct kmq_setattr_args *uap) |
no test coverage detected