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