From a0de03bbdd2f12ad6f8ab374cbe98dd907d1f4cd Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.com>
Date: Tue, 22 Jul 2014 11:59:51 +0000
Subject: [PATCH] Accepting request 241871 from
 home:jankara:branches:filesystems

Update to 3.2.1

OBS-URL: https://build.opensuse.org/request/show/241871
OBS-URL: https://build.opensuse.org/package/show/filesystems/xfsprogs?expand=0&rev=29
---
 ...-Fix-printing-of-AGF-and-AGI-buffers.patch | 60 +++++++++++++++++++
 xfsprogs-3.2.0.tar.gz                         |  3 -
 xfsprogs-3.2.1.tar.gz                         |  3 +
 xfsprogs.changes                              | 13 ++++
 xfsprogs.spec                                 |  4 +-
 5 files changed, 79 insertions(+), 4 deletions(-)
 create mode 100644 logprint-Fix-printing-of-AGF-and-AGI-buffers.patch
 delete mode 100644 xfsprogs-3.2.0.tar.gz
 create mode 100644 xfsprogs-3.2.1.tar.gz

diff --git a/logprint-Fix-printing-of-AGF-and-AGI-buffers.patch b/logprint-Fix-printing-of-AGF-and-AGI-buffers.patch
new file mode 100644
index 0000000..5c502f7
--- /dev/null
+++ b/logprint-Fix-printing-of-AGF-and-AGI-buffers.patch
@@ -0,0 +1,60 @@
+From 655b1e99f115f13f93143b69fe1a56d11f8651ee Mon Sep 17 00:00:00 2001
+From: Jan Kara <jack@suse.cz>
+Date: Mon, 14 Jul 2014 16:39:42 +0200
+Subject: [PATCH] logprint: Fix printing of AGF and AGI buffers
+
+Currently xfs_logprint doesn't show detailed data about AGF and AGI
+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 or xfs_agi_t respectively.
+
+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@suse.cz>
+---
+ logprint/log_misc.c | 20 ++++++++++++++++++--
+ 1 file changed, 18 insertions(+), 2 deletions(-)
+
+diff --git a/logprint/log_misc.c b/logprint/log_misc.c
+index d482cf3fba57..c9286c67b913 100644
+--- a/logprint/log_misc.c
++++ b/logprint/log_misc.c
+@@ -325,7 +325,15 @@ xlog_print_trans_buffer(xfs_caddr_t *ptr, int len, int *i, int num_ops)
+ 	} else if (be32_to_cpu(*(__be32 *)(*ptr)) == XFS_AGI_MAGIC) {
+ 		agi = (xfs_agi_t *)(*ptr);
+ 		printf(_("AGI Buffer: XAGI  "));
+-		if (be32_to_cpu(head->oh_len) < sizeof(xfs_agi_t) -
++		/*
++		 * v4 filesystems only contain the fields before the uuid.
++		 * Even v5 filesystems don't log any field beneath it. That
++		 * means that the size that is logged is almost always going to
++		 * be smaller than the structure itself. Hence we need to make
++		 * sure that the buffer contains all the data we want to print
++		 * rather than just check against the structure size.
++		 */
++		if (be32_to_cpu(head->oh_len) < offsetof(xfs_agi_t, agi_uuid) -
+ 				XFS_AGI_UNLINKED_BUCKETS*sizeof(xfs_agino_t)) {
+ 			printf(_("out of space\n"));
+ 		} else {
+@@ -367,7 +375,15 @@ 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)) {
++		/*
++		 * v4 filesystems only contain the fields before the uuid.
++		 * Even v5 filesystems don't log any field beneath it. That
++		 * means that the size that is logged is almost always going to
++		 * be smaller than the structure itself. Hence we need to make
++		 * sure that the buffer contains all the data we want to print
++		 * rather than just check against the structure size.
++		 */
++		if (be32_to_cpu(head->oh_len) < offsetof(xfs_agf_t, agf_uuid)) {
+ 			printf(_("Out of space\n"));
+ 		} else {
+ 			printf("\n");
+-- 
+1.8.1.4
+
diff --git a/xfsprogs-3.2.0.tar.gz b/xfsprogs-3.2.0.tar.gz
deleted file mode 100644
index e1f1c8f..0000000
--- a/xfsprogs-3.2.0.tar.gz
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:62a986afb3459718a5a915403483b022f8237d50c293aafd8392872c187fcbb3
-size 1465887
diff --git a/xfsprogs-3.2.1.tar.gz b/xfsprogs-3.2.1.tar.gz
new file mode 100644
index 0000000..00f9ef8
--- /dev/null
+++ b/xfsprogs-3.2.1.tar.gz
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:83f8ea4c38fe9f42b9f12cd523519287a9695f2cf4f3064e9e9a839f71185767
+size 1475624
diff --git a/xfsprogs.changes b/xfsprogs.changes
index 59e62c6..edfff3c 100644
--- a/xfsprogs.changes
+++ b/xfsprogs.changes
@@ -1,3 +1,16 @@
+-------------------------------------------------------------------
+Tue Jul 22 09:59:46 UTC 2014 - jack@suse.cz
+
+- Updated to 3.2.1
+  - fix xfs_mdrestore so that non-crc filesystem is properly restored as non-crc
+  - minor xfs_fsr fixes to be more robust
+  - various fixes to xfs_repair to properly fix filesystems with v5 superblock
+  - fix data corruption when using xfs_copy
+  - fix adding extended attributes using xfs_db
+  - add support for free inode btree feature
+logprint-Fix-printing-of-AGF-and-AGI-buffers.patch:
+  - fix printing of AGF and AGI buffers in xfs_logprint
+
 -------------------------------------------------------------------
 Mon May 19 14:19:11 UTC 2014 - jeffm@suse.com
 
diff --git a/xfsprogs.spec b/xfsprogs.spec
index f912ae5..c1a098d 100644
--- a/xfsprogs.spec
+++ b/xfsprogs.spec
@@ -27,7 +27,7 @@ BuildRequires:  libuuid-devel
 %else
 BuildRequires:  libuuid-devel
 %endif
-Version:        3.2.0
+Version:        3.2.1
 Release:        0
 %if 0%{?suse_version} >= 1010
 # hint for ZYPP
@@ -40,6 +40,7 @@ Group:          System/Filesystems
 Source0:        xfsprogs-%{version}.tar.gz
 Patch0:         xfsprogs-docdir.diff
 Patch1:         xfsprogs-ppc64.diff
+Patch2:         logprint-Fix-printing-of-AGF-and-AGI-buffers.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 
 %description
@@ -75,6 +76,7 @@ want to install xfsprogs.
 %patch0
 %endif
 %patch1
+%patch2 -p1
 
 %build
 export OPTIMIZER="-fPIC"