2.26.2-1: upgrade to stable release

This commit is contained in:
Karel Zak 2015-04-30 12:55:13 +02:00
parent 3fe05ecbfc
commit 0b35981e89
8 changed files with 7 additions and 557 deletions

1
.gitignore vendored
View File

@ -41,3 +41,4 @@
/util-linux-2.26-rc2.tar.xz
/util-linux-2.26.tar.xz
/util-linux-2.26.1.tar.xz
/util-linux-2.26.2.tar.xz

View File

@ -1,62 +0,0 @@
From 376484140cb7ef117616ac2880bd8ec18381b18f Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 13 Apr 2015 10:29:00 +0200
Subject: [PATCH 2/5] libfdisk: (dos) retain existing boot flag when resizing
a partition
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1210912
Signed-off-by: Karel Zak <kzak@redhat.com>
Co-Author: awilliam@redhat.com
---
libfdisk/src/dos.c | 8 +++++---
libfdisk/src/partition.c | 3 +--
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index dce9829..6468071 100644
--- a/libfdisk/src/dos.c
+++ b/libfdisk/src/dos.c
@@ -1221,7 +1221,7 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
}
}
- set_partition(cxt, n, 0, start, stop, sys, pa && pa->boot == 1 ? 1 : 0);
+ set_partition(cxt, n, 0, start, stop, sys, fdisk_partition_is_bootable(pa));
if (n > 4) {
struct pte *pe = self_pte(cxt, n);
set_partition(cxt, n - 1, 1, pe->offset, stop,
@@ -1963,13 +1963,15 @@ static int dos_set_partition(struct fdisk_context *cxt, size_t n,
set_partition(cxt, n, 0, start, start + size - 1,
pa->type ? pa->type->code : p->sys_ind,
- pa->boot == 1);
+ FDISK_IS_UNDEF(pa->boot) ?
+ p->boot_ind == ACTIVE_FLAG :
+ fdisk_partition_is_bootable(pa));
} else {
DBG(LABEL, ul_debug("DOS: keep size, modify properties"));
if (pa->type)
p->sys_ind = pa->type->code;
if (!FDISK_IS_UNDEF(pa->boot))
- p->boot_ind = pa->boot == 1 ? ACTIVE_FLAG : 0;
+ p->boot_ind = fdisk_partition_is_bootable(pa) ? ACTIVE_FLAG : 0;
}
partition_set_changed(cxt, n, 1);
diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c
index 03c0eb5..a0b9ca5 100644
--- a/libfdisk/src/partition.c
+++ b/libfdisk/src/partition.c
@@ -757,8 +757,7 @@ int fdisk_partition_to_string(struct fdisk_partition *pa,
}
break;
case FDISK_FIELD_BOOT:
- if (fdisk_partition_is_bootable(pa))
- rc = asprintf(&p, "%c", pa->boot ? '*' : ' ');
+ p = fdisk_partition_is_bootable(pa) ? strdup("*") : NULL;
break;
case FDISK_FIELD_START:
if (fdisk_partition_has_start(pa)) {
--
2.1.0

View File

@ -1,41 +0,0 @@
From 6ece2f94849d5c61920d435804fb72b59503686f Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 25 Mar 2015 11:08:22 +0100
Subject: [PATCH 1/5] libfdisk: fix symbols versioning script
Really stupid copy & past mistake. The libfdisk symbols should not be
prefixed by MOUNT_ suffix.
This change makes binaries linked with libfdisk 2.26 incompatible with
new libfdisk. Fortunately, 2.26 has been the first release and very
probably the library has been used for util-linux fdisks only.
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libfdisk/src/libfdisk.sym | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/libfdisk/src/libfdisk.sym b/libfdisk/src/libfdisk.sym
index 8364fe7..541b247 100644
--- a/libfdisk/src/libfdisk.sym
+++ b/libfdisk/src/libfdisk.sym
@@ -1,11 +1,12 @@
/*
* The symbol versioning ensures that a new application requiring symbol foo;
- * can't run with old libblkid.so not providing foo;
- * version info can't enforce this since we never change the SONAME.
+ * can't run with old library.so not providing foo.
+
+ * Version info can't enforce this since we never change the SONAME.
*
- * Copyright (C) 2014 Karel Zak <kzak@redhat.com>
+ * Copyright (C) 2014-2015 Karel Zak <kzak@redhat.com>
*/
-MOUNT_2.26 {
+FDISK_2.26 {
global:
fdisk_add_partition;
fdisk_align_lba;
--
2.1.0

View File

@ -1,357 +0,0 @@
From 4bcc9fdca681b48c54954924608b8c337d61fbad Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 13 Apr 2015 13:40:25 +0200
Subject: [PATCH 4/5] libfdisk: support bootbits protection from (p)MBR
Signed-off-by: Karel Zak <kzak@redhat.com>
---
include/pt-mbr.h | 1 +
libfdisk/docs/libfdisk-sections.txt | 6 ++-
libfdisk/src/context.c | 33 ++++++++++++++++-
libfdisk/src/dos.c | 5 ++-
libfdisk/src/fdiskP.h | 4 +-
libfdisk/src/gpt.c | 6 ++-
libfdisk/src/libfdisk.h.in | 2 +
libfdisk/src/libfdisk.sym | 5 +++
libfdisk/src/sgi.c | 2 +-
libfdisk/src/sun.c | 2 +-
libfdisk/src/utils.c | 73 ++++++++++++++++++++++++++-----------
11 files changed, 109 insertions(+), 30 deletions(-)
diff --git a/include/pt-mbr.h b/include/pt-mbr.h
index 1279e3c..6957b95 100644
--- a/include/pt-mbr.h
+++ b/include/pt-mbr.h
@@ -11,6 +11,7 @@ struct dos_partition {
} __attribute__((packed));
#define MBR_PT_OFFSET 0x1be
+#define MBR_PT_BOOTBITS_SIZE 440
static inline struct dos_partition *mbr_get_partition(unsigned char *mbr, int i)
{
diff --git a/libfdisk/docs/libfdisk-sections.txt b/libfdisk/docs/libfdisk-sections.txt
index 676d500..2d5cd92 100644
--- a/libfdisk/docs/libfdisk-sections.txt
+++ b/libfdisk/docs/libfdisk-sections.txt
@@ -279,6 +279,7 @@ fdisk_unref_table
fdisk_context
fdisk_assign_device
fdisk_deassign_device
+fdisk_enable_bootbits_protection
fdisk_enable_details
fdisk_enable_listonly
fdisk_get_alignment_offset
@@ -297,22 +298,23 @@ fdisk_get_parent
fdisk_get_physector_size
fdisk_get_sector_size
fdisk_get_size_unit
-FDISK_PLURAL
-FDISK_SINGULAR
fdisk_get_unit
fdisk_get_units_per_sector
fdisk_has_label
+fdisk_has_protected_bootbits
fdisk_is_details
fdisk_is_labeltype
fdisk_is_listonly
fdisk_is_readonly
fdisk_new_context
fdisk_new_nested_context
+FDISK_PLURAL
fdisk_ref_context
fdisk_set_first_lba
fdisk_set_last_lba
fdisk_set_size_unit
fdisk_set_unit
+FDISK_SINGULAR
fdisk_unref_context
fdisk_use_cylinders
</SECTION>
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 84867b0..efc961c 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -94,12 +94,13 @@ static int init_nested_from_parent(struct fdisk_context *cxt, int isnew)
cxt->user_log_sector = parent->user_log_sector;
cxt->user_pyh_sector = parent->user_pyh_sector;
- /* parent <--> nested independent setting, initialize for new nested
+ /* parent <--> nested independent setting, initialize for new nested
* contexts only */
if (isnew) {
cxt->listonly = parent->listonly;
cxt->display_details = parent->display_details;
cxt->display_in_cyl_units = parent->display_in_cyl_units;
+ cxt->protect_bootbits = parent->protect_bootbits;
}
free(cxt->dev_path);
@@ -304,6 +305,36 @@ int fdisk_has_label(struct fdisk_context *cxt)
}
/**
+ * fdisk_has_protected_bootbits:
+ * @cxt: fdisk context
+ *
+ * Returns: return 1 if boot bits protection enabled.
+ */
+int fdisk_has_protected_bootbits(struct fdisk_context *cxt)
+{
+ return cxt && cxt->protect_bootbits;
+}
+
+/**
+ * fdisk_enable_bootbits_protection:
+ * @cxt: fdisk context
+ * @enable: 1 or 0
+ *
+ * The library zeroizes all the first sector when create a new disk label by
+ * default. This function allows to control this behavior. For now it's
+ * supported for MBR and GPT.
+ *
+ * Returns: 0 on success, < 0 on error.
+ */
+int fdisk_enable_bootbits_protection(struct fdisk_context *cxt, int enable)
+{
+ if (!cxt)
+ return -EINVAL;
+ cxt->protect_bootbits = enable ? 1 : 0;
+ return 0;
+}
+
+/**
* fdisk_get_npartitions:
* @cxt: context
*
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index 6468071..f2308e3 100644
--- a/libfdisk/src/dos.c
+++ b/libfdisk/src/dos.c
@@ -659,7 +659,10 @@ static int dos_create_disklabel(struct fdisk_context *cxt)
if (!has_id)
random_get_bytes(&id, sizeof(id));
- rc = fdisk_init_firstsector_buffer(cxt);
+ if (fdisk_has_protected_bootbits(cxt))
+ rc = fdisk_init_firstsector_buffer(cxt, 0, MBR_PT_BOOTBITS_SIZE);
+ else
+ rc = fdisk_init_firstsector_buffer(cxt, 0, 0);
if (rc)
return rc;
dos_init(cxt);
diff --git a/libfdisk/src/fdiskP.h b/libfdisk/src/fdiskP.h
index dc561f3..0ca498d 100644
--- a/libfdisk/src/fdiskP.h
+++ b/libfdisk/src/fdiskP.h
@@ -350,6 +350,7 @@ struct fdisk_context {
unsigned int readonly : 1, /* don't write to the device */
display_in_cyl_units : 1, /* for obscure labels */
display_details : 1, /* expert display mode */
+ protect_bootbits : 1, /* don't zeroize fll irst sector */
listonly : 1; /* list partition, nothing else */
int sizeunit; /* SIZE fields, FDISK_SIZEUNIT_* */
@@ -402,7 +403,8 @@ extern int fdisk_apply_user_device_properties(struct fdisk_context *cxt);
extern void fdisk_zeroize_device_properties(struct fdisk_context *cxt);
/* utils.c */
-extern int fdisk_init_firstsector_buffer(struct fdisk_context *cxt);
+extern int fdisk_init_firstsector_buffer(struct fdisk_context *cxt,
+ unsigned int protect_off, unsigned int protect_size);
extern int fdisk_read_firstsector(struct fdisk_context *cxt);
extern char *fdisk_partname(const char *dev, size_t partno);
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
index 61b0a32..22e2d16 100644
--- a/libfdisk/src/gpt.c
+++ b/libfdisk/src/gpt.c
@@ -27,6 +27,7 @@
#include "bitops.h"
#include "strutils.h"
#include "all-io.h"
+#include "pt-mbr.h"
/**
* SECTION: gpt
@@ -406,7 +407,10 @@ static int gpt_mknew_pmbr(struct fdisk_context *cxt)
if (!cxt || !cxt->firstsector)
return -ENOSYS;
- rc = fdisk_init_firstsector_buffer(cxt);
+ if (fdisk_has_protected_bootbits(cxt))
+ rc = fdisk_init_firstsector_buffer(cxt, 0, MBR_PT_BOOTBITS_SIZE);
+ else
+ rc = fdisk_init_firstsector_buffer(cxt, 0, 0);
if (rc)
return rc;
diff --git a/libfdisk/src/libfdisk.h.in b/libfdisk/src/libfdisk.h.in
index 3aeef1e..78c0728 100644
--- a/libfdisk/src/libfdisk.h.in
+++ b/libfdisk/src/libfdisk.h.in
@@ -211,6 +211,8 @@ enum {
int fdisk_set_size_unit(struct fdisk_context *cxt, int unit);
int fdisk_get_size_unit(struct fdisk_context *cxt);
+int fdisk_has_protected_bootbits(struct fdisk_context *cxt);
+int fdisk_enable_bootbits_protection(struct fdisk_context *cxt, int enable);
/* parttype.c */
struct fdisk_parttype *fdisk_new_parttype(void);
diff --git a/libfdisk/src/libfdisk.sym b/libfdisk/src/libfdisk.sym
index 541b247..9f720ff 100644
--- a/libfdisk/src/libfdisk.sym
+++ b/libfdisk/src/libfdisk.sym
@@ -239,3 +239,8 @@ global:
local:
*;
};
+
+FDISK_2.27 {
+ fdisk_enable_bootbits_protection;
+ fdisk_has_protected_bootbits;
+} FDISK_2.26;
diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c
index cd4cedf..7cc68b5 100644
--- a/libfdisk/src/sgi.c
+++ b/libfdisk/src/sgi.c
@@ -965,7 +965,7 @@ static int sgi_create_disklabel(struct fdisk_context *cxt)
}
}
#endif
- rc = fdisk_init_firstsector_buffer(cxt);
+ rc = fdisk_init_firstsector_buffer(cxt, 0, 0);
if (rc)
return rc;
diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c
index d99c39f..27e3bdd 100644
--- a/libfdisk/src/sun.c
+++ b/libfdisk/src/sun.c
@@ -209,7 +209,7 @@ static int sun_create_disklabel(struct fdisk_context *cxt)
assert(fdisk_is_label(cxt, SUN));
/* map first sector to header */
- rc = fdisk_init_firstsector_buffer(cxt);
+ rc = fdisk_init_firstsector_buffer(cxt, 0, 0);
if (rc)
return rc;
diff --git a/libfdisk/src/utils.c b/libfdisk/src/utils.c
index 482a306..cc470d9 100644
--- a/libfdisk/src/utils.c
+++ b/libfdisk/src/utils.c
@@ -10,14 +10,49 @@
* @short_description: misc fdisk functions
*/
+static int read_from_device(struct fdisk_context *cxt,
+ unsigned char *buf,
+ uintmax_t start, size_t size)
+{
+ ssize_t r;
+
+ assert(cxt);
+
+ DBG(CXT, ul_debugobj(cxt, "reading: offset=%ju, size=%zu",
+ start, size));
+
+ r = lseek(cxt->dev_fd, start, SEEK_SET);
+ if (r == -1)
+ {
+ DBG(CXT, ul_debugobj(cxt, "failed to seek to offset %ju: %m", start));
+ return -errno;
+ }
+
+ r = read(cxt->dev_fd, buf, size);
+ if (r < 0 || r != size) {
+ if (!errno)
+ errno = EINVAL; /* probably too small file/device */
+ DBG(CXT, ul_debugobj(cxt, "failed to read %zu from offset %ju: %m",
+ size, start));
+ return -errno;
+ }
+
+ return 0;
+}
+
+
/*
* Zeros in-memory first sector buffer
*/
-int fdisk_init_firstsector_buffer(struct fdisk_context *cxt)
+int fdisk_init_firstsector_buffer(struct fdisk_context *cxt,
+ unsigned int protect_off,
+ unsigned int protect_size)
{
if (!cxt)
return -EINVAL;
+ assert(protect_off + protect_size <= cxt->sector_size);
+
if (!cxt->firstsector || cxt->firstsector_bufsz != cxt->sector_size) {
/* Let's allocate a new buffer if no allocated yet, or the
* current buffer has incorrect size */
@@ -36,43 +71,37 @@ int fdisk_init_firstsector_buffer(struct fdisk_context *cxt)
DBG(CXT, ul_debugobj(cxt, "zeroize in-memory first sector buffer"));
memset(cxt->firstsector, 0, cxt->firstsector_bufsz);
+
+ if (protect_size) {
+ /*
+ * It would be possible to reuse data from cxt->firstsector
+ * (call memset() for non-protected area only) and avoid one
+ * read() from the device, but it seems like a too fragile
+ * solution as we have no clue about stuff in the buffer --
+ * maybe it was already modified. Let's re-read from the device
+ * to be sure. -- kzak 13-Apr-2015
+ */
+ DBG(CXT, ul_debugobj(cxt, "first sector protection enabled -- re-reading"));
+ read_from_device(cxt, cxt->firstsector, protect_off, protect_size);
+ }
return 0;
}
int fdisk_read_firstsector(struct fdisk_context *cxt)
{
- ssize_t r;
int rc;
assert(cxt);
assert(cxt->sector_size);
- rc = fdisk_init_firstsector_buffer(cxt);
+ rc = fdisk_init_firstsector_buffer(cxt, 0, 0);
if (rc)
return rc;
assert(cxt->sector_size == cxt->firstsector_bufsz);
- DBG(CXT, ul_debugobj(cxt, "reading first sector "
- "buffer [sector_size=%lu]", cxt->sector_size));
-
- r = lseek(cxt->dev_fd, 0, SEEK_SET);
- if (r == -1)
- {
- DBG(CXT, ul_debugobj(cxt, "failed to seek to first sector %m"));
- return -errno;
- }
-
- r = read(cxt->dev_fd, cxt->firstsector, cxt->sector_size);
- if (r != cxt->sector_size) {
- if (!errno)
- errno = EINVAL; /* probably too small file/device */
- DBG(CXT, ul_debugobj(cxt, "failed to read first sector %m"));
- return -errno;
- }
-
- return 0;
+ return read_from_device(cxt, cxt->firstsector, 0, cxt->sector_size);
}
/**
--
2.1.0

View File

@ -1,26 +0,0 @@
From 67414f247ef7a3177c1349de7e18fbfe7ad5f904 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 13 Apr 2015 13:41:10 +0200
Subject: [PATCH 5/5] sfdisk: enable bootbits protection
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1210428
Signed-off-by: Karel Zak <kzak@redhat.com>
---
disk-utils/sfdisk.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 8846df8..dcdae33 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -190,6 +190,7 @@ static void sfdisk_init(struct sfdisk *sf)
if (!sf->cxt)
err(EXIT_FAILURE, _("failed to allocate libfdisk context"));
fdisk_set_ask(sf->cxt, ask_callback, (void *) sf);
+ fdisk_enable_bootbits_protection(sf->cxt, 1);
if (sf->label_nested) {
struct fdisk_context *x = fdisk_new_nested_context(sf->cxt,
--
2.1.0

View File

@ -1,62 +0,0 @@
From 3275c1ac6d28c2257eb031277510bc9da99deedd Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 13 Apr 2015 12:08:50 +0200
Subject: [PATCH 3/5] sfdisk: improve -N warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
---
disk-utils/sfdisk.8 | 9 ++++++++-
disk-utils/sfdisk.c | 9 +++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/disk-utils/sfdisk.8 b/disk-utils/sfdisk.8
index 66a8f99..0d63b6b 100644
--- a/disk-utils/sfdisk.8
+++ b/disk-utils/sfdisk.8
@@ -57,7 +57,14 @@ input format. If standard input is a terminal, then \fBsfdisk\fR starts an
interactive session.
.sp
If the option \fB\-N\fR is specified, then the changes are applied to
-the partition addressed by \fIpartition-number\fR.
+the partition addressed by \fIpartition-number\fR. The unspecified fields
+of the partition are not modified.
+.sp
+Note that it's possible to address unused partition by \fB\-N\fR. For example
+MBR always contains 4 partitions, but the number of the used partitions may be
+smaller. In this case sfdisk follows the default values from the partition
+table and it does not use built-in defaults for the unused partition specified
+by \fB\-N\fR. See also \fB\---append\fR.
.TP
.BR \-a , " \-\-activate \fIdevice\fR [" \fIpartition-number\fR...]
Switch on the bootable flag. If no \fIpartition-number\fR is specified,
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 2e89d94..8846df8 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -1109,16 +1109,21 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
*/
if (partno >= 0) {
size_t n;
+
if (!fdisk_has_label(sf->cxt))
errx(EXIT_FAILURE, _("%s: cannot modify partition %d: "
"no partition table was found"),
- devname, partno);
+ devname, partno + 1);
n = fdisk_get_npartitions(sf->cxt);
if ((size_t) partno > n)
errx(EXIT_FAILURE, _("%s: cannot modify partition %d: "
"partition table contains only %zu "
"partitions"),
- devname, partno, n);
+ devname, partno + 1, n);
+
+ if (!fdisk_is_partition_used(sf->cxt, partno))
+ fdisk_warnx(sf->cxt, _("warning: %s: partition %d is not defined yet"),
+ devname, partno + 1);
created = 1;
next_partno = partno;
}
--
2.1.0

View File

@ -1 +1 @@
2308850946766677f3fabe0685e85de8 util-linux-2.26.1.tar.xz
9bdf368c395f1b70325d0eb22c7f48fb util-linux-2.26.2.tar.xz

View File

@ -1,7 +1,7 @@
### Header
Summary: A collection of basic system utilities
Name: util-linux
Version: 2.26.1
Version: 2.26.2
Release: 1%{?dist}
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
Group: System Environment/Base
@ -78,13 +78,6 @@ Requires: libfdisk = %{version}-%{release}
# 151635 - makeing /var/log/lastlog
Patch0: 2.23-login-lastlog-create.patch
# upstream v2.27 / v2.26.2 backports (#1210428 and #1210912)
Patch1: 2.27-libfdisk-fix-symbols-versioning-script.patch
Patch2: 2.27-libfdisk-dos-retain-existing-boot-flag-when-resizing.patch
Patch3: 2.27-sfdisk-improve-N-warnings.patch
Patch4: 2.27-libfdisk-support-bootbits-protection-from-p-MBR.patch
Patch5: 2.27-sfdisk-enable-bootbits-protection.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
@ -886,6 +879,10 @@ exit 0
%{_libdir}/python*/site-packages/libmount/*
%changelog
* Thu Apr 30 2015 Karel Zak <kzak@redhat.com> 2.26.2-1
- upgrade to v2.26.2
ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.26/v2.26.2-ReleaseNotes
* Mon Apr 13 2015 Karel Zak <kzak@redhat.com> 2.26.1-1
- upgrade to v2.26.1
ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.26/v2.26.1-ReleaseNotes