qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/5] linux-user: Implement pivot_root


From: Laurent Vivier
Subject: Re: [PATCH 5/5] linux-user: Implement pivot_root
Date: Tue, 25 May 2021 22:21:09 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1

Le 24/05/2021 à 06:54, YAMAMOTO Takashi a écrit :
> Used by runc.
> 
> Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
> ---
>  linux-user/syscall.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 2947e79dc0..e739921e86 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -35,6 +35,7 @@
>  #include <sys/prctl.h>
>  #include <sys/resource.h>
>  #include <sys/swap.h>
> +#include <sys/syscall.h>

we don't need that include, see below

>  #include <linux/capability.h>
>  #include <sched.h>
>  #include <sys/timex.h>
> @@ -8254,6 +8255,11 @@ static int host_to_target_cpu_mask(const unsigned long 
> *host_mask,
>      return 0;
>  }
>  
> +static int pivot_root(const char *new_root, const char *put_old)
> +{
> +    return syscall(SYS_pivot_root, new_root, put_old);
> +}

Better to use:

#if defined(TARGET_NR_pivot_root) && defined(__NR_pivot_root)
_syscall2(int, pivot_root, const char *, new_root, const char *, put_old)
#endif

> +
>  /* This is an internal helper for do_syscall so that it is easier
>   * to have a single return point, so that actions, such as logging
>   * of syscall results, can be performed.
> @@ -13222,6 +13228,23 @@ static abi_long do_syscall1(void *cpu_env, int num, 
> abi_long arg1,
>          return ret;
>  #endif
>  
> +#if defined(TARGET_NR_pivot_root)
> +    case TARGET_NR_pivot_root:
> +        {
> +            void *p2;
> +            p = lock_user_string(arg1); /* new_root */
> +            p2 = lock_user_string(arg2); /* put_old */
> +            if (!p || !p2) {
> +                ret = -TARGET_EFAULT;
> +            } else {
> +                ret = get_errno(pivot_root(p, p2));
> +            }
> +            unlock_user(p2, arg2, 0);
> +            unlock_user(p, arg1, 0);
> +        }
> +        return ret;
> +#endif
> +
>      default:
>          qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
>          return -TARGET_ENOSYS;
> 

Thanks,
Laurent



reply via email to

[Prev in Thread] Current Thread [Next in Thread]