[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 07/12] bsd-user: sysctl helper funtions: sysctl_name2oid and s
From: |
Warner Losh |
Subject: |
[PATCH v2 07/12] bsd-user: sysctl helper funtions: sysctl_name2oid and sysctl_oidfmt |
Date: |
Mon, 13 Feb 2023 17:27:52 -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>
Reviewed-by: Warner Losh <imp@bsdimp.com>
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 457e61f5b36..084d53c16f6 100644
--- a/bsd-user/freebsd/os-sys.c
+++ b/bsd-user/freebsd/os-sys.c
@@ -240,6 +240,24 @@ static void G_GNUC_UNUSED h2t_old_sysctl(void *holdp,
size_t *holdlen, uint32_t
#endif
}
+/*
+ * Convert the undocmented name2oid sysctl data for the target.
+ */
+static inline void G_GNUC_UNUSED 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 G_GNUC_UNUSED 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 v2 00/12] 2023 Q1 bsd-user upstreaming: bugfixes and sysctl, Warner Losh, 2023/02/13
- [PATCH v2 01/12] bsd-user: Don't truncate the return value from freebsd_syscall, Warner Losh, 2023/02/13
- [PATCH v2 02/12] build: Don't specify -no-pie for --static user-mode programs, Warner Losh, 2023/02/13
- [PATCH v2 03/12] bsd-user: Add sysarch syscall, Warner Losh, 2023/02/13
- [PATCH v2 05/12] bsd-user: Helper routines oidfmt, Warner Losh, 2023/02/13
- [PATCH v2 04/12] bsd-user: various helper routines for sysctl, Warner Losh, 2023/02/13
- [PATCH v2 07/12] bsd-user: sysctl helper funtions: sysctl_name2oid and sysctl_oidfmt,
Warner Losh <=
- [PATCH v2 08/12] bsd-user: common routine do_freebsd_sysctl_oid for all sysctl variants, Warner Losh, 2023/02/13
- [PATCH v2 09/12] bsd-user: Start translation of arch-specific sysctls, Warner Losh, 2023/02/13
- [PATCH v2 12/12] bsd-user: Add -strict, Warner Losh, 2023/02/13