Commit bc21b29b authored by Pavel Emelyanov's avatar Pavel Emelyanov

fdinfo: Report miss of required entries on parse

Otherwise dump succeeds but is inconsistent.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 1fef8420
...@@ -714,6 +714,7 @@ int parse_fdinfo(int fd, int type, ...@@ -714,6 +714,7 @@ int parse_fdinfo(int fd, int type,
{ {
FILE *f; FILE *f;
char str[256]; char str[256];
bool entry_met = false;
sprintf(str, "/proc/self/fdinfo/%d", fd); sprintf(str, "/proc/self/fdinfo/%d", fd);
f = fopen(str, "r"); f = fopen(str, "r");
...@@ -741,6 +742,8 @@ int parse_fdinfo(int fd, int type, ...@@ -741,6 +742,8 @@ int parse_fdinfo(int fd, int type,
ret = cb(&entry, arg); ret = cb(&entry, arg);
if (ret) if (ret)
return ret; return ret;
entry_met = true;
continue; continue;
} }
if (fdinfo_field(str, "tfd")) { if (fdinfo_field(str, "tfd")) {
...@@ -755,6 +758,8 @@ int parse_fdinfo(int fd, int type, ...@@ -755,6 +758,8 @@ int parse_fdinfo(int fd, int type,
ret = cb(&entry, arg); ret = cb(&entry, arg);
if (ret) if (ret)
return ret; return ret;
entry_met = true;
continue; continue;
} }
if (fdinfo_field(str, "inotify wd")) { if (fdinfo_field(str, "inotify wd")) {
...@@ -791,11 +796,18 @@ int parse_fdinfo(int fd, int type, ...@@ -791,11 +796,18 @@ int parse_fdinfo(int fd, int type,
if (ret) if (ret)
return ret; return ret;
entry_met = true;
continue; continue;
} }
} }
fclose(f); fclose(f);
if (!entry_met) {
pr_err("No records of type %d found in fdinfo file\n", type);
goto parse_err;
}
return 0; return 0;
parse_err: parse_err:
......
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