From 0da23ac99dda029fe4d33ffc9ef48a8a245b6a17 Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Sat, 12 May 2012 09:07:41 +0000 Subject: 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 (x86) MFC after: 1 month --- sys/boot/common/boot.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/boot/common/boot.c b/sys/boot/common/boot.c index c6ab6812da72..8ea06dd577de 100644 --- a/sys/boot/common/boot.c +++ b/sys/boot/common/boot.c @@ -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); } -- cgit v1.2.3