Whamcloud - gitweb
e2fsck: rbtree bitmap for dir
[tools/e2fsprogs.git] / lib / support / print_fs_flags.c
1 /*
2  * print_flags.c        - Print ext2_filsys flags
3  *
4  * Copyright (C) 1993, 1994  Remy Card <card@masi.ibp.fr>
5  *                           Laboratoire MASI, Institut Blaise Pascal
6  *                           Universite Pierre et Marie Curie (Paris VI)
7  *
8  * %Begin-Header%
9  * This file may be redistributed under the terms of the GNU Library
10  * General Public License, version 2.
11  * %End-Header%
12  */
13
14 #include "config.h"
15 #include <stdio.h>
16
17 #include "ext2fs/ext2fs.h"
18
19 struct flags_name {
20         unsigned long   flag;
21         const char      *name;
22 };
23
24 static const struct flags_name flags_array[] = {
25         { EXT2_FLAG_RW, "EXT2_FLAG_RW" },
26         { EXT2_FLAG_CHANGED, "EXT2_FLAG_CHANGED" },
27         { EXT2_FLAG_DIRTY, "EXT2_FLAG_DIRTY" },
28         { EXT2_FLAG_VALID, "EXT2_FLAG_VALID" },
29         { EXT2_FLAG_IB_DIRTY, "EXT2_FLAG_IB_DIRTY" },
30         { EXT2_FLAG_BB_DIRTY, "EXT2_FLAG_BB_DIRTY" },
31         { EXT2_FLAG_SWAP_BYTES, "EXT2_FLAG_SWAP_BYTES" },
32         { EXT2_FLAG_SWAP_BYTES_READ, "EXT2_FLAG_SWAP_BYTES_READ" },
33         { EXT2_FLAG_SWAP_BYTES_WRITE, "EXT2_FLAG_SWAP_BYTES_WRITE" },
34         { EXT2_FLAG_MASTER_SB_ONLY, "EXT2_FLAG_MASTER_SB_ONLY" },
35         { EXT2_FLAG_FORCE, "EXT2_FLAG_FORCE" },
36         { EXT2_FLAG_SUPER_ONLY, "EXT2_FLAG_SUPER_ONLY" },
37         { EXT2_FLAG_JOURNAL_DEV_OK, "EXT2_FLAG_JOURNAL_DEV_OK" },
38         { EXT2_FLAG_IMAGE_FILE, "EXT2_FLAG_IMAGE_FILE" },
39         { EXT2_FLAG_EXCLUSIVE, "EXT2_FLAG_EXCLUSIVE" },
40         { EXT2_FLAG_SOFTSUPP_FEATURES, "EXT2_FLAG_SOFTSUPP_FEATURES" },
41         { EXT2_FLAG_NOFREE_ON_ERROR, "EXT2_FLAG_NOFREE_ON_ERROR" },
42         { EXT2_FLAG_64BITS, "EXT2_FLAG_64BITS" },
43         { EXT2_FLAG_PRINT_PROGRESS, "EXT2_FLAG_PRINT_PROGRESS" },
44         { EXT2_FLAG_DIRECT_IO, "EXT2_FLAG_DIRECT_IO" },
45         { EXT2_FLAG_SKIP_MMP, "EXT2_FLAG_SKIP_MMP" },
46         { EXT2_FLAG_IGNORE_CSUM_ERRORS, "EXT2_FLAG_IGNORE_CSUM_ERRORS" },
47         { EXT2_FLAG_SHARE_DUP, "EXT2_FLAG_SHARE_DUP" },
48         { EXT2_FLAG_IGNORE_SB_ERRORS, "EXT2_FLAG_IGNORE_SB_ERRORS" },
49         { EXT2_FLAG_BBITMAP_TAIL_PROBLEM, "EXT2_FLAG_BBITMAP_TAIL_PROBLEM" },
50         { EXT2_FLAG_IBITMAP_TAIL_PROBLEM, "EXT2_FLAG_IBITMAP_TAIL_PROBLEM" },
51         { EXT2_FLAG_THREADS, "EXT2_FLAG_THREADS" },
52         { 0, NULL },
53 };
54
55 void print_fs_flags(FILE * f, unsigned long flags)
56 {
57         const struct flags_name *fp;
58         int     first = 1, pos = 16;
59
60         for (fp = flags_array; fp->flag != 0; fp++) {
61                 if ((flags & fp->flag) == 0)
62                         continue;
63                 pos += strlen(fp->name) + 1;
64                 if (pos > 72) {
65                         fputs("\n\t", f);
66                         pos = 9 + strlen(fp->name);
67                 }
68                 if (first)
69                         first = 0;
70                 else
71                         fputc(' ', f);
72                 fputs(fp->name, f);
73         }
74         fputc('\n', f);
75 }