git: 7211cd2cce74 - main - kern/kern_fork.c: define the exterror category for fork
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 25 Jan 2026 15:56:47 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=7211cd2cce746972af2d60d4b5bf0c087f016731
commit 7211cd2cce746972af2d60d4b5bf0c087f016731
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-01-08 00:31:22 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-01-25 15:52:55 +0000
kern/kern_fork.c: define the exterror category for fork
Convert EINVALs in kern_fork.c into EXTERRORs.
Reviewed by: asomers, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54592
---
sys/kern/kern_fork.c | 35 ++++++++++++++++++-----------------
sys/sys/exterr_cat.h | 1 +
2 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index c559de34c60c..746aaf20ce03 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -37,10 +37,12 @@
#include "opt_ktrace.h"
#include "opt_kstack_pages.h"
+#define EXTERR_CATEGORY EXTERR_CAT_FORK
#include <sys/systm.h>
#include <sys/acct.h>
#include <sys/bitstring.h>
#include <sys/eventhandler.h>
+#include <sys/exterrvar.h>
#include <sys/fcntl.h>
#include <sys/filedesc.h>
#include <sys/jail.h>
@@ -164,10 +166,11 @@ sys_rfork(struct thread *td, struct rfork_args *uap)
/* Don't allow kernel-only flags. */
if ((uap->flags & RFKERNELONLY) != 0)
- return (EINVAL);
+ return (EXTERROR(EINVAL, "Kernel-only flags %#jx", uap->flags));
/* RFSPAWN must not appear with others */
if ((uap->flags & RFSPAWN) != 0 && uap->flags != RFSPAWN)
- return (EINVAL);
+ return (EXTERROR(EINVAL, "RFSPAWN must be the only flag %#jx",
+ uap->flags));
AUDIT_ARG_FFLAGS(uap->flags);
bzero(&fr, sizeof(fr));
@@ -869,34 +872,32 @@ fork1(struct thread *td, struct fork_req *fr)
else
MPASS(fr->fr_procp == NULL);
- /* Check for the undefined or unimplemented flags. */
if ((flags & ~(RFFLAGS | RFTSIGFLAGS(RFTSIGMASK))) != 0)
- return (EINVAL);
+ return (EXTERROR(EINVAL,
+ "Undef or unimplemented flags %#jx", flags));
- /* Signal value requires RFTSIGZMB. */
if ((flags & RFTSIGFLAGS(RFTSIGMASK)) != 0 && (flags & RFTSIGZMB) == 0)
- return (EINVAL);
+ return (EXTERROR(EINVAL,
+ "Signal value requires RFTSIGZMB", flags));
- /* Can't copy and clear. */
- if ((flags & (RFFDG|RFCFDG)) == (RFFDG|RFCFDG))
- return (EINVAL);
+ if ((flags & (RFFDG | RFCFDG)) == (RFFDG | RFCFDG))
+ return (EXTERROR(EINVAL, "Can not copy and clear"));
- /* Check the validity of the signal number. */
if ((flags & RFTSIGZMB) != 0 && (u_int)RFTSIGNUM(flags) > _SIG_MAXSIG)
- return (EINVAL);
+ return (EXTERROR(EINVAL, "Invalid signal", RFTSIGNUM(flags)));
if ((flags & RFPROCDESC) != 0) {
- /* Can't not create a process yet get a process descriptor. */
if ((flags & RFPROC) == 0)
- return (EINVAL);
+ return (EXTERROR(EINVAL,
+ "Can not not create a process yet get a process descriptor"));
- /* Must provide a place to put a procdesc if creating one. */
if (fr->fr_pd_fd == NULL)
- return (EINVAL);
+ return (EXTERROR(EINVAL,
+ "Must provide a place to put a procdesc if creating one"));
- /* Check if we are using supported flags. */
if ((fr->fr_pd_flags & ~PD_ALLOWED_AT_FORK) != 0)
- return (EINVAL);
+ return (EXTERROR(EINVAL,
+ "Invallid pdflags at fork %#jx", fr->fr_pd_flags));
}
p1 = td->td_proc;
diff --git a/sys/sys/exterr_cat.h b/sys/sys/exterr_cat.h
index 24f07539fe35..daf0419754b7 100644
--- a/sys/sys/exterr_cat.h
+++ b/sys/sys/exterr_cat.h
@@ -37,6 +37,7 @@
#define EXTERR_CAT_GEOM 12
#define EXTERR_CAT_FUSE_VFS 13
#define EXTERR_CAT_FUSE_DEVICE 14
+#define EXTERR_CAT_FORK 15
#endif