All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: Linux kernel's fchmodat has three args (no 4th arg)
@ 2009-04-18 17:47 takasi-y
  2009-04-18 18:02 ` Aurelien Jarno
  0 siblings, 1 reply; 4+ messages in thread
From: takasi-y @ 2009-04-18 17:47 UTC (permalink / raw)
  To: qemu-devel

In Linux kernel, fchmodat() takes tree args.
4th value <int flags> is only processed by libc. It can be passed as 0 to
 host libc, because it has been processed on target side. 

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
---

In Linux kernel, this has three args at least between 2.6.16 ... current(2.6.29+)
In QEMU, this has been implemented as four args from the first.
But has not results error until #7118 was introduced.

Tested on x86_64 host(Debian 5.0.1) + sh4a target(GentooLinux glibc2.8)
/yoshii

---
 linux-user/syscall.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ffdbb98..2fc6817 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -309,9 +309,9 @@ static int sys_faccessat(int dirfd, const char *pathname, int mode, int flags)
 }
 #endif
 #ifdef TARGET_NR_fchmodat
-static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode, int flags)
+static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode)
 {
-  return (fchmodat(dirfd, pathname, mode, flags));
+  return (fchmodat(dirfd, pathname, mode, 0));
 }
 #endif
 #if defined(TARGET_NR_fchownat) && defined(USE_UID16)
@@ -428,8 +428,7 @@ static int sys_utimensat(int dirfd, const char *pathname,
 _syscall4(int,sys_faccessat,int,dirfd,const char *,pathname,int,mode,int,flags)
 #endif
 #if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat)
-_syscall4(int,sys_fchmodat,int,dirfd,const char *,pathname,
-          mode_t,mode,int,flags)
+_syscall3(int,sys_fchmodat,int,dirfd,const char *,pathname, mode_t,mode)
 #endif
 #if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) && defined(USE_UID16)
 _syscall5(int,sys_fchownat,int,dirfd,const char *,pathname,
@@ -4944,7 +4943,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_fchmodat:
         if (!(p = lock_user_string(arg2)))
             goto efault;
-        ret = get_errno(sys_fchmodat(arg1, p, arg3, arg4));
+        ret = get_errno(sys_fchmodat(arg1, p, arg3));
         unlock_user(p, arg2, 0);
         break;
 #endif
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: Linux kernel's fchmodat has three args (no 4th arg)
  2009-04-18 17:47 [Qemu-devel] [PATCH] linux-user: Linux kernel's fchmodat has three args (no 4th arg) takasi-y
@ 2009-04-18 18:02 ` Aurelien Jarno
  2009-04-19  7:39   ` [Qemu-devel] [PATCH] linux-user: Linux kernel's fchmodat and faccessat have " takasi-y
  0 siblings, 1 reply; 4+ messages in thread
From: Aurelien Jarno @ 2009-04-18 18:02 UTC (permalink / raw)
  To: qemu-devel

On Sun, Apr 19, 2009 at 02:47:44AM +0900, takasi-y@ops.dti.ne.jp wrote:
> In Linux kernel, fchmodat() takes tree args.
> 4th value <int flags> is only processed by libc. It can be passed as 0 to
>  host libc, because it has been processed on target side. 
> 
> Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
> ---
> 
> In Linux kernel, this has three args at least between 2.6.16 ... current(2.6.29+)
> In QEMU, this has been implemented as four args from the first.
> But has not results error until #7118 was introduced.

Good catch. It seems that it's also the case for faccessat. Could you
please follow-up with a patch fixing both? Thanks.

> Tested on x86_64 host(Debian 5.0.1) + sh4a target(GentooLinux glibc2.8)
> /yoshii
> 
> ---
>  linux-user/syscall.c |    9 ++++-----
>  1 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ffdbb98..2fc6817 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -309,9 +309,9 @@ static int sys_faccessat(int dirfd, const char *pathname, int mode, int flags)
>  }
>  #endif
>  #ifdef TARGET_NR_fchmodat
> -static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode, int flags)
> +static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode)
>  {
> -  return (fchmodat(dirfd, pathname, mode, flags));
> +  return (fchmodat(dirfd, pathname, mode, 0));
>  }
>  #endif
>  #if defined(TARGET_NR_fchownat) && defined(USE_UID16)
> @@ -428,8 +428,7 @@ static int sys_utimensat(int dirfd, const char *pathname,
>  _syscall4(int,sys_faccessat,int,dirfd,const char *,pathname,int,mode,int,flags)
>  #endif
>  #if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat)
> -_syscall4(int,sys_fchmodat,int,dirfd,const char *,pathname,
> -          mode_t,mode,int,flags)
> +_syscall3(int,sys_fchmodat,int,dirfd,const char *,pathname, mode_t,mode)
>  #endif
>  #if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) && defined(USE_UID16)
>  _syscall5(int,sys_fchownat,int,dirfd,const char *,pathname,
> @@ -4944,7 +4943,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>      case TARGET_NR_fchmodat:
>          if (!(p = lock_user_string(arg2)))
>              goto efault;
> -        ret = get_errno(sys_fchmodat(arg1, p, arg3, arg4));
> +        ret = get_errno(sys_fchmodat(arg1, p, arg3));
>          unlock_user(p, arg2, 0);
>          break;
>  #endif
> -- 
> 1.5.6.5
> 
> 
> 
> 

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH] linux-user: Linux kernel's fchmodat and faccessat have three args (no 4th arg)
  2009-04-18 18:02 ` Aurelien Jarno
@ 2009-04-19  7:39   ` takasi-y
  2009-04-19  8:52     ` [Qemu-devel] " Aurelien Jarno
  0 siblings, 1 reply; 4+ messages in thread
From: takasi-y @ 2009-04-19  7:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aurelien Jarno

In Linux kernel, fchmodat() and faccessat() take tree args.
4th value <int flags> is only processed by libc.

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
---

> Good catch. It seems that it's also the case for faccessat. Could you
> please follow-up with a patch fixing both? Thanks.
Oh, that's right. I have added it.

I use 0 for the flag value to host libc's faccessat(),
This is because faccessat() in libc attempt to call kernel faccessat() only if
 ((flag == 0 || ((flag & ~AT_EACCESS) == 0 && ! __libc_enable_secure))
, otherwise access() or fstat64 is used.
# Only be checked with sysdeps/unix/sysv/linux/faccessat.c in eglibc-2.8.

Three cases below have been tested (flag!=0 case is out of scope)
 faccessat(AT_FDCWD, "testfile", F_OK|W_OK, 0)
 - ENOENT without testfile
 - EACCESS with testfile 0400
 - ok with testfile 0600
on x86_64 host(Debian 5.0.1) + sh4a target(GentooLinux glibc2.8).

/yoshii
---
 linux-user/syscall.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ffdbb98..0bc9902 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -303,15 +303,15 @@ static int sys_getcwd1(char *buf, size_t size)
  */
 
 #ifdef TARGET_NR_faccessat
-static int sys_faccessat(int dirfd, const char *pathname, int mode, int flags)
+static int sys_faccessat(int dirfd, const char *pathname, int mode)
 {
-  return (faccessat(dirfd, pathname, mode, flags));
+  return (faccessat(dirfd, pathname, mode, 0));
 }
 #endif
 #ifdef TARGET_NR_fchmodat
-static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode, int flags)
+static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode)
 {
-  return (fchmodat(dirfd, pathname, mode, flags));
+  return (fchmodat(dirfd, pathname, mode, 0));
 }
 #endif
 #if defined(TARGET_NR_fchownat) && defined(USE_UID16)
@@ -425,11 +425,10 @@ static int sys_utimensat(int dirfd, const char *pathname,
  * Try direct syscalls instead
  */
 #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)
-_syscall4(int,sys_faccessat,int,dirfd,const char *,pathname,int,mode,int,flags)
+_syscall3(int,sys_faccessat,int,dirfd,const char *,pathname,int,mode)
 #endif
 #if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat)
-_syscall4(int,sys_fchmodat,int,dirfd,const char *,pathname,
-          mode_t,mode,int,flags)
+_syscall3(int,sys_fchmodat,int,dirfd,const char *,pathname, mode_t,mode)
 #endif
 #if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) && defined(USE_UID16)
 _syscall5(int,sys_fchownat,int,dirfd,const char *,pathname,
@@ -4218,7 +4217,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_faccessat:
         if (!(p = lock_user_string(arg2)))
             goto efault;
-        ret = get_errno(sys_faccessat(arg1, p, arg3, arg4));
+        ret = get_errno(sys_faccessat(arg1, p, arg3));
         unlock_user(p, arg2, 0);
         break;
 #endif
@@ -4944,7 +4943,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_fchmodat:
         if (!(p = lock_user_string(arg2)))
             goto efault;
-        ret = get_errno(sys_fchmodat(arg1, p, arg3, arg4));
+        ret = get_errno(sys_fchmodat(arg1, p, arg3));
         unlock_user(p, arg2, 0);
         break;
 #endif
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] Re: [PATCH] linux-user: Linux kernel's fchmodat and faccessat have three args (no 4th arg)
  2009-04-19  7:39   ` [Qemu-devel] [PATCH] linux-user: Linux kernel's fchmodat and faccessat have " takasi-y
@ 2009-04-19  8:52     ` Aurelien Jarno
  0 siblings, 0 replies; 4+ messages in thread
From: Aurelien Jarno @ 2009-04-19  8:52 UTC (permalink / raw)
  To: takasi-y; +Cc: qemu-devel

On Sun, Apr 19, 2009 at 04:39:02PM +0900, takasi-y@ops.dti.ne.jp wrote:
> In Linux kernel, fchmodat() and faccessat() take tree args.
> 4th value <int flags> is only processed by libc.
> 
> Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
> ---

Thanks, applied.

> > Good catch. It seems that it's also the case for faccessat. Could you
> > please follow-up with a patch fixing both? Thanks.
> Oh, that's right. I have added it.
> 
> I use 0 for the flag value to host libc's faccessat(),
> This is because faccessat() in libc attempt to call kernel faccessat() only if
>  ((flag == 0 || ((flag & ~AT_EACCESS) == 0 && ! __libc_enable_secure))
> , otherwise access() or fstat64 is used.
> # Only be checked with sysdeps/unix/sysv/linux/faccessat.c in eglibc-2.8.
> 
> Three cases below have been tested (flag!=0 case is out of scope)
>  faccessat(AT_FDCWD, "testfile", F_OK|W_OK, 0)
>  - ENOENT without testfile
>  - EACCESS with testfile 0400
>  - ok with testfile 0600
> on x86_64 host(Debian 5.0.1) + sh4a target(GentooLinux glibc2.8).
> 
> /yoshii
> ---
>  linux-user/syscall.c |   17 ++++++++---------
>  1 files changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ffdbb98..0bc9902 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -303,15 +303,15 @@ static int sys_getcwd1(char *buf, size_t size)
>   */
>  
>  #ifdef TARGET_NR_faccessat
> -static int sys_faccessat(int dirfd, const char *pathname, int mode, int flags)
> +static int sys_faccessat(int dirfd, const char *pathname, int mode)
>  {
> -  return (faccessat(dirfd, pathname, mode, flags));
> +  return (faccessat(dirfd, pathname, mode, 0));
>  }
>  #endif
>  #ifdef TARGET_NR_fchmodat
> -static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode, int flags)
> +static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode)
>  {
> -  return (fchmodat(dirfd, pathname, mode, flags));
> +  return (fchmodat(dirfd, pathname, mode, 0));
>  }
>  #endif
>  #if defined(TARGET_NR_fchownat) && defined(USE_UID16)
> @@ -425,11 +425,10 @@ static int sys_utimensat(int dirfd, const char *pathname,
>   * Try direct syscalls instead
>   */
>  #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)
> -_syscall4(int,sys_faccessat,int,dirfd,const char *,pathname,int,mode,int,flags)
> +_syscall3(int,sys_faccessat,int,dirfd,const char *,pathname,int,mode)
>  #endif
>  #if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat)
> -_syscall4(int,sys_fchmodat,int,dirfd,const char *,pathname,
> -          mode_t,mode,int,flags)
> +_syscall3(int,sys_fchmodat,int,dirfd,const char *,pathname, mode_t,mode)
>  #endif
>  #if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) && defined(USE_UID16)
>  _syscall5(int,sys_fchownat,int,dirfd,const char *,pathname,
> @@ -4218,7 +4217,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>      case TARGET_NR_faccessat:
>          if (!(p = lock_user_string(arg2)))
>              goto efault;
> -        ret = get_errno(sys_faccessat(arg1, p, arg3, arg4));
> +        ret = get_errno(sys_faccessat(arg1, p, arg3));
>          unlock_user(p, arg2, 0);
>          break;
>  #endif
> @@ -4944,7 +4943,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>      case TARGET_NR_fchmodat:
>          if (!(p = lock_user_string(arg2)))
>              goto efault;
> -        ret = get_errno(sys_fchmodat(arg1, p, arg3, arg4));
> +        ret = get_errno(sys_fchmodat(arg1, p, arg3));
>          unlock_user(p, arg2, 0);
>          break;
>  #endif
> -- 
> 1.5.6.5
> 
> 

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-19  8:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-18 17:47 [Qemu-devel] [PATCH] linux-user: Linux kernel's fchmodat has three args (no 4th arg) takasi-y
2009-04-18 18:02 ` Aurelien Jarno
2009-04-19  7:39   ` [Qemu-devel] [PATCH] linux-user: Linux kernel's fchmodat and faccessat have " takasi-y
2009-04-19  8:52     ` [Qemu-devel] " Aurelien Jarno

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.