[CRIU] [PATCH 7/8] util: Add open_proc_nocheck helper

Cyrill Gorcunov gorcunov at openvz.org
Fri Mar 23 09:30:52 EDT 2012


Will need it to test if file descriptor
is rather a socket.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 include/util.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/util.h b/include/util.h
index 9899cca..ddd6150 100644
--- a/include/util.h
+++ b/include/util.h
@@ -196,6 +196,17 @@ int do_open_proc(pid_t pid, int flags, const char *fmt, ...);
 #define open_proc_rw(pid, fmt, ...)				\
 	__open_proc(pid, O_RDWR, fmt, ##__VA_ARGS__)
 
+#define __open_proc_nocheck(pid, flags, fmt, ...)		\
+	({							\
+		int __fd = do_open_proc(pid, flags,		\
+					fmt, ##__VA_ARGS__);	\
+								\
+		__fd;						\
+	})
+
+#define open_proc_nocheck(pid, fmt, ...)			\
+	__open_proc_nocheck(pid, O_RDONLY, fmt, ##__VA_ARGS__)
+
 /* DIR *opendir_proc(pid_t pid, const char *fmt, ...); */
 #define opendir_proc(pid, fmt, ...)					\
 	({								\
-- 
1.7.7.6



More information about the CRIU mailing list