* [LTP] [PATCH] syscalls/fsetxattr02.c: Fix the failure of opening device files
@ 2018-08-08 16:01 Xiao Yang
2018-08-09 14:57 ` Rafael David Tinoco
0 siblings, 1 reply; 5+ messages in thread
From: Xiao Yang @ 2018-08-08 16:01 UTC (permalink / raw)
To: ltp
If temporary directory(TMPDIR/TEMPDIR) is on the mountpoint which
is mounted with nodev option or temporary directory is mounted with
with nodev option directly(e.g. tmpfs is mounted on /tmp), open(2)
has no permission to open device files in the temporary directory
and returned EACCES. as below:
--------------------------------------------------------------------
safe_macros.c:225: BROK: fsetxattr02.c:215: open(fsetxattr02chr,0,00) failed: EACCES
--------------------------------------------------------------------
We try to fix this issue by creating device files in /dev/ instead.
This is the same issue reported by open11, please see the mail:
http://lists.linux.it/pipermail/ltp/2018-July/008641.html
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
testcases/kernel/syscalls/fsetxattr/fsetxattr02.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
index a1be652..356e527 100644
--- a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
+++ b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
@@ -52,11 +52,13 @@
#define FILENAME "fsetxattr02testfile"
#define DIRNAME "fsetxattr02testdir"
#define SYMLINK "fsetxattr02symlink"
-#define FIFO "fsetxattr02fifo"
-#define CHR "fsetxattr02chr"
-#define BLK "fsetxattr02blk"
+#define FIFO "/dev/fsetxattr02fifo"
+#define CHR "/dev/fsetxattr02chr"
+#define BLK "/dev/fsetxattr02blk"
#define SOCK "fsetxattr02sock"
+static char *dev_files[3] = {FIFO, CHR, BLK};
+
struct test_case {
char *fname;
int fd;
@@ -240,6 +242,11 @@ static void cleanup(void)
if (tc[i].fd > 0)
SAFE_CLOSE(tc[i].fd);
}
+
+ for (i = 0; i < ARRAY_SIZE(dev_files); i++) {
+ if (!access(dev_files[i], F_OK))
+ SAFE_UNLINK(dev_files[i]);
+ }
}
static struct tst_test test = {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH v2] syscalls/fsetxattr02.c: Fix the failure of opening device files
2018-08-09 14:57 ` Rafael David Tinoco
@ 2018-08-09 6:26 ` Xiao Yang
2018-08-10 12:50 ` Cyril Hrubis
2018-08-10 0:13 ` [LTP] [PATCH] " Xiao Yang
1 sibling, 1 reply; 5+ messages in thread
From: Xiao Yang @ 2018-08-09 6:26 UTC (permalink / raw)
To: ltp
If temporary directory(TMPDIR/TEMPDIR) is on the mountpoint which
is mounted with nodev option or temporary directory is mounted with
with nodev option directly(e.g. tmpfs is mounted on /tmp), open(2)
has no permission to open device files in the temporary directory
and returns EACCES. as below:
--------------------------------------------------------------------
safe_macros.c:225: BROK: fsetxattr02.c:215: open(fsetxattr02chr,0,00) failed: EACCES
--------------------------------------------------------------------
We try to fix this issue by creating device files in /dev/ instead.
This is the same issue reported by open11, please see the mail:
http://lists.linux.it/pipermail/ltp/2018-July/008641.html
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Changes in v2:
Acquire basename to avoid breaking OFFSET logic.
---
testcases/kernel/syscalls/fsetxattr/fsetxattr02.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
index a1be652..13e1735 100644
--- a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
+++ b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
@@ -52,11 +52,13 @@
#define FILENAME "fsetxattr02testfile"
#define DIRNAME "fsetxattr02testdir"
#define SYMLINK "fsetxattr02symlink"
-#define FIFO "fsetxattr02fifo"
-#define CHR "fsetxattr02chr"
-#define BLK "fsetxattr02blk"
+#define FIFO "/dev/fsetxattr02fifo"
+#define CHR "/dev/fsetxattr02chr"
+#define BLK "/dev/fsetxattr02blk"
#define SOCK "fsetxattr02sock"
+static char *dev_files[3] = {FIFO, CHR, BLK};
+
struct test_case {
char *fname;
int fd;
@@ -139,6 +141,9 @@ static struct test_case tc[] = {
static void verify_fsetxattr(unsigned int i)
{
+ /* acquire basename to avoid breaking OFFSET logic*/
+ tc[i].fname = strstr(tc[i].fname, "fsetxattr02");
+
/* some tests might require existing keys for each iteration */
if (tc[i].needskeyset) {
SAFE_FSETXATTR(tc[i].fd, tc[i].key, tc[i].value, tc[i].size,
@@ -240,6 +245,11 @@ static void cleanup(void)
if (tc[i].fd > 0)
SAFE_CLOSE(tc[i].fd);
}
+
+ for (i = 0; i < ARRAY_SIZE(dev_files); i++) {
+ if (!access(dev_files[i], F_OK))
+ SAFE_UNLINK(dev_files[i]);
+ }
}
static struct tst_test test = {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH] syscalls/fsetxattr02.c: Fix the failure of opening device files
2018-08-08 16:01 [LTP] [PATCH] syscalls/fsetxattr02.c: Fix the failure of opening device files Xiao Yang
@ 2018-08-09 14:57 ` Rafael David Tinoco
2018-08-09 6:26 ` [LTP] [PATCH v2] " Xiao Yang
2018-08-10 0:13 ` [LTP] [PATCH] " Xiao Yang
0 siblings, 2 replies; 5+ messages in thread
From: Rafael David Tinoco @ 2018-08-09 14:57 UTC (permalink / raw)
To: ltp
> --- a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
> +++ b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
> @@ -52,11 +52,13 @@
> #define FILENAME "fsetxattr02testfile"
> #define DIRNAME "fsetxattr02testdir"
> #define SYMLINK "fsetxattr02symlink"
> -#define FIFO "fsetxattr02fifo"
> -#define CHR "fsetxattr02chr"
> -#define BLK "fsetxattr02blk"
> +#define FIFO "/dev/fsetxattr02fifo"
> +#define CHR "/dev/fsetxattr02chr"
> +#define BLK "/dev/fsetxattr02blk"
Thanks for catching this!! Minor issue: This will break OFFSET logic for
tst_res() messages. They are skipping 11 chars because all files started
with "fsetxattr02".
-Rafael
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH] syscalls/fsetxattr02.c: Fix the failure of opening device files
2018-08-09 14:57 ` Rafael David Tinoco
2018-08-09 6:26 ` [LTP] [PATCH v2] " Xiao Yang
@ 2018-08-10 0:13 ` Xiao Yang
1 sibling, 0 replies; 5+ messages in thread
From: Xiao Yang @ 2018-08-10 0:13 UTC (permalink / raw)
To: ltp
On 2018/08/09 22:57, Rafael David Tinoco wrote:
>> --- a/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
>> +++ b/testcases/kernel/syscalls/fsetxattr/fsetxattr02.c
>> @@ -52,11 +52,13 @@
>> #define FILENAME "fsetxattr02testfile"
>> #define DIRNAME "fsetxattr02testdir"
>> #define SYMLINK "fsetxattr02symlink"
>> -#define FIFO "fsetxattr02fifo"
>> -#define CHR "fsetxattr02chr"
>> -#define BLK "fsetxattr02blk"
>> +#define FIFO "/dev/fsetxattr02fifo"
>> +#define CHR "/dev/fsetxattr02chr"
>> +#define BLK "/dev/fsetxattr02blk"
> Thanks for catching this!! Minor issue: This will break OFFSET logic for
> tst_res() messages. They are skipping 11 chars because all files started
> with "fsetxattr02".
Hi Rafael,
Sorry for this rough fix, and i will send v2 patch as you suggested.
Thanks,
Xiao Yang
> -Rafael
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH v2] syscalls/fsetxattr02.c: Fix the failure of opening device files
2018-08-09 6:26 ` [LTP] [PATCH v2] " Xiao Yang
@ 2018-08-10 12:50 ` Cyril Hrubis
0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2018-08-10 12:50 UTC (permalink / raw)
To: ltp
Hi!
> We try to fix this issue by creating device files in /dev/ instead.
I do not like much that we are messing up with the system directories.
Maybe we could mount a tmpfs over a directory in the test temporary
directory if we detect that the test temporary directory is mounted
with nodev. The downsinde is that it will be a bit more complicated
than this solution.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-08-10 12:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-08 16:01 [LTP] [PATCH] syscalls/fsetxattr02.c: Fix the failure of opening device files Xiao Yang
2018-08-09 14:57 ` Rafael David Tinoco
2018-08-09 6:26 ` [LTP] [PATCH v2] " Xiao Yang
2018-08-10 12:50 ` Cyril Hrubis
2018-08-10 0:13 ` [LTP] [PATCH] " Xiao Yang
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.