iflags.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #ifndef _LINUX_IFLAGS_H
  2. #define _LINUX_IFLAGS_H
  3. /*
  4. * A universal set of inode flags.
  5. *
  6. * Originally taken from ext2/3 with additions for other filesystems.
  7. * Filesystems supporting this interface should interoperate with
  8. * the lsattr and chattr command line tools.
  9. *
  10. * This interface is supported in whole or in part by:
  11. * ext2
  12. * ext3
  13. * xfs
  14. * jfs
  15. * gfs2
  16. *
  17. */
  18. #define IFLAGS_GET_IOC _IOR('f', 1, long)
  19. #define IFLAGS_SET_IOC _IOW('f', 2, long)
  20. /*
  21. * These values are provided for use as indices of an array
  22. * for use with the iflags_cvt function below
  23. */
  24. enum {
  25. iflag_SecureRm = 0, /* Secure deletion */
  26. iflag_Unrm = 1, /* Undelete */
  27. iflag_Compress = 2, /* Compress file */
  28. iflag_Sync = 3, /* Synchronous updates */
  29. iflag_Immutable = 4, /* Immutable */
  30. iflag_Append = 5, /* Append */
  31. iflag_NoDump = 6, /* Don't dump file */
  32. iflag_NoAtime = 7, /* No atime updates */
  33. /* Reserved for compression usage */
  34. iflag_Dirty = 8,
  35. iflag_ComprBlk = 9, /* One or more compressed clusters */
  36. iflag_NoComp = 10, /* Don't compress */
  37. iflag_Ecompr = 11, /* Compression error */
  38. /* End of compression flags */
  39. iflag_Btree = 12, /* btree format dir */
  40. iflag_Index = 12, /* hash-indexed directory */
  41. iflag_Imagic = 13, /* AFS directory */
  42. iflag_JournalData = 14, /* file data should be journaled */
  43. iflag_NoTail = 15, /* file tail should not be merged */
  44. iflag_DirSync = 16, /* dirsync behaviour */
  45. iflag_TopDir = 17, /* Top of directory hierarchies */
  46. iflag_Extent = 19, /* Extents */
  47. iflag_DirectIO = 20, /* Always use direct I/O on this file */
  48. iflag_Reserved = 31 /* reserved for ext2/3 lib */
  49. };
  50. #define __IFL(x) (1<<(iflag_##x))
  51. #define IFLAG_SECRM __IFL(SecureRm) /* 0x00000001 */
  52. #define IFLAG_UNRM __IFL(Unrm) /* 0x00000002 */
  53. #define IFLAG_COMPR __IFL(Compr) /* 0x00000004 */
  54. #define IFLAG_SYNC __IFL(Sync) /* 0x00000008 */
  55. #define IFLAG_IMMUTABLE __IFL(Immutable) /* 0x00000010 */
  56. #define IFLAG_APPEND __IFL(Append) /* 0x00000020 */
  57. #define IFLAG_NODUMP __IFL(NoDump) /* 0x00000040 */
  58. #define IFLAG_NOATIME __IFL(NoAtime) /* 0x00000080 */
  59. #define IFLAG_DIRTY __IFL(Dirty) /* 0x00000100 */
  60. #define IFLAG_COMPRBLK __IFL(ComprBlk) /* 0x00000200 */
  61. #define IFLAG_NOCOMP __IFL(NoComp) /* 0x00000400 */
  62. #define IFLAG_ECOMPR __IFL(Ecompr) /* 0x00000800 */
  63. #define IFLAG_BTREE __IFL(Btree) /* 0x00001000 */
  64. #define IFLAG_INDEX __IFL(Index) /* 0x00001000 */
  65. #define IFLAG_IMAGIC __IFL(Imagic) /* 0x00002000 */
  66. #define IFLAG_JOURNAL_DATA __IFL(JournalData) /* 0x00004000 */
  67. #define IFLAG_NOTAIL __IFL(NoTail) /* 0x00008000 */
  68. #define IFLAG_DIRSYNC __IFL(DirSync) /* 0x00010000 */
  69. #define IFLAG_TOPDIR __IFL(TopDir) /* 0x00020000 */
  70. #define IFLAG_EXTENT __IFL(Extent) /* 0x00080000 */
  71. #define IFLAG_DIRECTIO __IFL(DirectIO) /* 0x00100000 */
  72. #define IFLAG_RESERVED __IFL(Reserved) /* 0x80000000 */
  73. #ifdef __KERNEL__
  74. /**
  75. * iflags_cvt
  76. * @table: A table of 32 u32 flags
  77. * @val: a 32 bit value to convert
  78. *
  79. * This function can be used to convert between IFLAGS values and
  80. * the filesystem's own flags values.
  81. *
  82. * Returns: the converted flags
  83. */
  84. static inline u32 iflags_cvt(const u32 *table, u32 val)
  85. {
  86. u32 res = 0;
  87. while(val) {
  88. if (val & 1)
  89. res |= *table;
  90. table++;
  91. val >>= 1;
  92. }
  93. return res;
  94. }
  95. #endif /* __KERNEL__ */
  96. #endif /* _LINUX_IFLAGS_H */