• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Referred from linux kernel include/uapi/linux/fs.h
4  * Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
5  * Copyright (c) Zilogic Systems Pvt. Ltd., 2018
6  * Email: code@zilogic.com
7  */
8 
9 #ifndef LAPI_FS_H__
10 #define LAPI_FS_H__
11 
12 #include "config.h"
13 #ifndef HAVE_MOUNT_SETATTR
14 # include <linux/fs.h>
15 #endif
16 
17 #include <sys/user.h>
18 #include <limits.h>
19 #include "lapi/abisize.h"
20 
21 #ifndef FS_IOC_GETFLAGS
22 # define	FS_IOC_GETFLAGS	_IOR('f', 1, long)
23 #endif
24 
25 #ifndef FS_IOC_SETFLAGS
26 # define	FS_IOC_SETFLAGS	_IOW('f', 2, long)
27 #endif
28 
29 #ifndef FS_COMPR_FL
30 # define	FS_COMPR_FL        0x00000004 /* Compress file */
31 #endif
32 
33 #ifndef FS_IMMUTABLE_FL
34 # define FS_IMMUTABLE_FL	   0x00000010 /* Immutable file */
35 #endif
36 
37 #ifndef FS_APPEND_FL
38 # define FS_APPEND_FL	   0x00000020 /* writes to file may only append */
39 #endif
40 
41 #ifndef FS_NODUMP_FL
42 # define FS_NODUMP_FL	   0x00000040 /* do not dump file */
43 #endif
44 
45 #ifndef FS_VERITY_FL
46 # define FS_VERITY_FL	   0x00100000 /* Verity protected inode */
47 #endif
48 
49 /*
50  * Helper function to get MAX_LFS_FILESIZE.
51  * Missing PAGE_SHIFT on some libc prevents defining MAX_LFS_FILESIZE.
52  *
53  * 64 bit: macro taken from kernel from include/linux/fs.h
54  * 32 bit: own implementation
55  */
tst_max_lfs_filesize(void)56 static inline long long tst_max_lfs_filesize(void)
57 {
58 #ifdef TST_ABI64
59 	return LLONG_MAX;
60 #else
61         long page_size = getpagesize();
62         long long ret = ULONG_MAX;
63 
64         while (page_size >>= 1)
65                 ret <<= 1;
66 
67         return ret;
68 #endif
69 }
70 
71 #endif /* LAPI_FS_H__ */
72