[CRIU] [PATCH 2/3] files: Search fdinfo_descs by id and type
Pavel Emelyanov
xemul at parallels.com
Tue Mar 27 04:45:37 EDT 2012
Currently only type is taken into account, but further we will need to distinguish
types as well.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
files.c | 10 +++++-----
include/files.h | 3 ++-
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/files.c b/files.c
index 2ee020e..e7b813e 100644
--- a/files.c
+++ b/files.c
@@ -44,14 +44,14 @@ int prepare_shared_fdinfo(void)
return 0;
}
-static struct fdinfo_desc *find_fd(u64 id)
+static struct fdinfo_desc *find_fd(struct fdinfo_entry *fe)
{
struct fdinfo_desc *fi;
int i;
for (i = 0; i < nr_fdinfo_descs; i++) {
fi = fdinfo_descs + i;
- if (fi->id == id)
+ if ((fi->id == fe->id) && (fi->type == fe->type))
return fi;
}
@@ -81,7 +81,7 @@ static int collect_fd(int pid, struct fdinfo_entry *e)
for (i = 0; i < nr_fdinfo_descs; i++) {
desc = &fdinfo_descs[i];
- if (desc->id != e->id)
+ if ((desc->id != e->id) || (desc->type != e->type))
continue;
futex_inc(&fdinfo_descs[i].users);
@@ -105,6 +105,7 @@ static int collect_fd(int pid, struct fdinfo_entry *e)
memzero(desc, sizeof(*desc));
desc->id = e->id;
+ desc->type = e->type;
desc->addr = e->addr;
desc->pid = pid;
INIT_LIST_HEAD(&desc->list);
@@ -420,8 +421,7 @@ static int open_fdinfo(int pid, struct fdinfo_entry *fe, int *fdinfo_fd, int sta
{
u32 mag;
int ret = 0;
-
- struct fdinfo_desc *fi = find_fd(fe->id);
+ struct fdinfo_desc *fi = find_fd(fe);
if (move_img_fd(fdinfo_fd, (int)fe->addr))
return -1;
diff --git a/include/files.h b/include/files.h
index fb8d952..e330e4c 100644
--- a/include/files.h
+++ b/include/files.h
@@ -23,7 +23,8 @@ struct fmap_fd {
};
struct fdinfo_desc {
- u64 id;
+ u32 id;
+ u32 type;
u64 addr;
int pid;
futex_t real_pid;
--
1.7.6.5
More information about the CRIU
mailing list