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 { ...@@ -96,6 +96,7 @@ struct fstype {
int code; int code;
int (*dump)(struct mount_info *pm); int (*dump)(struct mount_info *pm);
int (*restore)(struct mount_info *pm); int (*restore)(struct mount_info *pm);
int (*parse)(struct mount_info *pm);
}; };
struct mount_info { struct mount_info {
...@@ -108,7 +109,6 @@ struct mount_info { ...@@ -108,7 +109,6 @@ struct mount_info {
int master_id; int master_id;
int shared_id; int shared_id;
struct fstype *fstype; struct fstype *fstype;
char *kfstype;
char *source; char *source;
char *options; char *options;
bool mounted; bool mounted;
......
...@@ -487,8 +487,6 @@ err: ...@@ -487,8 +487,6 @@ err:
int btrfs_parse_mountinfo(struct mount_info *m) int btrfs_parse_mountinfo(struct mount_info *m)
{ {
if (strcmp(m->kfstype, "btrfs"))
return 0;
return btrfs_parse_volume(m) ? 0 : -1; return btrfs_parse_volume(m) ? 0 : -1;
} }
......
...@@ -603,6 +603,10 @@ static struct fstype fstypes[] = { ...@@ -603,6 +603,10 @@ static struct fstype fstypes[] = {
}, { }, {
.name = "simfs", .name = "simfs",
.code = FSTYPE__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) ...@@ -1143,7 +1147,6 @@ void mnt_entry_free(struct mount_info *mi)
xfree(mi->root); xfree(mi->root);
xfree(mi->mountpoint); xfree(mi->mountpoint);
xfree(mi->kfstype);
xfree(mi->source); xfree(mi->source);
xfree(mi->options); xfree(mi->options);
xfree(mi); xfree(mi);
......
...@@ -761,9 +761,6 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new) ...@@ -761,9 +761,6 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new)
return -1; return -1;
ret = -1; ret = -1;
new->kfstype = xstrdup(fstype);
if (!new->kfstype)
goto err;
new->fstype = find_fstype_by_name(fstype); new->fstype = find_fstype_by_name(fstype);
new->options = xmalloc(strlen(opt) + 1); new->options = xmalloc(strlen(opt) + 1);
...@@ -810,18 +807,18 @@ struct mount_info *parse_mountinfo(pid_t pid) ...@@ -810,18 +807,18 @@ struct mount_info *parse_mountinfo(pid_t pid)
goto err; goto err;
} }
pr_info("\ttype %s (%s) source %s %x %s @ %s flags %x options %s\n", pr_info("\ttype %s source %s %x %s @ %s flags %x options %s\n",
new->fstype->name, new->kfstype, new->source, new->fstype->name, new->source,
new->s_dev, new->root, new->mountpoint, new->s_dev, new->root, new->mountpoint,
new->flags, new->options); new->flags, new->options);
/* if (new->fstype->parse) {
* BTRFS requires subvolumes parsing. ret = new->fstype->parse(new);
*/ if (ret) {
if (btrfs_parse_mountinfo(new)) { pr_err("Failed to parse FS specific data on %s\n",
pr_err("Failed to parse FS specific data on %s\n", new->mountpoint);
new->mountpoint); goto err;
goto err; }
} }
} }
out: out:
......
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