gfs2-utils: master - libgfs2: allow dir_split_leaf to receive a leaf buffer
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=c3058a31...
Commit: c3058a31dce54f3b2fc4d07a4fac0b9add885c08
Parent: f52c560d48b4a6b85851f8e02c619c8e4d0fa589
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Feb 21 09:33:24 2013 -0700
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon May 20 11:12:45 2013 -0500
libgfs2: allow dir_split_leaf to receive a leaf buffer
This is a small performance improvement. Rather than having function
dir_split_leaf read in the leaf to be split, this patch lets the
buffer_head to be passed in from the calling function, which has it
read in anyway.
---
gfs2/libgfs2/fs_ops.c | 9 ++++-----
gfs2/libgfs2/libgfs2.h | 2 +-
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 8b67d2a..89adf32 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -925,9 +925,10 @@ void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out)
}
}
-void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t leaf_no)
+void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t leaf_no,
+ struct gfs2_buffer_head *obh)
{
- struct gfs2_buffer_head *nbh, *obh;
+ struct gfs2_buffer_head *nbh;
struct gfs2_leaf *nleaf, *oleaf;
struct gfs2_dirent *dent, *prev = NULL, *next = NULL, *new;
uint32_t start, len, half_len, divider;
@@ -951,7 +952,6 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t leaf_no)
nleaf = (struct gfs2_leaf *)nbh->b_data;
nleaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
- obh = bread(dip->i_sbd, leaf_no);
oleaf = (struct gfs2_leaf *)obh->b_data;
len = 1 << (dip->i_di.di_depth - be16_to_cpu(oleaf->lf_depth));
@@ -1036,7 +1036,6 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t leaf_no)
bmodified(dip->i_bh);
bmodified(obh); /* Need to do this in case nothing was moved */
- brelse(obh);
bmodified(nbh);
brelse(nbh);
}
@@ -1183,8 +1182,8 @@ restart:
if (dirent_alloc(dip, bh, len, &dent)) {
if (be16_to_cpu(leaf->lf_depth) < dip->i_di.di_depth) {
+ dir_split_leaf(dip, lindex, leaf_no, bh);
brelse(bh);
- dir_split_leaf(dip, lindex, leaf_no);
goto restart;
} else if (dip->i_di.di_depth < GFS2_DIR_MAX_DEPTH) {
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 043d0e1..6e99b94 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -470,7 +470,7 @@ extern void gfs2_get_leaf_nr(struct gfs2_inode *dip, uint32_t index,
uint64_t *leaf_out);
extern void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out);
extern void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
- uint64_t leaf_no);
+ uint64_t leaf_no, struct gfs2_buffer_head *obh);
extern void gfs2_free_block(struct gfs2_sbd *sdp, uint64_t block);
extern int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t block);
extern int gfs2_get_leaf(struct gfs2_inode *dip, uint64_t leaf_no,
10 years, 12 months
gfs2-utils: master - libgfs2: externalize dir_split_leaf
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=f52c560d...
Commit: f52c560d48b4a6b85851f8e02c619c8e4d0fa589
Parent: 9a61ff6028330e478ca67fbed5f9ef97c31662cc
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Feb 21 09:29:24 2013 -0700
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon May 20 11:12:45 2013 -0500
libgfs2: externalize dir_split_leaf
This patch makes libgfs2 externalize function dir_split_leaf so that
fsck.gfs2 can split leafs in a future patch.
---
gfs2/libgfs2/fs_ops.c | 3 +--
gfs2/libgfs2/libgfs2.h | 2 ++
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 51e6abf..8b67d2a 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -925,8 +925,7 @@ void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out)
}
}
-static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
- uint64_t leaf_no)
+void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t leaf_no)
{
struct gfs2_buffer_head *nbh, *obh;
struct gfs2_leaf *nleaf, *oleaf;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 55847c8..043d0e1 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -469,6 +469,8 @@ extern void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
extern void gfs2_get_leaf_nr(struct gfs2_inode *dip, uint32_t index,
uint64_t *leaf_out);
extern void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out);
+extern void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
+ uint64_t leaf_no);
extern void gfs2_free_block(struct gfs2_sbd *sdp, uint64_t block);
extern int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t block);
extern int gfs2_get_leaf(struct gfs2_inode *dip, uint64_t leaf_no,
10 years, 12 months
cluster: RHEL510 - rgmanager: ip.sh: Fix for ipv6 addrs with uppercase hex digits
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=7473b8cf019...
Commit: 7473b8cf0199b7f0e819cd78bd53f215ed371095
Parent: f6df91f927b79c1c8e3078d1bcaf7ff0eb9383f6
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Mon May 20 11:48:26 2013 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Mon May 20 11:53:07 2013 -0400
rgmanager: ip.sh: Fix for ipv6 addrs with uppercase hex digits
This patch fixes a bug that causes ip.sh to fail when using an IPv6
address with uppercase hex alphabetic digits.
This problem appears to not affect RHEL 6 or later.
Resolves: rhbz#865462
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/resources/ip.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/resources/ip.sh b/rgmanager/src/resources/ip.sh
index bbd85f3..c5ffaed 100755
--- a/rgmanager/src/resources/ip.sh
+++ b/rgmanager/src/resources/ip.sh
@@ -932,6 +932,7 @@ inet6)
;;
*)
if [ "${OCF_RESKEY_address//:/}" != "${OCF_RESKEY_address}" ]; then
+ OCF_RESKEY_address="$(echo $OCF_RESKEY_address | tr '[:upper:]' '[:lower:]')"
export OCF_RESKEY_family=inet6
else
export OCF_RESKEY_family=inet
10 years, 12 months
gfs2-utils: master - gfs2l: Improve grammar layout and path parsing
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=9a61ff60...
Commit: 9a61ff6028330e478ca67fbed5f9ef97c31662cc
Parent: 1478c07d6490490ddb10be606760208243cb0bbd
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Sat May 18 23:04:34 2013 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Sat May 18 23:04:34 2013 +0100
gfs2l: Improve grammar layout and path parsing
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(a)redhat.com>
---
gfs2/libgfs2/lexer.l | 5 +
gfs2/libgfs2/parser.y | 198 ++++++++++++++++++++++++------------------------
2 files changed, 104 insertions(+), 99 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; }
%%
/**
10 years, 12 months
gfs2-utils: master - gfs2l: Read from stdin by default
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=1478c07d...
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");
10 years, 12 months
gfs2-utils: master - gfs2l: Add options to print block types and fields
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=b6fa8428...
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;
10 years, 12 months
gfs2-utils: master - gfs2l: Add hash comments
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=6e455ab1...
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]+
%%
10 years, 12 months
gfs2-utils: master - gfs2l: Enable setting the type of a block
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=6ee32886...
Commit: 6ee32886070b682b8ccb02ddeeba86b28e6b83be
Parent: cc0a456dd650c793e4ebce10b0bb7c7ff5048a90
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Sat May 18 00:13:41 2013 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Sat May 18 00:13:41 2013 +0100
gfs2l: Enable setting the type of a block
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(a)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; }
10 years, 12 months
gfs2-utils: master - gfs2l: Improve usage message and opt handling
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=cc0a456d...
Commit: cc0a456dd650c793e4ebce10b0bb7c7ff5048a90
Parent: 65ddd7e85220b9c3a295c45cb1bb3dc175f45d3c
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri May 17 22:20:25 2013 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Fri May 17 22:20:25 2013 +0100
gfs2l: Improve usage message and opt handling
Tweak the usage message and add a help option to print it on demand.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/gfs2l.c | 21 +++++++++++++++++----
1 files 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);
10 years, 12 months
gfs2-utils: master - gfs2-utils build: Fix reporting lack of check
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=65ddd7e8...
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])
10 years, 12 months