[CRIU] [PATCH 3/6] fowners: Add file owners dumping
Cyrill Gorcunov
gorcunov at openvz.org
Mon Apr 9 16:03:03 EDT 2012
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
cr-dump.c | 34 ++++++++++++++++++++++++++++++++++
include/files.h | 1 +
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/cr-dump.c b/cr-dump.c
index 90d828a..2b73e57 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -177,6 +177,7 @@ static int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
rfe.flags = p->flags;
rfe.pos = p->pos;
rfe.id = id;
+ rfe.fown = p->fown;
rfd = fdset_fd(glob_fdset, CR_FD_REG_FILES);
@@ -246,6 +247,7 @@ dump:
pe.id = id;
pe.pipe_id = p->id;
pe.flags = p->flags;
+ pe.fown = p->fown;
if (write_img(fd_pipes, &pe))
goto err_close;
@@ -381,6 +383,11 @@ static int dump_task_special_files(pid_t pid, const struct cr_fdset *cr_fdset)
static int fill_fd_params(pid_t pid, int fd, int lfd, struct fd_parms *p)
{
+ struct f_owner_ex owner_ex;
+ u32 v[2];
+
+ memzero(p, sizeof(*p));
+
if (fstat(lfd, &p->stat) < 0) {
pr_perror("Can't stat fd %d\n", lfd);
return -1;
@@ -395,6 +402,33 @@ static int fill_fd_params(pid_t pid, int fd, int lfd, struct fd_parms *p)
pr_info("%d fdinfo %d: pos: %16lx flags: %16o\n",
pid, fd, p->pos, p->flags);
+ p->fown.signum = fcntl(lfd, F_GETSIG, 0);
+ if (p->fown.signum < 0) {
+ pr_perror("Can't get owner signum on %d\n", lfd);
+ return -1;
+ }
+
+ if (fcntl(lfd, F_GETOWN_EX, (long)&owner_ex)) {
+ pr_perror("Can't get owners on %d\n", lfd);
+ return -1;
+ }
+
+ /*
+ * Simple case -- nothing is changed.
+ */
+ if (owner_ex.pid == 0)
+ return 0;
+
+ if (fcntl(lfd, F_GETOWNER_UIDS, (long)&v)) {
+ pr_perror("Can't get owner uids on %d\n", lfd);
+ return -1;
+ }
+
+ p->fown.uid = v[0];
+ p->fown.euid = v[1];
+ p->fown.pid_type= owner_ex.type;
+ p->fown.pid = owner_ex.pid;
+
return 0;
}
diff --git a/include/files.h b/include/files.h
index 5232e14..5d63db6 100644
--- a/include/files.h
+++ b/include/files.h
@@ -15,6 +15,7 @@ struct fd_parms {
struct stat stat;
u32 id;
pid_t pid;
+ fown_t fown;
};
enum fdinfo_states {
--
1.7.7.6
More information about the CRIU
mailing list