Skip to content

Commit d995dc9

Browse files
committed
vm/vm_mmap.c: add two examples of using exterrors
Reviewed by: brooks Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D50483
1 parent 92b393c commit d995dc9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sys/vm/vm_mmap.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@
4040
* Mapped file (mmap) interface to VM
4141
*/
4242

43-
#include <sys/cdefs.h>
4443
#include "opt_hwpmc_hooks.h"
4544
#include "opt_vm.h"
4645

46+
#define EXTERR_CATEGORY EXTERR_CAT_MMAP
4747
#include <sys/param.h>
4848
#include <sys/systm.h>
4949
#include <sys/capsicum.h>
50+
#include <sys/exterrvar.h>
5051
#include <sys/kernel.h>
5152
#include <sys/lock.h>
5253
#include <sys/mutex.h>
@@ -190,12 +191,16 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp)
190191
pos = mrp->mr_pos;
191192
check_fp_fn = mrp->mr_check_fp_fn;
192193

193-
if ((prot & ~(_PROT_ALL | PROT_MAX(_PROT_ALL))) != 0)
194+
if ((prot & ~(_PROT_ALL | PROT_MAX(_PROT_ALL))) != 0) {
195+
SET_ERROR0(EINVAL, "unknown PROT bits");
194196
return (EINVAL);
197+
}
195198
max_prot = PROT_MAX_EXTRACT(prot);
196199
prot = PROT_EXTRACT(prot);
197-
if (max_prot != 0 && (max_prot & prot) != prot)
200+
if (max_prot != 0 && (max_prot & prot) != prot) {
201+
SET_ERROR0(ENOTSUP, "prot is not subset of max_prot");
198202
return (ENOTSUP);
203+
}
199204

200205
p = td->td_proc;
201206

0 commit comments

Comments
 (0)