• 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 #ifdef HAVE_LINUX_FS_H
10 # include <linux/fs.h>
11 #endif
12 
13 #include <sys/user.h>
14 #include <limits.h>
15 #include "lapi/abisize.h"
16 
17 #ifndef LAPI_FS_H
18 #define LAPI_FS_H
19 
20 #ifndef FS_IOC_GETFLAGS
21 #define	FS_IOC_GETFLAGS	_IOR('f', 1, long)
22 #endif
23 
24 #ifndef FS_IOC_SETFLAGS
25 #define	FS_IOC_SETFLAGS	_IOW('f', 2, long)
26 #endif
27 
28 #ifndef FS_COMPR_FL
29 #define	FS_COMPR_FL        0x00000004 /* Compress file */
30 #endif
31 
32 #ifndef FS_IMMUTABLE_FL
33 #define FS_IMMUTABLE_FL	   0x00000010 /* Immutable file */
34 #endif
35 
36 #ifndef FS_APPEND_FL
37 #define FS_APPEND_FL	   0x00000020 /* writes to file may only append */
38 #endif
39 
40 #ifndef FS_NODUMP_FL
41 #define FS_NODUMP_FL	   0x00000040 /* do not dump file */
42 #endif
43 
44 /*
45  * Helper function to get MAX_LFS_FILESIZE.
46  * Missing PAGE_SHIFT on some libc prevents defining MAX_LFS_FILESIZE.
47  *
48  * 64 bit: macro taken from kernel from include/linux/fs.h
49  * 32 bit: own implementation
50  */
tst_max_lfs_filesize(void)51 static inline loff_t tst_max_lfs_filesize(void)
52 {
53 #ifdef TST_ABI64
54 	return (loff_t)LLONG_MAX;
55 #else
56         long page_size = getpagesize();
57         loff_t ret = ULONG_MAX;
58 
59         while (page_size >>= 1)
60                 ret <<= 1;
61 
62         return ret;
63 #endif
64 }
65 
66 #endif
67