diff options
author | Andriy Gapon <avg@FreeBSD.org> | 2012-05-12 09:07:41 +0000 |
---|---|---|
committer | Andriy Gapon <avg@FreeBSD.org> | 2012-05-12 09:07:41 +0000 |
commit | 0da23ac99dda029fe4d33ffc9ef48a8a245b6a17 (patch) | |
tree | 4a2eb9dad0c18698040578a1342fa0a4c16331f5 | |
parent | 1702e62f67dacc0c3cbd77c73f9f611340850872 (diff) |
Notes
-rw-r--r-- | sys/boot/common/boot.c | 18 |
1 files 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); } |