• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved.
4  * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
5  * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
6  */
7 
8 /*\
9  * [Description]
10  *
11  * Verify that unlink(2) fails with EROFS when target file is on a read-only
12  * filesystem.
13  */
14 
15 #include <sys/ioctl.h>
16 #include "tst_test.h"
17 #include "lapi/fs.h"
18 
19 #define MNTPOINT "erofs"
20 #define FILENAME MNTPOINT"/file"
21 
run(void)22 static void run(void)
23 {
24 	TST_EXP_FAIL(unlink(FILENAME), EROFS,
25 		"%s", "target file in read-only filesystem");
26 }
27 
28 static struct tst_test test = {
29 	.test_all = run,
30 	.needs_rofs = 1,
31 	.needs_root = 1,
32 	.mntpoint = MNTPOINT,
33 };
34