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