rpms/parted/devel parted-1.7.1-O_DIRECT.patch, NONE, 1.1 parted-1.7.1-dasd.patch, NONE, 1.1 parted.spec, 1.74, 1.75 parted-1.7.0-dasd.patch, 1.2, NONE parted-1.7.1-dasdfixes.patch, 1.1, NONE

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Thu Jun 22 18:26:56 UTC 2006


Author: dcantrel

Update of /cvs/dist/rpms/parted/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv3373

Modified Files:
	parted.spec 
Added Files:
	parted-1.7.1-O_DIRECT.patch parted-1.7.1-dasd.patch 
Removed Files:
	parted-1.7.0-dasd.patch parted-1.7.1-dasdfixes.patch 
Log Message:
- Roll dasd patches together
- Use O_DIRECT to prevent first partition corruption on GPT disks


parted-1.7.1-O_DIRECT.patch:
 linux.c |   39 ++++++++++++++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 7 deletions(-)

--- NEW FILE parted-1.7.1-O_DIRECT.patch ---
diff -urN parted-1.7.1.orig/libparted/arch/linux.c parted-1.7.1/libparted/arch/linux.c
--- parted-1.7.1.orig/libparted/arch/linux.c	2006-06-22 14:18:31.000000000 -0400
+++ parted-1.7.1/libparted/arch/linux.c	2006-06-22 14:24:59.000000000 -0400
@@ -30,6 +30,7 @@
 #include <libgen.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <syscall.h>
 #include <unistd.h>
@@ -1212,7 +1213,7 @@
                 if (!name)
                         break;
                 if (!_partition_is_mounted_by_path (name)) {
-                        fd = open (name, O_WRONLY, 0);
+                        fd = open (name, O_WRONLY | O_DIRECT, 0);
                         if (fd > 0) {
                                 ioctl (fd, BLKFLSBUF);
                                 close (fd);
@@ -1228,11 +1229,11 @@
         LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
 
 retry:
-        arch_specific->fd = open (dev->path, O_RDWR);
+        arch_specific->fd = open (dev->path, O_RDWR | O_DIRECT);
         if (arch_specific->fd == -1) {
                 char*   rw_error_msg = strerror (errno);
 
-                arch_specific->fd = open (dev->path, O_RDONLY);
+                arch_specific->fd = open (dev->path, O_RDONLY | O_DIRECT);
                 if (arch_specific->fd == -1) {
                         if (ped_exception_throw (
                                 PED_EXCEPTION_ERROR,
@@ -1375,6 +1376,7 @@
         int                     status;
         PedExceptionOption      ex_status;
         size_t                  read_length = count * dev->sector_size;
+        void*                   diobuf;
 
         PED_ASSERT (dev->sector_size % 512 == 0, return 0);
 
@@ -1412,8 +1414,12 @@
                 }
         }
 
+        if (posix_memalign(&diobuf, PED_SECTOR_SIZE, count * PED_SECTOR_SIZE) != 0)
+                return 0;
         while (1) {
-                status = read (arch_specific->fd, buffer, read_length);
+                status = read (arch_specific->fd, diobuf, read_length);
+                if (status > 0)
+                        memcpy(buffer, diobuf, status);
                 if (status == count * dev->sector_size) break;
                 if (status > 0) {
                         read_length -= status;
@@ -1430,6 +1436,7 @@
 
                 switch (ex_status) {
                         case PED_EXCEPTION_IGNORE:
+                                free(diobuf);
                                 return 1;
 
                         case PED_EXCEPTION_RETRY:
@@ -1438,9 +1445,11 @@
                         case PED_EXCEPTION_UNHANDLED:
                                 ped_exception_catch ();
                         case PED_EXCEPTION_CANCEL:
+                                free(diobuf);
                                 return 0;
                 }
         }
+        free(diobuf);
 
         return 1;
 }
@@ -1486,6 +1495,8 @@
         int                     status;
         PedExceptionOption      ex_status;
         size_t                  write_length = count * dev->sector_size;
+        void*                   diobuf;
+        void*                   diobuf_start;
 
         PED_ASSERT(dev->sector_size % 512 == 0, return 0);
 
@@ -1539,12 +1550,16 @@
                 dev->path, buffer, (int) start, (int) count);
 #else
         dev->dirty = 1;
+        if (posix_memalign(&diobuf, PED_SECTOR_SIZE, count * PED_SECTOR_SIZE) != 0)
+                return 0;
+        memcpy(diobuf, buffer, count * PED_SECTOR_SIZE);
+        diobuf_start = diobuf;
         while (1) {
-                status = write (arch_specific->fd, buffer, write_length);
+                status = write (arch_specific->fd, diobuf, write_length);
                 if (status == count * dev->sector_size) break;
                 if (status > 0) {
                         write_length -= status;
-                        buffer += status;
+                        diobuf += status;
                         continue;
                 }
 
@@ -1556,6 +1571,7 @@
 
                 switch (ex_status) {
                         case PED_EXCEPTION_IGNORE:
+                                free(diobuf_start);
                                 return 1;
 
                         case PED_EXCEPTION_RETRY:
@@ -1564,9 +1580,11 @@
                         case PED_EXCEPTION_UNHANDLED:
                                 ped_exception_catch ();
                         case PED_EXCEPTION_CANCEL:
+                                free(diobuf_start);
                                 return 0;
                 }
         }
+        free(diobuf_start);
 #endif /* !READ_ONLY */
         return 1;
 }
@@ -1579,18 +1597,25 @@
         LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
         PedSector       done = 0;
         int             status;
+        void*           diobuf;
 
         PED_ASSERT(dev != NULL, return 0);
         
         if (!_device_seek (dev, start))
                 return 0;
 
+        if (posix_memalign(&diobuf, PED_SECTOR_SIZE, count * PED_SECTOR_SIZE) != 0)
+                return 0;
+
         for (done = 0; done < count; done += status / dev->sector_size) {
-                status = read (arch_specific->fd, buffer,
+                status = read (arch_specific->fd, diobuf,
                                (size_t) ((count-done) * dev->sector_size));
+                if (status > 0)
+                        memcpy(buffer, diobuf, status);
                 if (status < 0)
                         break;
         }
+        free(diobuf);
 
         return done;
 }

parted-1.7.1-dasd.patch:
 include/parted/device.h      |    1 
 include/parted/disk.h        |    3 
 include/parted/fdasd.h       |  230 +++++++
 include/parted/linux.h       |    5 
 include/parted/vtoc.h        |  371 +++++++++++
 libparted/arch/linux.c       |   81 ++
 libparted/labels/Makefile.am |    5 
 libparted/labels/dasd.c      |  876 ++++++++++++++++++++++++++++
 libparted/labels/fdasd.c     | 1302 +++++++++++++++++++++++++++++++++++++++++
 libparted/labels/vtoc.c      | 1343 +++++++++++++++++++++++++++++++++++++++++++
 libparted/libparted.c        |    9 
 11 files changed, 4222 insertions(+), 4 deletions(-)

--- NEW FILE parted-1.7.1-dasd.patch ---
diff -urN parted-1.7.1.orig/include/parted/device.h parted-1.7.1/include/parted/device.h
--- parted-1.7.1.orig/include/parted/device.h	2006-06-22 14:11:48.000000000 -0400
+++ parted-1.7.1/include/parted/device.h	2006-06-22 14:12:10.000000000 -0400
@@ -43,6 +43,7 @@
         PED_DEVICE_ATARAID      = 6,
         PED_DEVICE_I2O          = 7,
         PED_DEVICE_UBD          = 8,
+        PED_DEVICE_DASD         = 9,
         PED_DEVICE_SX8          = 11
 } PedDeviceType;
 
diff -urN parted-1.7.1.orig/include/parted/disk.h parted-1.7.1/include/parted/disk.h
--- parted-1.7.1.orig/include/parted/disk.h	2006-05-25 13:28:43.000000000 -0400
+++ parted-1.7.1/include/parted/disk.h	2006-06-22 14:12:10.000000000 -0400
@@ -46,7 +46,8 @@
         PED_PARTITION_LOGICAL           = 0x01,
         PED_PARTITION_EXTENDED          = 0x02,
         PED_PARTITION_FREESPACE         = 0x04,
-        PED_PARTITION_METADATA          = 0x08
+        PED_PARTITION_METADATA          = 0x08,
+        PED_PARTITION_PROTECTED         = 0x10
 } PedPartitionType;
 
 /**
diff -urN parted-1.7.1.orig/include/parted/fdasd.h parted-1.7.1/include/parted/fdasd.h
--- parted-1.7.1.orig/include/parted/fdasd.h	1969-12-31 19:00:00.000000000 -0500
+++ parted-1.7.1/include/parted/fdasd.h	2006-06-22 14:12:10.000000000 -0400
@@ -0,0 +1,230 @@
+/*
+ * File...........: s390-tools/fdasd/fdasd.h
+ * Author(s)......: Volker Sameske <sameske at de.ibm.com>
+ *                  Horst Hummel   <Horst.Hummel at de.ibm.com>
+ * Bugreports.to..: <Linux390 at de.ibm.com>
+ * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2001-2002
+ *
+ * History of changes (starts March 2001)
+ * version 1.01 - menu entry 's' to show mapping devnode - DS name
+ *         1.02 - DS names count now from 0001 instead from 0000
+ *         1.03 - volser checks: 'AA AAA' to 'AAAAA '
+ *              - removed dependency to kernel headers.
+ *         1.04 - added -p option
+ *         1.05 - new API policy, set it back to 0
+ */
+#ifndef FDASD_H
+#define FDASD_H
+
+/*****************************************************************************
+ * SECTION: Definitions needed for DASD-API (see dasd.h)                     *
+ *****************************************************************************/
+
+#define DASD_IOCTL_LETTER 'D'
+
+#define DASD_PARTN_BITS 2
+
+#define PARTITION_LINUX_SWAP    0x82
+#define PARTITION_LINUX         0x83
+#define PARTITION_LINUX_EXT     0x85
+#define PARTITION_LINUX_LVM     0x8e
+#define PARTITION_LINUX_RAID    0xfd
+#define PARTITION_LINUX_LVM_OLD 0xfe
+
+#define PART_TYPE_NATIVE "NATIVE"
+#define PART_TYPE_SWAP   "SWAP  "
+#define PART_TYPE_RAID   "RAID  "
+#define PART_TYPE_LVM   "LVM   "
+
+#ifdef DEBUG_DASD
+#define PDEBUG           fprintf(stderr, "%s:%d:%s\n", \
+                         __FILE__,                              \
+                         __LINE__,                              \
+                         __PRETTY_FUNCTION__);
+#else
+#define PDEBUG
+#endif
+
+/* 
+ * struct dasd_information_t
+ * represents any data about the device, which is visible to userspace.
+ *  including foramt and featueres.
+ */
+typedef struct dasd_information_t {
+        unsigned int devno;           /* S/390 devno                         */
+        unsigned int real_devno;      /* for aliases                         */
+        unsigned int schid;           /* S/390 subchannel identifier         */
+        unsigned int cu_type  : 16;   /* from SenseID                        */
+        unsigned int cu_model :  8;   /* from SenseID                        */
+        unsigned int dev_type : 16;   /* from SenseID                        */
+        unsigned int dev_model : 8;   /* from SenseID                        */
+        unsigned int open_count; 
+        unsigned int req_queue_len; 
+        unsigned int chanq_len;       /* length of chanq                     */
+        char type[4];                 /* from discipline.name, 'none' for    */
+	                              /* unknown                             */
+        unsigned int status;          /* current device level                */
+        unsigned int label_block;     /* where to find the VOLSER            */
+        unsigned int FBA_layout;      /* fixed block size (like AIXVOL)      */
+        unsigned int characteristics_size;
+        unsigned int confdata_size;
+        char characteristics[64];     /* from read_device_characteristics    */
+        char configuration_data[256]; /* from read_configuration_data        */
+} dasd_information_t;
+
+/* 
+ * struct format_data_t
+ * represents all data necessary to format a dasd
+ */
+typedef struct format_data_t {
+	int start_unit; /* from track */
+	int stop_unit;  /* to track */
+	int blksize;    /* sectorsize */
+        int intensity;  
+} format_data_t;
+
+/*
+ * values to be used for format_data_t.intensity
+ * 0/8: normal format
+ * 1/9: also write record zero
+ * 3/11: also write home address
+ * 4/12: invalidate track
+ */
+#define DASD_FMT_INT_FMT_R0 1 /* write record zero */
+#define DASD_FMT_INT_FMT_HA 2 /* write home address, also set FMT_R0 ! */
+#define DASD_FMT_INT_INVAL  4 /* invalidate tracks */
+#define DASD_FMT_INT_COMPAT 8 /* use OS/390 compatible disk layout */
+
+
+/* Disable the volume (for Linux) */
+#define BIODASDDISABLE _IO(DASD_IOCTL_LETTER,0) 
+/* Enable the volume (for Linux) */
+#define BIODASDENABLE  _IO(DASD_IOCTL_LETTER,1)  
+
+/* retrieve API version number */
+#define DASDAPIVER     _IOR(DASD_IOCTL_LETTER,0,int)
+/* Get information on a dasd device (enhanced) */
+#define BIODASDINFO   _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
+
+
+/*****************************************************************************
+ * SECTION: Further IOCTL Definitions  (see fs.h)                            *
+ *****************************************************************************/
+/* re-read partition table */
+#define BLKRRPART  _IO(0x12,95)	
+/* get block device sector size */
+#define BLKSSZGET  _IO(0x12,104)
+
+/*****************************************************************************
+ * SECTION: Definition from hdreq.h                                          *
+ *****************************************************************************/
+
+struct fdasd_hd_geometry {
+      unsigned char heads;
+      unsigned char sectors;
+      unsigned short cylinders;
+      unsigned long start;
+};
+
+/* get device geometry */
+#define HDIO_GETGEO		0x0301	
+
+/*****************************************************************************
+ * SECTION: FDASD internal types                                             *
+ *****************************************************************************/
+
+#define DASD_MIN_API_VERSION 0
+
+#define DEFAULT_FDASD_CONF "/etc/fdasd.conf" /* default config file */
+
+#define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
+#define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
+
+#define FDASD_VERSION "1.05"
+#define FDASD_ERROR "fdasd error: "
+#define DEVICE "device"
+#define DISC   "disc"
+#define PART   "part"
+
+#define ALTERNATE_CYLINDERS_USED 0x10
+
+typedef struct partition_info {
+        u_int8_t           used;
+        unsigned long      start_trk;
+        unsigned long      end_trk;
+        unsigned long      len_trk;
+        unsigned long      fspace_trk;
+        format1_label_t  * f1; 
+        struct partition_info *next;
+        struct partition_info *prev;
+        u_int8_t           type;
+} partition_info_t;
+
+
+typedef struct config_data {
+	unsigned long start;
+	unsigned long stop;
+} config_data_t;
+
+
+typedef struct fdasd_anchor {
+        int vlabel_changed;
[...3973 lines suppressed...]
+			bzero(tmp, sizeof(ds7ext_t));
+			tmp = ext;
+			if (verbose) 
+				printf("FMT7 add extent: " \
+				       "merge with successor\n");
+			i = -1;
+			continue;
+		} 
+	}
+}
+
+
+/*
+ * remove a free space extent description from the VTOC FMT7 DSCB
+ */
+void 
+vtoc_update_format7_label_del (format7_label_t *f7, int verbose, 
+			       u_int32_t a, u_int32_t b) 
+{
+	PDEBUG
+	ds7ext_t *ext;
+	int i, counter=0;
+	
+	for (i=0; i<16; i++)
+	{
+		if (i<5) 
+			ext = &f7->DS7EXTNT[i]; 
+		else 
+			ext = &f7->DS7ADEXT[i-5];
+
+		if ((a == ext->a) && (b == ext->b))
+		{
+			/* fills up whole free space gap */
+			bzero(ext, sizeof(ds7ext_t));
+			if (verbose) 
+				printf("FMT7 del extent: " \
+				       "fills whole gap\n");
+			counter++;
+			break;
+		}
+
+		if ((a == ext->a) && (b < ext->b))
+		{
+			/* left-bounded in free space gap */
+			ext->a = b + 1;
+			if (verbose) 
+				printf("FMT7 add extent: " \
+				       "left-bounded\n");
+			counter++;
+			break;
+		}
+
+		if ((a > ext->a) && (b == ext->b))
+		{
+			/* right-bounded in free space gap */
+			ext->b = a - 1;
+			if (verbose) 
+				printf("FMT7 add extent: " \
+				       "right-bounded\n");
+			counter++;
+			break;
+		}
+
+		if ((a > ext->a) && (b < ext->b))
+		{
+			/* partition devides free space into 2 pieces */
+			vtoc_update_format7_label_add(f7, verbose, 
+						      b+1, ext->b);
+			ext->b = a - 1;
+			if (verbose) 
+				printf("FMT7 add extent: " \
+				       "2 pieces\n");
+			counter++;
+			break;
+		}
+
+		if (((a < ext->a) && (b > ext->a)) || ((a < ext->b) && (b > ext->b)))
+		{
+			printf ("BUG: specified free space extent for deleting "
+				"doesn't match free space currently shown in "
+				"FMT7 DSCB!\nexiting...\n");
+			printf ("%d %d %d %d\n", a, b, ext->a, ext->b);
+			exit(1);
+		}
+	}
+
+	if (counter > 0) return;
+
+	printf("BUG: specified free space extent for " \
+	       "deleting not found in FMT7 DSCB!\n" \
+	       "exiting...\n");
+	exit(1);
+}
+
+
+/*
+ *
+ */
+void
+vtoc_set_freespace(format4_label_t *f4,
+		   format5_label_t *f5,
+		   format7_label_t *f7,
+		   char ch,
+		   int verbose,
+		   u_int32_t start,
+		   u_int32_t stop,
+		   int cyl,
+		   int trk)
+{
+	PDEBUG
+	if ((cyl * trk) > BIG_DISK_SIZE)
+	{
+		if (ch == '+')
+		{
+			vtoc_update_format7_label_add(f7, verbose, 
+						      start, stop);
+		}
+		else if (ch == '-')
+		{
+			vtoc_update_format7_label_del(f7, verbose, 
+						      start, stop);
+		}
+		else
+		{
+			printf("BUG: syntax error in " \
+			       "vtoc_set_freespace call\n");
+		}
+
+		vtoc_reorganize_FMT7_extents (f7);
+
+		f4->DS4VTOCI = 0xa0;
+		f4->DS4EFLVL = 0x07;
+		vtoc_set_cchhb(&f4->DS4EFPTR, 0x0000, 0x0001, 0x03);
+	}
+	else
+	{
+		u_int16_t x,y;
+		u_int8_t z;
+
+		x = (u_int16_t) start;
+		y = (u_int16_t) ((stop - start + 1) / trk);
+		z =  (u_int8_t) ((stop - start + 1) % trk);
+
+		if (ch == '+')
+		{
+			vtoc_update_format5_label_add(f5, verbose,
+						      cyl, trk,
+						      x, y, z);
+		}
+		else if (ch == '-')
+		{
+			vtoc_update_format5_label_del(f5, verbose, 
+						      cyl, trk,
+						      x, y, z);
+		}
+		else
+		{
+			printf("BUG: syntax error in " \
+			       "vtoc_set_freespace call\n");
+		}
+		vtoc_reorganize_FMT5_extents (f5);
+	}
+		
+}
diff -urN parted-1.7.1.orig/libparted/libparted.c parted-1.7.1/libparted/libparted.c
--- parted-1.7.1.orig/libparted/libparted.c	2006-05-25 13:29:06.000000000 -0400
+++ parted-1.7.1/libparted/libparted.c	2006-06-22 14:12:10.000000000 -0400
@@ -89,12 +89,17 @@
 extern void ped_disk_pc98_init ();
 extern void ped_disk_sun_init ();
 extern void ped_disk_amiga_init ();
+extern void ped_disk_dasd_init ();
 
 static void
 init_disk_types ()
 {
 	ped_disk_loop_init ();	/* must be last in the probe list */
 
+#if defined(__s390__) || defined(__s390x__)
+	ped_disk_dasd_init();
+#endif
+
 	ped_disk_sun_init ();
 #ifdef ENABLE_PC98
 	ped_disk_pc98_init ();
@@ -145,10 +150,14 @@
 extern void ped_disk_pc98_done ();
 extern void ped_disk_sun_done ();
 extern void ped_disk_amiga_done ();
+extern void ped_disk_dasd_done ();
 
 static void
 done_disk_types ()
 {
+#if defined(__s390__) || (__s390x__)
+	ped_disk_dasd_done ();
+#endif
 	ped_disk_sun_done ();
 #ifdef ENABLE_PC98
 	ped_disk_pc98_done ();


Index: parted.spec
===================================================================
RCS file: /cvs/dist/rpms/parted/devel/parted.spec,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- parted.spec	15 Jun 2006 20:16:26 -0000	1.74
+++ parted.spec	22 Jun 2006 18:26:53 -0000	1.75
@@ -4,17 +4,16 @@
 Summary: The GNU disk partition manipulation program.
 Name: parted
 Version: 1.7.1
-Release: 5
+Release: 6
 Source: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.bz2
 Patch0: parted-1.7.0-fat.c.patch
 Patch1: parted-1.7.0-sx8.patch
-Patch3: parted-1.7.0-dasd.patch
+Patch3: parted-1.7.1-dasd.patch
 Patch4: parted-1.7.0-iseries.patch
 Patch5: parted-1.7.1-dm.patch
 Patch6: parted-1.7.0-aix.patch
 Patch7: parted-1.7.0-headers.patch
-
-Patch10: parted-1.7.1-dasdfixes.patch
+Patch8: parted-1.7.1-O_DIRECT.patch
 
 Buildroot: %{_tmppath}/%{name}-root
 License: GPL
@@ -51,7 +50,7 @@
 %patch5 -p1 -b .dm
 %patch6 -p1 -b .aix
 %patch7 -p1 -b .headers
-%patch10 -p1 -b .dasdfixes
+%patch8 -p1 -b .o_direct
 
 iconv -f iso-8859-1 -t utf-8 < doc/pt_BR-parted.8 > doc/pt_BR-parted.8_
 mv doc/pt_BR-parted.8_ doc/pt_BR-parted.8
@@ -101,6 +100,10 @@
 %{_libdir}/*.so
 
 %changelog
+* Thu Jun 22 2006 David Cantrell <dcantrell at redhat.com> - 1.7.1-6
+- Roll dasd patches together
+- Use O_DIRECT to prevent first partition corruption on GPT disks
+
 * Thu Jun 15 2006 Jeremy Katz <katzj at redhat.com> - 1.7.1-5
 - fix segfaults with dasd devices
 


--- parted-1.7.0-dasd.patch DELETED ---


--- parted-1.7.1-dasdfixes.patch DELETED ---




More information about the fedora-cvs-commits mailing list