[CRIU] [crtools-bot for Kir Kolyshkin ] util.c: introduce open_proc_rw()

Cyrill Gorcunov gorcunov at openvz.org
Fri Feb 17 07:46:25 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit 03294077af6ed3defcb223c1a1e2867a2062c7f9
Author: Kir Kolyshkin <kir at openvz.org>
Date:   Fri Feb 17 01:39:33 2012 +0400

    util.c: introduce open_proc_rw()
    
    To be used by the next patch
    
    Signed-off-by: Kir Kolyshkin <kir at openvz.org>
    Acked-by: Pavel Emelyanov <xemul at parallels.com>
    Signed-off-by: Cyrill Gorcunov <gorcunov 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, ...)


More information about the CRIU mailing list