* [LTP] [PATCH v1] Add mkdir10 test
@ 2024-01-18 15:35 Andrea Cervesato
2024-02-02 17:10 ` Cyril Hrubis
0 siblings, 1 reply; 3+ messages in thread
From: Andrea Cervesato @ 2024-01-18 15:35 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test has been extracted from symlink01 and it verifies that
mkdir() can't overwrite symlink() generated files.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 2 +-
testcases/kernel/syscalls/mkdir/.gitignore | 1 +
testcases/kernel/syscalls/mkdir/mkdir10.c | 30 ++++++++++++++++++++++
3 files changed, 32 insertions(+), 1 deletion(-)
create mode 100644 testcases/kernel/syscalls/mkdir/mkdir10.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 8dd8a49ca..e62e793e3 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -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
diff --git a/testcases/kernel/syscalls/mkdir/.gitignore b/testcases/kernel/syscalls/mkdir/.gitignore
index 880ff50c0..416fbbd7c 100644
--- a/testcases/kernel/syscalls/mkdir/.gitignore
+++ b/testcases/kernel/syscalls/mkdir/.gitignore
@@ -3,3 +3,4 @@
/mkdir04
/mkdir05
/mkdir09
+/mkdir10
diff --git a/testcases/kernel/syscalls/mkdir/mkdir10.c b/testcases/kernel/syscalls/mkdir/mkdir10.c
new file mode 100644
index 000000000..b0c0993ba
--- /dev/null
+++ b/testcases/kernel/syscalls/mkdir/mkdir10.c
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ * Author: David Fenner
+ * Copilot: Jon Hendrickson
+ * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that mkdir() can't overwrite symlink() generated files.
+ */
+
+#include "tst_test.h"
+
+static void run(void)
+{
+ char *symname = "my_symlink0";
+
+ SAFE_SYMLINK(tst_get_tmpdir(), symname);
+ TST_EXP_FAIL(mkdir(symname, 0777), EEXIST);
+
+ SAFE_UNLINK(symname);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .needs_tmpdir = 1,
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v1] Add mkdir10 test
2024-01-18 15:35 [LTP] [PATCH v1] Add mkdir10 test Andrea Cervesato
@ 2024-02-02 17:10 ` Cyril Hrubis
2024-02-07 12:57 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2024-02-02 17:10 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> +static void run(void)
> +{
> + char *symname = "my_symlink0";
> +
> + SAFE_SYMLINK(tst_get_tmpdir(), symname);
> + TST_EXP_FAIL(mkdir(symname, 0777), EEXIST);
This can be easily added into mkdir03.c as well as a few more different
cases (we can't overwrite named pipe, directory, device node, etc.) if
we wanted to.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v1] Add mkdir10 test
2024-02-02 17:10 ` Cyril Hrubis
@ 2024-02-07 12:57 ` Andrea Cervesato via ltp
0 siblings, 0 replies; 3+ messages in thread
From: Andrea Cervesato via ltp @ 2024-02-07 12:57 UTC (permalink / raw)
To: Cyril Hrubis, Andrea Cervesato; +Cc: ltp
Hi,
On 2/2/24 18:10, Cyril Hrubis wrote:
> Hi!
>> +static void run(void)
>> +{
>> + char *symname = "my_symlink0";
>> +
>> + SAFE_SYMLINK(tst_get_tmpdir(), symname);
>> + TST_EXP_FAIL(mkdir(symname, 0777), EEXIST);
> This can be easily added into mkdir03.c as well as a few more different
> cases (we can't overwrite named pipe, directory, device node, etc.) if
> we wanted to.
>
I would prefer to keep mkdir10 and add more cases rather than
complicating mkdir01 that seems more focusing on checking multiple errors.
Andrea Cervesato
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-07 12:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-18 15:35 [LTP] [PATCH v1] Add mkdir10 test Andrea Cervesato
2024-02-02 17:10 ` Cyril Hrubis
2024-02-07 12:57 ` Andrea Cervesato via ltp
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.