[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] libgfs2: Add some tables of symbolic constant names



>From cebc412778d0963a65b42f3e89dd27bad30ef50f Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <swhiteho redhat com>
Date: Thu, 22 Dec 2011 15:40:59 +0000
Subject: [PATCH] libgfs2: Add some tables of symbolic constant names

This covers metadata types, formats and di_flags. As time goes
on, I expect the number of fields in the lgfs2_symbolic to expand.

Signed-off-by: Steven Whitehouse <swhiteho redhat com>
---
 gfs2/libgfs2/libgfs2.h |   11 ++++++++
 gfs2/libgfs2/meta.c    |   67 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 77 insertions(+), 1 deletions(-)

diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index dedf8b8..c304a0c 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -101,6 +101,11 @@ enum lgfs2_meta_type {
 	LGFS2_MT_NR,
 };
 
+struct lgfs2_symbolic {
+	const uint32_t key;
+	const char *value;
+};
+
 struct lgfs2_metafield {
 	const char *name;
 	const unsigned offset;
@@ -311,6 +316,12 @@ struct metapath {
 /* meta.c */
 extern const struct lgfs2_metadata lgfs2_metadata[];
 extern const unsigned lgfs2_metadata_size;
+extern const struct lgfs2_symbolic lgfs2_metatypes[];
+extern const unsigned lgfs2_metatype_size;
+extern const struct lgfs2_symbolic lgfs2_metaformats[];
+extern const unsigned lgfs2_metaformat_size;
+extern const struct lgfs2_symbolic lgfs2_di_flags[];
+extern const unsigned lgfs2_di_flag_size;
 extern int lgfs2_selfcheck(void);
 
 /* bitmap.c */
diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
index bff8c30..64bdf91 100644
--- a/gfs2/libgfs2/meta.c
+++ b/gfs2/libgfs2/meta.c
@@ -1,6 +1,72 @@
 #include <stdint.h>
 #include "libgfs2.h"
 
+#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+#define SYM(x) { x, #x },
+
+const struct lgfs2_symbolic lgfs2_metatypes[] = {
+SYM(GFS2_METATYPE_NONE)
+SYM(GFS2_METATYPE_SB)
+SYM(GFS2_METATYPE_RG)
+SYM(GFS2_METATYPE_RB)
+SYM(GFS2_METATYPE_DI)
+SYM(GFS2_METATYPE_IN)
+SYM(GFS2_METATYPE_LF)
+SYM(GFS2_METATYPE_JD)
+SYM(GFS2_METATYPE_LH)
+SYM(GFS2_METATYPE_LD)
+SYM(GFS2_METATYPE_LB)
+SYM(GFS2_METATYPE_EA)
+SYM(GFS2_METATYPE_ED)
+SYM(GFS2_METATYPE_QC)
+};
+
+const unsigned lgfs2_metatype_size = ARRAY_SIZE(lgfs2_metatypes);
+
+const struct lgfs2_symbolic lgfs2_metaformats[] = {
+SYM(GFS2_FORMAT_NONE)
+SYM(GFS2_FORMAT_SB)
+SYM(GFS2_FORMAT_RG)
+SYM(GFS2_FORMAT_RB)
+SYM(GFS2_FORMAT_DI)
+SYM(GFS2_FORMAT_IN)
+SYM(GFS2_FORMAT_LF)
+SYM(GFS2_FORMAT_JD)
+SYM(GFS2_FORMAT_LH)
+SYM(GFS2_FORMAT_LD)
+SYM(GFS2_FORMAT_LB)
+SYM(GFS2_FORMAT_EA)
+SYM(GFS2_FORMAT_ED)
+SYM(GFS2_FORMAT_QC)
+SYM(GFS2_FORMAT_RI)
+SYM(GFS2_FORMAT_DE)
+SYM(GFS2_FORMAT_QU)
+};
+
+const unsigned lgfs2_metaformat_size = ARRAY_SIZE(lgfs2_metaformats);
+
+const struct lgfs2_symbolic lgfs2_di_flags[] = {
+SYM(GFS2_DIF_JDATA)
+SYM(GFS2_DIF_EXHASH)
+SYM(GFS2_DIF_UNUSED)
+SYM(GFS2_DIF_EA_INDIRECT)
+SYM(GFS2_DIF_DIRECTIO)
+SYM(GFS2_DIF_IMMUTABLE)
+SYM(GFS2_DIF_APPENDONLY)
+SYM(GFS2_DIF_NOATIME)
+SYM(GFS2_DIF_SYNC)
+SYM(GFS2_DIF_SYSTEM)
+SYM(GFS2_DIF_TRUNC_IN_PROG)
+SYM(GFS2_DIF_INHERIT_DIRECTIO)
+SYM(GFS2_DIF_INHERIT_JDATA)
+};
+
+const unsigned lgfs2_di_flag_size = ARRAY_SIZE(lgfs2_di_flags);
+
+#undef SYM
+
+
+
 
 #define F(f,...)  { .name = #f, \
 		    .offset = offsetof(struct STRUCT, f), \
@@ -10,7 +76,6 @@
 #define RF(f) F(f, .reserved=1)
 #define RFP(f) F(f, .pointer=1, .reserved=1)
 
-#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
 
 #define MH(f) F(f.mh_magic) \
 	      F(f.mh_type) \
-- 
1.7.4.4




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]