ChangeLog, Makefile.in, e2p.h, pf.c:
Makefile.in: Install the e2p.h header.
e2p.h, pf.c (print_flags): Change the third parameter of print_flags()
to be an option parameter, although we only support one option at this
point.
pf.c (print_flags): Updated to use a more generic structure for
storing the ext2 inode flags. Add support for the (current) set of
compression flags.
diff --git a/lib/e2p/ChangeLog b/lib/e2p/ChangeLog
index afdcfa6..ac3c6a4 100644
--- a/lib/e2p/ChangeLog
+++ b/lib/e2p/ChangeLog
@@ -1,3 +1,15 @@
+2000-02-10 Theodore Ts'o <tytso@valinux.com>
+
+ * Makefile.in: Install the e2p.h header.
+
+ * e2p.h, pf.c (print_flags): Change the third parameter of
+ print_flags() to be an option parameter, although we only
+ support one option at this point.
+
+ * pf.c (print_flags): Updated to use a more generic structure for
+ storing the ext2 inode flags. Add support for the
+ (current) set of compression flags.
+
1999-11-19 <tytso@valinux.com>
* Makefile.in (distclean): Remove TAGS and Makefile.in.old from
diff --git a/lib/e2p/Makefile.in b/lib/e2p/Makefile.in
index 5ee673b..c33b1ba 100644
--- a/lib/e2p/Makefile.in
+++ b/lib/e2p/Makefile.in
@@ -28,6 +28,8 @@
$(srcdir)/setflags.c $(srcdir)/setversion.c \
$(srcdir)/uuid.c
+HFILES= e2p.h
+
LIBRARY= libe2p
LIBDIR= e2p
@@ -69,16 +71,21 @@
@BSDLIB_CMT@ $(CC) $(ALL_CFLAGS) -fpic -o pic/$*.o -c $<
installdirs::
- $(top_srcdir)/mkinstalldirs $(DESTDIR)$(libdir)
+ $(top_srcdir)/mkinstalldirs $(DESTDIR)$(libdir) \
+ $(DESTDIR)$(includedir)/e2p
install:: all installdirs
$(INSTALL_DATA) libe2p.a $(DESTDIR)$(libdir)/libe2p.a
$(CHMOD) 644 $(DESTDIR)$(libdir)/libe2p.a
-$(RANLIB) $(DESTDIR)$(libdir)/libe2p.a
$(CHMOD) $(LIBMODE) $(DESTDIR)$(libdir)/libe2p.a
+ for i in $(HFILES); do \
+ $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/e2p/$$i; \
+ done
uninstall::
$(RM) -f $(DESTDIR)$(libdir)/libe2p.a
+ $(RM) -rf $(DESTDIR)$(includedir)/e2p
clean::
$(RM) -f \#* *.s *.o *.a *~ *.bak core profiled/* checker/*
diff --git a/lib/e2p/e2p.h b/lib/e2p/e2p.h
index 9f5636c..07af08b 100644
--- a/lib/e2p/e2p.h
+++ b/lib/e2p/e2p.h
@@ -8,6 +8,12 @@
#define E2P_FEATURE_INCOMPAT 1
#define E2P_FEATURE_RO_INCOMPAT 2
+
+/* `options' for print_flags() */
+
+#define PFOPT_LONG 1 /* Must be 1 for compatibility with `int long_format'. */
+
+
int fgetflags (const char * name, unsigned long * flags);
int fgetversion (const char * name, unsigned long * version);
int fsetflags (const char * name, unsigned long flags);
@@ -19,7 +25,7 @@
void * private);
void list_super (struct ext2_super_block * s);
void print_fs_errors (FILE * f, unsigned short errors);
-void print_flags (FILE * f, unsigned long flags, int long_format);
+void print_flags (FILE * f, unsigned long flags, unsigned options);
void print_fs_state (FILE * f, unsigned short state);
int setflags (int fd, unsigned long flags);
int setversion (int fd, unsigned long version);
diff --git a/lib/e2p/pf.c b/lib/e2p/pf.c
index 8ef00b8..91bd59e 100644
--- a/lib/e2p/pf.c
+++ b/lib/e2p/pf.c
@@ -18,78 +18,50 @@
#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
-#ifdef EXT2_NOATIME_FL
- EXT2_NOATIME_FL,
-#endif
- 0};
+struct flags_name {
+ unsigned long flag;
+ char *short_name;
+ char *long_name;
+};
-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
-#ifdef EXT2_NOATIME_FL
- "A",
-#endif
- NULL};
+static struct flags_name flags_array[] = {
+ { EXT2_SECRM_FL, "s", "Secure_Deletion" },
+ { EXT2_UNRM_FL, "u" , "Undelete" },
+ { EXT2_SYNC_FL, "S", "Synchronous_Updates" },
+ { EXT2_IMMUTABLE_FL, "i", "Immutable" },
+ { EXT2_APPEND_FL, "a", "Append_Only" },
+ { EXT2_NODUMP_FL, "d", "No_Dump" },
+ { EXT2_NOATIME_FL, "A", "No_Atime" },
+ { EXT2_COMPR_FL, "c", "Compression_requested" },
+ { EXT2_COMPRBLK_FL, "B", "Compressed_file" },
+ { EXT2_DIRTY_FL, "D", "Compressed dirty file" },
+ { EXT2_NOCOMP_FL, "X", "Raw_access" },
+ { EXT2_ECOMPR_FL, "E", "Compression_Error" },
+ { 0, NULL, 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
-#ifdef EXT2_NOATIME_FL
- "No_Atime, ",
-#endif
- NULL};
-
-void print_flags (FILE * f, unsigned long flags, int long_format)
+void print_flags (FILE * f, unsigned long flags, unsigned options)
{
- int i;
- const char ** flags_names;
+ int long_opt = (options & PFOPT_LONG);
+ struct flags_name *fp;
+ int first = 1;
- 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, "-");
+ for (fp = flags_array; fp->flag != 0; fp++) {
+ if (flags & fp->flag) {
+ if (long_opt) {
+ if (first)
+ first = 0;
+ else
+ fputs(", ", f);
+ fputs(fp->long_name, f);
+ } else
+ fputs(fp->short_name, f);
+ } else {
+ if (!long_opt)
+ fputs("-", f);
+ }
}
+ if (long_opt && first)
+ fputs("---", f);
}
+