[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/9] bsd-user: sysctl helper funtions: sysctl_name2oid and sysctl
From: |
Warner Losh |
Subject: |
[PATCH 5/9] bsd-user: sysctl helper funtions: sysctl_name2oid and sysctl_oidfmt |
Date: |
Fri, 10 Feb 2023 16:18:25 -0700 |
From: Juergen Lock <nox@jelal.kn-bremen.de>
Helper functions for sysctl implementations. sysctl_name2oid and
sysctl_oidfmt convert oids between host and targets
Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/freebsd/os-sys.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c
index e3b9f168a2b..ac5ab9b17bc 100644
--- a/bsd-user/freebsd/os-sys.c
+++ b/bsd-user/freebsd/os-sys.c
@@ -115,6 +115,24 @@ static int sysctl_oldcvt(void *holdp, size_t *holdlen,
uint32_t kind)
return 0;
}
+/*
+ * Convert the undocmented name2oid sysctl data for the target.
+ */
+static inline void sysctl_name2oid(uint32_t *holdp, size_t holdlen)
+{
+ size_t i, num = holdlen / sizeof(uint32_t);
+
+ for (i = 0; i < num; i++) {
+ holdp[i] = tswap32(holdp[i]);
+ }
+}
+
+static inline void sysctl_oidfmt(uint32_t *holdp)
+{
+ /* byte swap the kind */
+ holdp[0] = tswap32(holdp[0]);
+}
+
/* sysarch() is architecture dependent. */
abi_long do_freebsd_sysarch(void *cpu_env, abi_long arg1, abi_long arg2)
{
--
2.39.1
[PATCH 5/9] bsd-user: sysctl helper funtions: sysctl_name2oid and sysctl_oidfmt,
Warner Losh <=
[PATCH 3/9] bsd-user: Add sysarch syscall, Warner Losh, 2023/02/10
[PATCH 6/9] bsd-user: common routine do_freebsd_sysctl_oid for all sysctl variants, Warner Losh, 2023/02/10
[PATCH 7/9] bsd-user: do_freebsd_sysctl helper for sysctl(2), Warner Losh, 2023/02/10