From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@redhat.com, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 3/4] xfs_db: complain about dir/attr blocks with bad magics
Date: Mon, 10 Apr 2017 15:47:59 -0700 [thread overview]
Message-ID: <149186447976.32572.12577770552523190852.stgit@birch.djwong.org> (raw)
In-Reply-To: <149186446125.32572.5134583964816531229.stgit@birch.djwong.org>
From: Darrick J. Wong <darrick.wong@oracle.com>
The directory and attribute manipulation code also use the block's magic
number to figure out the real type of the block we're analyzing. If the
magic doesn't match any of the known magics, we end up with the field
type set to the raw attr3/dir3 type and no child type to descend into.
Since there's no print function, we trip over the assertion about
FTARG_OKEMPTY and crash. Instead provide a print function that
complains about the bad magic number.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
db/attr.c | 21 +++++++++++++++++++++
db/attr.h | 3 +++
db/dir2.c | 21 +++++++++++++++++++++
db/dir2.h | 3 +++
db/field.c | 16 ++++++++--------
5 files changed, 56 insertions(+), 8 deletions(-)
diff --git a/db/attr.c b/db/attr.c
index e26ac67..68a3116 100644
--- a/db/attr.c
+++ b/db/attr.c
@@ -574,3 +574,24 @@ const struct xfs_buf_ops xfs_attr3_db_buf_ops = {
.verify_read = xfs_attr3_db_read_verify,
.verify_write = xfs_attr3_db_write_verify,
};
+
+int
+attr_print_func(
+ void *obj,
+ int bit,
+ int count,
+ char *fmtstr,
+ int size,
+ int arg,
+ int base,
+ int array)
+{
+ __be32 magic32;
+ __be16 magic16;
+
+ magic32 = *(__be32 *)obj;
+ magic16 = ((struct xfs_da_blkinfo *)obj)->magic;
+ dbprintf(_("Unknown attribute buffer magic (0x%x:0x%x)!\n"),
+ magic32, magic16);
+ return 0;
+}
diff --git a/db/attr.h b/db/attr.h
index bc3431f..525b144 100644
--- a/db/attr.h
+++ b/db/attr.h
@@ -35,3 +35,6 @@ extern int attr_leaf_name_size(void *obj, int startoff, int idx);
extern int attr_size(void *obj, int startoff, int idx);
extern const struct xfs_buf_ops xfs_attr3_db_buf_ops;
+
+extern int attr_print_func(void *obj, int bit, int count, char *fmtstr,
+ int size, int arg, int base, int array);
diff --git a/db/dir2.c b/db/dir2.c
index 533f705..3b89330 100644
--- a/db/dir2.c
+++ b/db/dir2.c
@@ -1041,3 +1041,24 @@ const struct xfs_buf_ops xfs_dir3_db_buf_ops = {
.verify_read = xfs_dir3_db_read_verify,
.verify_write = xfs_dir3_db_write_verify,
};
+
+int
+dir2_print_func(
+ void *obj,
+ int bit,
+ int count,
+ char *fmtstr,
+ int size,
+ int arg,
+ int base,
+ int array)
+{
+ __be32 magic32;
+ __be16 magic16;
+
+ magic32 = *(__be32 *)obj;
+ magic16 = ((struct xfs_da_blkinfo *)obj)->magic;
+ dbprintf(_("Unknown directory buffer magic (0x%x:0x%x)!\n"),
+ magic32, magic16);
+ return 0;
+}
diff --git a/db/dir2.h b/db/dir2.h
index 0c2a62e..6d12cc1 100644
--- a/db/dir2.h
+++ b/db/dir2.h
@@ -62,3 +62,6 @@ extern int dir2_data_union_size(void *obj, int startoff, int idx);
extern int dir2_size(void *obj, int startoff, int idx);
extern const struct xfs_buf_ops xfs_dir3_db_buf_ops;
+
+extern int dir2_print_func(void *obj, int bit, int count, char *fmtstr,
+ int size, int arg, int base, int array);
diff --git a/db/field.c b/db/field.c
index 1968dd5..5496789 100644
--- a/db/field.c
+++ b/db/field.c
@@ -59,8 +59,8 @@ const ftattr_t ftattrtab[] = {
FTARG_DONULL, NULL, NULL },
/* attr fields */
- { FLDT_ATTR, "attr", NULL, (char *)attr_flds, attr_size, FTARG_SIZE,
- NULL, attr_flds },
+ { FLDT_ATTR, "attr", attr_print_func, (char *)attr_flds, attr_size,
+ FTARG_SIZE, NULL, attr_flds },
{ FLDT_ATTR_BLKINFO, "attr_blkinfo", NULL, (char *)attr_blkinfo_flds,
SI(bitsz(struct xfs_da_blkinfo)), 0, NULL, attr_blkinfo_flds },
{ FLDT_ATTR_LEAF_ENTRY, "attr_leaf_entry", fp_sarray,
@@ -89,8 +89,8 @@ const ftattr_t ftattrtab[] = {
attrshort_size, FTARG_SIZE, NULL, attr_shortform_flds },
/* attr3 specific fields */
- { FLDT_ATTR3, "attr3", NULL, (char *)attr3_flds, attr_size, FTARG_SIZE,
- NULL, attr3_flds },
+ { FLDT_ATTR3, "attr3", attr_print_func, (char *)attr3_flds, attr_size,
+ FTARG_SIZE, NULL, attr3_flds },
{ FLDT_ATTR3_LEAF_HDR, "attr3_leaf_hdr", NULL,
(char *)attr3_leaf_hdr_flds, SI(bitsz(struct xfs_attr3_leaf_hdr)),
0, NULL, attr3_leaf_hdr_flds },
@@ -219,8 +219,8 @@ const ftattr_t ftattrtab[] = {
SI(bitsz(xfs_dinode_t)), 0, NULL, inode_v3_flds },
/* dir v2 fields */
- { FLDT_DIR2, "dir2", NULL, (char *)dir2_flds, dir2_size, FTARG_SIZE,
- NULL, dir2_flds },
+ { FLDT_DIR2, "dir2", dir2_print_func, (char *)dir2_flds, dir2_size,
+ FTARG_SIZE, NULL, dir2_flds },
{ FLDT_DIR2_BLOCK_TAIL, "dir2_block_tail", NULL,
(char *)dir2_block_tail_flds, SI(bitsz(xfs_dir2_block_tail_t)), 0,
NULL, dir2_block_tail_flds },
@@ -262,8 +262,8 @@ const ftattr_t ftattrtab[] = {
FTARG_SIZE, NULL, dir2sf_flds },
/* dir v3 fields */
- { FLDT_DIR3, "dir3", NULL, (char *)dir3_flds, dir2_size, FTARG_SIZE,
- NULL, dir3_flds },
+ { FLDT_DIR3, "dir3", dir2_print_func, (char *)dir3_flds, dir2_size,
+ FTARG_SIZE, NULL, dir3_flds },
{ FLDT_DIR3_BLKHDR, "dir3_blk_hdr", NULL, (char *)dir3_blkhdr_flds,
SI(bitsz(struct xfs_dir3_blk_hdr)), 0, NULL, dir3_blkhdr_flds },
{ FLDT_DIR3_DATA_HDR, "dir3_data_hdr", NULL, (char *)dir3_data_hdr_flds,
next prev parent reply other threads:[~2017-04-10 22:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-10 22:47 [PATCH v2 0/4] xfs_db misc. btree dumping improvements Darrick J. Wong
2017-04-10 22:47 ` [PATCH 1/4] xfs_db: don't print arrays off the end of a buffer Darrick J. Wong
2017-04-26 17:12 ` Eric Sandeen
2017-04-26 17:45 ` Darrick J. Wong
2017-04-10 22:47 ` [PATCH 2/4] xfs_db: use iocursor type to guess btree geometry if bad magic Darrick J. Wong
2017-04-11 0:03 ` Dave Chinner
2017-04-11 0:19 ` Darrick J. Wong
2017-04-11 0:20 ` [PATCH v2 " Darrick J. Wong
2017-04-26 17:48 ` Eric Sandeen
2017-04-26 18:25 ` Darrick J. Wong
2017-04-26 18:41 ` Eric Sandeen
2017-04-26 18:43 ` Darrick J. Wong
2017-04-26 18:47 ` [PATCH v3 " Eric Sandeen
2017-04-26 19:11 ` Darrick J. Wong
2017-04-10 22:47 ` Darrick J. Wong [this message]
2017-04-11 21:42 ` [PATCH 3/4] xfs_db: complain about dir/attr blocks with bad magics Darrick J. Wong
2017-04-10 22:48 ` [PATCH 4/4] xfs_db: dump metadata btrees via 'btdump' Darrick J. Wong
2017-04-26 19:50 ` Eric Sandeen
2017-04-26 20:27 ` Darrick J. Wong
2017-04-26 20:36 ` [PATCH v2 " Darrick J. Wong
2017-04-26 21:35 ` Eric Sandeen
-- strict thread matches above, loose matches on Subject: below --
2017-04-08 3:03 [RFC PATCH v1 0/4] xfs_db misc. btree dumping improvements Darrick J. Wong
2017-04-08 3:04 ` [PATCH 3/4] xfs_db: complain about dir/attr blocks with bad magics Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=149186447976.32572.12577770552523190852.stgit@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.