Add mkdir10 test
PATCH v2 1/1 Add mkdir10 test
From: Andrea Cervesato <[email protected]>
This test has been extracted from symlink01 and it verifies that mkdir() can't overwrite certain types of files, such as simlinks, directories, pipes, devices, etc.
--- runtest/syscalls | 2 +- testcases/kernel/syscalls/mkdir/.gitignore | 1 + testcases/kernel/syscalls/mkdir/mkdir10.c | 57 ++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 testcases/kernel/syscalls/mkdir/mkdir10.c
runtest/syscalls +1 -1
@@ -757,8 +757,8 @@ mkdir02 mkdir02 mkdir03 mkdir03 mkdir04 mkdir04 mkdir05 mkdir05 -mkdir05A symlink01 -T mkdir05 mkdir09 mkdir09 +mkdir10 mkdir10 #mkdirat test cases mkdirat01 mkdirat01
testcases/kernel/syscalls/mkdir/.gitignore +1 -0
@@ -3,3 +3,4 @@ /mkdir04 /mkdir05 /mkdir09 +/mkdir10
testcases/kernel/syscalls/mkdir/mkdir10.c new file +57 -0
57 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Andrea,
I was thinking if this is filesystem specific (struct inode_operations mkdir member is in fs/*/*.c - all filesystems), but it looks to me that code which checks for EEXIST is in may_create() in fs/namei.c, which is VFS. Therefore there is really no point to use .all_filesystems = 1.
LGTM, just few nits below.
Quoted 4 lines
From: Andrea Cervesato <[email protected]>
This test has been extracted from symlink01 and it verifies that
mkdir()can't overwrite certain types of files, such as simlinks,
^ symlinks
Quoted 15 lines
directories, pipes, devices, etc.
Signed-off-by Andrea Cervesato <[email protected]>--- runtest/syscalls | 2 +- testcases/kernel/syscalls/mkdir/.gitignore | 1 + testcases/kernel/syscalls/mkdir/mkdir10.c | 57 ++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 testcases/kernel/syscalls/mkdir/mkdir10.cruntest/syscalls +0
-0
runtest/syscalls mkdir02 mkdir02 · line 760
Quoted 4 lines
runtest/syscalls +0
-1@@ -757,8 +757,8 @@ mkdir02 mkdir02 mkdir03 mkdir03 mkdir04 mkdir04 mkdir05 mkdir05 -mkdir05A symlink01 -T mkdir05
This is not the case, but beware runtest/smoketest also use some of symlink tests you recently rewrite.
Quoted 2 lines
runtest/syscalls +1
-0mkdir09 mkdir09 +mkdir10 mkdir10
...
testcases/kernel/syscalls/mkdir/mkdir10.c line 5
Quoted 8 lines
testcases/kernel/syscalls/mkdir/mkdir10.c new file +5
-0@@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. +* Author: David Fenner +* Copilot: Jon Hendrickson
very nit:
Authors: David Fenner, Jon Hendrickson
Quoted 7 lines
testcases/kernel/syscalls/mkdir/mkdir10.c new file +7
-0+* Copyright (C) 2024 Andrea Cervesato [email protected] +*/ + +/*\ +* [Description] +* +* This test verifies that mkdir() can't overwrite certain generated files, such
testcases/kernel/syscalls/mkdir/mkdir10.c line 22
Quoted 10 lines
testcases/kernel/syscalls/mkdir/mkdir10.c new file +10
-0+* as symlinks, pipes, devices, folders, etc. +*/ + +#include "tst_test.h" + +#define FILE_FOLDER "myfolder" +#define FILE_MYFILE "myfile" +#define FILE_FIFO "mypipe" +#define FILE_SYMLINK "mylink" +#define FILE_DEVICE "/dev/null"
nit: _PATH_DEVNULL from <paths.h> defines "/dev/null".
testcases/kernel/syscalls/mkdir/mkdir10.c line 34
Quoted 12 lines
testcases/kernel/syscalls/mkdir/mkdir10.c new file +12
-0+ +struct tcase { +char *file; +char *msg; +}; + +static struct tcase tcases[] = { + {FILE_FOLDER ,"folder already exists" }, + {FILE_MYFILE ,"file already exists" }, + {FILE_FIFO ,"fifo already exists" }, + {FILE_SYMLINK ,"symlink already exists" }, + {FILE_DEVICE ,"device already exists" },
very nit: "folder", "file", ...
TST_EXP_FAIL(mkdir(tc->file, 0777), EEXIST, "%s already exists", tc->msg);
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
This test can be actually be merged with mkdir01, so I will send an another patch for this use case. Please ignore the patch.
Andrea
Quoted 85 lines · Petr Vorel
Hi Andrea,
I was thinking if this is filesystem specific (struct
inode_operationsmkdir member is infs/*/*.c- all filesystems), but it looks to me that code which checks for EEXIST is inmay_create()infs/namei.c, which is VFS. Therefore there is really no point to use .all_filesystems = 1.LGTM, just few nits below.
Reviewed-by Petr Vorel <[email protected]>Quoted 3 lines
From: Andrea Cervesato <[email protected]>
This test has been extracted from symlink01 and it verifies thatmkdir()can't overwrite certain types of files, such as simlinks,^ symlinks
Quoted 13 lines
directories, pipes, devices, etc.
Signed-off-by Andrea Cervesato <[email protected]>--- runtest/syscalls | 2 +- testcases/kernel/syscalls/mkdir/.gitignore | 1 + testcases/kernel/syscalls/mkdir/mkdir10.c | 57 ++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-)create mode 100644
testcases/kernel/syscalls/mkdir/mkdir10.cruntest/syscalls +0
-0runtest/syscalls mkdir02 mkdir02 · line 760
Quoted 4 lines
runtest/syscalls +0
-1@@ -757,8 +757,8 @@ mkdir02 mkdir02 mkdir03 mkdir03 mkdir04 mkdir04 mkdir05 mkdir05 -mkdir05A symlink01 -T mkdir05This is not the case, but beware runtest/smoketest also use some of symlink tests you recently rewrite.
Quoted 2 lines
runtest/syscalls +1
-0mkdir09 mkdir09 +mkdir10 mkdir10...
testcases/kernel/syscalls/mkdir/mkdir10.c line 5
Quoted 8 lines
testcases/kernel/syscalls/mkdir/mkdir10.c new file +5
-0@@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. +* Author: David Fenner +* Copilot: Jon Hendrickson very nit:
Authors: David Fenner, Jon HendricksonQuoted 7 lines
testcases/kernel/syscalls/mkdir/mkdir10.c new file +7
-0+* Copyright (C) 2024 Andrea Cervesato [email protected] +*/ + +/*\ +* [Description] +* +* This test verifies that mkdir() can't overwrite certain generated files, such testcases/kernel/syscalls/mkdir/mkdir10.c line 22
Quoted 10 lines
testcases/kernel/syscalls/mkdir/mkdir10.c new file +10
-0+* as symlinks, pipes, devices, folders, etc. +*/ + +#include "tst_test.h" + +#define FILE_FOLDER "myfolder" +#define FILE_MYFILE "myfile" +#define FILE_FIFO "mypipe" +#define FILE_SYMLINK "mylink" +#define FILE_DEVICE "/dev/null"nit:
_PATH_DEVNULLfrom <paths.h> defines "/dev/null".testcases/kernel/syscalls/mkdir/mkdir10.c line 34
Quoted 12 lines
testcases/kernel/syscalls/mkdir/mkdir10.c new file +12
-0+ +struct tcase { +char *file; +char *msg; +}; + +static struct tcase tcases[] = { + {FILE_FOLDER ,"folder already exists" }, + {FILE_MYFILE ,"file already exists" }, + {FILE_FIFO ,"fifo already exists" }, + {FILE_SYMLINK ,"symlink already exists" }, + {FILE_DEVICE ,"device already exists" },very nit: "folder", "file", ...
TST_EXP_FAIL(mkdir(tc->file, 0777), EEXIST, "%s already exists", tc->msg);Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp