public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents is not defined
@ 2013-03-13 14:01 Markos Chandras
  2013-03-13 17:20 ` Mike Frysinger
  2013-03-13 17:58 ` Jan Stancek
  0 siblings, 2 replies; 7+ messages in thread
From: Markos Chandras @ 2013-03-13 14:01 UTC (permalink / raw)
  To: ltp-list

From: Markos Chandras <markos.chandras@imgtec.com>

New Linux Kernel architectures do not define NR_getdents so we
try to use the getdents64 syscall instead

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
---
 testcases/kernel/syscalls/getdents/getdents.h |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/testcases/kernel/syscalls/getdents/getdents.h b/testcases/kernel/syscalls/getdents/getdents.h
index 1d5e584..12d2be4 100644
--- a/testcases/kernel/syscalls/getdents/getdents.h
+++ b/testcases/kernel/syscalls/getdents/getdents.h
@@ -38,12 +38,23 @@
  * declare our own here.  Wheeeeee.
  */
 
+#ifdef SYS_getdents
 struct linux_dirent {
 	unsigned long   d_ino;
 	unsigned long   d_off;
 	unsigned short  d_reclen;
 	char            d_name[];
 };
+#else
+/* Use the 64-bit definition */
+struct linux_dirent {
+	unsigned long long	d_ino;
+	long long		d_off;
+	unsigned short		d_reclen;
+	unsigned char		d_type;
+	char			d_name[0];
+};
+#endif
 
 static inline int
 getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
@@ -57,7 +68,11 @@ getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
 	unsigned int i;
 
 	ptrs.buf = buf;
+#ifdef SYS_getdents
 	ret = syscall(SYS_getdents, fd, buf, count);
+#else
+	ret = syscall(SYS_getdents64, fd, buf, count);
+#endif
 	if (ret < 0)
 		return ret;
 
-- 
1.7.1



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents is not defined
  2013-03-13 14:01 [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents is not defined Markos Chandras
@ 2013-03-13 17:20 ` Mike Frysinger
  2013-03-13 17:21   ` Markos Chandras
  2013-03-13 17:58 ` Jan Stancek
  1 sibling, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2013-03-13 17:20 UTC (permalink / raw)
  To: ltp-list


[-- Attachment #1.1: Type: Text/Plain, Size: 475 bytes --]

On Wednesday 13 March 2013 10:01:34 Markos Chandras wrote:
> +#ifdef SYS_getdents
>  struct linux_dirent {
>  	unsigned long   d_ino;
>  	unsigned long   d_off;
>  	unsigned short  d_reclen;
>  	char            d_name[];
>  };
> +#else
> +/* Use the 64-bit definition */
> +struct linux_dirent {
> +	unsigned long long	d_ino;
> +	long long		d_off;
> +	unsigned short		d_reclen;
> +	unsigned char		d_type;
> +	char			d_name[0];

any reason for using [0] instead of [] ?
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 238 bytes --]

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents is not defined
  2013-03-13 17:20 ` Mike Frysinger
@ 2013-03-13 17:21   ` Markos Chandras
  0 siblings, 0 replies; 7+ messages in thread
From: Markos Chandras @ 2013-03-13 17:21 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list

On 13 March 2013 17:20, Mike Frysinger <vapier@gentoo.org> wrote:
> On Wednesday 13 March 2013 10:01:34 Markos Chandras wrote:
>> +#ifdef SYS_getdents
>>  struct linux_dirent {
>>       unsigned long   d_ino;
>>       unsigned long   d_off;
>>       unsigned short  d_reclen;
>>       char            d_name[];
>>  };
>> +#else
>> +/* Use the 64-bit definition */
>> +struct linux_dirent {
>> +     unsigned long long      d_ino;
>> +     long long               d_off;
>> +     unsigned short          d_reclen;
>> +     unsigned char           d_type;
>> +     char                    d_name[0];
>
> any reason for using [0] instead of [] ?
> -mike

Nope just copying what kernel does in $KDIR/include/linux/dirent.h

-- 
Regards,
Markos Chandras

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents is not defined
  2013-03-13 14:01 [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents is not defined Markos Chandras
  2013-03-13 17:20 ` Mike Frysinger
@ 2013-03-13 17:58 ` Jan Stancek
  2013-03-13 18:03   ` Markos Chandras
  1 sibling, 1 reply; 7+ messages in thread
From: Jan Stancek @ 2013-03-13 17:58 UTC (permalink / raw)
  To: Markos Chandras; +Cc: ltp-list



----- Original Message -----
> From: "Markos Chandras" <markos.chandras@gmail.com>
> To: ltp-list@lists.sourceforge.net
> Sent: Wednesday, 13 March, 2013 3:01:34 PM
> Subject: [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents	is not defined
> 
> From: Markos Chandras <markos.chandras@imgtec.com>
> 
> New Linux Kernel architectures do not define NR_getdents so we
> try to use the getdents64 syscall instead
> 
> Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
> ---
>  testcases/kernel/syscalls/getdents/getdents.h |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/getdents/getdents.h
> b/testcases/kernel/syscalls/getdents/getdents.h
> index 1d5e584..12d2be4 100644
> --- a/testcases/kernel/syscalls/getdents/getdents.h
> +++ b/testcases/kernel/syscalls/getdents/getdents.h
> @@ -38,12 +38,23 @@
>   * declare our own here.  Wheeeeee.
>   */
>  
> +#ifdef SYS_getdents
>  struct linux_dirent {
>  	unsigned long   d_ino;
>  	unsigned long   d_off;
>  	unsigned short  d_reclen;
>  	char            d_name[];
>  };
> +#else
> +/* Use the 64-bit definition */
> +struct linux_dirent {
> +	unsigned long long	d_ino;
> +	long long		d_off;
> +	unsigned short		d_reclen;
> +	unsigned char		d_type;
> +	char			d_name[0];
> +};
> +#endif
>  
>  static inline int
>  getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
> @@ -57,7 +68,11 @@ getdents(unsigned int fd, struct dirent *dirp,
> unsigned int count)
>  	unsigned int i;
>  
>  	ptrs.buf = buf;
> +#ifdef SYS_getdents
>  	ret = syscall(SYS_getdents, fd, buf, count);
> +#else
> +	ret = syscall(SYS_getdents64, fd, buf, count);
> +#endif

Just a thought.. What about turning it to runtime check? There could be parameter to switch between
SYS_getdents/SYS_getdents64 and we can have both (with/without that parameter) in runtest/syscalls.
If it's supported it runs, if not ends with TCONF. That way we could have both version on arches
that support both syscalls.

Regards,
Jan

>  	if (ret < 0)
>  		return ret;
>  
> --
> 1.7.1
> 
> 
> 
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents is not defined
  2013-03-13 17:58 ` Jan Stancek
@ 2013-03-13 18:03   ` Markos Chandras
  2013-03-13 18:23     ` chrubis
  0 siblings, 1 reply; 7+ messages in thread
From: Markos Chandras @ 2013-03-13 18:03 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp-list

On 13 March 2013 17:58, Jan Stancek <jstancek@redhat.com> wrote:
>
>
> ----- Original Message -----
>> From: "Markos Chandras" <markos.chandras@gmail.com>
>> To: ltp-list@lists.sourceforge.net
>> Sent: Wednesday, 13 March, 2013 3:01:34 PM
>> Subject: [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents  is not defined
>>
>> From: Markos Chandras <markos.chandras@imgtec.com>
>>
>> New Linux Kernel architectures do not define NR_getdents so we
>> try to use the getdents64 syscall instead
>>
>> Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
>> ---
>>  testcases/kernel/syscalls/getdents/getdents.h |   15 +++++++++++++++
>>  1 files changed, 15 insertions(+), 0 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/getdents/getdents.h
>> b/testcases/kernel/syscalls/getdents/getdents.h
>> index 1d5e584..12d2be4 100644
>> --- a/testcases/kernel/syscalls/getdents/getdents.h
>> +++ b/testcases/kernel/syscalls/getdents/getdents.h
>> @@ -38,12 +38,23 @@
>>   * declare our own here.  Wheeeeee.
>>   */
>>
>> +#ifdef SYS_getdents
>>  struct linux_dirent {
>>       unsigned long   d_ino;
>>       unsigned long   d_off;
>>       unsigned short  d_reclen;
>>       char            d_name[];
>>  };
>> +#else
>> +/* Use the 64-bit definition */
>> +struct linux_dirent {
>> +     unsigned long long      d_ino;
>> +     long long               d_off;
>> +     unsigned short          d_reclen;
>> +     unsigned char           d_type;
>> +     char                    d_name[0];
>> +};
>> +#endif
>>
>>  static inline int
>>  getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
>> @@ -57,7 +68,11 @@ getdents(unsigned int fd, struct dirent *dirp,
>> unsigned int count)
>>       unsigned int i;
>>
>>       ptrs.buf = buf;
>> +#ifdef SYS_getdents
>>       ret = syscall(SYS_getdents, fd, buf, count);
>> +#else
>> +     ret = syscall(SYS_getdents64, fd, buf, count);
>> +#endif
>
> Just a thought.. What about turning it to runtime check? There could be parameter to switch between
> SYS_getdents/SYS_getdents64 and we can have both (with/without that parameter) in runtest/syscalls.
> If it's supported it runs, if not ends with TCONF. That way we could have both version on arches
> that support both syscalls.
>

The problem is that for arches that don't have SYS_getdents defined,
you will not be able to compile LTP on them so you really need to
hide this codepath from them.

A similar commit that changes the codepath based on whether a
particular __NR_XX is defined is this
https://github.com/linux-test-project/ltp/commit/75201f160b9aa49af70d8f46fb1f087e63d603dd

I don't see an easy way to determine if __NR_XX is defined or not
during runtime.

-- 
Regards,
Markos Chandras

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents is not defined
  2013-03-13 18:03   ` Markos Chandras
@ 2013-03-13 18:23     ` chrubis
       [not found]       ` <CAG2jQ8hbT_8h8KR0V2=7qzwdSy8cqzOWb_oHt4JJ5Y22yFEeDg@mail.gmail.com>
  0 siblings, 1 reply; 7+ messages in thread
From: chrubis @ 2013-03-13 18:23 UTC (permalink / raw)
  To: Markos Chandras; +Cc: ltp-list

Hi!
> The problem is that for arches that don't have SYS_getdents defined,
> you will not be able to compile LTP on them so you really need to
> hide this codepath from them.
> 
> A similar commit that changes the codepath based on whether a
> particular __NR_XX is defined is this
> https://github.com/linux-test-project/ltp/commit/75201f160b9aa49af70d8f46fb1f087e63d603dd
> 
> I don't see an easy way to determine if __NR_XX is defined or not
> during runtime.

There is code that tries to address this issue in
testcases/kernel/include/linux_syscall_numbers.h
which defines macro ltp_syscall() that turns undefined
syscall numbers into ENOSYS.

The idea is to:

1) include sys/syscall.h to get the definitions system definitons

2) if your system headers are older (i.e. particular __NR_xxx is not defined)
   definitions from arch.in files are used

3) if __NR_xxx is not defined, there are stubs at the end of the header
   that defines the __NR_xxx to 0 which is then used by the ltp_syscall()
   macro to return -1 and set errno to ENOSYS

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents is not defined
       [not found]         ` <CAG2jQ8j23+74_JZbrkM55aKg4YG+V-g4G1+NsS4fLGy=efRDjQ@mail.gmail.com>
@ 2013-03-14 16:29           ` chrubis
  0 siblings, 0 replies; 7+ messages in thread
From: chrubis @ 2013-03-14 16:29 UTC (permalink / raw)
  To: Markos Chandras; +Cc: ltp-list

Hi!
> 
> I wrote patch that does what we talked about.
> 
> https://github.com/hwoarang/ltp/commit/3e361757a9cfd6c6af50a395c2de68777356a4b6
> 
> If you are happy with the way it is implemented, I will post it to the
> mailing list for further review.

The patch looks realtive good, please send it to he ML for review.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2013-03-14 16:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-13 14:01 [LTP] [PATCH 1/2] syscalls/getdents: Use getdents64 if SYS_getdents is not defined Markos Chandras
2013-03-13 17:20 ` Mike Frysinger
2013-03-13 17:21   ` Markos Chandras
2013-03-13 17:58 ` Jan Stancek
2013-03-13 18:03   ` Markos Chandras
2013-03-13 18:23     ` chrubis
     [not found]       ` <CAG2jQ8hbT_8h8KR0V2=7qzwdSy8cqzOWb_oHt4JJ5Y22yFEeDg@mail.gmail.com>
     [not found]         ` <CAG2jQ8j23+74_JZbrkM55aKg4YG+V-g4G1+NsS4fLGy=efRDjQ@mail.gmail.com>
2013-03-14 16:29           ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox