From: Eryu Guan <eguan@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/flock: open test file with O_RDWR mode
Date: Thu, 18 May 2017 01:09:56 +0800 [thread overview]
Message-ID: <20170517170956.27118-1-eguan@redhat.com> (raw)
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
next reply other threads:[~2017-05-17 17:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-17 17:09 Eryu Guan [this message]
2017-06-05 14:25 ` [LTP] [PATCH] syscalls/flock: open test file with O_RDWR mode Eryu Guan
2017-06-07 10:58 ` Jan Stancek
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=20170517170956.27118-1-eguan@redhat.com \
--to=eguan@redhat.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