xref: /aosp_15_r20/external/ltp/testcases/lib/tst_fsfreeze.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2010 Hajime Taira <[email protected]>
4  *                    Masatake Yamato <[email protected]>
5  * Copyright (c) 2023 Petr Vorel <[email protected]>
6  *
7  * Based on fsfreeze from util-linux.
8  */
9 
10 #include <linux/fs.h>
11 #include <stdio.h>
12 
13 #define TST_NO_DEFAULT_MAIN
14 #include "tst_test.h"
15 #include "tst_safe_macros.h"
16 
help(void)17 static void help(void)
18 {
19 	printf("Freeze and unfreeze the device.\n");
20 	printf("Usage: tst_fsfreeze device\n");
21 }
22 
main(int argc,char * argv[])23 int main(int argc, char *argv[])
24 {
25 	int fd;
26 
27 	if (argc < 2) {
28 		help();
29 		return 1;
30 	}
31 
32 	fd = SAFE_OPEN(argv[1], O_RDONLY);
33 	SAFE_IOCTL(fd, FIFREEZE, 0);
34 	SAFE_IOCTL(fd, FITHAW, 0);
35 	SAFE_CLOSE(fd);
36 
37 	return 0;
38 }
39