[CRIU] [PATCH cr 7/8] util: add ability to change a proc mount point
Andrey Vagin
avagin at openvz.org
Wed May 16 04:32:40 EDT 2012
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
include/util.h | 1 +
util.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/include/util.h b/include/util.h
index 714bfdd..520b06a 100644
--- a/include/util.h
+++ b/include/util.h
@@ -169,6 +169,7 @@ extern int reopen_fd_as_safe(char *file, int line, int new_fd, int old_fd, bool
#define reopen_fd_as(new_fd, old_fd) reopen_fd_as_safe(__FILE__, __LINE__, new_fd, old_fd, false)
#define reopen_fd_as_nocheck(new_fd, old_fd) reopen_fd_as_safe(__FILE__, __LINE__, new_fd, old_fd, true)
+void set_proc_mountpoint(char *path);
int open_pid_proc(pid_t pid);
int close_pid_proc(void);
diff --git a/util.c b/util.c
index ee35f70..2bfb7c6 100644
--- a/util.c
+++ b/util.c
@@ -219,6 +219,12 @@ int close_pid_proc(void)
return ret;
}
+static char proc_mountpoint[PATH_MAX] = "/proc";
+void set_proc_mountpoint(char *path)
+{
+ strcpy(proc_mountpoint, path);
+}
+
inline int open_pid_proc(pid_t pid)
{
char path[18];
@@ -228,7 +234,7 @@ inline int open_pid_proc(pid_t pid)
return open_proc_fd;
close_pid_proc();
- sprintf(path, "/proc/%d", pid);
+ sprintf(path, "%s/%d", proc_mountpoint, pid);
fd = open(path, O_RDONLY);
if (fd < 0)
pr_perror("Can't open %s", path);
--
1.7.1
More information about the CRIU
mailing list