blob: 9b68d8901b9121900a100f60b9bee5df148dec9b [file] [log] [blame]
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +00001/* vi: set sw=4 ts=4: */
2/*
3 * See README for additional information
4 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02005 * Licensed under GPLv2, see file LICENSE in this source tree.
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +00006 */
7
8#include "libbb.h"
9#include "e2fs_lib.h"
10
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +000011/* Print file attributes on an ext2 file system */
Denys Vlasenko965b7952020-11-30 13:03:03 +010012const uint32_t e2attr_flags_value[] ALIGN4 = {
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000013#ifdef ENABLE_COMPRESSION
14 EXT2_COMPRBLK_FL,
15 EXT2_DIRTY_FL,
16 EXT2_NOCOMPR_FL,
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000017#endif
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000018 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 Vlasenko83dff7f2021-06-20 12:34:05 +020027 EXT2_ECOMPR_FL,
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000028 EXT3_JOURNAL_DATA_FL,
Denys Vlasenko83dff7f2021-06-20 12:34:05 +020029 EXT2_INDEX_FL,
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000030 EXT2_NOTAIL_FL,
Denys Vlasenko83dff7f2021-06-20 12:34:05 +020031 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 Vlasenkoc4f623e2006-12-26 01:30:59 +000038};
39
Denys Vlasenko3e134eb2016-04-22 18:09:21 +020040const char e2attr_flags_sname[] ALIGN1 =
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +000041#ifdef ENABLE_COMPRESSION
Denys Vlasenko83dff7f2021-06-20 12:34:05 +020042 "BZX"
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +000043#endif
Denys Vlasenko83dff7f2021-06-20 12:34:05 +020044 "suSDiadAcEjItTeCFNPV";
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000045
Denys Vlasenko3e134eb2016-04-22 18:09:21 +020046static const char e2attr_flags_lname[] ALIGN1 =
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000047#ifdef ENABLE_COMPRESSION
48 "Compressed_File" "\0"
49 "Compressed_Dirty_File" "\0"
50 "Compression_Raw_Access" "\0"
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000051#endif
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000052 "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 Vlasenko83dff7f2021-06-20 12:34:05 +020061 "Encrypted" "\0"
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000062 "Journaled_Data" "\0"
Denys Vlasenko83dff7f2021-06-20 12:34:05 +020063 "Indexed_directory" "\0"
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000064 "No_Tailmerging" "\0"
65 "Top_of_Directory_Hierarchies" "\0"
Denys Vlasenko83dff7f2021-06-20 12:34:05 +020066 "Extents" "\0"
67 "No_COW" "\0"
68 "Casefold" "\0"
69 "Inline_Data" "\0"
70 "Project_Hierarchy" "\0"
71 "Verity" "\0"
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000072 /* Another trailing NUL is added by compiler */;
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +000073
Denys Vlasenko87c40cf2021-06-24 09:31:57 +020074void 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
96void print_e2flags(unsigned flags)
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +000097{
Denis Vlasenkod059ddc2007-10-30 19:36:07 +000098 const uint32_t *fv;
99 const char *fn;
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000100
Denis Vlasenkod059ddc2007-10-30 19:36:07 +0000101 fv = e2attr_flags_value;
Denys Vlasenko87c40cf2021-06-24 09:31:57 +0200102 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 Vlasenkoc4f623e2006-12-26 01:30:59 +0000111}