blob: 8ef00b8255aceb6d09f74db2951fd14f70cf4481 [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +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>
Theodore Ts'o3839e651997-04-26 13:21:57 +000018
19#include "e2p.h"
20
Theodore Ts'of3db3561997-04-26 13:34:30 +000021static const unsigned long flags_array[] = {
22 EXT2_SECRM_FL,
23 EXT2_UNRM_FL,
24 EXT2_COMPR_FL,
25 EXT2_SYNC_FL,
26#ifdef EXT2_IMMUTABLE_FL
27 EXT2_IMMUTABLE_FL,
28#endif
29#ifdef EXT2_APPEND_FL
30 EXT2_APPEND_FL,
31#endif
32#ifdef EXT2_NODUMP_FL
33 EXT2_NODUMP_FL,
34#endif
Theodore Ts'o5c576471997-04-29 15:29:49 +000035#ifdef EXT2_NOATIME_FL
36 EXT2_NOATIME_FL,
37#endif
Theodore Ts'of3db3561997-04-26 13:34:30 +000038 0};
39
40static const char * short_flags[] = {
41 "s",
42 "u",
43 "c",
44 "S",
45#ifdef EXT2_IMMUTABLE_FL
46 "i",
47#endif
48#ifdef EXT2_APPEND_FL
49 "a",
50#endif
51#ifdef EXT2_NODUMP_FL
52 "d",
53#endif
Theodore Ts'o5c576471997-04-29 15:29:49 +000054#ifdef EXT2_NOATIME_FL
55 "A",
56#endif
Theodore Ts'of3db3561997-04-26 13:34:30 +000057 NULL};
58
59static const char * long_flags[] = {
60 "Secure_Deletion, ",
61 "Undelete, ",
62 "Compressed_File, ",
63 "Synchronous_Updates, ",
64#ifdef EXT2_IMMUTABLE_FL
65 "Immutable, ",
66#endif
67#ifdef EXT2_NODUMP_FL
68 "Append_Only, ",
69#endif
70#ifdef EXT2_NODUMP_FL
71 "No_Dump, ",
72#endif
Theodore Ts'o5c576471997-04-29 15:29:49 +000073#ifdef EXT2_NOATIME_FL
74 "No_Atime, ",
75#endif
Theodore Ts'of3db3561997-04-26 13:34:30 +000076 NULL};
77
78void print_flags (FILE * f, unsigned long flags, int long_format)
Theodore Ts'o3839e651997-04-26 13:21:57 +000079{
Theodore Ts'of3db3561997-04-26 13:34:30 +000080 int i;
81 const char ** flags_names;
82
83 if (long_format)
84 flags_names = long_flags;
Theodore Ts'o3839e651997-04-26 13:21:57 +000085 else
Theodore Ts'of3db3561997-04-26 13:34:30 +000086 flags_names = short_flags;
87
88 for (i = 0; flags_array[i] != 0; i++)
89 {
90 if (flags & flags_array[i])
91 fprintf (f, flags_names[i]);
92 else
93 fprintf (f, "-");
94 }
Theodore Ts'o3839e651997-04-26 13:21:57 +000095}