]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
db: verify buffer on type change
authorDave Chinner <dchinner@redhat.com>
Thu, 1 May 2014 23:30:47 +0000 (09:30 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 1 May 2014 23:30:47 +0000 (09:30 +1000)
Currently when the type command is run, we simply change the type
associated with the buffer, but don't verify it. This results in
unchecked CRCs being displayed. Hence when changing the type, run
the verifier associated with the type to determine if the buffer
contents is valid or not.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
db/io.c
db/io.h
db/type.c

diff --git a/db/io.c b/db/io.c
index 387f17156a9f2dd78e8dfd09e993aafbb69f9b62..7f1b76a2594635a5824ebf401d1ca29f89b74e42 100644 (file)
--- a/db/io.c
+++ b/db/io.c
@@ -552,6 +552,30 @@ set_cur(
                ring_add();
 }
 
+void
+set_iocur_type(
+       const typ_t     *t)
+{
+       struct xfs_buf  *bp = iocur_top->bp;
+
+       iocur_top->typ = t;
+
+       /* verify the buffer if the type has one. */
+       if (!bp)
+               return;
+       if (!t->bops) {
+               bp->b_ops = NULL;
+               bp->b_flags |= LIBXFS_B_UNCHECKED;
+               return;
+       }
+       if (!(bp->b_flags & LIBXFS_B_UPTODATE))
+               return;
+       bp->b_error = 0;
+       bp->b_ops = t->bops;
+       bp->b_ops->verify_read(bp);
+       bp->b_flags &= ~LIBXFS_B_UNCHECKED;
+}
+
 static void
 stack_help(void)
 {
diff --git a/db/io.h b/db/io.h
index 7875119c63c0a7727941ee206b759083e1bf1bdd..71082e6ba1aab9e64fad81e6c00362b4453957c1 100644 (file)
--- a/db/io.h
+++ b/db/io.h
@@ -62,6 +62,7 @@ extern void     write_cur(void);
 extern void    set_cur(const struct typ *t, __int64_t d, int c, int ring_add,
                        bbmap_t *bbmap);
 extern void     ring_add(void);
+extern void    set_iocur_type(const struct typ *t);
 
 /*
  * returns -1 for unchecked, 0 for bad and 1 for good
index 04d0d56e0dcc22d2f956971dda3892e65a8b4cd7..b29f2a47a5907ebf42246129b64e9b338a264ec1 100644 (file)
--- a/db/type.c
+++ b/db/type.c
@@ -162,10 +162,11 @@ type_f(
                if (tt == NULL) {
                        dbprintf(_("no such type %s\n"), argv[1]);
                } else {
-                       if (iocur_top->typ == NULL) {
-                           dbprintf(_("no current object\n"));
-                       } else {
-                           iocur_top->typ = cur_typ = tt;
+                       if (iocur_top->typ == NULL)
+                               dbprintf(_("no current object\n"));
+                       else {
+                               cur_typ = tt;
+                               set_iocur_type(tt);
                        }
                }
        }