From: Federico Bonfiglio <fedebonfi95@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4 1/2] include/SAFE_UNSHARE() macro added
Date: Thu, 28 Mar 2019 21:22:35 +0100 [thread overview]
Message-ID: <20190328202235.7872-1-fedebonfi95@gmail.com> (raw)
In-Reply-To: <20190326192052.GA15776@rei.lan>
---
Hi Cyril, thanks again for your review. Here the updated patches, I removed the "." check and split them.
I left the include/lapi/ioctl_ns.h in the testcases patch since it doesn't have to do with SAFE_UNSHARE.
However let me know if it belongs here instead
include/tst_safe_macros.h | 4 ++++
lib/tst_safe_macros.c | 17 +++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 5e85abc9c..04aedb39a 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -526,4 +526,8 @@ int safe_personality(const char *filename, unsigned int lineno,
} \
} while (0)
+void safe_unshare(const char *file, const int lineno, int flags);
+#define SAFE_UNSHARE(flags) safe_unshare(__FILE__, __LINE__, (flags))
+
+
#endif /* SAFE_MACROS_H__ */
diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c
index c375030a4..9480ca910 100644
--- a/lib/tst_safe_macros.c
+++ b/lib/tst_safe_macros.c
@@ -18,6 +18,7 @@
#define _GNU_SOURCE
#include <unistd.h>
#include <errno.h>
+#include <sched.h>
#include "config.h"
#ifdef HAVE_SYS_FANOTIFY_H
# include <sys/fanotify.h>
@@ -197,3 +198,19 @@ int safe_chroot(const char *file, const int lineno, const char *path)
return rval;
}
+
+void safe_unshare(const char *file, const int lineno, int flags)
+{
+ int res;
+
+ res = unshare(flags);
+ if (res == -1) {
+ if (errno == EINVAL) {
+ tst_brk_(file, lineno, TCONF | TERRNO,
+ "unshare(%d) unsupported", flags);
+ } else {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "unshare(%d) unsupported", flags);
+ }
+ }
+}
--
2.11.0
next prev parent reply other threads:[~2019-03-28 20:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-24 20:29 [LTP] [PATCH v1] Test ioctl syscall for NS_GET_* requests YourName
2019-03-04 16:16 ` Cyril Hrubis
2019-03-11 7:25 ` [LTP] [PATCH v2] " Federico Bonfiglio
2019-03-18 14:22 ` Cyril Hrubis
2019-03-18 15:30 ` Cyril Hrubis
2019-03-19 18:09 ` [LTP] [PATCH v3] " Federico Bonfiglio
2019-03-26 19:20 ` Cyril Hrubis
2019-03-28 20:22 ` Federico Bonfiglio [this message]
2019-04-03 15:19 ` [LTP] [PATCH v4 1/2] include/SAFE_UNSHARE() macro added Cyril Hrubis
2019-03-28 20:22 ` [LTP] [PATCH v4 2/2] Test ioctl syscall for NS_GET_* requests Federico Bonfiglio
2019-04-03 15:22 ` Cyril Hrubis
2019-04-11 19:25 ` [LTP] [PATCH v5] " Federico Bonfiglio
2019-04-12 14:33 ` Cyril Hrubis
2019-05-06 10:14 ` [LTP] NS_* ioctl commands fail in 32bit compat mode (-m32) Richard Palethorpe
2019-05-06 10:39 ` Richard Palethorpe
2019-05-13 9:00 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190328202235.7872-1-fedebonfi95@gmail.com \
--to=fedebonfi95@gmail.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox