| 1114 | } |
| 1115 | |
| 1116 | static struct mntarg * |
| 1117 | parse_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 | } |