summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authorrodrigc <rodrigc@FreeBSD.org>2009-06-01 01:02:30 +0000
committerrodrigc <rodrigc@FreeBSD.org>2009-06-01 01:02:30 +0000
commit2380a39febcd4ecf99729dd7a1887661f1a5ab81 (patch)
tree74e51078ec3549432e91cb91eaba5a7e13cebe39 /sys/boot
parent95a5c8db946a1a257637d69644d55b86531668f6 (diff)
downloadFreeBSD-src-2380a39febcd4ecf99729dd7a1887661f1a5ab81.zip
FreeBSD-src-2380a39febcd4ecf99729dd7a1887661f1a5ab81.tar.gz
sys/boot/common.c
================= Extend the loader to parse the root file system mount options in /etc/fstab, and set a new loader variable vfs.root.mountfrom.options with these options. The root mount options must be a comma-delimited string, as specified in /etc/fstab. Only set the vfs.root.mountfrom.options variable if it has not been set in the environment. sys/kern/vfs_mount.c ==================== When mounting the root file system, pass the mount options specified in vfs.root.mountfrom.options, but filter out "rw" and "noro", since the initial mount of the root file system must be done as "ro". While we are here, try to add a few hints to the mountroot prompt to give users and idea what might of gone wrong during mounting of the root file system. Reviewed by: jhb (an earlier patch)
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/common/boot.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/sys/boot/common/boot.c b/sys/boot/common/boot.c
index 515d0fa..315c039 100644
--- a/sys/boot/common/boot.c
+++ b/sys/boot/common/boot.c
@@ -287,7 +287,7 @@ getbootfile(int try)
int
getrootmount(char *rootdev)
{
- char lbuf[128], *cp, *ep, *dev, *fstyp;
+ char lbuf[128], *cp, *ep, *dev, *fstyp, *options;
int fd, error;
if (getenv("vfs.root.mountfrom") != NULL)
@@ -331,11 +331,30 @@ getrootmount(char *rootdev)
*cp = 0;
fstyp = strdup(ep);
- /* build the final result and save it */
+ /* skip whitespace up to mount options */
+ cp += 1;
+ while ((*cp != 0) && isspace(*cp))
+ cp++;
+ if (*cp == 0) /* misformatted */
+ continue;
+ /* skip text to end of mount options and delimit */
+ ep = cp;
+ while ((*cp != 0) && !isspace(*cp))
+ cp++;
+ *cp = 0;
+ options = strdup(ep);
+ /* Build the <fstype>:<device> and save it in vfs.root.mountfrom */
sprintf(lbuf, "%s:%s", fstyp, dev);
free(dev);
free(fstyp);
setenv("vfs.root.mountfrom", lbuf, 0);
+
+ /* Don't override vfs.root.mountfrom.options if it is already set */
+ if (getenv("vfs.root.mountfrom.options") == NULL) {
+ /* save mount options */
+ setenv("vfs.root.mountfrom.options", options, 0);
+ }
+ free(options);
error = 0;
break;
}
OpenPOWER on IntegriCloud