diff -ur parted-1.9.0.orig/libparted/arch/linux.c parted-1.9.0/libparted/arch/linux.c --- parted-1.9.0.orig/libparted/arch/linux.c 2009-11-03 11:35:00.000000000 +0100 +++ parted-1.9.0/libparted/arch/linux.c 2009-11-03 11:45:48.000000000 +0100 @@ -646,10 +646,14 @@ #if USE_BLKID get_blkid_topology(arch_specific); #endif + +#if defined __s390__ || defined __s390x__ /* Return PED_SECTOR_SIZE_DEFAULT for DASDs. */ if (dev->type == PED_DEVICE_DASD) { + arch_specific->real_sector_size = dev->sector_size; dev->sector_size = PED_SECTOR_SIZE_DEFAULT; } +#endif if (dev->sector_size != PED_SECTOR_SIZE_DEFAULT) { ped_exception_throw ( @@ -1069,6 +1073,7 @@ return 0; } +#if defined __s390__ || defined __s390x__ static int init_dasd (PedDevice* dev, const char* model_name) { @@ -1124,6 +1129,7 @@ error: return 0; } +#endif static int init_generic (PedDevice* dev, const char* model_name) @@ -1270,10 +1276,12 @@ goto error_free_arch_specific; break; +#if defined __s390__ || defined __s390x__ case PED_DEVICE_DASD: if (!init_dasd (dev, _("IBM S390 DASD drive"))) goto error_free_arch_specific; break; +#endif case PED_DEVICE_VIODASD: if (!init_generic (dev, _("IBM iSeries Virtual DASD"))) Only in parted-1.9.0/libparted/arch: linux.c.orig Only in parted-1.9.0/libparted/arch: linux.c.rej Only in parted-1.9.0/libparted/arch: linux.c~ diff -ur parted-1.9.0.orig/libparted/arch/linux.h parted-1.9.0/libparted/arch/linux.h --- parted-1.9.0.orig/libparted/arch/linux.h 2009-11-03 11:35:00.000000000 +0100 +++ parted-1.9.0/libparted/arch/linux.h 2009-11-03 11:44:40.000000000 +0100 @@ -18,10 +18,6 @@ #ifndef PED_ARCH_LINUX_H_INCLUDED #define PED_ARCH_LINUX_H_INCLUDED -#if defined(__s390__) || defined(__s390x__) -# include -#endif - #if HAVE_BLKID_BLKID_H # include #endif @@ -35,8 +31,6 @@ char* dmtype; /**< device map target type */ #if defined(__s390__) || defined(__s390x__) unsigned int real_sector_size; - /* IBM internal dasd structure (i guess ;), required. */ - struct fdasd_anchor *anchor; #endif #if HAVE_BLKID_BLKID_H blkid_probe probe; Only in parted-1.9.0/libparted/arch: linux.h.orig Only in parted-1.9.0/libparted/arch: linux.h.rej Only in parted-1.9.0/libparted/arch: linux.h~ diff -ur parted-1.9.0.orig/libparted/labels/dasd.c parted-1.9.0/libparted/labels/dasd.c --- parted-1.9.0.orig/libparted/labels/dasd.c 2009-11-03 11:35:00.000000000 +0100 +++ parted-1.9.0/libparted/labels/dasd.c 2009-11-03 11:48:17.000000000 +0100 @@ -66,14 +66,10 @@ int system; int raid; int lvm; - void *part_info; } DasdPartitionData; typedef struct { - unsigned int real_sector_size; unsigned int format_type; - /* IBM internal dasd structure (i guess ;), required. */ - struct fdasd_anchor *anchor; } DasdDiskSpecific; static PedDiskType dasd_disk_type; @@ -98,17 +94,8 @@ return NULL; } - /* because we lie to parted we have to compensate with the - real sector size. Record that now. */ - if (ioctl(arch_specific->fd, BLKSSZGET, - &disk_specific->real_sector_size) == -1) { - ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, - _("Unable to determine the block " - "size of this dasd")); - free(disk_specific); - free(disk); - return NULL; - } + /* CDL format, newer */ + disk_specific->format_type = 2; return disk; } @@ -123,7 +110,8 @@ if (!new_disk) return NULL; - new_disk->disk_specific = NULL; + memcpy(new_disk->disk_specific, disk->disk_specific, + sizeof(DasdDiskSpecific)); return new_disk; } @@ -187,6 +175,8 @@ fdasd_recreate_vtoc(&anchor); fdasd_write_labels(&anchor, arch_specific->fd); + fdasd_cleanup(&anchor); + return 1; } @@ -203,6 +193,7 @@ partition_info_t *p; LinuxSpecific* arch_specific; DasdDiskSpecific* disk_specific; + struct fdasd_anchor anchor; PDEBUG; @@ -216,35 +207,32 @@ arch_specific = LINUX_SPECIFIC(dev); disk_specific = disk->disk_specific; - disk_specific->anchor = ped_malloc(sizeof(fdasd_anchor_t)); - PDEBUG; - fdasd_initialize_anchor(disk_specific->anchor); + fdasd_initialize_anchor(&anchor); - fdasd_get_geometry(disk_specific->anchor, arch_specific->fd); + fdasd_get_geometry(&anchor, arch_specific->fd); /* check dasd for labels and vtoc */ - if (fdasd_check_volume(disk_specific->anchor, arch_specific->fd)) + if (fdasd_check_volume(&anchor, arch_specific->fd)) goto error_close_dev; - if ((disk_specific->anchor->geo.cylinders - * disk_specific->anchor->geo.heads) > BIG_DISK_SIZE) - disk_specific->anchor->big_disk++; + if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE) + anchor.big_disk++; ped_disk_delete_all (disk); - if (strncmp(disk_specific->anchor->vlabel->volkey, + if (strncmp(anchor.vlabel->volkey, vtoc_ebcdic_enc ("LNX1", str, 4), 4) == 0) { DasdPartitionData* dasd_data; /* LDL format, old one */ disk_specific->format_type = 1; start = 24; - end = (long long)(long long) disk_specific->anchor->geo.cylinders - * (long long)disk_specific->anchor->geo.heads + end = (long long)(long long) anchor.geo.cylinders + * (long long)anchor.geo.heads * (long long)disk->dev->hw_geom.sectors - * (long long)disk_specific->real_sector_size + * (long long)arch_specific->real_sector_size / (long long)disk->dev->sector_size - 1; part = ped_partition_new (disk, PED_PARTITION_PROTECTED, NULL, start, end); if (!part) @@ -260,13 +248,15 @@ if (!ped_disk_add_partition (disk, part, NULL)) goto error_close_dev; + fdasd_cleanup(&anchor); + return 1; } /* CDL format, newer */ disk_specific->format_type = 2; - p = disk_specific->anchor->first; + p = anchor.first; PDEBUG; for (i = 1 ; i <= USABLE_PARTITIONS; i++) { @@ -281,11 +271,11 @@ start = (long long)(long long) p->start_trk * (long long) disk->dev->hw_geom.sectors - * (long long) disk_specific->real_sector_size + * (long long) arch_specific->real_sector_size / (long long) disk->dev->sector_size; end = (long long)((long long) p->end_trk + 1) * (long long) disk->dev->hw_geom.sectors - * (long long) disk_specific->real_sector_size + * (long long) arch_specific->real_sector_size / (long long) disk->dev->sector_size - 1; part = ped_partition_new(disk, PED_PARTITION_NORMAL, NULL, start, end); @@ -331,24 +321,25 @@ vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44); - dasd_data->part_info = (void *) p; dasd_data->type = 0; constraint_exact = ped_constraint_exact (&part->geom); if (!constraint_exact) goto error_close_dev; - if (!ped_disk_add_partition(disk, part, constraint_exact)) + if (!ped_disk_add_partition(disk, part, constraint_exact)) { + ped_constraint_destroy(constraint_exact); goto error_close_dev; + } ped_constraint_destroy(constraint_exact); if (p->fspace_trk > 0) { start = (long long)((long long) p->end_trk + 1) * (long long) disk->dev->hw_geom.sectors - * (long long) disk_specific->real_sector_size + * (long long) arch_specific->real_sector_size / (long long) disk->dev->sector_size; end = (long long)((long long) p->end_trk + 1 + p->fspace_trk) * (long long) disk->dev->hw_geom.sectors - * (long long) disk_specific->real_sector_size + * (long long) arch_specific->real_sector_size / (long long) disk->dev->sector_size - 1; part = ped_partition_new (disk, PED_PARTITION_NORMAL, NULL, start, end); @@ -361,8 +352,10 @@ if (!constraint_exact) goto error_close_dev; - if (!ped_disk_add_partition(disk, part, constraint_exact)) + if (!ped_disk_add_partition(disk, part, constraint_exact)) { + ped_constraint_destroy(constraint_exact); goto error_close_dev; + } ped_constraint_destroy (constraint_exact); } @@ -371,16 +364,20 @@ } PDEBUG; + fdasd_cleanup(&anchor); return 1; error_close_dev: PDEBUG; + fdasd_cleanup(&anchor); return 0; } static int -dasd_update_type (const PedDisk* disk) +dasd_update_type (const PedDisk* disk, struct fdasd_anchor *anchor, + partition_info_t *part_info[USABLE_PARTITIONS]) { + int i; PedPartition* part; LinuxSpecific* arch_specific; DasdDiskSpecific* disk_specific; @@ -390,22 +387,21 @@ PDEBUG; - for (part = ped_disk_next_partition(disk, NULL); part; - part = ped_disk_next_partition(disk, part)) { + for (i = 1; i <= USABLE_PARTITIONS; i++) { partition_info_t *p; char *ch = NULL; DasdPartitionData* dasd_data; PDEBUG; - if (part->type & PED_PARTITION_FREESPACE - || part->type & PED_PARTITION_METADATA) + part = ped_disk_get_partition(disk, i); + if (!part) continue; PDEBUG; dasd_data = part->disk_specific; - p = dasd_data->part_info; + p = part_info[i - 1]; if (!p ) { PDEBUG; @@ -447,7 +443,7 @@ break; } - disk_specific->anchor->vtoc_changed++; + anchor->vtoc_changed++; vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44); } @@ -463,6 +459,9 @@ partition_info_t *p; LinuxSpecific* arch_specific; DasdDiskSpecific* disk_specific; + struct fdasd_anchor anchor; + partition_info_t *part_info[USABLE_PARTITIONS]; + PED_ASSERT(disk != NULL, return 0); PED_ASSERT(disk->dev != NULL, return 0); @@ -475,23 +474,21 @@ if (disk_specific->format_type == 1) return 1; - /* XXX re-initialize anchor? */ - fdasd_initialize_anchor(disk_specific->anchor); - fdasd_get_geometry(disk_specific->anchor, arch_specific->fd); + /* initialize the anchor */ + fdasd_initialize_anchor(&anchor); + fdasd_get_geometry(&anchor, arch_specific->fd); /* check dasd for labels and vtoc */ - if (fdasd_check_volume(disk_specific->anchor, arch_specific->fd)) + if (fdasd_check_volume(&anchor, arch_specific->fd)) goto error; - if ((disk_specific->anchor->geo.cylinders - * disk_specific->anchor->geo.heads) > BIG_DISK_SIZE) - disk_specific->anchor->big_disk++; + if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE) + anchor.big_disk++; - fdasd_recreate_vtoc(disk_specific->anchor); + fdasd_recreate_vtoc(&anchor); for (i = 1; i <= USABLE_PARTITIONS; i++) { unsigned int start, stop; - int type; PDEBUG; part = ped_disk_get_partition(disk, i); @@ -501,41 +498,40 @@ PDEBUG; start = part->geom.start * disk->dev->sector_size - / disk_specific->real_sector_size / disk->dev->hw_geom.sectors; + / arch_specific->real_sector_size / disk->dev->hw_geom.sectors; stop = (part->geom.end + 1) - * disk->dev->sector_size / disk_specific->real_sector_size + * disk->dev->sector_size / arch_specific->real_sector_size / disk->dev->hw_geom.sectors - 1; PDEBUG; dasd_data = part->disk_specific; - type = dasd_data->type; - PDEBUG; - - p = fdasd_add_partition(disk_specific->anchor, start, stop); + p = fdasd_add_partition(&anchor, start, stop); if (!p) { PDEBUG; - return 0; + goto error; } - dasd_data->part_info = (void *) p; + part_info[i - 1] = p; p->type = dasd_data->system; } PDEBUG; - if (!fdasd_prepare_labels(disk_specific->anchor, arch_specific->fd)) - return 0; + if (!fdasd_prepare_labels(&anchor, arch_specific->fd)) + goto error; - dasd_update_type(disk); + dasd_update_type(disk, &anchor, part_info); PDEBUG; - if (!fdasd_write_labels(disk_specific->anchor, arch_specific->fd)) - return 0; + if (!fdasd_write_labels(&anchor, arch_specific->fd)) + goto error; + fdasd_cleanup(&anchor); return 1; error: PDEBUG; + fdasd_cleanup(&anchor); return 0; } @@ -557,6 +553,23 @@ return 0; } +static PedPartition* +dasd_partition_duplicate (const PedPartition *part) +{ + PedPartition *new_part; + + new_part = ped_partition_new (part->disk, part->type, part->fs_type, + part->geom.start, part->geom.end); + if (!new_part) + return NULL; + new_part->num = part->num; + + memcpy(new_part->disk_specific, part->disk_specific, + sizeof(DasdPartitionData)); + + return new_part; +} + static void dasd_partition_destroy (PedPartition* part) { @@ -650,9 +662,9 @@ static PedAlignment* dasd_get_partition_alignment(const PedDisk *disk) { - DasdDiskSpecific* disk_specific = disk->disk_specific; + LinuxSpecific *arch_specific = LINUX_SPECIFIC(disk->dev); PedSector sector_size = - disk_specific->real_sector_size / disk->dev->sector_size; + arch_specific->real_sector_size / disk->dev->sector_size; return ped_alignment_new(0, disk->dev->hw_geom.sectors * sector_size); } @@ -670,7 +683,7 @@ arch_specific = LINUX_SPECIFIC (disk->dev); disk_specific = disk->disk_specific; - sector_size = disk_specific->real_sector_size / disk->dev->sector_size; + sector_size = arch_specific->real_sector_size / disk->dev->sector_size; if (!ped_alignment_init (&start_align, 0, disk->dev->hw_geom.sectors * sector_size)) @@ -796,7 +809,7 @@ else /* Mark the start of the disk as metadata. */ vtoc_end = (FIRST_USABLE_TRK * (long long) disk->dev->hw_geom.sectors - * (long long) disk_specific->real_sector_size + * (long long) arch_specific->real_sector_size / (long long) disk->dev->sector_size) - 1; new_part = ped_partition_new (disk,PED_PARTITION_METADATA,NULL,0,vtoc_end); @@ -828,6 +841,7 @@ partition_set_system: dasd_partition_set_system, partition_new: dasd_partition_new, + partition_duplicate: dasd_partition_duplicate, partition_destroy: dasd_partition_destroy, partition_set_flag: dasd_partition_set_flag, partition_get_flag: dasd_partition_get_flag, @@ -841,8 +855,6 @@ get_max_primary_partition_count: dasd_get_max_primary_partition_count, get_max_supported_partition_count: dasd_get_max_supported_partition_count, get_partition_alignment: dasd_get_partition_alignment, - - partition_duplicate: NULL }; static PedDiskType dasd_disk_type = { Only in parted-1.9.0/libparted/labels: dasd.c.orig Only in parted-1.9.0/libparted/labels: dasd.c.rej Only in parted-1.9.0/libparted/labels: dasd.c~