Commit 1f9798a6 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Pavel Emelyanov

reserve the extra room in fstypes[]

Preparation. Enlarge fstypes[] to make it possible to add the new
fstype's dynamically.

This means ths find_fstype_by_name() and decode_fstype() need the
additional ->name == NULL check to terminate the search.

Also change them to start with "i == 1", we rely on the fact that
fstypes[0] is FSTYPE__UNSUPPORTED anyway.
Signed-off-by: 's avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7e657d04
...@@ -1105,7 +1105,7 @@ static int always_fail(struct mount_info *pm) ...@@ -1105,7 +1105,7 @@ static int always_fail(struct mount_info *pm)
return -1; return -1;
} }
static struct fstype fstypes[] = { static struct fstype fstypes[32] = {
{ {
.name = "unsupported", .name = "unsupported",
.code = FSTYPE__UNSUPPORTED, .code = FSTYPE__UNSUPPORTED,
...@@ -1198,9 +1198,14 @@ struct fstype *find_fstype_by_name(char *_fst) ...@@ -1198,9 +1198,14 @@ struct fstype *find_fstype_by_name(char *_fst)
fst[i] = 0; fst[i] = 0;
for (i = 0; i < ARRAY_SIZE(fstypes); i++) { for (i = 1; i < ARRAY_SIZE(fstypes); i++) {
if (!strcmp(fstypes[i].name, fst)) struct fstype *fstype = fstypes + i;
return fstypes + i;
if (!fstype->name)
break;
if (!strcmp(fstype->name, fst))
return fstype;
} }
return &fstypes[0]; return &fstypes[0];
...@@ -1213,9 +1218,15 @@ static struct fstype *decode_fstype(u32 fst) ...@@ -1213,9 +1218,15 @@ static struct fstype *decode_fstype(u32 fst)
if (fst == FSTYPE__UNSUPPORTED) if (fst == FSTYPE__UNSUPPORTED)
goto uns; goto uns;
for (i = 0; i < ARRAY_SIZE(fstypes); i++) for (i = 1; i < ARRAY_SIZE(fstypes); i++) {
if (fstypes[i].code == fst) struct fstype *fstype = fstypes + i;
return fstypes + i;
if (!fstype->name)
break;
if (fstype->code == fst)
return fstype;
}
uns: uns:
return &fstypes[0]; return &fstypes[0];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment