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