public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] containers: Use raw setns syscall for versions of glibc that don't include it
@ 2015-06-30  6:18 Hangbin Liu
  2015-06-30  6:55 ` Jan Stancek
  0 siblings, 1 reply; 4+ messages in thread
From: Hangbin Liu @ 2015-06-30  6:18 UTC (permalink / raw)
  To: LTP List

On RHEL6.6, the kernel support setns syscall, but glibc(2.12) does not support
this syscall. Thus ltp build failed with "userns04.c:58: undefined reference
to `setns'". Use raw setns syscall to make ltp build pass.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 testcases/kernel/containers/userns/userns_helper.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/testcases/kernel/containers/userns/userns_helper.h b/testcases/kernel/containers/userns/userns_helper.h
index da03bae..9107886 100644
--- a/testcases/kernel/containers/userns/userns_helper.h
+++ b/testcases/kernel/containers/userns/userns_helper.h
@@ -15,6 +15,19 @@
 #include "test.h"
 #include "safe_macros.h"
 
+/*
+ * Use raw setns syscall for versions of glibc that don't include it (namely
+ * glibc-2.12)
+ */
+#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 14
+#ifdef SYS_setns
+int setns(int fd, int nstype)
+{
+	return syscall(SYS_setns, fd, nstype);
+}
+#endif
+#endif
+
 static int dummy_child(void *v)
 {
 	(void) v;
-- 
1.9.3


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] containers: Use raw setns syscall for versions of glibc that don't include it
  2015-06-30  6:18 Hangbin Liu
@ 2015-06-30  6:55 ` Jan Stancek
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Stancek @ 2015-06-30  6:55 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: LTP List





----- Original Message -----
> From: "Hangbin Liu" <liuhangbin@gmail.com>
> To: "LTP List" <ltp-list@lists.sourceforge.net>
> Sent: Tuesday, 30 June, 2015 8:18:45 AM
> Subject: [LTP] [PATCH] containers: Use raw setns syscall for versions of	glibc that don't include it
> 
> On RHEL6.6, the kernel support setns syscall, but glibc(2.12) does not
> support
> this syscall. Thus ltp build failed with "userns04.c:58: undefined reference
> to `setns'". Use raw setns syscall to make ltp build pass.
> 
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
>  testcases/kernel/containers/userns/userns_helper.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/testcases/kernel/containers/userns/userns_helper.h
> b/testcases/kernel/containers/userns/userns_helper.h
> index da03bae..9107886 100644
> --- a/testcases/kernel/containers/userns/userns_helper.h
> +++ b/testcases/kernel/containers/userns/userns_helper.h
> @@ -15,6 +15,19 @@
>  #include "test.h"
>  #include "safe_macros.h"
>  
> +/*
> + * Use raw setns syscall for versions of glibc that don't include it (namely
> + * glibc-2.12)
> + */
> +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 14
> +#ifdef SYS_setns
> +int setns(int fd, int nstype)
> +{
> +	return syscall(SYS_setns, fd, nstype);
> +}
> +#endif
> +#endif
> +

This will still fail if SYS_setns is not defined.

We have ltp_syscall and "linux_syscall_numbers.h", which can guaruantee
that __NR_setns will be defined and ltp_syscall will break with TCONF
in case you get ENOSYS.

So if you add dummy call to setns in setup():
  ltp_syscall(__NR_setns, -1, 0);
you can stop the testcase quite early with TCONF if setns is not supported.

Regards,
Jan

>  static int dummy_child(void *v)
>  {
>  	(void) v;
> --
> 1.9.3
> 
> 
> ------------------------------------------------------------------------------
> Don't Limit Your Business. Reach for the Cloud.
> GigeNET's Cloud Solutions provide you with the tools and support that
> you need to offload your IT needs and focus on growing your business.
> Configured For All Businesses. Start Your Cloud Today.
> https://www.gigenetcloud.com/
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH] containers: Use raw setns syscall for versions of glibc that don't include it
@ 2015-07-01  3:33 Hangbin Liu
  2015-07-14  9:31 ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Hangbin Liu @ 2015-07-01  3:33 UTC (permalink / raw)
  To: LTP List

The setns() system call was added to glibc in version 2.14. On systems with
lower version glic, like RHEL6.6 glibc 2.12, ltp will build failed with
error "userns04.c:58: undefined reference to `setns'". Use ltp_syscall to make
build pass.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 testcases/kernel/containers/userns/userns_helper.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/testcases/kernel/containers/userns/userns_helper.h b/testcases/kernel/containers/userns/userns_helper.h
index da03bae..21e5cb8 100644
--- a/testcases/kernel/containers/userns/userns_helper.h
+++ b/testcases/kernel/containers/userns/userns_helper.h
@@ -15,6 +15,16 @@
 #include "test.h"
 #include "safe_macros.h"
 
+/*
+ * Use raw setns syscall for versions of glibc that don't include it
+ */
+#if __GLIBC__ <= 2 && __GLIBC_MINOR__ < 14
+int setns(int fd, int nstype)
+{
+	return ltp_syscall(__NR_setns, fd, nstype);
+}
+#endif
+
 static int dummy_child(void *v)
 {
 	(void) v;
-- 
1.9.3


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] containers: Use raw setns syscall for versions of glibc that don't include it
  2015-07-01  3:33 [LTP] [PATCH] containers: Use raw setns syscall for versions of glibc that don't include it Hangbin Liu
@ 2015-07-14  9:31 ` Cyril Hrubis
  0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2015-07-14  9:31 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: LTP List

Hi!
> diff --git a/testcases/kernel/containers/userns/userns_helper.h b/testcases/kernel/containers/userns/userns_helper.h
> index da03bae..21e5cb8 100644
> --- a/testcases/kernel/containers/userns/userns_helper.h
> +++ b/testcases/kernel/containers/userns/userns_helper.h
> @@ -15,6 +15,16 @@
>  #include "test.h"
>  #include "safe_macros.h"
>  
> +/*
> + * Use raw setns syscall for versions of glibc that don't include it
> + */
> +#if __GLIBC__ <= 2 && __GLIBC_MINOR__ < 14
> +int setns(int fd, int nstype)
> +{
> +	return ltp_syscall(__NR_setns, fd, nstype);
> +}
> +#endif

I would rather see this as configure check. Simple
AC_CHECK_FUNCS([setns]) would do, then we can use #ifndef HAVE_SETNS in
the source after we include config.h.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2015-07-14  9:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-01  3:33 [LTP] [PATCH] containers: Use raw setns syscall for versions of glibc that don't include it Hangbin Liu
2015-07-14  9:31 ` Cyril Hrubis
  -- strict thread matches above, loose matches on Subject: below --
2015-06-30  6:18 Hangbin Liu
2015-06-30  6:55 ` Jan Stancek

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