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

Pavel Emelyanov xemul at parallels.com
Sat Mar 24 12:11:18 EDT 2012


On 03/23/2012 05:30 PM, Cyrill Gorcunov wrote:
> Will need it to test if file descriptor
> is rather a socket.

What socket? You cannot open other task's sockets via proc!

> 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, ...)					\
>  	({								\



More information about the CRIU mailing list