aboutsummaryrefslogtreecommitdiffstats
path: root/lib/e2p/pf.c
blob: ec18dcb83f30238b705c7cfa92b52c584d2b2764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * pf.c			- Print file attributes on an ext2 file system
 *
 * Copyright (C) 1993, 1994  Remy Card <card@masi.ibp.fr>
 *                           Laboratoire MASI, Institut Blaise Pascal
 *                           Universite Pierre et Marie Curie (Paris VI)
 *
 * This file can be redistributed under the terms of the GNU Library General
 * Public License
 */

/*
 * History:
 * 93/10/30	- Creation
 */

#include <stdio.h>

#include "e2p.h"

static const unsigned long flags_array[] = {
	EXT2_SECRM_FL,
	EXT2_UNRM_FL,
	EXT2_COMPR_FL,
	EXT2_SYNC_FL,
#ifdef	EXT2_IMMUTABLE_FL
	EXT2_IMMUTABLE_FL,
#endif
#ifdef	EXT2_APPEND_FL
	EXT2_APPEND_FL,
#endif
#ifdef	EXT2_NODUMP_FL
	EXT2_NODUMP_FL,
#endif
	0};

static const char * short_flags[] = {
	"s",
	"u",
	"c",
	"S",
#ifdef	EXT2_IMMUTABLE_FL
	"i",
#endif
#ifdef	EXT2_APPEND_FL
	"a",
#endif
#ifdef	EXT2_NODUMP_FL
	"d",
#endif
	NULL};

static const char * long_flags[] = {
	"Secure_Deletion, ",
	"Undelete, ",
	"Compressed_File, ",
	"Synchronous_Updates, ",
#ifdef	EXT2_IMMUTABLE_FL
	"Immutable, ",
#endif
#ifdef	EXT2_NODUMP_FL
	"Append_Only, ",
#endif
#ifdef	EXT2_NODUMP_FL
	"No_Dump, ",
#endif
	NULL};

void print_flags (FILE * f, unsigned long flags, int long_format)
{
	int i;
	const char ** flags_names;

	if (long_format)
		flags_names = long_flags;
	else
		flags_names = short_flags;

	for (i = 0; flags_array[i] != 0; i++)
	{
		if (flags & flags_array[i])
			fprintf (f, flags_names[i]);
		else
			fprintf (f, "-");
	}
}