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 EISDIR when
12 * oldpath is not a directory and newpath is an existing directory.
13 */
14
15 #include <stdio.h>
16 #include "tst_test.h"
17
18 #define MNT_POINT "mntpoint"
19 #define TEMP_FILE "tmpfile"
20 #define TEMP_DIR "tmpdir"
21
setup(void)22 static void setup(void)
23 {
24 SAFE_CHDIR(MNT_POINT);
25 SAFE_TOUCH(TEMP_FILE, 0700, NULL);
26 SAFE_MKDIR(TEMP_DIR, 00770);
27 }
28
run(void)29 static void run(void)
30 {
31 TST_EXP_FAIL(rename(TEMP_FILE, TEMP_DIR),
32 EISDIR);
33 }
34
35 static struct tst_test test = {
36 .setup = setup,
37 .test_all = run,
38 .needs_root = 1,
39 .mount_device = 1,
40 .mntpoint = MNT_POINT,
41 .all_filesystems = 1
42 };
43