summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2012-05-12 09:07:41 +0000
committeravg <avg@FreeBSD.org>2012-05-12 09:07:41 +0000
commitd62be9765a8345694cea5f609f5f8ea7b4fdddcb (patch)
tree4a2eb9dad0c18698040578a1342fa0a4c16331f5
parenta1cf7817fdc316198beb7e881a16684b20ea9ab8 (diff)
downloadFreeBSD-src-d62be9765a8345694cea5f609f5f8ea7b4fdddcb.zip
FreeBSD-src-d62be9765a8345694cea5f609f5f8ea7b4fdddcb.tar.gz
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
-rw-r--r--sys/boot/common/boot.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/boot/common/boot.c b/sys/boot/common/boot.c
index c6ab681..8ea06dd 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);
}
OpenPOWER on IntegriCloud