| 732 | |
| 733 | #define ERRMSGL 255 |
| 734 | static int |
| 735 | parse_mount(char **conf) |
| 736 | { |
| 737 | char *errmsg; |
| 738 | struct mntarg *ma; |
| 739 | char *dev, *fs, *opts, *tok; |
| 740 | int delay, error, timeout; |
| 741 | |
| 742 | error = parse_token(conf, &tok); |
| 743 | if (error) |
| 744 | return (error); |
| 745 | fs = tok; |
| 746 | error = parse_skipto(&tok, ':'); |
| 747 | if (error) { |
| 748 | free(fs, M_TEMP); |
| 749 | return (error); |
| 750 | } |
| 751 | parse_poke(&tok, '\0'); |
| 752 | parse_advance(&tok); |
| 753 | dev = tok; |
| 754 | |
| 755 | if (root_mount_mddev != -1) { |
| 756 | /* Handle substitution for the md unit number. */ |
| 757 | tok = strstr(dev, "md#"); |
| 758 | if (tok != NULL) |
| 759 | tok[2] = '0' + root_mount_mddev; |
| 760 | } |
| 761 | |
| 762 | /* Parse options. */ |
| 763 | error = parse_token(conf, &tok); |
| 764 | opts = (error == 0) ? tok : NULL; |
| 765 | |
| 766 | printf("Trying to mount root from %s:%s [%s]...\n", fs, dev, |
| 767 | (opts != NULL) ? opts : ""); |
| 768 | |
| 769 | errmsg = malloc(ERRMSGL, M_TEMP, M_WAITOK | M_ZERO); |
| 770 | |
| 771 | if (vfs_byname(fs) == NULL) { |
| 772 | strlcpy(errmsg, "unknown file system", ERRMSGL); |
| 773 | error = ENOENT; |
| 774 | goto out; |
| 775 | } |
| 776 | |
| 777 | error = vfs_mountroot_wait_if_neccessary(fs, dev); |
| 778 | if (error != 0) |
| 779 | goto out; |
| 780 | |
| 781 | delay = hz / 10; |
| 782 | timeout = root_mount_timeout * hz; |
| 783 | |
| 784 | for (;;) { |
| 785 | ma = NULL; |
| 786 | ma = mount_arg(ma, "fstype", fs, -1); |
| 787 | ma = mount_arg(ma, "fspath", "/", -1); |
| 788 | ma = mount_arg(ma, "from", dev, -1); |
| 789 | ma = mount_arg(ma, "errmsg", errmsg, ERRMSGL); |
| 790 | ma = mount_arg(ma, "ro", NULL, 0); |
| 791 | ma = parse_mountroot_options(ma, opts); |
no test coverage detected