• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright (C) 2012 Cyril Hrubis chrubis@suse.cz
3  */
4 
5 #ifndef TST_SAFE_FILE_OPS
6 #define TST_SAFE_FILE_OPS
7 
8 #include "safe_file_ops_fn.h"
9 
10 #define SAFE_FILE_SCANF(path, fmt, ...) \
11 	safe_file_scanf(__FILE__, __LINE__, NULL, \
12 	                (path), (fmt), ## __VA_ARGS__)
13 
14 #define FILE_LINES_SCANF(path, fmt, ...) \
15 	file_lines_scanf(__FILE__, __LINE__, NULL, 0,\
16 			(path), (fmt), ## __VA_ARGS__)
17 
18 #define SAFE_FILE_LINES_SCANF(path, fmt, ...) \
19 	file_lines_scanf(__FILE__, __LINE__, NULL, 1,\
20 			(path), (fmt), ## __VA_ARGS__)
21 
22 #define SAFE_READ_MEMINFO(item) \
23        ({long tst_rval; \
24         SAFE_FILE_LINES_SCANF("/proc/meminfo", item " %ld", \
25                         &tst_rval); \
26         tst_rval;})
27 
28 #define FILE_PRINTF(path, fmt, ...) \
29 	file_printf(__FILE__, __LINE__, \
30 		    (path), (fmt), ## __VA_ARGS__)
31 
32 #define SAFE_FILE_PRINTF(path, fmt, ...) \
33 	safe_file_printf(__FILE__, __LINE__, NULL, \
34 	                 (path), (fmt), ## __VA_ARGS__)
35 
36 #define SAFE_CP(src, dst) \
37 	safe_cp(__FILE__, __LINE__, NULL, (src), (dst))
38 
39 #define SAFE_TOUCH(pathname, mode, times) \
40 	safe_touch(__FILE__, __LINE__, NULL, \
41 			(pathname), (mode), (times))
42 
43 #define SAFE_MOUNT_OVERLAY() \
44 	((void) mount_overlay(__FILE__, __LINE__, 1))
45 
46 #define TST_MOUNT_OVERLAY() \
47 	(mount_overlay(__FILE__, __LINE__, 0) == 0)
48 
49 #endif /* TST_SAFE_FILE_OPS */
50