[CRIU] [PATCH 2/5] util.c: introduce open_proc_rw()
Kir Kolyshkin
kir at openvz.org
Thu Feb 16 16:39:33 EST 2012
To be used by the next patch
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
include/util.h | 1 +
util.c | 11 ++++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/include/util.h b/include/util.h
index 16508e5..5d43dd3 100644
--- a/include/util.h
+++ b/include/util.h
@@ -206,6 +206,7 @@ extern void hex_dump(void *addr, unsigned long len);
int open_pid_proc(pid_t pid);
int open_proc(int pid_dir_fd, char *fmt, ...);
+int open_proc_rw(int pid_dir_fd, char *fmt, ...)
DIR *opendir_proc(int pid_dir_fd, char *fmt, ...);
FILE *fopen_proc(int pid_dir_fd, char *fmt, ...);
diff --git a/util.c b/util.c
index 1bb00a0..dfbcb98 100644
--- a/util.c
+++ b/util.c
@@ -217,7 +217,7 @@ int open_pid_proc(pid_t pid)
return fd;
}
-#define do_open_proc(pid_dir_fd, fmt) \
+#define do_open_proc(pid_dir_fd, fmt, flags) \
({ \
char fname[64]; \
va_list args; \
@@ -226,12 +226,17 @@ int open_pid_proc(pid_t pid)
vsnprintf(fname, sizeof(fname), fmt, args); \
va_end(args); \
\
- openat(pid_dir_fd, fname, O_RDONLY); \
+ openat(pid_dir_fd, fname, flags); \
})
int open_proc(int pid_dir_fd, char *fmt, ...)
{
- return do_open_proc(pid_dir_fd, fmt);
+ return do_open_proc(pid_dir_fd, fmt, O_RDONLY);
+}
+
+int open_proc_rw(int pid_dir_fd, char *fmt, ...)
+{
+ return do_open_proc(pid_dir_fd, fmt, O_RDWR);
}
DIR *opendir_proc(int pid_dir_fd, char *fmt, ...)
--
1.7.7.6
More information about the CRIU
mailing list