summaryrefslogtreecommitdiff
path: root/sbin/sysctl
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2013-07-18 05:02:58 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2013-07-18 05:02:58 +0000
commit79a73574f61e53ff42d4708942a046eca09c6106 (patch)
treeaaabd850fbe0b65c15c55ec2b49aa02653eea9d4 /sbin/sysctl
parentfd1dd940f054a464dadcd15a996f0e8b0f9ccd54 (diff)
Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently. suggested by Rafael Neves (rafaelneves (at) gmail.com)
Diffstat (limited to 'sbin/sysctl')
-rw-r--r--sbin/sysctl/sysctl.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index c26d5b2cef0..e5df3e3c385 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.c,v 1.193 2013/07/18 03:26:48 guenther Exp $ */
+/* $OpenBSD: sysctl.c,v 1.194 2013/07/18 05:02:57 guenther Exp $ */
/* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */
/*
@@ -1127,7 +1127,11 @@ vfsinit(void)
buflen = 4;
if (sysctl(mib, 3, &maxtypenum, &buflen, (void *)0, (size_t)0) < 0)
return;
- maxtypenum++; /* + generic (0) */
+ /*
+ * We need to do 0..maxtypenum so add one, and then we offset them
+ * all by (another) one by inserting VFS_GENERIC entries at zero
+ */
+ maxtypenum += 2;
if ((vfs_typenums = calloc(maxtypenum, sizeof(int))) == NULL)
return;
if ((vfsvars = calloc(maxtypenum, sizeof(*vfsvars))) == NULL) {
@@ -1142,7 +1146,7 @@ vfsinit(void)
mib[2] = VFS_CONF;
buflen = sizeof vfc;
for (loc = lastused, cnt = 1; cnt < maxtypenum; cnt++) {
- mib[3] = cnt;
+ mib[3] = cnt - 1;
if (sysctl(mib, 4, &vfc, &buflen, (void *)0, (size_t)0) < 0) {
if (errno == EOPNOTSUPP)
continue;
@@ -1200,7 +1204,7 @@ sysctl_vfsgen(char *string, char **bufpp, int mib[], int flags, int *typep)
mib[1] = VFS_GENERIC;
mib[2] = VFS_CONF;
- mib[3] = indx + 1;
+ mib[3] = indx;
size = sizeof vfc;
if (sysctl(mib, 4, &vfc, &size, (void *)0, (size_t)0) < 0) {
if (errno != EOPNOTSUPP)