2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

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: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Oleg Nesterov
2015-03-29 19:23:57 +02:00
committed by Pavel Emelyanov
parent b23268e492
commit 2cfeeac465

View File

@@ -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);