git: d995dc937a3c - main - vm/vm_mmap.c: add two examples of using exterrors
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 31 May 2025 19:52:52 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=d995dc937a3c999daa8e0675d1ec45f9ab422cb5
commit d995dc937a3c999daa8e0675d1ec45f9ab422cb5
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-05-23 05:36:13 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-05-31 19:52:41 +0000
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
---
sys/vm/vm_mmap.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index afc25965d73c..492233215d4b 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -40,13 +40,14 @@
* Mapped file (mmap) interface to VM
*/
-#include <sys/cdefs.h>
#include "opt_hwpmc_hooks.h"
#include "opt_vm.h"
+#define EXTERR_CATEGORY EXTERR_CAT_MMAP
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/capsicum.h>
+#include <sys/exterrvar.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
@@ -190,12 +191,16 @@ kern_mmap(struct thread *td, const struct mmap_req *mrp)
pos = mrp->mr_pos;
check_fp_fn = mrp->mr_check_fp_fn;
- if ((prot & ~(_PROT_ALL | PROT_MAX(_PROT_ALL))) != 0)
+ if ((prot & ~(_PROT_ALL | PROT_MAX(_PROT_ALL))) != 0) {
+ SET_ERROR0(EINVAL, "unknown PROT bits");
return (EINVAL);
+ }
max_prot = PROT_MAX_EXTRACT(prot);
prot = PROT_EXTRACT(prot);
- if (max_prot != 0 && (max_prot & prot) != prot)
+ if (max_prot != 0 && (max_prot & prot) != prot) {
+ SET_ERROR0(ENOTSUP, "prot is not subset of max_prot");
return (ENOTSUP);
+ }
p = td->td_proc;