Commit f899d040 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Cyrill Gorcunov

files: Handle the absence of ID in proc fdinfo

This makes crtools correctly abort when working on wrong kernel.
Otherwise all the open files will have the same (garbage) ID and
the subsequent restore will result in broken app.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent cc14c6eb
...@@ -307,7 +307,7 @@ out_close: ...@@ -307,7 +307,7 @@ out_close:
static int read_fd_params(pid_t pid, int pid_dir, char *fd, struct fd_parms *p) static int read_fd_params(pid_t pid, int pid_dir, char *fd, struct fd_parms *p)
{ {
FILE *file; FILE *file;
unsigned int f; int ret;
file = fopen_proc(pid_dir, "fdinfo/%s", fd); file = fopen_proc(pid_dir, "fdinfo/%s", fd);
if (!file) { if (!file) {
...@@ -316,9 +316,14 @@ static int read_fd_params(pid_t pid, int pid_dir, char *fd, struct fd_parms *p) ...@@ -316,9 +316,14 @@ static int read_fd_params(pid_t pid, int pid_dir, char *fd, struct fd_parms *p)
} }
p->fd_name = atoi(fd); p->fd_name = atoi(fd);
fscanf(file, "pos:\t%li\nflags:\t%o\nid:\t%s\n", &p->pos, &p->flags, p->id); ret = fscanf(file, "pos:\t%li\nflags:\t%o\nid:\t%s\n", &p->pos, &p->flags, p->id);
fclose(file); fclose(file);
if (ret != 3) {
pr_err("Bad format of fdinfo file (%d items, want 3)\n", ret);
return -1;
}
pr_info("%d fdinfo %s: pos: %16lx flags: %16o id %s\n", pr_info("%d fdinfo %s: pos: %16lx flags: %16o id %s\n",
pid, fd, p->pos, p->flags, p->id); pid, fd, p->pos, p->flags, p->id);
......
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