blob: 2194ac6bf679b123eebed169cca81d0c0765415c [file] [log] [blame]
Mike Frysingerd89e6292005-04-24 05:07:59 +00001/*
2 * pf.c - Print file attributes on an ext2 file system
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 * This file can be redistributed under the terms of the GNU Library General
9 * Public License
10 */
11
12/*
13 * History:
14 * 93/10/30 - Creation
15 */
16
17#include <stdio.h>
18
19#include "e2p.h"
20
21struct flags_name {
22 unsigned long flag;
23 const char *short_name;
24 const char *long_name;
25};
26
"Vladimir N. Oleynik"1f0262b2005-10-20 11:17:48 +000027static const struct flags_name flags_array[] = {
Mike Frysingerd89e6292005-04-24 05:07:59 +000028 { EXT2_SECRM_FL, "s", "Secure_Deletion" },
29 { EXT2_UNRM_FL, "u" , "Undelete" },
30 { EXT2_SYNC_FL, "S", "Synchronous_Updates" },
31 { EXT2_DIRSYNC_FL, "D", "Synchronous_Directory_Updates" },
32 { EXT2_IMMUTABLE_FL, "i", "Immutable" },
33 { EXT2_APPEND_FL, "a", "Append_Only" },
34 { EXT2_NODUMP_FL, "d", "No_Dump" },
35 { EXT2_NOATIME_FL, "A", "No_Atime" },
36 { EXT2_COMPR_FL, "c", "Compression_Requested" },
37#ifdef ENABLE_COMPRESSION
38 { EXT2_COMPRBLK_FL, "B", "Compressed_File" },
39 { EXT2_DIRTY_FL, "Z", "Compressed_Dirty_File" },
40 { EXT2_NOCOMPR_FL, "X", "Compression_Raw_Access" },
41 { EXT2_ECOMPR_FL, "E", "Compression_Error" },
42#endif
43 { EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" },
44 { EXT2_INDEX_FL, "I", "Indexed_direcctory" },
45 { EXT2_NOTAIL_FL, "t", "No_Tailmerging" },
46 { EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" },
47 { 0, NULL, NULL }
48};
49
50void print_flags (FILE * f, unsigned long flags, unsigned options)
51{
52 int long_opt = (options & PFOPT_LONG);
"Vladimir N. Oleynik"1f0262b2005-10-20 11:17:48 +000053 const struct flags_name *fp;
Mike Frysingerd89e6292005-04-24 05:07:59 +000054 int first = 1;
55
56 for (fp = flags_array; fp->flag != 0; fp++) {
57 if (flags & fp->flag) {
58 if (long_opt) {
59 if (first)
60 first = 0;
61 else
62 fputs(", ", f);
63 fputs(fp->long_name, f);
64 } else
65 fputs(fp->short_name, f);
66 } else {
67 if (!long_opt)
68 fputs("-", f);
69 }
70 }
71 if (long_opt && first)
72 fputs("---", f);
73}