3
0

e2fs_lib.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * See README for additional information
  4. *
  5. * Licensed under GPLv2, see file LICENSE in this source tree.
  6. */
  7. #include "libbb.h"
  8. #include "e2fs_lib.h"
  9. /* Print file attributes on an ext2 file system */
  10. const uint32_t e2attr_flags_value[] ALIGN4 = {
  11. #ifdef ENABLE_COMPRESSION
  12. EXT2_COMPRBLK_FL,
  13. EXT2_DIRTY_FL,
  14. EXT2_NOCOMPR_FL,
  15. #endif
  16. EXT2_SECRM_FL,
  17. EXT2_UNRM_FL,
  18. EXT2_SYNC_FL,
  19. EXT2_DIRSYNC_FL,
  20. EXT2_IMMUTABLE_FL,
  21. EXT2_APPEND_FL,
  22. EXT2_NODUMP_FL,
  23. EXT2_NOATIME_FL,
  24. EXT2_COMPR_FL,
  25. EXT2_ECOMPR_FL,
  26. EXT3_JOURNAL_DATA_FL,
  27. EXT2_INDEX_FL,
  28. EXT2_NOTAIL_FL,
  29. EXT2_TOPDIR_FL,
  30. EXT2_EXTENT_FL,
  31. EXT2_NOCOW_FL,
  32. EXT2_CASEFOLD_FL,
  33. EXT2_INLINE_DATA_FL,
  34. EXT2_PROJINHERIT_FL,
  35. EXT2_VERITY_FL,
  36. };
  37. const char e2attr_flags_sname[] ALIGN1 =
  38. #ifdef ENABLE_COMPRESSION
  39. "BZX"
  40. #endif
  41. "suSDiadAcEjItTeCFNPV";
  42. static const char e2attr_flags_lname[] ALIGN1 =
  43. #ifdef ENABLE_COMPRESSION
  44. "Compressed_File" "\0"
  45. "Compressed_Dirty_File" "\0"
  46. "Compression_Raw_Access" "\0"
  47. #endif
  48. "Secure_Deletion" "\0"
  49. "Undelete" "\0"
  50. "Synchronous_Updates" "\0"
  51. "Synchronous_Directory_Updates" "\0"
  52. "Immutable" "\0"
  53. "Append_Only" "\0"
  54. "No_Dump" "\0"
  55. "No_Atime" "\0"
  56. "Compression_Requested" "\0"
  57. "Encrypted" "\0"
  58. "Journaled_Data" "\0"
  59. "Indexed_directory" "\0"
  60. "No_Tailmerging" "\0"
  61. "Top_of_Directory_Hierarchies" "\0"
  62. "Extents" "\0"
  63. "No_COW" "\0"
  64. "Casefold" "\0"
  65. "Inline_Data" "\0"
  66. "Project_Hierarchy" "\0"
  67. "Verity" "\0"
  68. /* Another trailing NUL is added by compiler */;
  69. void print_e2flags_long(unsigned flags)
  70. {
  71. const uint32_t *fv;
  72. const char *fn;
  73. int first = 1;
  74. fv = e2attr_flags_value;
  75. fn = e2attr_flags_lname;
  76. do {
  77. if (flags & *fv) {
  78. if (!first)
  79. fputs(", ", stdout);
  80. fputs(fn, stdout);
  81. first = 0;
  82. }
  83. fv++;
  84. fn += strlen(fn) + 1;
  85. } while (*fn);
  86. if (first)
  87. fputs("---", stdout);
  88. }
  89. void print_e2flags(unsigned flags)
  90. {
  91. const uint32_t *fv;
  92. const char *fn;
  93. fv = e2attr_flags_value;
  94. fn = e2attr_flags_sname;
  95. do {
  96. char c = '-';
  97. if (flags & *fv)
  98. c = *fn;
  99. putchar(c);
  100. fv++;
  101. fn++;
  102. } while (*fn);
  103. }