This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 231938c4a15133798ac9260d8f4370d6f8cf9132
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Apr 27 13:04:34 2021 +0100
Convert rgrp printing functions to expect big-endian data
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/extended.c | 8 ++-----
gfs2/edit/gfs2hex.c | 48 ++++------------------------------------
gfs2/edit/hexedit.c | 60 +++++++++++++++++++++++---------------------------
gfs2/edit/hexedit.h | 2 +-
gfs2/libgfs2/libgfs2.h | 3 ++-
gfs2/libgfs2/ondisk.c | 32 ++++++++++++++++++---------
6 files changed, 58 insertions(+), 95 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index b0a75465..7050a36a 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -547,13 +547,9 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
if (ret != sizeof(buf)) {
perror("Failed to read resource group");
} else if (sbd.gfs1) {
- struct gfs_rgrp rg1;
- gfs_rgrp_in(&rg1, buf);
- gfs_rgrp_print(&rg1);
+ gfs_rgrp_print(buf);
} else {
- struct gfs2_rgrp rg;
- gfs2_rgrp_in(&rg, buf);
- gfs2_rgrp_print(&rg);
+ lgfs2_rgrp_print(buf);
}
}
last_entry_onscreen[dmode] = print_entry_ndx;
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index b8faf33a..5a2199de 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -416,44 +416,9 @@ static void gfs2_sb_print2(struct gfs2_sb *sbp2)
print_it(" sb_uuid", "%s", NULL, readable_uuid);
}
-/**
- * gfs1_rgrp_in - read in a gfs1 rgrp
- */
-static void gfs1_rgrp_in(struct gfs_rgrp *rgrp, const char *buf)
-{
- struct gfs_rgrp *str = (struct gfs_rgrp *)buf;
-
- gfs2_meta_header_in(&rgrp->rg_header, buf);
- rgrp->rg_flags = be32_to_cpu(str->rg_flags);
- rgrp->rg_free = be32_to_cpu(str->rg_free);
- rgrp->rg_useddi = be32_to_cpu(str->rg_useddi);
- rgrp->rg_freedi = be32_to_cpu(str->rg_freedi);
- gfs2_inum_in(&rgrp->rg_freedi_list, (char *)&str->rg_freedi_list);
- rgrp->rg_usedmeta = be32_to_cpu(str->rg_usedmeta);
- rgrp->rg_freemeta = be32_to_cpu(str->rg_freemeta);
- memcpy(rgrp->rg_reserved, str->rg_reserved, 64);
-}
-
-/**
- * gfs_rgrp_print - Print out a resource group header
- */
-static void gfs1_rgrp_print(struct gfs_rgrp *rg)
-{
- gfs2_meta_header_print(&rg->rg_header);
- pv(rg, rg_flags, "%"PRIu32, "0x%"PRIx32);
- pv(rg, rg_free, "%"PRIu32, "0x%"PRIx32);
- pv(rg, rg_useddi, "%"PRIu32, "0x%"PRIx32);
- pv(rg, rg_freedi, "%"PRIu32, "0x%"PRIx32);
- gfs2_inum_print(&rg->rg_freedi_list);
-
- pv(rg, rg_usedmeta, "%"PRIu32, "0x%"PRIx32);
- pv(rg, rg_freemeta, "%"PRIu32, "0x%"PRIx32);
-}
-
int display_gfs2(char *buf)
{
struct gfs2_meta_header mh;
- struct gfs2_rgrp rg;
struct gfs_log_header lh1;
struct gfs2_log_header lh;
@@ -479,15 +444,10 @@ int display_gfs2(char *buf)
break;
case GFS2_METATYPE_RG:
- if (sbd.gfs1) {
- struct gfs_rgrp rg1;
-
- gfs1_rgrp_in(&rg1, buf);
- gfs1_rgrp_print(&rg1);
- } else {
- gfs2_rgrp_in(&rg, buf);
- gfs2_rgrp_print(&rg);
- }
+ if (sbd.gfs1)
+ gfs_rgrp_print(buf);
+ else
+ lgfs2_rgrp_print(buf);
break;
case GFS2_METATYPE_RB:
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index e38d0b7b..c497c748 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -26,6 +26,10 @@
#include "extended.h"
#include "journal.h"
+#define printbe32(struct, member) do { \
+ print_it(" "#member, "%"PRIu32, "0x%"PRIx32,
be32_to_cpu(struct->member)); \
+ } while(0)
+
const char *mtypes[] = {"none", "sb", "rg", "rb",
"di", "in", "lf", "jd",
"lh", "ld", "ea", "ed", "lb",
"13", "qc"};
const char *allocdesc[2][5] = {
@@ -728,16 +732,18 @@ static uint64_t find_rgrp_block(struct gfs2_inode *dif, int rg)
/* ------------------------------------------------------------------------ */
/* gfs_rgrp_print - print a gfs1 resource group */
/* ------------------------------------------------------------------------ */
-void gfs_rgrp_print(struct gfs_rgrp *rg)
+void gfs_rgrp_print(void *rgp)
{
- gfs2_meta_header_print(&rg->rg_header);
- pv(rg, rg_flags, "%u", "0x%x");
- pv(rg, rg_free, "%u", "0x%x");
- pv(rg, rg_useddi, "%u", "0x%x");
- pv(rg, rg_freedi, "%u", "0x%x");
- gfs2_inum_print(&rg->rg_freedi_list);
- pv(rg, rg_usedmeta, "%u", "0x%x");
- pv(rg, rg_freemeta, "%u", "0x%x");
+ struct gfs_rgrp *rg = rgp;
+
+ lgfs2_meta_header_print(&rg->rg_header);
+ printbe32(rg, rg_flags);
+ printbe32(rg, rg_free);
+ printbe32(rg, rg_useddi);
+ printbe32(rg, rg_freedi);
+ lgfs2_inum_print(&rg->rg_freedi_list);
+ printbe32(rg, rg_usedmeta);
+ printbe32(rg, rg_freemeta);
}
/* ------------------------------------------------------------------------ */
@@ -774,46 +780,36 @@ static uint64_t get_rg_addr(int rgnum)
/* ------------------------------------------------------------------------ */
static void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full)
{
- union {
- struct gfs2_rgrp rg2;
- struct gfs_rgrp rg1;
- } rg;
struct gfs2_buffer_head *rbh;
+ struct gfs2_rgrp *rg;
uint64_t rgblk;
rgblk = get_rg_addr(rgnum);
rbh = bread(&sbd, rgblk);
- if (sbd.gfs1)
- gfs_rgrp_in(&rg.rg1, rbh->b_data);
- else
- gfs2_rgrp_in(&rg.rg2, rbh->b_data);
+ rg = (void *)rbh->b_data;
+
if (modify) {
- printf("RG #%d (block %llu / 0x%llx) rg_flags changed from 0x%08x to
0x%08x\n",
- rgnum, (unsigned long long)rgblk,
- (unsigned long long)rgblk, rg.rg2.rg_flags, new_flags);
- rg.rg2.rg_flags = new_flags;
- if (sbd.gfs1)
- gfs_rgrp_out(&rg.rg1, rbh->b_data);
- else
- gfs2_rgrp_out(&rg.rg2, rbh->b_data);
+ uint32_t flags = be32_to_cpu(rg->rg_flags);
+
+ printf("RG #%d (block %"PRIu64" / 0x%"PRIx64") rg_flags
changed from 0x%08x to 0x%08x\n",
+ rgnum, rgblk, rgblk, flags, new_flags);
+ rg->rg_flags = cpu_to_be32(new_flags);
bmodified(rbh);
- brelse(rbh);
} else {
if (full) {
print_gfs2("RG #%d", rgnum);
print_gfs2(" located at: %"PRIu64" (0x%"PRIx64")",
rgblk, rgblk);
eol(0);
if (sbd.gfs1)
- gfs_rgrp_print(&rg.rg1);
+ gfs_rgrp_print(rg);
else
- gfs2_rgrp_print(&rg.rg2);
+ lgfs2_rgrp_print(rg);
}
else
- printf("RG #%d (block %llu / 0x%llx) rg_flags = 0x%08x\n",
- rgnum, (unsigned long long)rgblk,
- (unsigned long long)rgblk, rg.rg2.rg_flags);
- brelse(rbh);
+ printf("RG #%d (block %"PRIu64" / 0x%"PRIx64") rg_flags =
0x%08x\n",
+ rgnum, rgblk, rgblk, be32_to_cpu(rg->rg_flags));
}
+ brelse(rbh);
if (modify)
fsync(sbd.device_fd);
}
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 35573415..51b466ee 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -232,7 +232,7 @@ extern int display(int identify_only, int trunc_zeros, uint64_t
flagref,
uint64_t ref_blk);
extern uint64_t check_keywords(const char *kword);
extern uint64_t masterblock(const char *fn);
-extern void gfs_rgrp_print(struct gfs_rgrp *rg);
+extern void gfs_rgrp_print(void *rgp);
extern int has_indirect_blocks(void);
extern const struct lgfs2_metadata *get_block_type(char *buf);
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index ab4c7320..ec013647 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -720,10 +720,10 @@ extern void gfs2_inum_print(const struct gfs2_inum *no);
extern void gfs2_meta_header_print(const struct gfs2_meta_header *mh);
extern void gfs2_sb_print(const struct gfs2_sb *sb);
extern void gfs2_rindex_print(const struct gfs2_rindex *ri);
-extern void gfs2_rgrp_print(const struct gfs2_rgrp *rg);
extern void gfs2_dinode_print(const struct gfs2_dinode *di);
extern void gfs2_log_header_print(const struct gfs2_log_header *lh);
/* These expect on-disk data instead of native-endian structs */
+extern void lgfs2_inum_print(void *nop);
extern void lgfs2_meta_header_print(void *mhp);
extern void lgfs2_log_descriptor_print(void *ldp);
extern void lgfs2_quota_print(void *qp);
@@ -731,6 +731,7 @@ extern void lgfs2_quota_change_print(void *qcp);
extern void lgfs2_statfs_change_print(void *scp);
extern void lgfs2_ea_header_print(void *eap);
extern void lgfs2_leaf_print(void *lfp);
+extern void lgfs2_rgrp_print(void *rgp);
__END_DECLS
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 0e51a582..c349a4b4 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -73,6 +73,14 @@ void gfs2_inum_print(const struct gfs2_inum *no)
pv(no, no_addr, "%"PRIu64, "0x%"PRIx64);
}
+void lgfs2_inum_print(void *nop)
+{
+ struct gfs2_inum *no = nop;
+
+ printbe64(no, no_formal_ino);
+ printbe64(no, no_addr);
+}
+
void gfs2_meta_header_in(struct gfs2_meta_header *mh, const char *buf)
{
const struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf;
@@ -255,18 +263,20 @@ void gfs2_rgrp_out(const struct gfs2_rgrp *rg, char *buf)
lgfs2_rgrp_crc_set(buf);
}
-void gfs2_rgrp_print(const struct gfs2_rgrp *rg)
+void lgfs2_rgrp_print(void *rgp)
{
- gfs2_meta_header_print(&rg->rg_header);
- pv(rg, rg_flags, "%"PRIu32, "0x%"PRIx32);
- pv(rg, rg_free, "%"PRIu32, "0x%"PRIx32);
- pv(rg, rg_dinodes, "%"PRIu32, "0x%"PRIx32);
- pv(rg, rg_skip, "%"PRIu32, "0x%"PRIx32);
- pv(rg, rg_igeneration, "%"PRIu64, "0x%"PRIx64);
- pv(rg, rg_data0, "%"PRIu64, "0x%"PRIx64);
- pv(rg, rg_data, "%"PRIu32, "0x%"PRIx32);
- pv(rg, rg_bitbytes, "%"PRIu32, "0x%"PRIx32);
- pv(rg, rg_crc, "%"PRIu32, "0x%"PRIx32);
+ struct gfs2_rgrp *rg = rgp;
+
+ lgfs2_meta_header_print(&rg->rg_header);
+ printbe32(rg, rg_flags);
+ printbe32(rg, rg_free);
+ printbe32(rg, rg_dinodes);
+ printbe32(rg, rg_skip);
+ printbe64(rg, rg_igeneration);
+ printbe64(rg, rg_data0);
+ printbe32(rg, rg_data);
+ printbe32(rg, rg_bitbytes);
+ printbe32(rg, rg_crc);
}
void lgfs2_quota_print(void *qp)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.