[Top] [All Lists]

[PATCH] logprint: Fix printing of AGF buffers

To: xfs@xxxxxxxxxxx
Subject: [PATCH] logprint: Fix printing of AGF buffers
From: Jan Kara <jack@xxxxxxx>
Date: Mon, 14 Jul 2014 16:45:00 +0200
Cc: Jan Kara <jack@xxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
Currently xfs_logprint doesn't show detailed data about AGF buffers and
instead always shows "Out of space". This is because xfs_agf_t has
additional fields and padding which we never read from disk and thus
buffer length is always smaller than the size of xfs_agf_t.

Fix the problem by only making sure we have enough data in the buffer
to contain all the information we want to print.

Signed-off-by: Jan Kara <jack@xxxxxxx>
 logprint/log_misc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/logprint/log_misc.c b/logprint/log_misc.c
index d482cf3fba57..e7306c08789a 100644
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c
@@ -367,7 +367,8 @@ xlog_print_trans_buffer(xfs_caddr_t *ptr, int len, int *i, 
int num_ops)
        } else if (be32_to_cpu(*(__be32 *)(*ptr)) == XFS_AGF_MAGIC) {
                agf = (xfs_agf_t *)(*ptr);
                printf(_("AGF Buffer: XAGF  "));
-               if (be32_to_cpu(head->oh_len) < sizeof(xfs_agf_t)) {
+               /* Make sure buffer contains all the data we want to print */
+               if (be32_to_cpu(head->oh_len) < offsetof(xfs_agf_t, agf_uuid)) {
                        printf(_("Out of space\n"));
                } else {

<Prev in Thread] Current Thread [Next in Thread>