summaryrefslogtreecommitdiff
path: root/e2fsprogs/e2fs_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'e2fsprogs/e2fs_lib.c')
-rw-r--r--e2fsprogs/e2fs_lib.c98
1 files changed, 63 insertions, 35 deletions
diff --git a/e2fsprogs/e2fs_lib.c b/e2fsprogs/e2fs_lib.c
index 890cb30..89e0500 100644
--- a/e2fsprogs/e2fs_lib.c
+++ b/e2fsprogs/e2fs_lib.c
@@ -141,59 +141,87 @@ int fgetsetflags(const char *name, unsigned long *get_flags, unsigned long set_f
/* Print file attributes on an ext2 file system */
-struct flags_name {
- unsigned long flag;
- char short_name;
- const char *long_name;
+const uint32_t e2attr_flags_value[] = {
+#ifdef ENABLE_COMPRESSION
+ EXT2_COMPRBLK_FL,
+ EXT2_DIRTY_FL,
+ EXT2_NOCOMPR_FL,
+ EXT2_ECOMPR_FL,
+#endif
+ EXT2_INDEX_FL,
+ EXT2_SECRM_FL,
+ EXT2_UNRM_FL,
+ EXT2_SYNC_FL,
+ EXT2_DIRSYNC_FL,
+ EXT2_IMMUTABLE_FL,
+ EXT2_APPEND_FL,
+ EXT2_NODUMP_FL,
+ EXT2_NOATIME_FL,
+ EXT2_COMPR_FL,
+ EXT3_JOURNAL_DATA_FL,
+ EXT2_NOTAIL_FL,
+ EXT2_TOPDIR_FL
};
-/* TODO: apart from I and (disabled) COMPRESSION flags, this
- * is a duplicate of a table from chattr. Merge? */
-static const struct flags_name flags_array[] = {
- { EXT2_SECRM_FL, 's', "Secure_Deletion" },
- { EXT2_UNRM_FL, 'u' , "Undelete" },
- { EXT2_SYNC_FL, 'S', "Synchronous_Updates" },
- { EXT2_DIRSYNC_FL, 'D', "Synchronous_Directory_Updates" },
- { EXT2_IMMUTABLE_FL, 'i', "Immutable" },
- { EXT2_APPEND_FL, 'a', "Append_Only" },
- { EXT2_NODUMP_FL, 'd', "No_Dump" },
- { EXT2_NOATIME_FL, 'A', "No_Atime" },
- { EXT2_COMPR_FL, 'c', "Compression_Requested" },
+const char e2attr_flags_sname[] =
#ifdef ENABLE_COMPRESSION
- { EXT2_COMPRBLK_FL, 'B', "Compressed_File" },
- { EXT2_DIRTY_FL, 'Z', "Compressed_Dirty_File" },
- { EXT2_NOCOMPR_FL, 'X', "Compression_Raw_Access" },
- { EXT2_ECOMPR_FL, 'E', "Compression_Error" },
+ "BZXE"
#endif
- { EXT3_JOURNAL_DATA_FL, 'j', "Journaled_Data" },
- { EXT2_INDEX_FL, 'I', "Indexed_directory" },
- { EXT2_NOTAIL_FL, 't', "No_Tailmerging" },
- { EXT2_TOPDIR_FL, 'T', "Top_of_Directory_Hierarchies" },
- { 0, '\0', NULL }
-};
+ "I"
+ "suSDiadAcjtT";
+
+static const char e2attr_flags_lname[] =
+#ifdef ENABLE_COMPRESSION
+ "Compressed_File" "\0"
+ "Compressed_Dirty_File" "\0"
+ "Compression_Raw_Access" "\0"
+ "Compression_Error" "\0"
+#endif
+ "Indexed_directory" "\0"
+ "Secure_Deletion" "\0"
+ "Undelete" "\0"
+ "Synchronous_Updates" "\0"
+ "Synchronous_Directory_Updates" "\0"
+ "Immutable" "\0"
+ "Append_Only" "\0"
+ "No_Dump" "\0"
+ "No_Atime" "\0"
+ "Compression_Requested" "\0"
+ "Journaled_Data" "\0"
+ "No_Tailmerging" "\0"
+ "Top_of_Directory_Hierarchies" "\0"
+ /* Another trailing NUL is added by compiler */;
void print_flags(FILE *f, unsigned long flags, unsigned options)
{
- const struct flags_name *fp;
+ const uint32_t *fv;
+ const char *fn;
+ fv = e2attr_flags_value;
if (options & PFOPT_LONG) {
int first = 1;
- for (fp = flags_array; fp->short_name; fp++) {
- if (flags & fp->flag) {
+ fn = e2attr_flags_lname;
+ do {
+ if (flags & *fv) {
if (!first)
fputs(", ", f);
- fputs(fp->long_name, f);
+ fputs(fn, f);
first = 0;
}
- }
+ fv++;
+ fn += strlen(fn) + 1;
+ } while (*fn);
if (first)
fputs("---", f);
} else {
- for (fp = flags_array; fp->short_name; fp++) {
+ fn = e2attr_flags_sname;
+ do {
char c = '-';
- if (flags & fp->flag)
- c = fp->short_name;
+ if (flags & *fv)
+ c = *fn;
fputc(c, f);
- }
+ fv++;
+ fn++;
+ } while (*fn);
}
}