cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check
@ 2013-05-20 11:37 Andrew Price
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 2/7] gfs2l: Improve usage message and opt handling Andrew Price
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Andrew Price @ 2013-05-20 11:37 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Make configure.ac test the correct variable to conditionally warn of the
absence of 'check'.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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])
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Cluster-devel] [PATCH 2/7] gfs2l: Improve usage message and opt handling
  2013-05-20 11:37 [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check Andrew Price
@ 2013-05-20 11:37 ` Andrew Price
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 3/7] gfs2l: Enable setting the type of a block Andrew Price
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andrew Price @ 2013-05-20 11:37 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Tweak the usage message and add a help option to print it on demand.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/libgfs2/gfs2l.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/gfs2/libgfs2/gfs2l.c b/gfs2/libgfs2/gfs2l.c
index 2eacb2d..50ddb82 100644
--- a/gfs2/libgfs2/gfs2l.c
+++ b/gfs2/libgfs2/gfs2l.c
@@ -5,19 +5,23 @@
 
 static void usage(const char *cmd)
 {
-	fprintf(stderr, "Usage: %s -f <script_path> <fs_path>\n", cmd);
-	fprintf(stderr, "Use -f - for stdin\n");
+	printf("A language for modifying and querying a gfs2 file system.\n");
+	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");
 }
 
 struct cmdopts {
 	char *fspath;
 	FILE *src;
+	unsigned help:1;
 };
 
 static int getopts(int argc, char *argv[], struct cmdopts *opts)
 {
 	int opt;
-	while ((opt = getopt(argc, argv, "f:")) != -1) {
+	while ((opt = getopt(argc, argv, "f:h")) != -1) {
 		switch (opt) {
 		case 'f':
 			if (!strcmp("-", optarg)) {
@@ -30,14 +34,18 @@ static int getopts(int argc, char *argv[], struct cmdopts *opts)
 				}
 			}
 			break;
+		case 'h':
+			opts->help = 1;
+			return 0;
 		default:
-			usage(argv[0]);
+			fprintf(stderr, "Use -h for help\n");
 			return 1;
 		}
 	}
 
 	if (argc - optind != 1) {
 		usage(argv[0]);
+		fprintf(stderr, "Missing file system path. Use -h for help.\n");
 		return 1;
 	}
 
@@ -106,6 +114,11 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
+	if (opts.help) {
+		usage(argv[0]);
+		exit(0);
+	}
+
 	sdp = openfs(argv[optind]);
 	if (sdp == NULL) {
 		exit(1);
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Cluster-devel] [PATCH 3/7] gfs2l: Enable setting the type of a block
  2013-05-20 11:37 [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check Andrew Price
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 2/7] gfs2l: Improve usage message and opt handling Andrew Price
@ 2013-05-20 11:37 ` Andrew Price
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 4/7] gfs2l: Add hash comments Andrew Price
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andrew Price @ 2013-05-20 11:37 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This adds an optional type specifier to the set statement so that when
you do

   set 12345 <type> { ... }

the block's meta header fields will be set to that of <type> where
<type> is a structure name e.g. gfs2_rgrp.

This is useful for setting unallocated blocks to a certain block type
as the type can't be inferred from an existing meta header.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/libgfs2/lang.c    | 41 ++++++++++++++++++++++++++++++++++-------
 gfs2/libgfs2/lang.h    |  1 +
 gfs2/libgfs2/libgfs2.h |  1 +
 gfs2/libgfs2/meta.c    | 15 +++++++++++++++
 gfs2/libgfs2/parser.y  | 12 ++++++++++++
 5 files changed, 63 insertions(+), 7 deletions(-)

diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index 069750f..28805b5 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -27,6 +27,7 @@ const char* ast_type_string[] = {
 	[AST_EX_BLOCKSPEC] = "BLOCKSPEC",
 	[AST_EX_STRUCTSPEC] = "STRUCTSPEC",
 	[AST_EX_FIELDSPEC] = "FIELDSPEC",
+	[AST_EX_TYPESPEC] = "TYPESPEC",
 
 	// Keywords
 	[AST_KW_STATE] = "STATE",
@@ -64,6 +65,7 @@ static int ast_expr_init(struct ast_node *expr, ast_node_t type, const char *str
 	case AST_EX_BLOCKSPEC:
 	case AST_EX_STRUCTSPEC:
 	case AST_EX_FIELDSPEC:
+	case AST_EX_TYPESPEC:
 	case AST_KW_STATE:
 		break;
 	default:
@@ -173,7 +175,6 @@ static uint64_t ast_lookup_path(char *path, struct gfs2_sbd *sbd)
 		segment = strtok_r(NULL, "/", &c);
 	}
 
-	perror("Path lookup");
 	return 0;
 }
 
@@ -263,6 +264,8 @@ static uint64_t ast_lookup_block_num(struct ast_node *ast, struct gfs2_sbd *sbd)
 		bn = ast_lookup_block_num(ast->ast_left, sbd) + ast->ast_num;
 		break;
 	case AST_EX_ADDRESS:
+		if (gfs2_check_range(sbd, ast->ast_num))
+			break;
 		bn = ast->ast_num;
 		break;
 	case AST_EX_PATH:
@@ -284,6 +287,7 @@ static struct gfs2_buffer_head *ast_lookup_block(struct ast_node *node, struct g
 {
 	uint64_t bn = ast_lookup_block_num(node, sbd);
 	if (bn == 0) {
+		fprintf(stderr, "Block not found: %s\n", node->ast_text);
 		return NULL;
 	}
 
@@ -526,6 +530,23 @@ static int ast_field_set(struct gfs2_buffer_head *bh, const struct lgfs2_metafie
 	return AST_INTERP_INVAL;
 }
 
+static const struct lgfs2_metadata *lang_find_mtype(struct ast_node *node, struct gfs2_buffer_head *bh, unsigned ver)
+{
+	const struct lgfs2_metadata *mtype = NULL;
+
+	if (node->ast_type == AST_EX_TYPESPEC) {
+		mtype = lgfs2_find_mtype_name(node->ast_str, ver);
+		if (mtype == NULL)
+			fprintf(stderr, "Invalid block type: %s\n", node->ast_text);
+	} else {
+		mtype = lgfs2_find_mtype(lgfs2_get_block_type(bh), ver);
+		if (mtype == NULL)
+			fprintf(stderr, "Unrecognised block at: %s\n", node->ast_text);
+	}
+
+	return mtype;
+}
+
 /**
  * Interpret an assignment (set)
  */
@@ -536,9 +557,9 @@ static struct lgfs2_lang_result *ast_interp_set(struct lgfs2_lang_state *state,
 	struct ast_node *fieldspec;
 	struct ast_node *fieldname;
 	struct ast_node *fieldval;
-	uint32_t mh_type = 0;
 	int i = 0;
 	int ret = 0;
+	unsigned ver = sbd->gfs1 ? LGFS2_MD_GFS1 : LGFS2_MD_GFS2;
 
 	struct lgfs2_lang_result *result = calloc(1, sizeof(struct lgfs2_lang_result));
 	if (result == NULL) {
@@ -551,14 +572,20 @@ static struct lgfs2_lang_result *ast_interp_set(struct lgfs2_lang_state *state,
 		goto out_err;
 	}
 
-	mh_type = lgfs2_get_block_type(result->lr_bh);
-	if (mh_type == 0) {
+	result->lr_mtype = lang_find_mtype(lookup->ast_right, result->lr_bh, ver);
+	if (result->lr_mtype == NULL) {
+		fprintf(stderr, "Unrecognised block at: %s\n", lookup->ast_str);
 		goto out_err;
 	}
 
-	result->lr_mtype = lgfs2_find_mtype(mh_type, sbd->gfs1 ? LGFS2_MD_GFS1 : LGFS2_MD_GFS2);
-	if (result->lr_mtype == NULL) {
-		goto out_err;
+	if (lookup->ast_right->ast_type == AST_EX_TYPESPEC) {
+		struct gfs2_meta_header mh = {
+			.mh_magic = GFS2_MAGIC,
+			.mh_type = result->lr_mtype->mh_type,
+			.mh_format = result->lr_mtype->mh_format,
+		};
+		gfs2_meta_header_out(&mh, result->lr_bh->iov.iov_base);
+		lookup = lookup->ast_right;
 	}
 
 	for (fieldspec = lookup->ast_right;
diff --git a/gfs2/libgfs2/lang.h b/gfs2/libgfs2/lang.h
index 955e52e..7d9a6e9 100644
--- a/gfs2/libgfs2/lang.h
+++ b/gfs2/libgfs2/lang.h
@@ -30,6 +30,7 @@ typedef enum {
 	AST_EX_BLOCKSPEC,
 	AST_EX_STRUCTSPEC,
 	AST_EX_FIELDSPEC,
+	AST_EX_TYPESPEC,
 
 	// Keywords
 	AST_KW_STATE,
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 997e23f..55847c8 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -356,6 +356,7 @@ extern const struct lgfs2_symbolic lgfs2_ld1_types[];
 extern const unsigned lgfs2_ld1_type_size;
 extern int lgfs2_selfcheck(void);
 extern const struct lgfs2_metadata *lgfs2_find_mtype(uint32_t mh_type, const unsigned versions);
+extern const struct lgfs2_metadata *lgfs2_find_mtype_name(const char *name, const unsigned versions);
 
 /* bitmap.c */
 struct gfs2_bmap {
diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
index dc22e9a..94be823 100644
--- a/gfs2/libgfs2/meta.c
+++ b/gfs2/libgfs2/meta.c
@@ -1,4 +1,5 @@
 #include <stdint.h>
+#include <string.h>
 #include "libgfs2.h"
 
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
@@ -821,3 +822,17 @@ const struct lgfs2_metadata *lgfs2_find_mtype(uint32_t mh_type, const unsigned v
 
 	return NULL;
 }
+
+const struct lgfs2_metadata *lgfs2_find_mtype_name(const char *name, const unsigned versions)
+{
+	const struct lgfs2_metadata *m = lgfs2_metadata;
+	unsigned n = 0;
+
+	do {
+		if ((m[n].versions & versions) && !strcmp(m[n].name, name))
+			return &m[n];
+		n++;
+	} while (n < lgfs2_metadata_size);
+
+	return NULL;
+}
diff --git a/gfs2/libgfs2/parser.y b/gfs2/libgfs2/parser.y
index 0321d74..d60c1af 100644
--- a/gfs2/libgfs2/parser.y
+++ b/gfs2/libgfs2/parser.y
@@ -65,6 +65,12 @@ set_stmt:	TOK_SET blockspec structspec {
 			$2->ast_right = $3;
 			$$ = $1;
 		}
+		| TOK_SET blockspec typespec structspec {
+			$1->ast_right = $2;
+			$2->ast_right = $3;
+			$3->ast_right = $4;
+			$$ = $1;
+		}
 ;
 get_stmt:	TOK_GET blockspec { $1->ast_right = $2; $$ = $1; }
 		| TOK_GET blockspec TOK_STATE {
@@ -84,6 +90,11 @@ offset:		blockspec TOK_OFFSET {
 			$$ = $2;
 		}
 ;
+typespec:	identifier {
+			$1->ast_type = AST_EX_TYPESPEC;
+			$$ = $1;
+		}
+;
 block_literal:	identifier		{ $$ = $1; }
 ;
 subscript:	block_literal TOK_LBRACKET index TOK_RBRACKET {
@@ -107,6 +118,7 @@ path:		string			{
 		}
 ;
 structspec:	TOK_LBRACE fieldspecs TOK_RBRACE { $$ = $2; }
+structspec:	TOK_LBRACE TOK_RBRACE            { $$ = NULL; }
 ;
 fieldspecs:	fieldspecs TOK_COMMA fieldspec	{ $1->ast_left = $3; $$ = $1; }
 		| fieldspec			{ $$ = $1; }
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Cluster-devel] [PATCH 4/7] gfs2l: Add hash comments
  2013-05-20 11:37 [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check Andrew Price
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 2/7] gfs2l: Improve usage message and opt handling Andrew Price
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 3/7] gfs2l: Enable setting the type of a block Andrew Price
@ 2013-05-20 11:37 ` Andrew Price
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 5/7] gfs2l: Add options to print block types and fields Andrew Price
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andrew Price @ 2013-05-20 11:37 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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@redhat.com>
---
 gfs2/libgfs2/lexer.l | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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]+
 
 %%
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Cluster-devel] [PATCH 5/7] gfs2l: Add options to print block types and fields
  2013-05-20 11:37 [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check Andrew Price
                   ` (2 preceding siblings ...)
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 4/7] gfs2l: Add hash comments Andrew Price
@ 2013-05-20 11:37 ` Andrew Price
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 6/7] gfs2l: Read from stdin by default Andrew Price
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andrew Price @ 2013-05-20 11:37 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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@redhat.com>
---
 gfs2/libgfs2/gfs2l.c | 42 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

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;
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Cluster-devel] [PATCH 6/7] gfs2l: Read from stdin by default
  2013-05-20 11:37 [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check Andrew Price
                   ` (3 preceding siblings ...)
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 5/7] gfs2l: Add options to print block types and fields Andrew Price
@ 2013-05-20 11:37 ` Andrew Price
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 7/7] gfs2l: Improve grammar layout and path parsing Andrew Price
  2013-05-20 12:08 ` [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check Steven Whitehouse
  6 siblings, 0 replies; 8+ messages in thread
From: Andrew Price @ 2013-05-20 11:37 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Instead of requiring -f - in order to read from stdin, do that by
default.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/libgfs2/gfs2l.c | 7 +++----
 1 file 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");
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Cluster-devel] [PATCH 7/7] gfs2l: Improve grammar layout and path parsing
  2013-05-20 11:37 [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check Andrew Price
                   ` (4 preceding siblings ...)
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 6/7] gfs2l: Read from stdin by default Andrew Price
@ 2013-05-20 11:37 ` Andrew Price
  2013-05-20 12:08 ` [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check Steven Whitehouse
  6 siblings, 0 replies; 8+ messages in thread
From: Andrew Price @ 2013-05-20 11:37 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This makes a path a lexical entity so we don't have to kludge from a
string in the parse stage. It also tidies up the grammar layout and
simplifies the indentation to make it easier to maintain.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/libgfs2/lexer.l  |   5 ++
 gfs2/libgfs2/parser.y | 196 +++++++++++++++++++++++++-------------------------
 2 files changed, 103 insertions(+), 98 deletions(-)

diff --git a/gfs2/libgfs2/lexer.l b/gfs2/libgfs2/lexer.l
index 7fe1aba..04b3883 100644
--- a/gfs2/libgfs2/lexer.l
+++ b/gfs2/libgfs2/lexer.l
@@ -32,6 +32,7 @@ number			({decnumber}|{hexnumber})
 offset			\+{number}
 id			{letter}({letter}|{decdigit}|\.)*
 string			\'([^\']|\\\')*\'
+path			\'\/([^\']|\\\')*\'
 ccomment		\/\/.*\n
 shcomment		\#.*\n
 comment			({ccomment}|{shcomment})
@@ -69,6 +70,10 @@ get			{
 state			{
 			P(STATE, AST_KW_STATE, yytext);
 			}
+{path}			{
+			yytext[yyleng-1] = '\0';
+			P(PATH, AST_EX_PATH, yytext + 1);
+			}
 {string}		{
 			yytext[yyleng-1] = '\0';
 			P(STRING, AST_EX_STRING, yytext + 1);
diff --git a/gfs2/libgfs2/parser.y b/gfs2/libgfs2/parser.y
index d60c1af..521c5df 100644
--- a/gfs2/libgfs2/parser.y
+++ b/gfs2/libgfs2/parser.y
@@ -35,106 +35,106 @@ static int yyerror(struct lgfs2_lang_state *state, yyscan_t lexer, const char *e
 %token TOK_GET
 %token TOK_STATE
 %token TOK_STRING
+%token TOK_PATH
 %%
-script:		statements		{
-			state->ls_ast_root = $1;
-			state->ls_interp_curr = $1;
-		}
-		| statements TOK_SEMI	{
-			state->ls_ast_root = $1;
-			state->ls_interp_curr = $1;
-		}
-;
-statements:	statements TOK_SEMI statement	{
-			state->ls_ast_tail->ast_left = $3;
-			state->ls_ast_tail = $3;
-			$$ = $1;
-		}
-		| statement		{
-			if (state->ls_ast_tail == NULL)
-				state->ls_ast_tail = $1;
-			$$ = $1;
-		}
+script:	statements {
+		state->ls_ast_root = $1;
+		state->ls_interp_curr = $1;
+	}
+	| statements TOK_SEMI {
+		state->ls_ast_root = $1;
+		state->ls_interp_curr = $1;
+	}
 ;
-
-statement:	set_stmt		{ $$ = $1; }
-		| get_stmt		{ $$ = $1; }
-;
-set_stmt:	TOK_SET blockspec structspec {
-			$1->ast_right = $2;
-			$2->ast_right = $3;
-			$$ = $1;
-		}
-		| TOK_SET blockspec typespec structspec {
-			$1->ast_right = $2;
-			$2->ast_right = $3;
-			$3->ast_right = $4;
-			$$ = $1;
-		}
-;
-get_stmt:	TOK_GET blockspec { $1->ast_right = $2; $$ = $1; }
-		| TOK_GET blockspec TOK_STATE {
-			$1->ast_right = $2;
-			$2->ast_right = $3;
-			$$ = $1;
-		}
-;
-blockspec:	offset			{ $$ = $1; }
-		| address		{ $$ = $1; }
-		| path			{ $$ = $1; }
-		| block_literal		{ $$ = $1; }
-		| subscript		{ $$ = $1; }
-;
-offset:		blockspec TOK_OFFSET {
-			$2->ast_left = $1;
-			$$ = $2;
-		}
-;
-typespec:	identifier {
-			$1->ast_type = AST_EX_TYPESPEC;
-			$$ = $1;
-		}
-;
-block_literal:	identifier		{ $$ = $1; }
-;
-subscript:	block_literal TOK_LBRACKET index TOK_RBRACKET {
-			$4->ast_left = $1;
-			$1->ast_left = $3;
-			$$ = $4;
-		}
-;
-index:		number			{ $$ = $1; }
-		| identifier		{ $$ = $1; }
-;
-address:	number			{ $1->ast_type = AST_EX_ADDRESS; $$ = $1; }
-;
-path:		string			{
-			if (*($1->ast_str) != '/') {
-				fprintf(stderr, "Path doesn't begin with '/': %s\n", $1->ast_str);
-				YYABORT;
-			}
-			$1->ast_type = AST_EX_PATH;
-			$$ = $1;
-		}
-;
-structspec:	TOK_LBRACE fieldspecs TOK_RBRACE { $$ = $2; }
-structspec:	TOK_LBRACE TOK_RBRACE            { $$ = NULL; }
-;
-fieldspecs:	fieldspecs TOK_COMMA fieldspec	{ $1->ast_left = $3; $$ = $1; }
-		| fieldspec			{ $$ = $1; }
-;
-fieldspec:	identifier TOK_COLON fieldvalue {
-			$2->ast_right = $1;
-			$1->ast_right = $3;
-			$$ = $2;
-		}
-;
-fieldvalue:	number			{ $$ = $1; }
-		| string		{ $$ = $1; }
-;
-number:		TOK_NUMBER		{ $$ = $1; }
-string:		TOK_STRING		{ $$ = $1; }
-identifier:	TOK_ID			{ $$ = $1; }
+statements: statements TOK_SEMI statement {
+		state->ls_ast_tail->ast_left = $3;
+		state->ls_ast_tail = $3;
+		$$ = $1;
+	}
+	| statement {
+		if (state->ls_ast_tail == NULL)
+			state->ls_ast_tail = $1;
+		$$ = $1;
+	}
+;
+statement: set_stmt { $$ = $1;}
+	| get_stmt { $$ = $1; }
+;
+set_stmt: TOK_SET blockspec structspec {
+		$1->ast_right = $2;
+		$2->ast_right = $3;
+		$$ = $1;
+	}
+	| TOK_SET blockspec typespec structspec {
+		$1->ast_right = $2;
+		$2->ast_right = $3;
+		$3->ast_right = $4;
+		$$ = $1;
+	}
+;
+get_stmt: TOK_GET blockspec {
+		$1->ast_right = $2; $$ = $1;
+	}
+	| TOK_GET blockspec TOK_STATE {
+		$1->ast_right = $2;
+		$2->ast_right = $3;
+		$$ = $1;
+	}
+;
+blockspec: offset { $$ = $1; }
+	| address { $$ = $1; }
+	| path { $$ = $1; }
+	| block_literal { $$ = $1; }
+	| subscript { $$ = $1; }
+;
+offset:	blockspec TOK_OFFSET {
+		$2->ast_left = $1;
+		$$ = $2;
+	}
+;
+typespec: identifier {
+		$1->ast_type = AST_EX_TYPESPEC;
+		$$ = $1;
+	}
+;
+block_literal: identifier { $$ = $1; }
+;
+subscript: block_literal TOK_LBRACKET index TOK_RBRACKET {
+		$4->ast_left = $1;
+		$1->ast_left = $3;
+		$$ = $4;
+	}
+;
+index: number { $$ = $1; }
+	| identifier { $$ = $1; }
+;
+address: number {
+		$1->ast_type = AST_EX_ADDRESS;
+		$$ = $1;
+	 }
+;
+structspec: TOK_LBRACE fieldspecs TOK_RBRACE { $$ = $2; }
+	| TOK_LBRACE TOK_RBRACE { $$ = NULL; }
+;
+fieldspecs: fieldspecs TOK_COMMA fieldspec {
+		$1->ast_left = $3;
+		$$ = $1;
+	}
+	| fieldspec { $$ = $1; }
+;
+fieldspec: identifier TOK_COLON fieldvalue {
+		$2->ast_right = $1;
+		$1->ast_right = $3;
+		$$ = $2;
+	}
+;
+fieldvalue: number { $$ = $1; }
+	| string { $$ = $1; }
+;
+number: TOK_NUMBER { $$ = $1; }
+string: TOK_STRING { $$ = $1; }
+identifier: TOK_ID { $$ = $1; }
+path: TOK_PATH { $$ = $1; }
 %%
 
 /**
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check
  2013-05-20 11:37 [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check Andrew Price
                   ` (5 preceding siblings ...)
  2013-05-20 11:37 ` [Cluster-devel] [PATCH 7/7] gfs2l: Improve grammar layout and path parsing Andrew Price
@ 2013-05-20 12:08 ` Steven Whitehouse
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Whitehouse @ 2013-05-20 12:08 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

All looks good to me,

Steve.

On Mon, 2013-05-20 at 12:37 +0100, Andrew Price wrote:
> Make configure.ac test the correct variable to conditionally warn of the
> absence of 'check'.
> 
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
>  configure.ac | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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])




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-05-20 12:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-20 11:37 [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check Andrew Price
2013-05-20 11:37 ` [Cluster-devel] [PATCH 2/7] gfs2l: Improve usage message and opt handling Andrew Price
2013-05-20 11:37 ` [Cluster-devel] [PATCH 3/7] gfs2l: Enable setting the type of a block Andrew Price
2013-05-20 11:37 ` [Cluster-devel] [PATCH 4/7] gfs2l: Add hash comments Andrew Price
2013-05-20 11:37 ` [Cluster-devel] [PATCH 5/7] gfs2l: Add options to print block types and fields Andrew Price
2013-05-20 11:37 ` [Cluster-devel] [PATCH 6/7] gfs2l: Read from stdin by default Andrew Price
2013-05-20 11:37 ` [Cluster-devel] [PATCH 7/7] gfs2l: Improve grammar layout and path parsing Andrew Price
2013-05-20 12:08 ` [Cluster-devel] [PATCH 1/7] gfs2-utils build: Fix reporting lack of check Steven Whitehouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).