Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=c221ae9b218... Commit: c221ae9b218f4d087aac2a9d51d85b39957eb06f Parent: 7bb856e6925f0fbd64aae49c81e75d7eb44e2b9f Author: Andrew Price anprice@redhat.com AuthorDate: Wed Feb 27 15:32:16 2013 +0000 Committer: Andrew Price anprice@redhat.com CommitterDate: Wed Feb 27 15:33:43 2013 +0000
libgfs2: Move lgfs2_field_print into gfs2l and make it static
It's only used in lang.c and this will reduce the amount of UI code in libgfs2.
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/libgfs2/lang.c | 39 ++++++++++++++++++++++++++++++++++++++- gfs2/libgfs2/libgfs2.h | 3 --- gfs2/libgfs2/meta.c | 37 ------------------------------------- 3 files changed, 38 insertions(+), 41 deletions(-)
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c index 40a4355..069750f 100644 --- a/gfs2/libgfs2/lang.c +++ b/gfs2/libgfs2/lang.c @@ -298,6 +298,43 @@ static const char *bitstate_strings[] = { };
/** + * Print a representation of an arbitrary field of an arbitrary GFS2 block to stdout + * Returns 0 if successful, 1 otherwise + */ +static int field_print(const struct gfs2_buffer_head *bh, const struct lgfs2_metadata *mtype, + const struct lgfs2_metafield *field) +{ + const char *fieldp = (char *)bh->iov.iov_base + field->offset; + + printf("%s\t%"PRIu64"\t%u\t%u\t%s\t", mtype->name, bh->b_blocknr, field->offset, field->length, field->name); + if (field->flags & LGFS2_MFF_UUID) { + printf("'%s'\n", str_uuid((const unsigned char *)fieldp)); + } else if (field->flags & LGFS2_MFF_STRING) { + printf("'%s'\n", fieldp); + } else { + switch(field->length) { + case 1: + printf("%"PRIu8"\n", *(uint8_t *)fieldp); + break; + case 2: + printf("%"PRIu16"\n", be16_to_cpu(*(uint16_t *)fieldp)); + break; + case 4: + printf("%"PRIu32"\n", be32_to_cpu(*(uint32_t *)fieldp)); + break; + case 8: + printf("%"PRIu64"\n", be64_to_cpu(*(uint64_t *)fieldp)); + break; + default: + // "Reserved" field so just print 0 + printf("0\n"); + return 1; + } + } + return 0; +} + +/** * Print a representation of an arbitrary GFS2 block to stdout */ int lgfs2_lang_result_print(struct lgfs2_lang_result *result) @@ -305,7 +342,7 @@ int lgfs2_lang_result_print(struct lgfs2_lang_result *result) int i; if (result->lr_mtype != NULL) { for (i = 0; i < result->lr_mtype->nfields; i++) { - lgfs2_field_print(result->lr_bh, result->lr_mtype, &result->lr_mtype->fields[i]); + field_print(result->lr_bh, result->lr_mtype, &result->lr_mtype->fields[i]); } } else { printf("%"PRIu64": %s\n", result->lr_blocknr, bitstate_strings[result->lr_state]); diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index b2457c4..8dd8210 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -357,9 +357,6 @@ 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 int lgfs2_field_print(const struct gfs2_buffer_head *bh, - const struct lgfs2_metadata *mtype, - const struct lgfs2_metafield *field);
/* bitmap.c */ struct gfs2_bmap { diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c index 29bf239..dc22e9a 100644 --- a/gfs2/libgfs2/meta.c +++ b/gfs2/libgfs2/meta.c @@ -821,40 +821,3 @@ const struct lgfs2_metadata *lgfs2_find_mtype(uint32_t mh_type, const unsigned v
return NULL; } - -/** - * Print a representation of an arbitrary field of an arbitrary GFS2 block to stdout - * Returns 0 if successful, 1 otherwise - */ -int lgfs2_field_print(const struct gfs2_buffer_head *bh, const struct lgfs2_metadata *mtype, - const struct lgfs2_metafield *field) -{ - const char *fieldp = (char *)bh->iov.iov_base + field->offset; - - printf("%s\t%"PRIu64"\t%u\t%u\t%s\t", mtype->name, bh->b_blocknr, field->offset, field->length, field->name); - if (field->flags & LGFS2_MFF_UUID) { - printf("'%s'\n", str_uuid((const unsigned char *)fieldp)); - } else if (field->flags & LGFS2_MFF_STRING) { - printf("'%s'\n", fieldp); - } else { - switch(field->length) { - case 1: - printf("%"PRIu8"\n", *(uint8_t *)fieldp); - break; - case 2: - printf("%"PRIu16"\n", be16_to_cpu(*(uint16_t *)fieldp)); - break; - case 4: - printf("%"PRIu32"\n", be32_to_cpu(*(uint32_t *)fieldp)); - break; - case 8: - printf("%"PRIu64"\n", be64_to_cpu(*(uint64_t *)fieldp)); - break; - default: - // "Reserved" field so just print 0 - printf("0\n"); - return 1; - } - } - return 0; -}