* [LTP] [PATCH] syscalls/flock: open test file with O_RDWR mode
@ 2017-05-17 17:09 Eryu Guan
2017-06-05 14:25 ` Eryu Guan
0 siblings, 1 reply; 3+ messages in thread
From: Eryu Guan @ 2017-05-17 17:09 UTC (permalink / raw)
To: ltp
NFS requires the open mode to match the lock type, i.e. for LOCK_SH
file must be opened for read, and for LOCK_EX file must be opened
for write. Otherwise flock01 and flock04 fail on NFS with EBADF.
So open all test files in flock tests with O_RDWR mode that both
lock type requirements can be met.
Signed-off-by: Eryu Guan <eguan@redhat.com>
---
testcases/kernel/syscalls/flock/flock01.c | 2 +-
testcases/kernel/syscalls/flock/flock02.c | 2 +-
testcases/kernel/syscalls/flock/flock03.c | 2 +-
testcases/kernel/syscalls/flock/flock04.c | 2 +-
testcases/kernel/syscalls/flock/flock05.c | 2 +-
testcases/kernel/syscalls/flock/flock06.c | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/testcases/kernel/syscalls/flock/flock01.c b/testcases/kernel/syscalls/flock/flock01.c
index a7ecba1..3e17be4 100644
--- a/testcases/kernel/syscalls/flock/flock01.c
+++ b/testcases/kernel/syscalls/flock/flock01.c
@@ -153,7 +153,7 @@ void setup(void)
sprintf(filename, "flock01.%d", getpid());
/* creating temporary file */
- fd = creat(filename, 0644);
+ fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0644);
if (fd < 0)
tst_brkm(TBROK, tst_rmdir, "creating a new file failed");
}
diff --git a/testcases/kernel/syscalls/flock/flock02.c b/testcases/kernel/syscalls/flock/flock02.c
index 971160d..414df68 100644
--- a/testcases/kernel/syscalls/flock/flock02.c
+++ b/testcases/kernel/syscalls/flock/flock02.c
@@ -150,7 +150,7 @@ void setup(void)
sprintf(filename, "flock02.%d", getpid());
- fd = creat(filename, 0666);
+ fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
if (fd < 0)
tst_brkm(TFAIL | TERRNO, cleanup, "creat failed");
}
diff --git a/testcases/kernel/syscalls/flock/flock03.c b/testcases/kernel/syscalls/flock/flock03.c
index e53b3b7..420f509 100644
--- a/testcases/kernel/syscalls/flock/flock03.c
+++ b/testcases/kernel/syscalls/flock/flock03.c
@@ -181,7 +181,7 @@ static void setup(void)
TST_CHECKPOINT_INIT(tst_rmdir);
- fd = creat(FILE_NAME, 0666);
+ fd = open(FILE_NAME, O_CREAT | O_TRUNC | O_RDWR, 0666);
if (fd < 0) {
tst_resm(TBROK, "creating a new file failed");
cleanup();
diff --git a/testcases/kernel/syscalls/flock/flock04.c b/testcases/kernel/syscalls/flock/flock04.c
index 5dafaa4..87f1dfb 100644
--- a/testcases/kernel/syscalls/flock/flock04.c
+++ b/testcases/kernel/syscalls/flock/flock04.c
@@ -164,7 +164,7 @@ void setup(void)
sprintf(filename, "flock04.%d", getpid());
- fd = creat(filename, 0666);
+ fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
if (fd == -1)
tst_brkm(TFAIL, cleanup, "creating a new file failed");
}
diff --git a/testcases/kernel/syscalls/flock/flock05.c b/testcases/kernel/syscalls/flock/flock05.c
index d9d3d00..13ae2f6 100644
--- a/testcases/kernel/syscalls/flock/flock05.c
+++ b/testcases/kernel/syscalls/flock/flock05.c
@@ -182,7 +182,7 @@ void setup(void)
sprintf(filename, "flock05.%d", getpid());
/* creating temporary file */
- fd = creat(filename, 0666);
+ fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
if (fd == -1) {
tst_resm(TFAIL, "creating a new file failed");
diff --git a/testcases/kernel/syscalls/flock/flock06.c b/testcases/kernel/syscalls/flock/flock06.c
index d9c1d2d..a35c8cf 100644
--- a/testcases/kernel/syscalls/flock/flock06.c
+++ b/testcases/kernel/syscalls/flock/flock06.c
@@ -158,7 +158,7 @@ void setup(void)
sprintf(filename, "flock06.%d", getpid());
/* creating temporary file */
- fd = creat(filename, 0666);
+ fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
if (fd < 0)
tst_brkm(TBROK, tst_rmdir, "creating a new file failed");
close(fd);
--
2.9.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [LTP] [PATCH] syscalls/flock: open test file with O_RDWR mode
2017-05-17 17:09 [LTP] [PATCH] syscalls/flock: open test file with O_RDWR mode Eryu Guan
@ 2017-06-05 14:25 ` Eryu Guan
2017-06-07 10:58 ` Jan Stancek
0 siblings, 1 reply; 3+ messages in thread
From: Eryu Guan @ 2017-06-05 14:25 UTC (permalink / raw)
To: ltp
On Thu, May 18, 2017 at 01:09:56AM +0800, Eryu Guan wrote:
> NFS requires the open mode to match the lock type, i.e. for LOCK_SH
> file must be opened for read, and for LOCK_EX file must be opened
> for write. Otherwise flock01 and flock04 fail on NFS with EBADF.
>
> So open all test files in flock tests with O_RDWR mode that both
> lock type requirements can be met.
>
> Signed-off-by: Eryu Guan <eguan@redhat.com>
ping on this one.
Thanks,
Eryu
> ---
> testcases/kernel/syscalls/flock/flock01.c | 2 +-
> testcases/kernel/syscalls/flock/flock02.c | 2 +-
> testcases/kernel/syscalls/flock/flock03.c | 2 +-
> testcases/kernel/syscalls/flock/flock04.c | 2 +-
> testcases/kernel/syscalls/flock/flock05.c | 2 +-
> testcases/kernel/syscalls/flock/flock06.c | 2 +-
> 6 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/flock/flock01.c b/testcases/kernel/syscalls/flock/flock01.c
> index a7ecba1..3e17be4 100644
> --- a/testcases/kernel/syscalls/flock/flock01.c
> +++ b/testcases/kernel/syscalls/flock/flock01.c
> @@ -153,7 +153,7 @@ void setup(void)
> sprintf(filename, "flock01.%d", getpid());
>
> /* creating temporary file */
> - fd = creat(filename, 0644);
> + fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0644);
> if (fd < 0)
> tst_brkm(TBROK, tst_rmdir, "creating a new file failed");
> }
> diff --git a/testcases/kernel/syscalls/flock/flock02.c b/testcases/kernel/syscalls/flock/flock02.c
> index 971160d..414df68 100644
> --- a/testcases/kernel/syscalls/flock/flock02.c
> +++ b/testcases/kernel/syscalls/flock/flock02.c
> @@ -150,7 +150,7 @@ void setup(void)
>
> sprintf(filename, "flock02.%d", getpid());
>
> - fd = creat(filename, 0666);
> + fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
> if (fd < 0)
> tst_brkm(TFAIL | TERRNO, cleanup, "creat failed");
> }
> diff --git a/testcases/kernel/syscalls/flock/flock03.c b/testcases/kernel/syscalls/flock/flock03.c
> index e53b3b7..420f509 100644
> --- a/testcases/kernel/syscalls/flock/flock03.c
> +++ b/testcases/kernel/syscalls/flock/flock03.c
> @@ -181,7 +181,7 @@ static void setup(void)
>
> TST_CHECKPOINT_INIT(tst_rmdir);
>
> - fd = creat(FILE_NAME, 0666);
> + fd = open(FILE_NAME, O_CREAT | O_TRUNC | O_RDWR, 0666);
> if (fd < 0) {
> tst_resm(TBROK, "creating a new file failed");
> cleanup();
> diff --git a/testcases/kernel/syscalls/flock/flock04.c b/testcases/kernel/syscalls/flock/flock04.c
> index 5dafaa4..87f1dfb 100644
> --- a/testcases/kernel/syscalls/flock/flock04.c
> +++ b/testcases/kernel/syscalls/flock/flock04.c
> @@ -164,7 +164,7 @@ void setup(void)
>
> sprintf(filename, "flock04.%d", getpid());
>
> - fd = creat(filename, 0666);
> + fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
> if (fd == -1)
> tst_brkm(TFAIL, cleanup, "creating a new file failed");
> }
> diff --git a/testcases/kernel/syscalls/flock/flock05.c b/testcases/kernel/syscalls/flock/flock05.c
> index d9d3d00..13ae2f6 100644
> --- a/testcases/kernel/syscalls/flock/flock05.c
> +++ b/testcases/kernel/syscalls/flock/flock05.c
> @@ -182,7 +182,7 @@ void setup(void)
> sprintf(filename, "flock05.%d", getpid());
>
> /* creating temporary file */
> - fd = creat(filename, 0666);
> + fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
> if (fd == -1) {
> tst_resm(TFAIL, "creating a new file failed");
>
> diff --git a/testcases/kernel/syscalls/flock/flock06.c b/testcases/kernel/syscalls/flock/flock06.c
> index d9c1d2d..a35c8cf 100644
> --- a/testcases/kernel/syscalls/flock/flock06.c
> +++ b/testcases/kernel/syscalls/flock/flock06.c
> @@ -158,7 +158,7 @@ void setup(void)
> sprintf(filename, "flock06.%d", getpid());
>
> /* creating temporary file */
> - fd = creat(filename, 0666);
> + fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
> if (fd < 0)
> tst_brkm(TBROK, tst_rmdir, "creating a new file failed");
> close(fd);
> --
> 2.9.4
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [LTP] [PATCH] syscalls/flock: open test file with O_RDWR mode
2017-06-05 14:25 ` Eryu Guan
@ 2017-06-07 10:58 ` Jan Stancek
0 siblings, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2017-06-07 10:58 UTC (permalink / raw)
To: ltp
----- Original Message -----
> On Thu, May 18, 2017 at 01:09:56AM +0800, Eryu Guan wrote:
> > NFS requires the open mode to match the lock type, i.e. for LOCK_SH
> > file must be opened for read, and for LOCK_EX file must be opened
> > for write. Otherwise flock01 and flock04 fail on NFS with EBADF.
> >
> > So open all test files in flock tests with O_RDWR mode that both
> > lock type requirements can be met.
> >
> > Signed-off-by: Eryu Guan <eguan@redhat.com>
>
> ping on this one.
Pushed.
Thanks,
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-07 10:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-17 17:09 [LTP] [PATCH] syscalls/flock: open test file with O_RDWR mode Eryu Guan
2017-06-05 14:25 ` Eryu Guan
2017-06-07 10:58 ` Jan Stancek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox