[CRIU] [PATCH] unshare: Define UNSHARE_MOUNT_PROC constant

Andrey Vagin avagin at virtuozzo.com
Wed Mar 16 09:48:07 PDT 2016


Acked-by: Andrey Vagin <avagin at virtuozzo.com>

On Wed, Mar 16, 2016 at 03:24:36PM +0300, Pavel Emelyanov wrote:
> 
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
> ---
>  criu/crtools.c               | 6 +++---
>  criu/include/syscall-types.h | 2 ++
>  criu/mount.c                 | 3 ++-
>  3 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/criu/crtools.c b/criu/crtools.c
> index 800fa6d..5e51adb 100644
> --- a/criu/crtools.c
> +++ b/criu/crtools.c
> @@ -43,7 +43,7 @@
>  #include "fault-injection.h"
>  #include "lsm.h"
>  #include "proc_parse.h"
> -
> +#include "syscall-types.h"
>  #include "setproctitle.h"
>  
>  struct cr_options opts;
> @@ -121,7 +121,7 @@ static int parse_unshare_arg(char *opt)
>  		else if (!strcmp(opt, "user"))
>  			opts.unshare_flags |= CLONE_NEWUSER;
>  		else if (!strcmp(opt, "proc"))
> -			opts.unshare_flags |= 0x1; /* mount new proc */
> +			opts.unshare_flags |= UNSHARE_MOUNT_PROC; /* mount new proc */
>  		else {
>  			pr_msg("Error: unknown unshare flag %s\n", opt);
>  			return -1;
> @@ -134,7 +134,7 @@ static int parse_unshare_arg(char *opt)
>  	}
>  
>  	/* Only pid, mnt and user for now */
> -	if (opts.unshare_flags & ~(CLONE_NEWNS | CLONE_NEWPID | 0x1)) {
> +	if (opts.unshare_flags & ~(CLONE_NEWNS | CLONE_NEWPID | UNSHARE_MOUNT_PROC)) {
>  		pr_err("Unsharing this namespace(s) is not supported yet\n");
>  		return -1;
>  	}
> diff --git a/criu/include/syscall-types.h b/criu/include/syscall-types.h
> index fdfed9a..ef472a8 100644
> --- a/criu/include/syscall-types.h
> +++ b/criu/include/syscall-types.h
> @@ -71,6 +71,8 @@ struct itimerspec;
>  
>  #define CLONE_ALLNS	(CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_NEWNS | CLONE_NEWUSER | CLONE_NEWCGROUP)
>  
> +#define UNSHARE_MOUNT_PROC	0x1
> +
>  struct rlimit;
>  struct rlimit64;
>  
> diff --git a/criu/mount.c b/criu/mount.c
> index be905f4..9757799 100644
> --- a/criu/mount.c
> +++ b/criu/mount.c
> @@ -28,6 +28,7 @@
>  #include "kerndat.h"
>  #include "fs-magic.h"
>  #include "sysfs_parse.h"
> +#include "syscall-types.h"
>  
>  #include "images/mnt.pb-c.h"
>  #include "images/binfmt-misc.pb-c.h"
> @@ -3194,7 +3195,7 @@ int prepare_mnt_ns(void)
>  			return -1;
>  		}
>  
> -		if (opts.unshare_flags & 0x1) {
> +		if (opts.unshare_flags & UNSHARE_MOUNT_PROC) {
>  			mount(NULL, "/proc", NULL, MS_PRIVATE, NULL);
>  			if (mount("proc", "/proc", "proc",
>  						MS_MGC_VAL | MS_NOSUID | MS_NOEXEC | MS_NODEV,
> -- 
> 2.5.0


More information about the CRIU mailing list