syscalls/flock: open test file with O_RDWR mode
PATCH 1/1 syscalls/flock: open test file with O_RDWR mode
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.
--- 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(-)
testcases/kernel/syscalls/flock/flock01.c +1 -1
@@ -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" ); }
testcases/kernel/syscalls/flock/flock02.c +1 -1
@@ -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" ); }
testcases/kernel/syscalls/flock/flock03.c +1 -1
@@ -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 ();
testcases/kernel/syscalls/flock/flock04.c +1 -1
@@ -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" ); }
testcases/kernel/syscalls/flock/flock05.c +1 -1
@@ -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" );
testcases/kernel/syscalls/flock/flock06.c +1 -1
@@ -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);
Signature · 1 line
2.9.4
PATCH 1/1 syscalls/flock: open test file with O_RDWR mode
Quoted 8 lines · Eryu Guan
NFS requires the open mode to match the lock type, i.e. for
LOCK_SHfile must be opened for read, and forLOCK_EXfile must be opened for write. Otherwise flock01 and flock04 fail on NFS with EBADF.So open all test files in flock tests with
O_RDWRmode that both lock type requirements can be met.Signed-off-by Eryu Guan <[email protected]>
ping on this one.
Thanks,
Eryu
Quoted 90 lines
--- 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(-)testcases/kernel/syscalls/flock/flock01.c +1
-1@@ -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" ); }testcases/kernel/syscalls/flock/flock02.c +1
-1@@ -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" ); }testcases/kernel/syscalls/flock/flock03.c +1
-1@@ -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 ();testcases/kernel/syscalls/flock/flock04.c +1
-1@@ -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" ); }testcases/kernel/syscalls/flock/flock05.c +1
-1@@ -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" );testcases/kernel/syscalls/flock/flock06.c +1
-1@@ -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);Signature · 1 line
2.9.4
PATCH 1/1 syscalls/flock: open test file with O_RDWR mode
----- Original Message -----
Quoted 11 lines · Eryu Guan
Quoted 8 lines
NFS requires the open mode to match the lock type, i.e. for
LOCK_SHfile must be opened for read, and forLOCK_EXfile must be opened for write. Otherwise flock01 and flock04 fail on NFS with EBADF.So open all test files in flock tests with
O_RDWRmode that both lock type requirements can be met.Signed-off-by Eryu Guan <[email protected]>ping on this one.
Pushed.
Thanks,
Jan