Commit 2cfeeac4 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Pavel Emelyanov

parse_mountinfo: add the "end" block into the main loop

Preparation to simplify the review. parse_mountinfo() assumes that:

1. The "err:" block does all the necessary cleanups on failure.

   This is wrong, see the next patch.

2. We can never skip the mountpoint.

   This is true, but we are going to change this.

s/goto err/goto end/ in the main loop, add the "end:" label which inserts
the new mount_info into the list and then checks ret != 0 to figure out
whether we need to abort.
Signed-off-by: 's avatarOleg Nesterov <oleg@redhat.com>
Reviewed-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent b23268e4
......@@ -1016,22 +1016,19 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid)
while (fgets(str, sizeof(str), f)) {
struct mount_info *new;
int ret;
int ret = -1;
char *fst = NULL;
new = mnt_entry_alloc();
if (!new)
goto err;
goto end;
new->nsid = nsid;
new->next = list;
list = new;
ret = parse_mountinfo_ent(str, new, &fst);
if (ret < 0) {
pr_err("Bad format in %d mountinfo\n", pid);
goto err;
goto end;
}
pr_info("\ttype %s source %s mnt_id %d s_dev %#x %s @ %s flags %#x options %s\n",
......@@ -1044,9 +1041,17 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid)
if (ret) {
pr_err("Failed to parse FS specific data on %s\n",
new->mountpoint);
goto err;
goto end;
}
}
end:
if (new) {
new->next = list;
list = new;
}
if (ret)
goto err;
}
out:
fclose(f);
......
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