Philip Guenther <guent...@gmail.com> writes: > On Sun, Jul 14, 2013 at 12:54 AM, Rafael Neves <rafaelne...@gmail.com> wrote: >> The patch below fixes a bug on sysctl(8) introduced by revision 1.191 >> of sysctl.c. After rev1.191, `sysctl vfs' mangles information about >> filesystems (mounted instances of ffs are attributed to nfs, of nfs >> are atrributed to mfs, and so on). As a consequence, `sysctl >> vfs.mounts.nfs' reports 0 mounted instances on a diskless(8) setup, >> thus /etc/rc script (lines 335 to 342) doesn't add pf rules that allow >> NFS, and system hangs when it enables pf. > > First off: thank you for (a) noticing this, and (b) tracking down the > mismatch. > > ... >> --- sysctl.c 9 Jun 2013 12:54:38 -0000 1.192 >> +++ sysctl.c 14 Jul 2013 07:09:28 -0000 >> @@ -1175,8 +1175,8 @@ vfsinit(void) >> >> vfsname[0].ctl_name = "mounts"; >> vfsname[0].ctl_type = CTLTYPE_NODE; >> - vfsvars[0].list = vfsname + 1; >> - vfsvars[0].size = maxtypenum - 1; >> + vfsvars[0].list = vfsname; >> + vfsvars[0].size = maxtypenum; > > Soooooo close... > > While this fixes the observed problem, it's not 100% correct. The > glitch is that it fails a negative test: the command > sysctl vfs.mounts.mounts > should fail with the error > sysctl: third level name mounts in vfs.mounts.mounts is invalid > > but with your patch it silently succeeds. The vfsname list is offset > by one in vfsvars[0].list to prevent that, so the fix that avoids the > unwanted match against vfsname[0] is to keep the offset, but undo it > in the lookup: > > --- sysctl.c 9 Jun 2013 12:54:38 -0000 1.192 > +++ sysctl.c 15 Jul 2013 03:43:27 -0000 > @@ -1200,7 +1200,7 @@ sysctl_vfsgen(char *string, char **bufpp > > mib[1] = VFS_GENERIC; > mib[2] = VFS_CONF; > - mib[3] = indx; > + mib[3] = indx + 1; > size = sizeof vfc; > if (sysctl(mib, 4, &vfc, &size, (void *)0, (size_t)0) < 0) { > if (errno != EOPNOTSUPP) > > > That makes sense?
It does make sense to me. ok jca@ -- Jérémie Courrèges-Anglas PGP Key fingerprint: 61DB D9A0 00A4 67CF 2A90 8961 6191 8FBF 06A1 1494