Date: Sat, 12 May 2012 09:07:42 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r235330 - head/sys/boot/common Message-ID: <201205120907.q4C97gxC024378@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Sat May 12 09:07:41 2012 New Revision: 235330 URL: http://svn.freebsd.org/changeset/base/235330 Log: zfs boot: try to set vfs.root.mountfrom from currdev as a fallback This way with the new zfsloader there is no need to explicitly set zfs root filesystem either via vfs.root.mountfrom or fstab. It should be automatically picked up from currdev which is by default is set from bootfs. Tested by: Florian Wagner <florian@wagner-flo.net> (x86) MFC after: 1 month Modified: head/sys/boot/common/boot.c Modified: head/sys/boot/common/boot.c ============================================================================== --- head/sys/boot/common/boot.c Sat May 12 09:03:30 2012 (r235329) +++ head/sys/boot/common/boot.c Sat May 12 09:07:41 2012 (r235330) @@ -311,12 +311,12 @@ getrootmount(char *rootdev) if (getenv("vfs.root.mountfrom") != NULL) return(0); + error = 1; sprintf(lbuf, "%s/etc/fstab", rootdev); if ((fd = open(lbuf, O_RDONLY)) < 0) - return(1); + goto notfound; /* loop reading lines from /etc/fstab What was that about sscanf again? */ - error = 1; while (fgetstr(lbuf, sizeof(lbuf), fd) >= 0) { if ((lbuf[0] == 0) || (lbuf[0] == '#')) continue; @@ -377,6 +377,20 @@ getrootmount(char *rootdev) break; } close(fd); + +notfound: + if (error) { + const char *currdev; + + currdev = getenv("currdev"); + if (currdev != NULL && strncmp("zfs:", currdev, 4) == 0) { + cp = strdup(currdev); + cp[strlen(cp) - 1] = '\0'; + setenv("vfs.root.mountfrom", cp, 0); + error = 0; + } + } + return(error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205120907.q4C97gxC024378>