Page MenuHomeFreeBSD

D26239.id.diff
No OneTemporary

D26239.id.diff

Index: head/sbin/sysctl/sysctl.c
===================================================================
--- head/sbin/sysctl/sysctl.c
+++ head/sbin/sysctl/sysctl.c
@@ -697,6 +697,29 @@
return (0);
}
+static int
+S_pagesizes(size_t l2, void *p)
+{
+ char buf[256];
+ u_long *ps;
+ size_t l;
+ int i;
+
+ l = snprintf(buf, sizeof(buf), "{ ");
+ ps = p;
+ for (i = 0; i * sizeof(*ps) < l2 && ps[i] != 0 && l < sizeof(buf);
+ i++) {
+ l += snprintf(&buf[l], sizeof(buf) - l,
+ "%s%lu", i == 0 ? "" : ", ", ps[i]);
+ }
+ if (l < sizeof(buf))
+ (void)snprintf(&buf[l], sizeof(buf) - l, " }");
+
+ printf("%s", buf);
+
+ return (0);
+}
+
#ifdef __amd64__
static int
S_efi_map(size_t l2, void *p)
@@ -1002,6 +1025,8 @@
func = S_vmtotal;
else if (strcmp(fmt, "S,input_id") == 0)
func = S_input_id;
+ else if (strcmp(fmt, "S,pagesizes") == 0)
+ func = S_pagesizes;
#ifdef __amd64__
else if (strcmp(fmt, "S,efi_map_header") == 0)
func = S_efi_map;
Index: head/sys/kern/kern_mib.c
===================================================================
--- head/sys/kern/kern_mib.c
+++ head/sys/kern/kern_mib.c
@@ -246,22 +246,22 @@
pagesizes32[i] = (uint32_t)pagesizes[i];
len = sizeof(pagesizes32);
- if (len > req->oldlen)
+ if (len > req->oldlen && req->oldptr != NULL)
len = req->oldlen;
error = SYSCTL_OUT(req, pagesizes32, len);
} else
#endif
{
len = sizeof(pagesizes);
- if (len > req->oldlen)
+ if (len > req->oldlen && req->oldptr != NULL)
len = req->oldlen;
error = SYSCTL_OUT(req, pagesizes, len);
}
return (error);
}
SYSCTL_PROC(_hw, OID_AUTO, pagesizes,
- CTLTYPE_ULONG | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
- sysctl_hw_pagesizes, "LU",
+ CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
+ sysctl_hw_pagesizes, "S,pagesizes",
"Supported page sizes");
int adaptive_machine_arch = 1;

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 4:43 AM (19 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30799061
Default Alt Text
D26239.id.diff (1 KB)

Event Timeline