Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=1478c07d64…
Commit: 1478c07d6490490ddb10be606760208243cb0bbd
Parent: b6fa8428884dcdc33a84bb880ee7dad85a42040c
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Sat May 18 22:36:10 2013 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Sat May 18 22:36:10 2013 +0100
gfs2l: Read from stdin by default
Instead of requiring -f - in order to read from stdin, do that by
default.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/gfs2l.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/gfs2/libgfs2/gfs2l.c b/gfs2/libgfs2/gfs2l.c
index 9fc647a..e58c827 100644
--- a/gfs2/libgfs2/gfs2l.c
+++ b/gfs2/libgfs2/gfs2l.c
@@ -9,7 +9,7 @@ static void usage(const char *cmd)
printf("Usage: %s [options] <fs_path>\n", cmd);
printf("Available options:\n");
printf(" -h Print this help message and exit\n");
- printf(" -f <script_path> Path to script file or '-' for stdin\n");
+ printf(" -f <script_path> Path to script file or '-' for stdin (the default)\n");
printf(" -T Print a list of gfs2 structure types and exit\n");
printf(" -F <type> Print a list of fields belonging to a type and exit\n");
}
@@ -55,12 +55,11 @@ static void print_fields(const char *name)
static int getopts(int argc, char *argv[], struct cmdopts *opts)
{
int opt;
+ opts->src = stdin;
while ((opt = getopt(argc, argv, "F:f:hT")) != -1) {
switch (opt) {
case 'f':
- if (!strcmp("-", optarg)) {
- opts->src = stdin;
- } else {
+ if (strcmp("-", optarg)) {
opts->src = fopen(optarg, "r");
if (opts->src == NULL) {
perror("Failed to open source file");
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=b6fa842888…
Commit: b6fa8428884dcdc33a84bb880ee7dad85a42040c
Parent: 6e455ab187d62be0faf7f714a340fe9121f1ef28
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Sat May 18 01:28:58 2013 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Sat May 18 01:28:58 2013 +0100
gfs2l: Add options to print block types and fields
This adds a -T option which prints out the list of possible meta header
types to be used in gfs2l scripts. It also adds -F <type> which prints
a list of fields in a block type given by <type>. The fields are
prefixed by their offset in the structure.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/gfs2l.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 41 insertions(+), 1 deletions(-)
diff --git a/gfs2/libgfs2/gfs2l.c b/gfs2/libgfs2/gfs2l.c
index 50ddb82..9fc647a 100644
--- a/gfs2/libgfs2/gfs2l.c
+++ b/gfs2/libgfs2/gfs2l.c
@@ -10,6 +10,8 @@ static void usage(const char *cmd)
printf("Available options:\n");
printf(" -h Print this help message and exit\n");
printf(" -f <script_path> Path to script file or '-' for stdin\n");
+ printf(" -T Print a list of gfs2 structure types and exit\n");
+ printf(" -F <type> Print a list of fields belonging to a type and exit\n");
}
struct cmdopts {
@@ -18,10 +20,42 @@ struct cmdopts {
unsigned help:1;
};
+static int metastrcmp(const void *a, const void *b)
+{
+ const struct lgfs2_metadata *m1 = *(struct lgfs2_metadata **)a;
+ const struct lgfs2_metadata *m2 = *(struct lgfs2_metadata **)b;
+ return strcmp(m1->name, m2->name);
+}
+
+static void print_structs(void)
+{
+ const struct lgfs2_metadata *mlist[lgfs2_metadata_size];
+ int i;
+ for (i = 0; i < lgfs2_metadata_size; i++)
+ mlist[i] = &lgfs2_metadata[i];
+
+ qsort(mlist, lgfs2_metadata_size, sizeof(struct lgfs2_metadata *), metastrcmp);
+ for (i = 0; i < lgfs2_metadata_size; i++)
+ if (mlist[i]->mh_type != GFS2_METATYPE_NONE)
+ printf("%s\n", mlist[i]->name);
+}
+
+static void print_fields(const char *name)
+{
+ const struct lgfs2_metadata *m = lgfs2_find_mtype_name(name, LGFS2_MD_GFS1|LGFS2_MD_GFS2);
+ if (m != NULL) {
+ const struct lgfs2_metafield *fields = m->fields;
+ const unsigned nfields = m->nfields;
+ int i;
+ for (i = 0; i < nfields; i++)
+ printf("0x%.4x %s\n", fields[i].offset, fields[i].name);
+ }
+}
+
static int getopts(int argc, char *argv[], struct cmdopts *opts)
{
int opt;
- while ((opt = getopt(argc, argv, "f:h")) != -1) {
+ while ((opt = getopt(argc, argv, "F:f:hT")) != -1) {
switch (opt) {
case 'f':
if (!strcmp("-", optarg)) {
@@ -34,6 +68,12 @@ static int getopts(int argc, char *argv[], struct cmdopts *opts)
}
}
break;
+ case 'T':
+ print_structs();
+ exit(0);
+ case 'F':
+ print_fields(optarg);
+ exit(0);
case 'h':
opts->help = 1;
return 0;
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=6e455ab187…
Commit: 6e455ab187d62be0faf7f714a340fe9121f1ef28
Parent: 6ee32886070b682b8ccb02ddeeba86b28e6b83be
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Sat May 18 00:22:06 2013 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Sat May 18 00:22:06 2013 +0100
gfs2l: Add hash comments
gfs2l now recognises # as a line comment. This was added in order to
enable writing executable scripts with "#!gfs2l -f" at the top of the
file.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/lexer.l | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/gfs2/libgfs2/lexer.l b/gfs2/libgfs2/lexer.l
index 36e1c2d..7fe1aba 100644
--- a/gfs2/libgfs2/lexer.l
+++ b/gfs2/libgfs2/lexer.l
@@ -32,7 +32,9 @@ number ({decnumber}|{hexnumber})
offset \+{number}
id {letter}({letter}|{decdigit}|\.)*
string \'([^\']|\\\')*\'
-comment \/\/.*\n
+ccomment \/\/.*\n
+shcomment \#.*\n
+comment ({ccomment}|{shcomment})
whitespace [ \t\r]+
%%
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=65ddd7e852…
Commit: 65ddd7e85220b9c3a295c45cb1bb3dc175f45d3c
Parent: 0492586f1f6e0198e9cc99eb846cc14d48e4c197
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri May 3 22:51:23 2013 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Fri May 17 21:56:20 2013 +0100
gfs2-utils build: Fix reporting lack of check
Make configure.ac test the correct variable to conditionally warn of the
absence of 'check'.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
configure.ac | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6940d79..c8e52a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -278,4 +278,4 @@ AC_CONFIG_FILES([Makefile
AC_OUTPUT
-test x"$BUILD_TESTS" = x && AC_MSG_NOTICE([package 'check' not found; unit tests will not be built])
+test x"$have_check" = "xyes" || AC_MSG_NOTICE([package 'check' not found; unit tests will not be built])