70a88ca8b4
IMPROVED: * Removed *BROKEN* dep. lrn2fixurshitk
127 lines
5.2 KiB
Go
127 lines
5.2 KiB
Go
//go:build linux
|
|
|
|
package fsutils
|
|
|
|
// https://github.com/torvalds/linux/blob/master/include/uapi/linux/fs.h "Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)"
|
|
const (
|
|
SecureDelete fsAttr = 1 << iota // Secure deletion
|
|
UnDelete // Undelete
|
|
CompressFile // Compress file
|
|
SyncUpdate // Synchronous updates
|
|
Immutable // Immutable file
|
|
AppendOnly // Writes to file may only append
|
|
NoDumpFile // Do not dump file
|
|
NoUpdateAtime // Do not update atime
|
|
IsDirty // Nobody knows what this does, lol.
|
|
CompressedClusters // One or more compressed clusters
|
|
NoCompress // Don't compress
|
|
EncFile // Encrypted file
|
|
BtreeFmt // Btree format dir
|
|
AfsDir // AFS directory
|
|
ReservedExt3 // Reserved for ext3
|
|
NoMergeTail // File tail should not be merged
|
|
DirSync // dirsync behaviour (directories only)
|
|
DirTop // Top of directory hierarchies
|
|
ReservedExt4a // Reserved for ext4
|
|
Extents // Extents
|
|
VerityProtected // Verity-protected inode
|
|
LargeEaInode // Inode used for large EA
|
|
ReservedExt4b // Reserved for ext4
|
|
NoCOWFile // Do not cow file
|
|
_ // (Unused)
|
|
DAX // Inode is DAX
|
|
_ // (Unused)
|
|
_ // (Unused)
|
|
ReservedExt4c // Reserved for ext4
|
|
UseParentProjId // Create with parents projid
|
|
CaseInsensitive // Folder is case-insensitive
|
|
ReservedExt2 // Reserved for ext2 lib
|
|
)
|
|
|
|
// These are the same value. For some reason.
|
|
const (
|
|
HashIdxDir fsAttr = BtreeFmt // Hash-indexed directory
|
|
)
|
|
|
|
var (
|
|
// AttrNameValueMap contains a mapping of attribute names (as designated by this package) to their flag values.
|
|
AttrNameValueMap map[string]fsAttr = map[string]fsAttr{
|
|
"SecureDelete": SecureDelete,
|
|
"UnDelete": UnDelete,
|
|
"CompressFile": CompressFile,
|
|
"SyncUpdate": SyncUpdate,
|
|
"Immutable": Immutable,
|
|
"AppendOnly": AppendOnly,
|
|
"NoDumpFile": NoDumpFile,
|
|
"NoUpdateAtime": NoUpdateAtime,
|
|
"IsDirty": IsDirty,
|
|
"CompressedClusters": CompressedClusters,
|
|
"NoCompress": NoCompress,
|
|
"EncFile": EncFile,
|
|
"BtreeFmt": BtreeFmt,
|
|
"HashIdxDir": HashIdxDir,
|
|
"AfsDir": AfsDir,
|
|
"ReservedExt3": ReservedExt3,
|
|
"NoMergeTail": NoMergeTail,
|
|
"DirSync": DirSync,
|
|
"DirTop": DirTop,
|
|
"ReservedExt4a": ReservedExt4a,
|
|
"Extents": Extents,
|
|
"VerityProtected": VerityProtected,
|
|
"LargeEaInode": LargeEaInode,
|
|
"ReservedExt4b": ReservedExt4b,
|
|
"NoCOWFile": NoCOWFile,
|
|
"DAX": DAX,
|
|
"ReservedExt4c": ReservedExt4c,
|
|
"UseParentProjId": UseParentProjId,
|
|
"CaseInsensitive": CaseInsensitive,
|
|
"ReservedExt2": ReservedExt2,
|
|
}
|
|
|
|
/*
|
|
AttrValueNameMap contains a mapping of attribute flags to their names (as designated by this package).
|
|
Note the oddball here, BtreeFmt and HashIdxDir are actually the same value, so their string value is unpredictable.
|
|
*/
|
|
AttrValueNameMap map[fsAttr]string = invertMap(AttrNameValueMap)
|
|
|
|
// KernelNameValueMap allows lookups using the symbol name as used in the Linux kernel source.
|
|
KernelNameValueMap map[string]fsAttr = map[string]fsAttr{
|
|
"FS_SECRM_FL": SecureDelete,
|
|
"FS_UNRM_FL": UnDelete,
|
|
"FS_COMPR_FL": CompressFile,
|
|
"FS_SYNC_FL": SyncUpdate,
|
|
"FS_IMMUTABLE_FL": Immutable,
|
|
"FS_APPEND_FL": AppendOnly,
|
|
"FS_NODUMP_FL": NoDumpFile,
|
|
"FS_NOATIME_FL": NoUpdateAtime,
|
|
"FS_DIRTY_FL": IsDirty,
|
|
"FS_COMPRBLK_FL": CompressedClusters,
|
|
"FS_NOCOMP_FL": NoCompress,
|
|
"FS_ENCRYPT_FL": EncFile,
|
|
"FS_BTREE_FL": BtreeFmt,
|
|
"FS_INDEX_FL": HashIdxDir,
|
|
"FS_IMAGIC_FL": AfsDir,
|
|
"FS_JOURNAL_DATA_FL": ReservedExt3,
|
|
"FS_NOTAIL_FL": NoMergeTail,
|
|
"FS_DIRSYNC_FL": DirSync,
|
|
"FS_TOPDIR_FL": DirTop,
|
|
"FS_HUGE_FILE_FL": ReservedExt4a,
|
|
"FS_EXTENT_FL": Extents,
|
|
"FS_VERITY_FL": VerityProtected,
|
|
"FS_EA_INODE_FL": LargeEaInode,
|
|
"FS_EOFBLOCKS_FL": ReservedExt4b,
|
|
"FS_NOCOW_FL": NoCOWFile,
|
|
"FS_DAX_FL": DAX,
|
|
"FS_INLINE_DATA_FL": ReservedExt4c,
|
|
"FS_PROJINHERIT_FL": UseParentProjId,
|
|
"FS_CASEFOLD_FL": CaseInsensitive,
|
|
"FS_RESERVED_FL": ReservedExt2,
|
|
}
|
|
|
|
/*
|
|
KernelValueNameMap contains a mapping of attribute flags to their kernel source symbol name.
|
|
Note the oddball here, BtreeFmt and HashIdxDir are actually the same value, so their string value is unpredictable.
|
|
*/
|
|
KernelValueNameMap map[fsAttr]string = invertMap(KernelNameValueMap)
|
|
)
|