diff options
| author | rmind <rmind@NetBSD.org> | 2008-07-02 20:06:09 +0000 |
|---|---|---|
| committer | rmind <rmind@NetBSD.org> | 2008-07-02 20:06:09 +0000 |
| commit | b7cdc71cd2bc2d0d32a3803119d1a5cf2388f13f (patch) | |
| tree | ab52e6ea7f02f03409e002d35ca6b4ca97a554d3 /sys/kern/sys_mqueue.c | |
| parent | 2a94bd63c1ee7547b7107d2b7adcf4bfd846bec1 (diff) | |
mq_open: fix confusion of FREAD/FWRITE and VREAD/VWRITE.
Diffstat (limited to 'sys/kern/sys_mqueue.c')
| -rw-r--r-- | sys/kern/sys_mqueue.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/kern/sys_mqueue.c b/sys/kern/sys_mqueue.c index b3436cf25a1..b2a75c63814 100644 --- a/sys/kern/sys_mqueue.c +++ b/sys/kern/sys_mqueue.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_mqueue.c,v 1.10 2008/04/24 15:35:30 ad Exp $ */ +/* $NetBSD: sys_mqueue.c,v 1.11 2008/07/02 20:06:09 rmind Exp $ */ /* * Copyright (c) 2007, 2008 Mindaugas Rasiukevicius <rmind at NetBSD org> @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.10 2008/04/24 15:35:30 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.11 2008/07/02 20:06:09 rmind Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -381,14 +381,16 @@ sys_mq_open(struct lwp *l, const struct sys_mq_open_args *uap, return error; } fp->f_type = DTYPE_MQUEUE; - fp->f_flag = (oflag & O_RDWR) ? (VREAD | VWRITE) : - ((oflag & O_RDONLY) ? VREAD : VWRITE); + fp->f_flag = FFLAGS(oflag) & (FREAD | FWRITE); fp->f_ops = &mqops; /* Look up for mqueue with such name */ mutex_enter(&mqlist_mtx); mq = mqueue_lookup(name); if (mq) { + const int acc_mode = (oflag & O_RDWR) ? (VREAD | VWRITE) : + ((oflag & O_RDONLY) ? VREAD : VWRITE); + KASSERT(mutex_owned(&mq->mq_mtx)); /* Check if mqueue is not marked as unlinking */ if (mq->mq_attrib.mq_flags & MQ_UNLINK) { @@ -401,7 +403,7 @@ sys_mq_open(struct lwp *l, const struct sys_mq_open_args *uap, goto exit; } /* Check the permission */ - if (mqueue_access(l, mq, fp->f_flag)) { + if (mqueue_access(l, mq, acc_mode)) { error = EACCES; goto exit; } |
