Add upstream patch to correct uninitialized fsid variable

(possible fix for RHBZ#863978).
This commit is contained in:
Richard W.M. Jones 2012-10-10 12:46:04 +00:00
parent b5e03c726d
commit 089650c0d7
2 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,55 @@
From 6eba9002956ac40db87d42fb653a0524dc568810 Mon Sep 17 00:00:00 2001
From: Goffredo Baroncelli <kreijack@inwind.it>
Date: Tue, 4 Sep 2012 19:59:26 +0200
Subject: [PATCH 1/1] Correct un-initialized fsid variable
---
disk-io.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/disk-io.c b/disk-io.c
index b21a87f..0395205 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -910,6 +910,7 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr)
{
u8 fsid[BTRFS_FSID_SIZE];
+ int fsid_is_initialized = 0;
struct btrfs_super_block buf;
int i;
int ret;
@@ -936,15 +937,26 @@ int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr)
if (ret < sizeof(buf))
break;
- if (btrfs_super_bytenr(&buf) != bytenr ||
- strncmp((char *)(&buf.magic), BTRFS_MAGIC,
+ if (btrfs_super_bytenr(&buf) != bytenr )
+ continue;
+ /* if magic is NULL, the device was removed */
+ if (buf.magic == 0 && i == 0)
+ return -1;
+ if (strncmp((char *)(&buf.magic), BTRFS_MAGIC,
sizeof(buf.magic)))
continue;
- if (i == 0)
+ if (!fsid_is_initialized) {
memcpy(fsid, buf.fsid, sizeof(fsid));
- else if (memcmp(fsid, buf.fsid, sizeof(fsid)))
+ fsid_is_initialized = 1;
+ } else if (memcmp(fsid, buf.fsid, sizeof(fsid))) {
+ /*
+ * the superblocks (the original one and
+ * its backups) contain data of different
+ * filesystems -> the super cannot be trusted
+ */
continue;
+ }
if (btrfs_super_generation(&buf) > transid) {
memcpy(sb, &buf, sizeof(*sb));
--
1.7.7.6

View File

@ -1,6 +1,6 @@
Name: btrfs-progs
Version: 0.19.20120817git043a639
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Userspace programs for btrfs
Group: System Environment/Base
@ -14,6 +14,7 @@ Patch3: Btrfs-progs-add-btrfs-device-ready-command.patch
Patch4: Btrfs-progs-detect-if-the-disk-we-are-formatting-is-.patch
Patch5: Btrfs-progs-only-enforce-a-maximum-size-if-we-specif.patch
Patch6: btrfs-init-dev-list.patch
Patch7: btrfs-progs-correct-uninitialized-fsid-variable.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -34,6 +35,7 @@ check, modify and correct any inconsistencies in the btrfs filesystem.
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%build
make CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags}
@ -70,6 +72,10 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man8/btrfs.8.gz
%changelog
* Wed Oct 10 2012 Richard W.M. Jones <rjones@redhat.com> 0.19.20120817git043a639-2
- Add upstream patch to correct uninitialized fsid variable
(possible fix for RHBZ#863978).
* Fri Aug 17 2012 Josef Bacik <josef@toxicpanda.com> 0.19.20120817git043a639-1
- update to latest btrfs-progs