Re: A little question about safe mode

From: John Baldwin <jhb_at_freebsd.org>
Date: Fri, 19 Oct 2012 08:52:35 -0400
On Thursday, October 18, 2012 1:52:57 pm Andriy Gapon wrote:
> on 18/10/2012 18:33 Andriy Gapon said the following:
> > on 18/10/2012 18:20 Andriy Gapon said the following:
> >> My guess is that the easiest way to avoid this ambiguity and the confusion that it
> >> causes (like the problem you described above) is to prepend "/dev/", if it's
> >> missing, right in vfs_mountroot.c before calling kernel_mount().
> > 
> > A patch (not tested):
> > 
> > --- a/sys/kern/vfs_mountroot.c
> > +++ b/sys/kern/vfs_mountroot.c
> > _at__at_ -676,6 +676,7 _at__at_ static int
> >  parse_mount(char **conf)
> >  {
> >  	char errmsg[255];
> > +	char devbuf[MNAMELEN];
> >  	struct mntarg *ma;
> >  	char *dev, *fs, *opts, *tok;
> >  	int delay, error, timeout;
> > _at__at_ -693,6 +694,11 _at__at_ parse_mount(char **conf)
> >  	parse_advance(&tok);
> >  	dev = tok;
> > 
> > +	if (dev[0] != '\0' && strncmp(dev, "/dev/", 5) != 0) {
> > +		snprintf(devbuf, sizeof(devbuf), "/dev/%s", dev);
> > +		dev = devbuf;
> > +	}
> > +
> >  	if (root_mount_mddev != -1) {
> >  		/* Handle substitution for the md unit number. */
> >  		tok = strstr(dev, "md#");
> > 
> > 
> 
> Oops, the patch incorrectly assumes that all "device names" are device names,
> which is incorrect e.g. for ZFS.  Maybe some other filesystems too.
> So don't try it :-)

It seems that perhaps what you want to do is try it with /dev/ and if that
doesn't work, fall back to the raw string?

-- 
John Baldwin
Received on Fri Oct 19 2012 - 13:32:30 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:31 UTC