]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: allow write -d to inodes
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 2 May 2017 16:12:31 +0000 (11:12 -0500)
committerEric Sandeen <sandeen@redhat.com>
Tue, 2 May 2017 16:12:31 +0000 (11:12 -0500)
Add a helper function to xfs_db so that we can recalculate the CRC of an
inode whose field we just wrote.  This enables us to write arbitrary
values with a good CRC for the purpose of checking the read verifiers on
a v5 filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/io.c
db/io.h
db/write.c

diff --git a/db/io.c b/db/io.c
index f39819581466c16c690eb67f323cbe20dbc6ed43..67ed5f9e0921bd8ee34e96a9702e2caebaccb158 100644 (file)
--- a/db/io.c
+++ b/db/io.c
@@ -464,6 +464,17 @@ xfs_dummy_verify(
        return;
 }
 
+void
+xfs_verify_recalc_inode_crc(
+       struct xfs_buf *bp)
+{
+       ASSERT(iocur_top->ino_buf);
+       ASSERT(iocur_top->bp == bp);
+
+       libxfs_dinode_calc_crc(mp, iocur_top->data);
+       iocur_top->ino_crc_ok = 1;
+}
+
 void
 xfs_verify_recalc_crc(
        struct xfs_buf *bp)
diff --git a/db/io.h b/db/io.h
index c69e9ce9e910fb8c9fddfb03baa08ae519251dad..12d96c2a58eb5fd588c5b1c187156f84291fa2ee 100644 (file)
--- a/db/io.h
+++ b/db/io.h
@@ -64,6 +64,7 @@ extern void   set_cur(const struct typ *t, __int64_t d, int c, int ring_add,
 extern void     ring_add(void);
 extern void    set_iocur_type(const struct typ *t);
 extern void    xfs_dummy_verify(struct xfs_buf *bp);
+extern void    xfs_verify_recalc_inode_crc(struct xfs_buf *bp);
 extern void    xfs_verify_recalc_crc(struct xfs_buf *bp);
 
 /*
index 5c83874f17fe880c4596274ee7bd8d96f832f633..70c986561308d6420ba69fac8a08fc10c19cac75 100644 (file)
@@ -137,7 +137,9 @@ write_f(
                return 0;
        }
 
-       if (invalid_data && iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF) {
+       if (invalid_data &&
+           iocur_top->typ->crc_off == TYP_F_NO_CRC_OFF &&
+           !iocur_top->ino_buf) {
                dbprintf(_("Cannot recalculate CRCs on this type of object\n"));
                return 0;
        }
@@ -164,6 +166,9 @@ write_f(
        if (corrupt) {
                local_ops.verify_write = xfs_dummy_verify;
                dbprintf(_("Allowing write of corrupted data and bad CRC\n"));
+       } else if (iocur_top->ino_buf) {
+               local_ops.verify_write = xfs_verify_recalc_inode_crc;
+               dbprintf(_("Allowing write of corrupted inode with good CRC\n"));
        } else { /* invalid data */
                local_ops.verify_write = xfs_verify_recalc_crc;
                dbprintf(_("Allowing write of corrupted data with good CRC\n"));