1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) International Business Machines Corp., 2001
4 * 07/2001 Ported by Wayne Boyer
5 * Copyright (c) 2022 SUSE LLC Avinesh Kumar <[email protected]>
6 */
7
8 /*\
9 * [Description]
10 *
11 * Verify that rename(2) fails with ENOTDIR, when
12 * oldpath is a directory and newpath exists but is not a directory.
13 *
14 */
15
16 #include <stdio.h>
17 #include "tst_test.h"
18
19 #define MNT_POINT "mntpoint"
20 #define TEMP_DIR "tmpdir"
21 #define TEMP_FILE "tmpfile"
22
setup(void)23 static void setup(void)
24 {
25 SAFE_CHDIR(MNT_POINT);
26 SAFE_MKDIR(TEMP_DIR, 00770);
27 SAFE_TOUCH(TEMP_FILE, 0700, NULL);
28 }
29
run(void)30 static void run(void)
31 {
32 TST_EXP_FAIL(rename(TEMP_DIR, TEMP_FILE),
33 ENOTDIR);
34 }
35
36 static struct tst_test test = {
37 .setup = setup,
38 .test_all = run,
39 .needs_root = 1,
40 .mount_device = 1,
41 .mntpoint = MNT_POINT,
42 .all_filesystems = 1
43 };
44