From b7679338df5635121b1ebd2e9e28b47691bd8f56 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 9 Nov 2009 17:46:21 +0000 Subject: [PATCH] - Fix error when creating a fresh dasd disk on a dasd device with a corrupted dasd label (#533808) --- parted-1.9.0-dasd-533808.patch | 114 +++++++++++++++++++++++++++++++++ parted.spec | 8 ++- 2 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 parted-1.9.0-dasd-533808.patch diff --git a/parted-1.9.0-dasd-533808.patch b/parted-1.9.0-dasd-533808.patch new file mode 100644 index 0000000..cabe334 --- /dev/null +++ b/parted-1.9.0-dasd-533808.patch @@ -0,0 +1,114 @@ +diff -up parted-1.9.0/libparted/arch/linux.c.dasd2 parted-1.9.0/libparted/arch/linux.c +--- parted-1.9.0/libparted/arch/linux.c.dasd2 2009-11-09 18:41:58.000000000 +0100 ++++ parted-1.9.0/libparted/arch/linux.c 2009-11-09 18:41:58.000000000 +0100 +@@ -22,6 +22,9 @@ + + #include + #include ++#if defined __s390__ || defined __s390x__ ++#include ++#endif + + #include + #include +@@ -1079,7 +1082,7 @@ init_dasd (PedDevice* dev, const char* m + { + struct stat dev_stat; + struct hd_geometry geo; +- char *errstr = 0; ++ dasd_information_t dasd_info; + + if (!_device_stat (dev, &dev_stat)) + goto error; +@@ -1115,15 +1118,18 @@ init_dasd (PedDevice* dev, const char* m + dev->hw_geom = dev->bios_geom; + } + ++ if (!ioctl(arch_specific->fd, BIODASDINFO, &dasd_info)) { ++ arch_specific->devno = dasd_info.devno; ++ } else { ++ arch_specific->devno = arch_specific->major * 256 + ++ arch_specific->minor; ++ } ++ + dev->model = strdup (model_name); + + ped_device_close (dev); + return 1; + +- ped_exception_throw ( PED_EXCEPTION_ERROR, +- PED_EXCEPTION_IGNORE_CANCEL, +- errstr ); +- + error_close_dev: + ped_device_close (dev); + error: +diff -up parted-1.9.0/libparted/arch/linux.h.dasd2 parted-1.9.0/libparted/arch/linux.h +--- parted-1.9.0/libparted/arch/linux.h.dasd2 2009-11-09 18:41:58.000000000 +0100 ++++ parted-1.9.0/libparted/arch/linux.h 2009-11-09 18:42:36.000000000 +0100 +@@ -31,6 +31,7 @@ struct _LinuxSpecific { + char* dmtype; /**< device map target type */ + #if defined(__s390__) || defined(__s390x__) + unsigned int real_sector_size; ++ unsigned int devno; + #endif + #if HAVE_BLKID_BLKID_H + blkid_probe probe; +diff -up parted-1.9.0/libparted/labels/dasd.c.dasd2 parted-1.9.0/libparted/labels/dasd.c +--- parted-1.9.0/libparted/labels/dasd.c.dasd2 2009-11-09 18:41:58.000000000 +0100 ++++ parted-1.9.0/libparted/labels/dasd.c 2009-11-09 18:42:59.000000000 +0100 +@@ -70,6 +70,7 @@ typedef struct { + + typedef struct { + unsigned int format_type; ++ volume_label_t vlabel; + } DasdDiskSpecific; + + static PedDiskType dasd_disk_type; +@@ -80,6 +81,7 @@ dasd_alloc (const PedDevice* dev) + PedDisk* disk; + LinuxSpecific* arch_specific; + DasdDiskSpecific *disk_specific; ++ char volser[7]; + + PED_ASSERT (dev != NULL, return NULL); + +@@ -97,6 +99,15 @@ dasd_alloc (const PedDevice* dev) + /* CDL format, newer */ + disk_specific->format_type = 2; + ++ /* Setup volume label (for fresh disks) */ ++ snprintf(volser, sizeof(volser), "0X%04X", arch_specific->devno); ++ vtoc_volume_label_init(&disk_specific->vlabel); ++ vtoc_volume_label_set_key(&disk_specific->vlabel, "VOL1"); ++ vtoc_volume_label_set_label(&disk_specific->vlabel, "VOL1"); ++ vtoc_volume_label_set_volser(&disk_specific->vlabel, volser); ++ vtoc_set_cchhb(&disk_specific->vlabel.vtoc, ++ VTOC_START_CC, VTOC_START_HH, 0x01); ++ + return disk; + } + +@@ -217,6 +228,9 @@ dasd_read (PedDisk* disk) + if (fdasd_check_volume(&anchor, arch_specific->fd)) + goto error_close_dev; + ++ /* Save volume label (read by fdasd_check_volume) for writing */ ++ memcpy(&disk_specific->vlabel, anchor.vlabel, sizeof(volume_label_t)); ++ + if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE) + anchor.big_disk++; + +@@ -477,10 +491,8 @@ dasd_write (const PedDisk* disk) + /* initialize the anchor */ + fdasd_initialize_anchor(&anchor); + fdasd_get_geometry(&anchor, arch_specific->fd); +- +- /* check dasd for labels and vtoc */ +- if (fdasd_check_volume(&anchor, arch_specific->fd)) +- goto error; ++ memcpy(anchor.vlabel, &disk_specific->vlabel, sizeof(volume_label_t)); ++ anchor.vlabel_changed++; + + if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE) + anchor.big_disk++; diff --git a/parted.spec b/parted.spec index 56bb618..6488287 100644 --- a/parted.spec +++ b/parted.spec @@ -4,7 +4,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 1.9.0 -Release: 21%{?dist} +Release: 22%{?dist} License: GPLv3+ Group: Applications/System URL: http://www.gnu.org/software/parted @@ -27,6 +27,7 @@ Patch16: %{name}-1.9.0-ped_partition_is_busy-no-exception.patch Patch17: %{name}-1.9.0-gpt-big-endian.patch Patch18: %{name}-1.9.0-export-alignment-info.patch Patch19: %{name}-1.9.0-dasd-fixes.patch +Patch20: %{name}-1.9.0-dasd-533808.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: e2fsprogs-devel @@ -82,6 +83,7 @@ Parted library, you need to install this package. %patch17 -p1 -b .gpt-big-endian %patch18 -p1 -b .export-align %patch19 -p1 -b .dasd +%patch20 -p1 -b .dasd2 aclocal --force -I m4 autoconf --force autoheader --force @@ -147,6 +149,10 @@ fi %{_exec_prefix}/%{_lib}/pkgconfig/libparted.pc %changelog +* Mon Nov 9 2009 Hans de Goede 1.9.0-22 +- Fix error when creating a fresh dasd disk on a dasd device + with a corrupted dasd label (#533808) + * Fri Nov 6 2009 Hans de Goede 1.9.0-21 - Fix a compiler warning which is causing build errors (#532425)