mirror of
https://git.FreeBSD.org/ports.git
synced 2025-01-14 07:43:06 +00:00
cf14e8bdd7
http://article.gmane.org/gmane.comp.emulators.qemu/267615 - Take updated bsd-user patches from sbruno's github repo. [1] - Add headers to my recent bsd-user patches. (they are applied as in the EXTRA_PATCHES order in the port Makefile) Submitted by: sbruno [1] Obtained from: https://github.com/seanbruno/qemu/commits/bsd-user [1]
64 lines
2.1 KiB
Plaintext
64 lines
2.1 KiB
Plaintext
From nox Mon Sep 17 00:00:00 2001
|
|
From: Juergen Lock <nox@jelal.kn-bremen.de>
|
|
Date: 05 Apr 2014 21:06:00 +0200
|
|
Subject: Fix bsd-user FreeBSD hw.availpages sysctl
|
|
|
|
hw.availpages is defined as OID_AUTO so the mib can change; find out
|
|
it's value at the first hw.* sysctl syscall.
|
|
|
|
Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
|
|
|
|
--- a/bsd-user/freebsd/os-sys.c
|
|
+++ b/bsd-user/freebsd/os-sys.c
|
|
@@ -219,24 +219,36 @@ abi_long do_freebsd_sysctl(CPUArchState
|
|
ret = 0;
|
|
goto out;
|
|
|
|
- case 851: /* hw.availpages */
|
|
+ default:
|
|
{
|
|
- long lvalue;
|
|
- size_t len = sizeof(lvalue);
|
|
+ static int oid_hw_availpages;
|
|
+
|
|
+ if (!oid_hw_availpages) {
|
|
+ int real_oid[CTL_MAXNAME+2];
|
|
+ size_t len = sizeof(real_oid) / sizeof(int);
|
|
|
|
- if (sysctlbyname("hw.availpages", &lvalue, &len, NULL, 0)
|
|
- == -1) {
|
|
- ret = -1;
|
|
- } else {
|
|
- (*(abi_ulong *)holdp) = tswapal((abi_ulong)lvalue);
|
|
- holdlen = sizeof(abi_ulong);
|
|
- ret = 0;
|
|
+ if (sysctlnametomib("hw.availpages", real_oid, &len) >= 0)
|
|
+ oid_hw_availpages = real_oid[1];
|
|
}
|
|
- }
|
|
- goto out;
|
|
|
|
- default:
|
|
- break;
|
|
+ if (oid_hw_availpages && snamep[1] == oid_hw_availpages) {
|
|
+ long lvalue;
|
|
+ size_t len = sizeof(lvalue);
|
|
+
|
|
+ if (sysctlbyname("hw.availpages", &lvalue, &len, NULL, 0)
|
|
+ == -1) {
|
|
+ ret = -1;
|
|
+ } else {
|
|
+ if (oldlen) {
|
|
+ (*(abi_ulong *)holdp) = tswapal((abi_ulong)lvalue);
|
|
+ }
|
|
+ holdlen = sizeof(abi_ulong);
|
|
+ ret = 0;
|
|
+ }
|
|
+ goto out;
|
|
+ }
|
|
+ break;
|
|
+ }
|
|
}
|
|
default:
|
|
break;
|