Author: avg
Date: Fri Jun 29 10:22:20 2012
New Revision: 237767
URL: http://svn.freebsd.org/changeset/base/237767

Log:
  MFC r235330: zfs boot: try to set vfs.root.mountfrom from currdev as a
  fallback

Modified:
  stable/9/sys/boot/common/boot.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)
  stable/9/sys/dev/   (props changed)
  stable/9/sys/dev/e1000/   (props changed)
  stable/9/sys/dev/isp/   (props changed)
  stable/9/sys/dev/ixgbe/   (props changed)
  stable/9/sys/fs/   (props changed)
  stable/9/sys/fs/ntfs/   (props changed)
  stable/9/sys/modules/   (props changed)

Modified: stable/9/sys/boot/common/boot.c
==============================================================================
--- stable/9/sys/boot/common/boot.c     Fri Jun 29 10:19:15 2012        
(r237766)
+++ stable/9/sys/boot/common/boot.c     Fri Jun 29 10:22:20 2012        
(r237767)
@@ -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);
 }
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "[email protected]"

Reply via email to