Commit 3708ecb4 authored by Pavel Emelyanov's avatar Pavel Emelyanov

mount: Introduce generic FSs parsing callback

And make use of it in for btrfs.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent b6e2dfd2
......@@ -96,6 +96,7 @@ struct fstype {
int code;
int (*dump)(struct mount_info *pm);
int (*restore)(struct mount_info *pm);
int (*parse)(struct mount_info *pm);
};
struct mount_info {
......@@ -108,7 +109,6 @@ struct mount_info {
int master_id;
int shared_id;
struct fstype *fstype;
char *kfstype;
char *source;
char *options;
bool mounted;
......
......@@ -487,8 +487,6 @@ err:
int btrfs_parse_mountinfo(struct mount_info *m)
{
if (strcmp(m->kfstype, "btrfs"))
return 0;
return btrfs_parse_volume(m) ? 0 : -1;
}
......
......@@ -603,6 +603,10 @@ static struct fstype fstypes[] = {
}, {
.name = "simfs",
.code = FSTYPE__SIMFS,
}, {
.name = "btrfs",
.code = FSTYPE__UNSUPPORTED,
.parse = btrfs_parse_mountinfo,
}
};
......@@ -1143,7 +1147,6 @@ void mnt_entry_free(struct mount_info *mi)
xfree(mi->root);
xfree(mi->mountpoint);
xfree(mi->kfstype);
xfree(mi->source);
xfree(mi->options);
xfree(mi);
......
......@@ -761,9 +761,6 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new)
return -1;
ret = -1;
new->kfstype = xstrdup(fstype);
if (!new->kfstype)
goto err;
new->fstype = find_fstype_by_name(fstype);
new->options = xmalloc(strlen(opt) + 1);
......@@ -810,20 +807,20 @@ struct mount_info *parse_mountinfo(pid_t pid)
goto err;
}
pr_info("\ttype %s (%s) source %s %x %s @ %s flags %x options %s\n",
new->fstype->name, new->kfstype, new->source,
pr_info("\ttype %s source %s %x %s @ %s flags %x options %s\n",
new->fstype->name, new->source,
new->s_dev, new->root, new->mountpoint,
new->flags, new->options);
/*
* BTRFS requires subvolumes parsing.
*/
if (btrfs_parse_mountinfo(new)) {
if (new->fstype->parse) {
ret = new->fstype->parse(new);
if (ret) {
pr_err("Failed to parse FS specific data on %s\n",
new->mountpoint);
goto err;
}
}
}
out:
fclose(f);
return list;
......
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