• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <avinesh.kumar@suse.com>
6  */
7 
8 /*\
9  * [Description]
10  *
11  * Verify that rename(2) fails with ENAMETOOLONG, when
12  * oldpath or newpath is too long.
13  */
14 
15 #include <stdio.h>
16 #include "tst_test.h"
17 
18 #define MNT_POINT "mntpoint"
19 #define TEMP_FILE "tmpfile"
20 
21 static char long_path[NAME_MAX + 1] = {[0 ... NAME_MAX] = 'a'};
22 
setup(void)23 static void setup(void)
24 {
25 	SAFE_CHDIR(MNT_POINT);
26 	SAFE_TOUCH(TEMP_FILE, 0700, NULL);
27 }
28 
run(void)29 static void run(void)
30 {
31 	TST_EXP_FAIL(rename(TEMP_FILE, long_path),
32 				ENAMETOOLONG);
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