2.24.1: upgrade

This commit is contained in:
Karel Zak 2014-01-21 09:54:54 +01:00
parent 120f8c1351
commit ea09323fa7
5 changed files with 8 additions and 175 deletions

1
.gitignore vendored
View File

@ -29,3 +29,4 @@
/util-linux-2.23.2.tar.xz
/util-linux-2.24-rc1.tar.xz
/util-linux-2.24.tar.xz
/util-linux-2.24.1.tar.xz

View File

@ -1,122 +0,0 @@
diff -up util-linux-2.24/libfdisk/src/gpt.c.kzak util-linux-2.24/libfdisk/src/gpt.c
--- util-linux-2.24/libfdisk/src/gpt.c.kzak 2013-10-21 13:03:38.782957983 +0200
+++ util-linux-2.24/libfdisk/src/gpt.c 2013-10-23 12:16:01.062783977 +0200
@@ -410,6 +410,46 @@ static int gpt_mknew_header_from_bkp(str
return 0;
}
+static struct gpt_header *gpt_copy_header(struct fdisk_context *cxt,
+ struct gpt_header *src)
+{
+ struct gpt_header *res;
+
+ if (!cxt || !src)
+ return NULL;
+
+ res = calloc(1, sizeof(*res));
+ if (!res) {
+ fdisk_warn(cxt, _("failed to allocate GPT header"));
+ return NULL;
+ }
+
+ res->my_lba = src->alternative_lba;
+ res->alternative_lba = src->my_lba;
+
+ res->signature = src->signature;
+ res->revision = src->revision;
+ res->size = src->size;
+ res->npartition_entries = src->npartition_entries;
+ res->sizeof_partition_entry = src->sizeof_partition_entry;
+ res->first_usable_lba = src->first_usable_lba;
+ res->last_usable_lba = src->last_usable_lba;
+
+ memcpy(&res->disk_guid, &src->disk_guid, sizeof(src->disk_guid));
+
+
+ if (res->my_lba == GPT_PRIMARY_PARTITION_TABLE_LBA)
+ res->partition_entry_lba = cpu_to_le64(2);
+ else {
+ uint64_t esz = le32_to_cpu(src->npartition_entries) * sizeof(struct gpt_entry);
+ uint64_t esects = (esz + cxt->sector_size - 1) / cxt->sector_size;
+
+ res->partition_entry_lba = cpu_to_le64(cxt->total_sectors - 1 - esects);
+ }
+
+ return res;
+}
+
/*
* Builds a clean new GPT header (currently under revision 1.0).
*
@@ -776,10 +816,13 @@ static struct gpt_header *gpt_read_heade
else
free(ents);
+ DBG(LABEL, dbgprint("found valid GPT Header on LBA %ju", lba));
return header;
invalid:
free(header);
free(ents);
+
+ DBG(LABEL, dbgprint("read GPT Header on LBA %ju failed", lba));
return NULL;
}
@@ -1091,6 +1134,8 @@ static int gpt_probe_label(struct fdisk_
gpt = self_label(cxt);
+ /* TODO: it would be nice to support scenario when GPT headers are OK,
+ * but PMBR is corrupt */
mbr_type = valid_pmbr(cxt);
if (!mbr_type)
goto failed;
@@ -1102,20 +1147,36 @@ static int gpt_probe_label(struct fdisk_
gpt->pheader = gpt_read_header(cxt, GPT_PRIMARY_PARTITION_TABLE_LBA,
&gpt->ents);
- /*
- * TODO: If the primary GPT is corrupt, we must check the last LBA of the
- * device to see if it has a valid GPT Header and point to a valid GPT
- * Partition Entry Array.
- * If it points to a valid GPT Partition Entry Array, then software should
- * restore the primary GPT if allowed by platform policy settings.
- *
- * For now we just abort GPT probing!
- */
- if (!gpt->pheader || !gpt->ents)
+ if (gpt->pheader)
+ /* primary OK, try backup from alternative LBA */
+ gpt->bheader = gpt_read_header(cxt,
+ le64_to_cpu(gpt->pheader->alternative_lba),
+ NULL);
+ else
+ /* primary corrupted -- try last LBA */
+ gpt->bheader = gpt_read_header(cxt, last_lba(cxt), &gpt->ents);
+
+ if (!gpt->pheader && !gpt->bheader)
goto failed;
- /* OK, probing passed, now initialize backup header and fdisk variables. */
- gpt->bheader = gpt_read_header(cxt, last_lba(cxt), NULL);
+ /* primary OK, backup corrupted -- recovery */
+ if (gpt->pheader && !gpt->bheader) {
+ fdisk_warnx(cxt, _("The backup GPT table is corrupt, but the "
+ "primary appears OK, so that will be used."));
+ gpt->bheader = gpt_copy_header(cxt, gpt->pheader);
+ if (!gpt->bheader)
+ goto failed;
+ gpt_recompute_crc(gpt->bheader, gpt->ents);
+
+ /* primary corrupted, backup OK -- recovery */
+ } else if (!gpt->pheader && gpt->bheader) {
+ fdisk_warnx(cxt, _("The primary GPT table is corrupt, but the "
+ "backup appears OK, so that will be used."));
+ gpt->pheader = gpt_copy_header(cxt, gpt->bheader);
+ if (!gpt->pheader)
+ goto failed;
+ gpt_recompute_crc(gpt->pheader, gpt->ents);
+ }
cxt->label->nparts_max = le32_to_cpu(gpt->pheader->npartition_entries);
cxt->label->nparts_cur = partitions_in_use(gpt->pheader, gpt->ents);

View File

@ -1,45 +0,0 @@
From 71d842c01992b3678de4da4773ed54f08c0ab4f6 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 18 Nov 2013 11:27:35 +0100
Subject: [PATCH] lsblk: fix -D segfault
References: https://bugzilla.redhat.com/show_bug.cgi?id=1031262
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/lsblk.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 9f7f1b6..9b53be3 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -903,7 +903,7 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line
if (cxt->discard && p)
tt_line_set_data(ln, col, p);
else
- tt_line_set_data(ln, col, "0");
+ tt_line_set_data(ln, col, xstrdup("0"));
break;
case COL_DGRAN:
if (lsblk->bytes)
@@ -936,7 +936,7 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line
if (cxt->discard && p)
tt_line_set_data(ln, col, p);
else
- tt_line_set_data(ln, col, "0");
+ tt_line_set_data(ln, col, xstrdup("0"));
break;
case COL_WSAME:
if (lsblk->bytes)
@@ -948,7 +948,7 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line
"queue/write_same_max_bytes", &x) == 0)
p = size_to_human_string(SIZE_SUFFIX_1LETTER, x);
}
- tt_line_set_data(ln, col, p ? p : "0");
+ tt_line_set_data(ln, col, p ? p : xstrdup("0"));
break;
};
}
--
1.8.3.1

View File

@ -1 +1 @@
4fac6443427f575fc5f3531a4ad2ca01 util-linux-2.24.tar.xz
88d46ae23ca599ac5af9cf96b531590f util-linux-2.24.1.tar.xz

View File

@ -1,8 +1,8 @@
### Header
Summary: A collection of basic system utilities
Name: util-linux
Version: 2.24
Release: 2%{?dist}
Version: 2.24.1
Release: 1%{?dist}
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
Group: System Environment/Base
URL: http://en.wikipedia.org/wiki/Util-linux
@ -77,11 +77,6 @@ Requires: libmount = %{version}-%{release}
# 151635 - makeing /var/log/lastlog
Patch0: 2.23-login-lastlog-create.patch
# backport from v2.25: 1022217 - fdisk mishandles GPT corruption
Patch1: 2.25-libfdisk-gpt-recovery.patch
# backport from v2.25 (or v2.24.1) #1031262 - lsblk -D segfault
Patch2: 2.25-lsblk-D-segfault.patch
%description
The util-linux package contains a large variety of low-level system
utilities that are necessary for a Linux system to function. Among
@ -816,6 +811,10 @@ fi
%{_libdir}/python*/site-packages/libmount/*
%changelog
* Mon Jan 20 2014 Karel Zak <kzak@redhat.com> 2.24.1-1
- upgrade to stable release 2.24.1
ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.24/v2.24.1-ReleaseNotes
* Mon Nov 18 2013 Karel Zak <kzak@redhat.com> 2.24-2
- fix #1031262 - lsblk -D segfault