busybox/e2fsprogs/e2fs_lib.c
<<
>>
Prefs
   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
   8#include "libbb.h"
   9#include "e2fs_lib.h"
  10
  11/* Print file attributes on an ext2 file system */
  12const uint32_t e2attr_flags_value[] ALIGN4 = {
  13#ifdef ENABLE_COMPRESSION
  14        EXT2_COMPRBLK_FL,
  15        EXT2_DIRTY_FL,
  16        EXT2_NOCOMPR_FL,
  17#endif
  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,
  27        EXT2_ECOMPR_FL,
  28        EXT3_JOURNAL_DATA_FL,
  29        EXT2_INDEX_FL,
  30        EXT2_NOTAIL_FL,
  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,
  38};
  39
  40const char e2attr_flags_sname[] ALIGN1 =
  41#ifdef ENABLE_COMPRESSION
  42        "BZX"
  43#endif
  44        "suSDiadAcEjItTeCFNPV";
  45
  46static const char e2attr_flags_lname[] ALIGN1 =
  47#ifdef ENABLE_COMPRESSION
  48        "Compressed_File" "\0"
  49        "Compressed_Dirty_File" "\0"
  50        "Compression_Raw_Access" "\0"
  51#endif
  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"
  61        "Encrypted" "\0"
  62        "Journaled_Data" "\0"
  63        "Indexed_directory" "\0"
  64        "No_Tailmerging" "\0"
  65        "Top_of_Directory_Hierarchies" "\0"
  66        "Extents" "\0"
  67        "No_COW" "\0"
  68        "Casefold" "\0"
  69        "Inline_Data" "\0"
  70        "Project_Hierarchy" "\0"
  71        "Verity" "\0"
  72        /* Another trailing NUL is added by compiler */;
  73
  74void 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)
  97{
  98        const uint32_t *fv;
  99        const char *fn;
 100
 101        fv = e2attr_flags_value;
 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);
 111}
 112