2 * Copyright (c) 2010 Marcel Moolenaar
3 * Copyright (c) 1999-2004 Poul-Henning Kamp
4 * Copyright (c) 1999 Michael Smith
5 * Copyright (c) 1989, 1993
6 * The Regents of the University of California. All rights reserved.
7 * (c) UNIX System Laboratories, Inc.
8 * All or some portions of this file are derived from material licensed
9 * to the University of California by American Telephone and Telegraph
10 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11 * the permission of UNIX System Laboratories, Inc.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 #include "opt_rootdevname.h"
40 #include <sys/cdefs.h>
41 __FBSDID("$FreeBSD$");
43 #include <sys/param.h>
46 #include <sys/fcntl.h>
48 #include <sys/kernel.h>
49 #include <sys/malloc.h>
50 #include <sys/mdioctl.h>
51 #include <sys/mount.h>
52 #include <sys/mutex.h>
53 #include <sys/namei.h>
56 #include <sys/filedesc.h>
57 #include <sys/reboot.h>
60 #include <sys/syscallsubr.h>
61 #include <sys/sysproto.h>
63 #include <sys/sysctl.h>
64 #include <sys/sysent.h>
65 #include <sys/systm.h>
66 #include <sys/vnode.h>
68 #include <geom/geom.h>
71 * The root filesystem is detailed in the kernel environment variable
72 * vfs.root.mountfrom, which is expected to be in the general format
74 * <vfsname>:[<path>][ <vfsname>:[<path>] ...]
75 * vfsname := the name of a VFS known to the kernel and capable
76 * of being mounted as root
77 * path := disk device name or other data used by the filesystem
78 * to locate its physical store
80 * If the environment variable vfs.root.mountfrom is a space separated list,
81 * each list element is tried in turn and the root filesystem will be mounted
82 * from the first one that suceeds.
84 * The environment variable vfs.root.mountfrom.options is a comma delimited
85 * set of string mount options. These mount options must be parseable
86 * by nmount() in the kernel.
89 static int parse_mount(char **);
90 static struct mntarg *parse_mountroot_options(struct mntarg *, const char *);
93 * The vnode of the system's root (/ in the filesystem, without chroot
96 struct vnode *rootvnode;
98 char *rootdevnames[2] = {NULL, NULL};
100 struct root_hold_token {
102 LIST_ENTRY(root_hold_token) list;
105 static LIST_HEAD(, root_hold_token) root_holds =
106 LIST_HEAD_INITIALIZER(root_holds);
115 static enum action root_mount_onfail = A_CONTINUE;
117 static int root_mount_mddev;
118 static int root_mount_complete;
120 /* By default wait up to 3 seconds for devices to appear. */
121 static int root_mount_timeout = 3;
123 struct root_hold_token *
124 root_mount_hold(const char *identifier)
126 struct root_hold_token *h;
131 h = malloc(sizeof *h, M_DEVBUF, M_ZERO | M_WAITOK);
133 mtx_lock(&mountlist_mtx);
134 LIST_INSERT_HEAD(&root_holds, h, list);
135 mtx_unlock(&mountlist_mtx);
140 root_mount_rel(struct root_hold_token *h)
145 mtx_lock(&mountlist_mtx);
146 LIST_REMOVE(h, list);
148 mtx_unlock(&mountlist_mtx);
156 /* No mutex is acquired here because int stores are atomic. */
157 return (root_mount_complete);
161 root_mount_wait(void)
165 * Panic on an obvious deadlock - the function can't be called from
166 * a thread which is doing the whole SYSINIT stuff.
168 KASSERT(curthread->td_proc->p_pid != 0,
169 ("root_mount_wait: cannot be called from the swapper thread"));
170 mtx_lock(&mountlist_mtx);
171 while (!root_mount_complete) {
172 msleep(&root_mount_complete, &mountlist_mtx, PZERO, "rootwait",
175 mtx_unlock(&mountlist_mtx);
183 if (VFS_ROOT(TAILQ_FIRST(&mountlist), LK_EXCLUSIVE, &rootvnode))
184 panic("Cannot find root vnode");
186 VOP_UNLOCK(rootvnode, 0);
188 p = curthread->td_proc;
189 FILEDESC_XLOCK(p->p_fd);
191 if (p->p_fd->fd_cdir != NULL)
192 vrele(p->p_fd->fd_cdir);
193 p->p_fd->fd_cdir = rootvnode;
196 if (p->p_fd->fd_rdir != NULL)
197 vrele(p->p_fd->fd_rdir);
198 p->p_fd->fd_rdir = rootvnode;
201 FILEDESC_XUNLOCK(p->p_fd);
203 EVENTHANDLER_INVOKE(mountroot);
207 vfs_mountroot_devfs(struct thread *td, struct mount **mpp)
209 struct vfsoptlist *opts;
210 struct vfsconf *vfsp;
216 vfsp = vfs_byname("devfs");
217 KASSERT(vfsp != NULL, ("Could not find devfs by name"));
221 mp = vfs_mount_alloc(NULLVP, vfsp, "/dev", td->td_ucred);
223 error = VFS_MOUNT(mp);
224 KASSERT(error == 0, ("VFS_MOUNT(devfs) failed %d", error));
228 opts = malloc(sizeof(struct vfsoptlist), M_MOUNT, M_WAITOK);
232 mtx_lock(&mountlist_mtx);
233 TAILQ_INSERT_HEAD(&mountlist, mp, mnt_list);
234 mtx_unlock(&mountlist_mtx);
239 error = kern_symlink(td, "/", "dev", UIO_SYSSPACE);
241 printf("kern_symlink /dev -> / returns %d\n", error);
247 vfs_mountroot_shuffle(struct thread *td, struct mount *mpdevfs)
250 struct mount *mporoot, *mpnroot;
251 struct vnode *vp, *vporoot, *vpdevfs;
255 mpnroot = TAILQ_NEXT(mpdevfs, mnt_list);
257 /* Shuffle the mountlist. */
258 mtx_lock(&mountlist_mtx);
259 mporoot = TAILQ_FIRST(&mountlist);
260 TAILQ_REMOVE(&mountlist, mpdevfs, mnt_list);
261 if (mporoot != mpdevfs) {
262 TAILQ_REMOVE(&mountlist, mpnroot, mnt_list);
263 TAILQ_INSERT_HEAD(&mountlist, mpnroot, mnt_list);
265 TAILQ_INSERT_TAIL(&mountlist, mpdevfs, mnt_list);
266 mtx_unlock(&mountlist_mtx);
268 cache_purgevfs(mporoot);
269 if (mporoot != mpdevfs)
270 cache_purgevfs(mpdevfs);
272 VFS_ROOT(mporoot, LK_EXCLUSIVE, &vporoot);
275 vporoot->v_iflag &= ~VI_MOUNT;
277 vporoot->v_mountedhere = NULL;
278 mporoot->mnt_flag &= ~MNT_ROOTFS;
279 mporoot->mnt_vnodecovered = NULL;
282 /* Set up the new rootvnode, and purge the cache */
283 mpnroot->mnt_vnodecovered = NULL;
285 cache_purgevfs(rootvnode->v_mount);
287 if (mporoot != mpdevfs) {
288 /* Remount old root under /.mount or /mnt */
290 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE,
294 NDFREE(&nd, NDF_ONLY_PNBUF);
296 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE,
302 error = (vp->v_type == VDIR) ? 0 : ENOTDIR;
304 error = vinvalbuf(vp, V_SAVE, 0, 0);
307 mporoot->mnt_vnodecovered = vp;
308 vp->v_mountedhere = mporoot;
309 strlcpy(mporoot->mnt_stat.f_mntonname,
315 NDFREE(&nd, NDF_ONLY_PNBUF);
317 if (error && bootverbose)
318 printf("mountroot: unable to remount previous root "
319 "under /.mount or /mnt (error %d).\n", error);
322 /* Remount devfs under /dev */
323 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, "/dev", td);
327 error = (vp->v_type == VDIR) ? 0 : ENOTDIR;
329 error = vinvalbuf(vp, V_SAVE, 0, 0);
331 vpdevfs = mpdevfs->mnt_vnodecovered;
332 if (vpdevfs != NULL) {
333 cache_purge(vpdevfs);
334 vpdevfs->v_mountedhere = NULL;
337 mpdevfs->mnt_vnodecovered = vp;
338 vp->v_mountedhere = mpdevfs;
343 if (error && bootverbose)
344 printf("mountroot: unable to remount devfs under /dev "
345 "(error %d).\n", error);
346 NDFREE(&nd, NDF_ONLY_PNBUF);
348 if (mporoot == mpdevfs) {
350 /* Unlink the no longer needed /dev/dev -> / symlink */
351 error = kern_unlink(td, "/dev/dev", UIO_SYSSPACE);
352 if (error && bootverbose)
353 printf("mountroot: unable to unlink /dev/dev "
354 "(error %d)\n", error);
361 * Configuration parser.
364 /* Parser character classes. */
365 #define CC_WHITESPACE -1
366 #define CC_NONWHITESPACE -2
373 parse_peek(char **conf)
380 parse_poke(char **conf, int c)
387 parse_advance(char **conf)
397 return ((c == ' ' || c == '\t' || c == '\n') ? 1 : 0);
401 parse_skipto(char **conf, int mc)
406 c = parse_peek(conf);
411 match = (c == ' ' || c == '\t' || c == '\n') ? 1 : 0;
413 case CC_NONWHITESPACE:
416 match = (c != ' ' && c != '\t') ? 1 : 0;
419 match = (c == mc) ? 1 : 0;
430 parse_token(char **conf, char **tok)
437 error = parse_skipto(conf, CC_NONWHITESPACE);
441 error = parse_skipto(conf, CC_WHITESPACE);
443 *tok = malloc(len + 1, M_TEMP, M_WAITOK | M_ZERO);
449 parse_dir_ask_printenv(const char *var)
455 printf(" %s=%s\n", var, val);
461 parse_dir_ask(char **conf)
467 printf("\nLoader variables:\n");
468 parse_dir_ask_printenv("vfs.root.mountfrom");
469 parse_dir_ask_printenv("vfs.root.mountfrom.options");
471 printf("\nManual root filesystem specification:\n");
472 printf(" <fstype>:<device> [options]\n");
473 printf(" Mount <device> using filesystem <fstype>\n");
474 printf(" and with the specified (optional) option list.\n");
476 printf(" eg. ufs:/dev/da0s1a\n");
477 printf(" zfs:tank\n");
478 printf(" cd9660:/dev/acd0 ro\n");
479 printf(" (which is equivalent to: ");
480 printf("mount -t cd9660 -o ro /dev/acd0 /)\n");
482 printf(" ? List valid disk boot devices\n");
483 printf(" . Yield 1 second (for background tasks)\n");
484 printf(" <empty line> Abort manual input\n");
488 printf("\nmountroot> ");
489 cngets(name, sizeof(name), GETS_ECHO);
492 if (name[0] == '?' && name[1] == '\0') {
493 printf("\nList of GEOM managed disk devices:\n ");
497 if (name[0] == '.' && name[1] == '\0') {
502 error = parse_mount(&mnt);
504 printf("Invalid file system specification.\n");
505 } while (error != 0);
511 parse_dir_md(char **conf)
515 struct md_ioctl *mdio;
521 error = parse_token(conf, &tok);
526 mdio = malloc(sizeof(*mdio) + len + 1, M_TEMP, M_WAITOK | M_ZERO);
527 path = (void *)(mdio + 1);
528 bcopy(tok, path, len);
531 /* Get file status. */
532 error = kern_stat(td, path, UIO_SYSSPACE, &sb);
536 /* Open /dev/mdctl so that we can attach/detach. */
537 error = kern_open(td, "/dev/" MDCTL_NAME, UIO_SYSSPACE, O_RDWR, 0);
541 fd = td->td_retval[0];
542 mdio->md_version = MDIOVERSION;
543 mdio->md_type = MD_VNODE;
545 if (root_mount_mddev != -1) {
546 mdio->md_unit = root_mount_mddev;
548 error = kern_ioctl(td, fd, MDIOCDETACH, (void *)mdio);
550 /* Ignore errors. We don't care. */
551 root_mount_mddev = -1;
554 mdio->md_file = (void *)(mdio + 1);
555 mdio->md_options = MD_AUTOUNIT | MD_READONLY;
556 mdio->md_mediasize = sb.st_size;
559 error = kern_ioctl(td, fd, MDIOCATTACH, (void *)mdio);
564 if (mdio->md_unit > 9) {
565 printf("rootmount: too many md units\n");
566 mdio->md_file = NULL;
567 mdio->md_options = 0;
568 mdio->md_mediasize = 0;
570 error = kern_ioctl(td, fd, MDIOCDETACH, (void *)mdio);
572 /* Ignore errors. We don't care. */
577 root_mount_mddev = mdio->md_unit;
578 printf(MD_NAME "%u attached to %s\n", root_mount_mddev, mdio->md_file);
580 error = kern_close(td, fd);
588 parse_dir_onfail(char **conf)
593 error = parse_token(conf, &action);
597 if (!strcmp(action, "continue"))
598 root_mount_onfail = A_CONTINUE;
599 else if (!strcmp(action, "panic"))
600 root_mount_onfail = A_PANIC;
601 else if (!strcmp(action, "reboot"))
602 root_mount_onfail = A_REBOOT;
603 else if (!strcmp(action, "retry"))
604 root_mount_onfail = A_RETRY;
606 printf("rootmount: %s: unknown action\n", action);
610 free(action, M_TEMP);
615 parse_dir_timeout(char **conf)
621 error = parse_token(conf, &tok);
625 secs = strtol(tok, &endtok, 0);
626 error = (secs < 0 || *endtok != '\0') ? EINVAL : 0;
628 root_mount_timeout = secs;
634 parse_directive(char **conf)
639 error = parse_token(conf, &dir);
643 if (strcmp(dir, ".ask") == 0)
644 error = parse_dir_ask(conf);
645 else if (strcmp(dir, ".md") == 0)
646 error = parse_dir_md(conf);
647 else if (strcmp(dir, ".onfail") == 0)
648 error = parse_dir_onfail(conf);
649 else if (strcmp(dir, ".timeout") == 0)
650 error = parse_dir_timeout(conf);
652 printf("mountroot: invalid directive `%s'\n", dir);
653 /* Ignore the rest of the line. */
654 (void)parse_skipto(conf, '\n');
662 parse_mount_dev_present(const char *dev)
667 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, dev, curthread);
671 NDFREE(&nd, NDF_ONLY_PNBUF);
672 return (error != 0) ? 0 : 1;
677 parse_mount(char **conf)
681 char *dev, *fs, *opts, *tok;
682 int delay, error, timeout;
684 error = parse_token(conf, &tok);
688 error = parse_skipto(&tok, ':');
693 parse_poke(&tok, '\0');
697 if (root_mount_mddev != -1) {
698 /* Handle substitution for the md unit number. */
699 tok = strstr(dev, "md#");
701 tok[2] = '0' + root_mount_mddev;
705 error = parse_token(conf, &tok);
706 opts = (error == 0) ? tok : NULL;
708 printf("Trying to mount root from %s:%s [%s]...\n", fs, dev,
709 (opts != NULL) ? opts : "");
711 errmsg = malloc(ERRMSGL, M_TEMP, M_WAITOK | M_ZERO);
713 if (vfs_byname(fs) == NULL) {
714 strlcpy(errmsg, "unknown file system", sizeof(errmsg));
719 if (strcmp(fs, "zfs") != 0 && dev[0] != '\0' &&
720 !parse_mount_dev_present(dev)) {
721 printf("mountroot: waiting for device %s ...\n", dev);
723 timeout = root_mount_timeout * hz;
725 pause("rmdev", delay);
727 } while (timeout > 0 && !parse_mount_dev_present(dev));
735 ma = mount_arg(ma, "fstype", fs, -1);
736 ma = mount_arg(ma, "fspath", "/", -1);
737 ma = mount_arg(ma, "from", dev, -1);
738 ma = mount_arg(ma, "errmsg", errmsg, ERRMSGL);
739 ma = mount_arg(ma, "ro", NULL, 0);
740 ma = parse_mountroot_options(ma, opts);
741 error = kernel_mount(ma, MNT_ROOTFS);
745 printf("Mounting from %s:%s failed with error %d",
747 if (errmsg[0] != '\0')
748 printf(": %s", errmsg);
752 free(errmsg, M_TEMP);
755 /* kernel_mount can return -1 on error. */
756 return ((error < 0) ? EDOOFUS : error);
761 vfs_mountroot_parse(struct sbuf *sb, struct mount *mpdevfs)
767 root_mount_mddev = -1;
770 conf = sbuf_data(sb);
771 mp = TAILQ_NEXT(mpdevfs, mnt_list);
772 error = (mp == NULL) ? 0 : EDOOFUS;
773 root_mount_onfail = A_CONTINUE;
775 error = parse_skipto(&conf, CC_NONWHITESPACE);
776 if (error == PE_EOL) {
777 parse_advance(&conf);
782 switch (parse_peek(&conf)) {
784 error = parse_skipto(&conf, '\n');
787 error = parse_directive(&conf);
790 error = parse_mount(&conf);
795 /* Ignore any trailing garbage on the line. */
796 if (parse_peek(&conf) != '\n') {
797 printf("mountroot: advancing to next directive...\n");
798 (void)parse_skipto(&conf, '\n');
800 mp = TAILQ_NEXT(mpdevfs, mnt_list);
806 * We failed to mount (a new) root.
808 switch (root_mount_onfail) {
812 panic("mountroot: unable to (re-)mount root.");
817 kern_reboot(RB_NOSYNC);
825 vfs_mountroot_conf0(struct sbuf *sb)
827 char *s, *tok, *mnt, *opt;
830 sbuf_printf(sb, ".onfail panic\n");
831 sbuf_printf(sb, ".timeout %d\n", root_mount_timeout);
832 if (boothowto & RB_ASKNAME)
833 sbuf_printf(sb, ".ask\n");
835 if (boothowto & RB_DFLTROOT)
836 sbuf_printf(sb, "%s\n", ROOTDEVNAME);
838 if (boothowto & RB_CDROM) {
839 sbuf_printf(sb, "cd9660:/dev/cd0 ro\n");
840 sbuf_printf(sb, ".timeout 0\n");
841 sbuf_printf(sb, "cd9660:/dev/acd0 ro\n");
842 sbuf_printf(sb, ".timeout %d\n", root_mount_timeout);
844 s = getenv("vfs.root.mountfrom");
846 opt = getenv("vfs.root.mountfrom.options");
848 error = parse_token(&tok, &mnt);
850 sbuf_printf(sb, "%s %s\n", mnt,
851 (opt != NULL) ? opt : "");
853 error = parse_token(&tok, &mnt);
859 if (rootdevnames[0] != NULL)
860 sbuf_printf(sb, "%s\n", rootdevnames[0]);
861 if (rootdevnames[1] != NULL)
862 sbuf_printf(sb, "%s\n", rootdevnames[1]);
864 if (!(boothowto & RB_DFLTROOT))
865 sbuf_printf(sb, "%s\n", ROOTDEVNAME);
867 if (!(boothowto & RB_ASKNAME))
868 sbuf_printf(sb, ".ask\n");
872 vfs_mountroot_readconf(struct thread *td, struct sbuf *sb)
874 static char buf[128];
878 int error, flags, len, vfslocked;
880 NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE,
883 error = vn_open(&nd, &flags, 0, NULL);
887 vfslocked = NDHASGIANT(&nd);
888 NDFREE(&nd, NDF_ONLY_PNBUF);
890 len = sizeof(buf) - 1;
892 error = vn_rdwr(UIO_READ, nd.ni_vp, buf, len, ofs,
893 UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred,
899 buf[len - resid] = 0;
900 sbuf_printf(sb, "%s", buf);
904 VOP_UNLOCK(nd.ni_vp, 0);
905 vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
906 VFS_UNLOCK_GIANT(vfslocked);
911 vfs_mountroot_wait(void)
913 struct root_hold_token *h;
914 struct timeval lastfail;
922 mtx_lock(&mountlist_mtx);
923 if (LIST_EMPTY(&root_holds)) {
924 mtx_unlock(&mountlist_mtx);
927 if (ppsratecheck(&lastfail, &curfail, 1)) {
928 printf("Root mount waiting for:");
929 LIST_FOREACH(h, &root_holds, list)
930 printf(" %s", h->who);
933 msleep(&root_holds, &mountlist_mtx, PZERO | PDROP, "roothold",
949 vfs_mountroot_wait();
951 sb = sbuf_new_auto();
952 vfs_mountroot_conf0(sb);
955 error = vfs_mountroot_devfs(td, &mp);
957 error = vfs_mountroot_parse(sb, mp);
959 error = vfs_mountroot_shuffle(td, mp);
962 error = vfs_mountroot_readconf(td, sb);
971 * Iterate over all currently mounted file systems and use
972 * the time stamp found to check and/or initialize the RTC.
973 * Call inittodr() only once and pass it the largest of the
974 * timestamps we encounter.
977 mtx_lock(&mountlist_mtx);
978 mp = TAILQ_FIRST(&mountlist);
980 if (mp->mnt_time > timebase)
981 timebase = mp->mnt_time;
982 mp = TAILQ_NEXT(mp, mnt_list);
984 mtx_unlock(&mountlist_mtx);
987 /* Keep prison0's root in sync with the global rootvnode. */
988 mtx_lock(&prison0.pr_mtx);
989 prison0.pr_root = rootvnode;
990 vref(prison0.pr_root);
991 mtx_unlock(&prison0.pr_mtx);
993 mtx_lock(&mountlist_mtx);
994 atomic_store_rel_int(&root_mount_complete, 1);
995 wakeup(&root_mount_complete);
996 mtx_unlock(&mountlist_mtx);
999 static struct mntarg *
1000 parse_mountroot_options(struct mntarg *ma, const char *options)
1003 char *name, *name_arg;
1004 char *val, *val_arg;
1007 if (options == NULL || options[0] == '\0')
1010 p = opts = strdup(options, M_MOUNT);
1015 while((name = strsep(&p, ",")) != NULL) {
1016 if (name[0] == '\0')
1019 val = strchr(name, '=');
1024 if( strcmp(name, "rw") == 0 ||
1025 strcmp(name, "noro") == 0) {
1027 * The first time we mount the root file system,
1028 * we need to mount 'ro', so We need to ignore
1029 * 'rw' and 'noro' mount options.
1033 name_arg = strdup(name, M_MOUNT);
1036 val_arg = strdup(val, M_MOUNT);
1038 ma = mount_arg(ma, name_arg, val_arg,
1039 (val_arg != NULL ? -1 : 0));
1041 free(opts, M_MOUNT);