Changes for kernel and Busybox
[tomato.git] / release / src / router / busybox / e2fsprogs / old_e2fsprogs / e2p / pf.c
blob02cbec7e0fef0167122f4ec6f5f4ccf160cdae48
1 /* vi: set sw=4 ts=4: */
2 /*
3 * pf.c - Print file attributes on an ext2 file system
5 * Copyright (C) 1993, 1994 Remy Card <card@masi.ibp.fr>
6 * Laboratoire MASI, Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
9 * This file can be redistributed under the terms of the GNU Library General
10 * Public License
14 * History:
15 * 93/10/30 - Creation
18 #include <stdio.h>
20 #include "e2p.h"
22 struct flags_name {
23 unsigned long flag;
24 const char *short_name;
25 const char *long_name;
28 static const struct flags_name flags_array[] = {
29 { EXT2_SECRM_FL, "s", "Secure_Deletion" },
30 { EXT2_UNRM_FL, "u" , "Undelete" },
31 { EXT2_SYNC_FL, "S", "Synchronous_Updates" },
32 { EXT2_DIRSYNC_FL, "D", "Synchronous_Directory_Updates" },
33 { EXT2_IMMUTABLE_FL, "i", "Immutable" },
34 { EXT2_APPEND_FL, "a", "Append_Only" },
35 { EXT2_NODUMP_FL, "d", "No_Dump" },
36 { EXT2_NOATIME_FL, "A", "No_Atime" },
37 { EXT2_COMPR_FL, "c", "Compression_Requested" },
38 #ifdef ENABLE_COMPRESSION
39 { EXT2_COMPRBLK_FL, "B", "Compressed_File" },
40 { EXT2_DIRTY_FL, "Z", "Compressed_Dirty_File" },
41 { EXT2_NOCOMPR_FL, "X", "Compression_Raw_Access" },
42 { EXT2_ECOMPR_FL, "E", "Compression_Error" },
43 #endif
44 { EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" },
45 { EXT2_INDEX_FL, "I", "Indexed_direcctory" },
46 { EXT2_NOTAIL_FL, "t", "No_Tailmerging" },
47 { EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" },
48 { 0, NULL, NULL }
51 void print_flags (FILE *f, unsigned long flags, unsigned options)
53 int long_opt = (options & PFOPT_LONG);
54 const struct flags_name *fp;
55 int first = 1;
57 for (fp = flags_array; fp->flag != 0; fp++) {
58 if (flags & fp->flag) {
59 if (long_opt) {
60 if (first)
61 first = 0;
62 else
63 fputs(", ", f);
64 fputs(fp->long_name, f);
65 } else
66 fputs(fp->short_name, f);
67 } else {
68 if (!long_opt)
69 fputs("-", f);
72 if (long_opt && first)
73 fputs("---", f);