MCPcopy Create free account
hub / github.com/F-Stack/f-stack / parse_mount

Function parse_mount

freebsd/kern/vfs_mountroot.c:734–820  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

732
733#define ERRMSGL 255
734static int
735parse_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);

Callers 2

parse_dir_askFunction · 0.85
vfs_mountroot_parseFunction · 0.85

Calls 14

parse_tokenFunction · 0.85
parse_skiptoFunction · 0.85
parse_pokeFunction · 0.85
parse_advanceFunction · 0.85
strstrFunction · 0.85
mallocFunction · 0.85
vfs_bynameFunction · 0.85
mount_argFunction · 0.85
parse_mountroot_optionsFunction · 0.85
kernel_mountFunction · 0.85
freeFunction · 0.70

Tested by

no test coverage detected