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

Function parse_mountroot_options

freebsd/kern/vfs_mountroot.c:1116–1160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1114}
1115
1116static struct mntarg *
1117parse_mountroot_options(struct mntarg *ma, const char *options)
1118{
1119 char *p;
1120 char *name, *name_arg;
1121 char *val, *val_arg;
1122 char *opts;
1123
1124 if (options == NULL || options[0] == '\0')
1125 return (ma);
1126
1127 p = opts = strdup(options, M_MOUNT);
1128 if (opts == NULL) {
1129 return (ma);
1130 }
1131
1132 while((name = strsep(&p, ",")) != NULL) {
1133 if (name[0] == '\0')
1134 break;
1135
1136 val = strchr(name, '=');
1137 if (val != NULL) {
1138 *val = '\0';
1139 ++val;
1140 }
1141 if( strcmp(name, "rw") == 0 ||
1142 strcmp(name, "noro") == 0) {
1143 /*
1144 * The first time we mount the root file system,
1145 * we need to mount 'ro', so We need to ignore
1146 * 'rw' and 'noro' mount options.
1147 */
1148 continue;
1149 }
1150 name_arg = strdup(name, M_MOUNT);
1151 val_arg = NULL;
1152 if (val != NULL)
1153 val_arg = strdup(val, M_MOUNT);
1154
1155 ma = mount_arg(ma, name_arg, val_arg,
1156 (val_arg != NULL ? -1 : 0));
1157 }
1158 free(opts, M_MOUNT);
1159 return (ma);
1160}

Callers 1

parse_mountFunction · 0.85

Calls 6

strdupFunction · 0.85
strsepFunction · 0.85
strchrFunction · 0.85
strcmpFunction · 0.85
mount_argFunction · 0.85
freeFunction · 0.70

Tested by

no test coverage detected