1 --- parted-1.6.25/include/parted/device.h.orig 2005-10-19 22:13:26.000000000 +0200
2 +++ parted-1.6.25/include/parted/device.h 2005-11-04 10:03:56.934241352 +0100
5 PED_DEVICE_ATARAID = 6,
12 typedef struct _PedDevice PedDevice;
13 diff -ruN --minimal parted-1.6.21.orig/include/parted/disk.h parted-1.6.21/include/parted/disk.h
14 --- parted-1.6.21.orig/include/parted/disk.h 2005-01-04 11:09:50.000000000 -0500
15 +++ parted-1.6.21/include/parted/disk.h 2005-01-21 15:00:40.422628505 -0500
17 PED_PARTITION_LOGICAL = 0x01,
18 PED_PARTITION_EXTENDED = 0x02,
19 PED_PARTITION_FREESPACE = 0x04,
20 - PED_PARTITION_METADATA = 0x08
21 + PED_PARTITION_METADATA = 0x08,
22 + PED_PARTITION_PROTECTED = 0x10
26 diff -ruN --minimal parted-1.6.21.orig/include/parted/linux.h parted-1.6.21/include/parted/linux.h
27 --- parted-1.6.21.orig/include/parted/linux.h 2001-12-26 19:26:08.000000000 -0500
28 +++ parted-1.6.21/include/parted/linux.h 2005-01-21 15:00:40.422628505 -0500
31 struct _LinuxSpecific {
33 +#if defined(__s390__) || defined(__s390x__)
34 + unsigned int real_sector_size;
35 + /* IBM internal dasd structure (i guess ;), required. */
36 + struct fdasd_anchor *anchor;
40 extern PedArchitecture ped_linux_arch;
41 diff -ruN --minimal parted-1.6.21.orig/libparted/Makefile.am parted-1.6.21/libparted/Makefile.am
42 --- parted-1.6.21.orig/libparted/Makefile.am 2005-01-05 18:16:52.000000000 -0500
43 +++ parted-1.6.21/libparted/Makefile.am 2005-01-21 15:00:40.423628479 -0500
56 diff -ruN --minimal parted-1.6.21.orig/libparted/disk_dasd.c parted-1.6.21/libparted/disk_dasd.c
57 --- parted-1.6.21.orig/libparted/disk_dasd.c 1969-12-31 19:00:00.000000000 -0500
58 +++ parted-1.6.21/libparted/disk_dasd.c 2005-01-21 15:00:40.425628426 -0500
60 +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
62 + libparted - a library for manipulating disk partitions
63 + Copyright (C) 2000, 2001 Free Software Foundation, Inc.
65 + This program is free software; you can redistribute it and/or modify
66 + it under the terms of the GNU General Public License as published by
67 + the Free Software Foundation; either version 2 of the License, or
68 + (at your option) any later version.
70 + This program is distributed in the hope that it will be useful,
71 + but WITHOUT ANY WARRANTY; without even the implied warranty of
72 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
73 + GNU General Public License for more details.
75 + You should have received a copy of the GNU General Public License
76 + along with this program; if not, write to the Free Software
77 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
79 + Contributor: Phil Knirsch <phil@redhat.de>
80 + Harald Hoyer <harald@redhat.de>
93 +#include <sys/stat.h>
94 +#include <sys/ioctl.h>
95 +#include <parted/parted.h>
96 +#include <parted/endian.h>
97 +#include <parted/debug.h>
101 +#include <parted/linux.h>
103 +#include <libintl.h>
105 +# define _(String) dgettext (PACKAGE, String)
107 +# define _(String) (String)
108 +#endif /* ENABLE_NLS */
111 +#define PARTITION_LINUX_SWAP 0x82
112 +#define PARTITION_LINUX 0x83
113 +#define PARTITION_LINUX_EXT 0x85
114 +#define PARTITION_LINUX_LVM 0x8e
115 +#define PARTITION_LINUX_RAID 0xfd
116 +#define PARTITION_LINUX_LVM_OLD 0xfe
119 +extern void ped_disk_dasd_init ();
120 +extern void ped_disk_dasd_done ();
123 +#define DASD_NAME "dasd"
131 +} DasdPartitionData;
134 + unsigned int real_sector_size;
135 + unsigned int format_type;
136 + /* IBM internal dasd structure (i guess ;), required. */
137 + struct fdasd_anchor *anchor;
140 +static int dasd_probe (PedDevice *dev);
141 +static int dasd_clobber (PedDevice* dev);
142 +static int dasd_read (PedDisk* disk);
143 +static int dasd_write (PedDisk* disk);
145 +static PedPartition* dasd_partition_new (
146 + const PedDisk* disk, PedPartitionType part_type,
147 + const PedFileSystemType* fs_type, PedSector start, PedSector end);
148 +static void dasd_partition_destroy (PedPartition* part);
149 +static int dasd_partition_set_flag (
150 + PedPartition* part, PedPartitionFlag flag, int state);
151 +static int dasd_partition_get_flag (
152 + const PedPartition* part, PedPartitionFlag flag);
153 +static int dasd_partition_is_flag_available (
154 + const PedPartition* part,
155 + PedPartitionFlag flag);
156 +static int dasd_partition_align (PedPartition* part,
157 + const PedConstraint* constraint);
158 +static int dasd_partition_enumerate (PedPartition* part);
159 +static int dasd_get_max_primary_partition_count (const PedDisk* disk);
161 +static PedDisk* dasd_alloc (PedDevice* dev);
162 +static PedDisk* dasd_duplicate (const PedDisk* disk);
163 +static void dasd_free (PedDisk* disk);
164 +static int dasd_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type);
165 +static int dasd_alloc_metadata (PedDisk* disk);
167 +static PedDiskOps dasd_disk_ops = {
169 + clobber: dasd_clobber,
174 + duplicate: dasd_duplicate,
176 + partition_set_system: dasd_partition_set_system,
178 + partition_new: dasd_partition_new,
179 + partition_destroy: dasd_partition_destroy,
180 + partition_set_flag: dasd_partition_set_flag,
181 + partition_get_flag: dasd_partition_get_flag,
182 + partition_is_flag_available: dasd_partition_is_flag_available,
183 + partition_set_name: NULL,
184 + partition_get_name: NULL,
185 + partition_align: dasd_partition_align,
186 + partition_enumerate: dasd_partition_enumerate,
188 + alloc_metadata: dasd_alloc_metadata,
189 + get_max_primary_partition_count:
190 + dasd_get_max_primary_partition_count,
192 + partition_duplicate: NULL
195 +static PedDiskType dasd_disk_type = {
198 + ops: &dasd_disk_ops,
203 +dasd_alloc (PedDevice* dev)
206 + LinuxSpecific* arch_specific;
207 + DasdDiskSpecific *disk_specific;
209 + PED_ASSERT (dev != NULL, return NULL);
211 + arch_specific = LINUX_SPECIFIC (dev);
212 + disk = _ped_disk_alloc (dev, &dasd_disk_type);
216 + disk->disk_specific = disk_specific = ped_malloc (sizeof (DasdDiskSpecific));
217 + if (!disk->disk_specific) {
222 + /* because we lie to parted we have to compensate with the
223 + real sector size. Record that now. */
224 + if (ioctl (arch_specific->fd, BLKSSZGET,
225 + &disk_specific->real_sector_size) == -1) {
226 + ped_exception_throw (PED_EXCEPTION_ERROR,
227 + PED_EXCEPTION_CANCEL,
228 + _("Unable to determine the block "
229 + "size of this dasd"));
230 + ped_free (disk_specific);
239 +dasd_duplicate (const PedDisk* disk)
243 + new_disk = ped_disk_new_fresh (disk->dev, &dasd_disk_type);
246 + new_disk->disk_specific = NULL;
251 +dasd_free (PedDisk* disk)
253 + PED_ASSERT (disk != NULL, return);
255 + _ped_disk_free (disk);
260 +ped_disk_dasd_init ()
262 + ped_register_disk_type (&dasd_disk_type);
266 +ped_disk_dasd_done ()
268 + ped_unregister_disk_type (&dasd_disk_type);
272 +dasd_probe (PedDevice *dev)
275 + LinuxSpecific* arch_specific;
276 + struct fdasd_anchor anchor;
278 + PED_ASSERT (dev != NULL, return 0);
279 + PED_ASSERT ((dev->type == PED_DEVICE_DASD || dev->type == PED_DEVICE_VIODASD), return 0);
281 + arch_specific = LINUX_SPECIFIC (dev);
283 + /* add partition test here */
284 + fdasd_initialize_anchor(&anchor);
286 + fdasd_get_geometry(&anchor, arch_specific->fd);
288 + fdasd_check_api_version(&anchor, arch_specific->fd);
290 + if (fdasd_check_volume(&anchor, arch_specific->fd))
291 + goto error_cleanup;
293 + fdasd_cleanup(&anchor);
297 + fdasd_cleanup(&anchor);
299 + ped_exception_throw ( PED_EXCEPTION_ERROR,
300 + PED_EXCEPTION_IGNORE_CANCEL,
308 +dasd_clobber (PedDevice* dev)
311 + LinuxSpecific* arch_specific;
312 + struct fdasd_anchor anchor;
314 + PED_ASSERT (dev != NULL, return 0);
316 + arch_specific = LINUX_SPECIFIC (dev);
318 + fdasd_initialize_anchor(&anchor);
319 + fdasd_get_geometry(&anchor, arch_specific->fd);
321 + fdasd_recreate_vtoc(&anchor);
322 + fdasd_write_labels(&anchor, arch_specific->fd);
330 +dasd_read (PedDisk* disk)
335 + PedPartition* part;
336 + PedSector start, end;
337 + PedConstraint* constraint_exact;
338 + partition_info_t *p;
339 + LinuxSpecific* arch_specific;
340 + DasdDiskSpecific* disk_specific;
344 + PED_ASSERT (disk != NULL, return 0);
346 + PED_ASSERT (disk->dev != NULL, return 0);
351 + arch_specific = LINUX_SPECIFIC (dev);
352 + disk_specific = disk->disk_specific;
354 + /* XXX why are we re-creating the anchor? */
355 + if (disk_specific->anchor) {
356 + fdasd_cleanup(disk_specific->anchor);
357 + free(disk_specific->anchor);
360 + disk_specific->anchor = ped_malloc(sizeof(fdasd_anchor_t));
364 + fdasd_initialize_anchor(disk_specific->anchor);
366 + fdasd_get_geometry(disk_specific->anchor, arch_specific->fd);
368 + /* check dasd for labels and vtoc */
369 + if (fdasd_check_volume(disk_specific->anchor, arch_specific->fd))
370 + goto error_close_dev;
372 + if ((disk_specific->anchor->geo.cylinders * disk_specific->anchor->geo.heads) > BIG_DISK_SIZE)
373 + disk_specific->anchor->big_disk++;
375 + ped_disk_delete_all (disk);
377 + if (strncmp(disk_specific->anchor->vlabel->volkey, vtoc_ebcdic_enc ("LNX1", str, 4), 4) == 0)
379 + DasdPartitionData* dasd_data;
381 + /* LDL format, old one */
382 + disk_specific->format_type = 1;
384 + end = (long long)(long long) disk_specific->anchor->geo.cylinders
385 + * (long long)disk_specific->anchor->geo.heads
386 + * (long long)disk->dev->hw_geom.sectors
387 + * (long long)disk_specific->real_sector_size
388 + / (long long)disk->dev->sector_size - 1;
389 + part = ped_partition_new (disk, PED_PARTITION_PROTECTED, NULL, start, end);
391 + goto error_close_dev;
393 + part->fs_type = ped_file_system_probe (&part->geom);
394 + dasd_data = part->disk_specific;
395 + dasd_data->raid = 0;
396 + dasd_data->lvm = 0;
397 + dasd_data->type = 0;
398 + if (!ped_disk_add_partition (disk, part, NULL))
399 + goto error_close_dev;
403 + /* CDL format, newer */
404 + disk_specific->format_type = 2;
406 + p = disk_specific->anchor->first;
409 + for (i = 1 ; i <= USABLE_PARTITIONS; i++)
411 + char *ch = p->f1->DS1DSNAM;
412 + DasdPartitionData* dasd_data;
415 + if (p->used != 0x01)
420 + start = (long long)(long long) p->start_trk
421 + * (long long) disk->dev->hw_geom.sectors
422 + * (long long) disk_specific->real_sector_size
423 + / (long long) disk->dev->sector_size
425 + end = (long long)((long long) p->end_trk + 1)
426 + * (long long) disk->dev->hw_geom.sectors
427 + * (long long) disk_specific->real_sector_size
428 + / (long long) disk->dev->sector_size
430 + part = ped_partition_new (disk, 0, NULL, start, end);
434 + goto error_close_dev;
439 + part->fs_type = ped_file_system_probe (&part->geom);
441 + vtoc_ebcdic_dec(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
442 + ch = strstr(p->f1->DS1DSNAM, "PART");
444 + strncpy(str, ch+9, 6);
446 + /*fprintf(stderr, "f1 label contains: >%s<\n", p->f1->DS1DSNAM);
448 + strcpy(str, "error");
449 + fprintf(stderr, "Error, f1 label contains: >%s<\n", p->f1->DS1DSNAM);
453 + dasd_data = part->disk_specific;
455 + if(strncmp(PART_TYPE_RAID, str, 6) == 0)
456 + ped_partition_set_flag(part, PED_PARTITION_RAID, 1);
458 + ped_partition_set_flag(part, PED_PARTITION_RAID, 0);
460 + if(strncmp(PART_TYPE_LVM, str, 6) == 0)
461 + ped_partition_set_flag(part, PED_PARTITION_LVM, 1);
463 + ped_partition_set_flag(part, PED_PARTITION_LVM, 0);
465 + if(strncmp(PART_TYPE_SWAP, str, 6) == 0) {
466 + dasd_data->system = PARTITION_LINUX_SWAP;
470 + vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
472 + dasd_data->part_info = (void *) p;
473 + dasd_data->type = 0;
475 + constraint_exact = ped_constraint_exact (&part->geom);
476 + if(!constraint_exact)
477 + goto error_close_dev;
478 + if (!ped_disk_add_partition (disk, part, constraint_exact))
479 + goto error_close_dev;
480 + ped_constraint_destroy (constraint_exact);
482 + if (p->fspace_trk > 0) {
483 + start = (long long)((long long) p->end_trk + 1)
484 + * (long long) disk->dev->hw_geom.sectors
485 + * (long long) disk_specific->real_sector_size
486 + / (long long) disk->dev->sector_size
488 + end = (long long)((long long) p->end_trk + 1 + p->fspace_trk)
489 + * (long long) disk->dev->hw_geom.sectors
490 + * (long long) disk_specific->real_sector_size
491 + / (long long) disk->dev->sector_size
493 + part = ped_partition_new (disk, 0, NULL, start, end);
495 + goto error_close_dev;
496 + part->type = PED_PARTITION_FREESPACE;
497 + constraint_exact = ped_constraint_exact (&part->geom);
498 + if(!constraint_exact)
499 + goto error_close_dev;
500 + if (!ped_disk_add_partition (disk, part, constraint_exact))
501 + goto error_close_dev;
502 + ped_constraint_destroy (constraint_exact);
517 +dasd_update_type(PedDisk* disk)
519 + PedPartition* part;
520 + LinuxSpecific* arch_specific;
521 + DasdDiskSpecific* disk_specific;
524 + arch_specific = LINUX_SPECIFIC (disk->dev);
525 + disk_specific = disk->disk_specific;
529 + for (part = ped_disk_next_partition (disk, NULL); part;
530 + part = ped_disk_next_partition (disk, part)) {
531 + partition_info_t *p;
533 + DasdPartitionData* dasd_data;
537 + if(part->type & PED_PARTITION_FREESPACE
538 + || part->type & PED_PARTITION_METADATA) {
544 + dasd_data = part->disk_specific;
545 + p = dasd_data->part_info;
550 + vtoc_ebcdic_dec(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
551 + ch = strstr(p->f1->DS1DSNAM, "PART");
552 + /*fprintf(stderr, "f1 label contains: >%s<\n", p->f1->DS1DSNAM);*/
556 + vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
563 + switch(dasd_data->system) {
564 + case PARTITION_LINUX_LVM:
566 + strncpy(ch, PART_TYPE_LVM, 6);
568 + case PARTITION_LINUX_RAID:
570 + strncpy(ch, PART_TYPE_RAID, 6);
572 + case PARTITION_LINUX:
574 + strncpy(ch, PART_TYPE_NATIVE, 6);
576 + case PARTITION_LINUX_SWAP:
578 + strncpy(ch, PART_TYPE_SWAP, 6);
582 + strncpy(ch, PART_TYPE_NATIVE, 6);
585 + disk_specific->anchor->vtoc_changed++;
587 + vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
593 +dasd_write (PedDisk* disk)
595 + DasdPartitionData* dasd_data;
596 + PedPartition* part;
599 + partition_info_t *p;
600 + LinuxSpecific* arch_specific;
601 + DasdDiskSpecific* disk_specific;
602 + PED_ASSERT (disk != NULL, return 0);
603 + PED_ASSERT (disk->dev != NULL, return 0);
605 + arch_specific = LINUX_SPECIFIC (disk->dev);
606 + disk_specific = disk->disk_specific;
610 + /* If formated in LDL, don't write anything. */
611 + if (disk_specific->format_type == 1)
614 + /* XXX re-initialize anchor? */
615 + fdasd_initialize_anchor(disk_specific->anchor);
616 + fdasd_get_geometry(disk_specific->anchor, arch_specific->fd);
618 + /* check dasd for labels and vtoc */
619 + if (fdasd_check_volume(disk_specific->anchor, arch_specific->fd))
622 + if ((disk_specific->anchor->geo.cylinders * disk_specific->anchor->geo.heads) > BIG_DISK_SIZE)
623 + disk_specific->anchor->big_disk++;
625 + fdasd_recreate_vtoc(disk_specific->anchor);
627 + for (i = 1; i <= USABLE_PARTITIONS; i++) {
628 + unsigned int start, stop;
632 + part = ped_disk_get_partition (disk, i);
638 + start = part->geom.start * disk->dev->sector_size
639 + / disk_specific->real_sector_size / disk->dev->hw_geom.sectors;
640 + stop = (part->geom.end + 1)
641 + * disk->dev->sector_size / disk_specific->real_sector_size
642 + / disk->dev->hw_geom.sectors - 1;
645 + dasd_data = part->disk_specific;
647 + type = dasd_data->type;
649 + /*fprintf(stderr, "Partition %d %ld - %ld \t", i, part->geom.start, part->geom.end);
650 + fprintf(stderr, "Partition %d %ld - %ld \n", i, start, stop);
653 + p = fdasd_add_partition(disk_specific->anchor, start, stop);
658 + dasd_data->part_info = (void *) p;
659 + p->type = dasd_data->system;
663 + if(!fdasd_prepare_labels(disk_specific->anchor, arch_specific->fd))
666 + dasd_update_type(disk);
669 + if(!fdasd_write_labels(disk_specific->anchor, arch_specific->fd))
678 +static PedPartition*
679 +dasd_partition_new (const PedDisk* disk, PedPartitionType part_type,
680 + const PedFileSystemType* fs_type,
681 + PedSector start, PedSector end)
683 + PedPartition* part;
685 + part = _ped_partition_alloc (disk, part_type, fs_type, start, end);
689 + part->disk_specific = ped_malloc (sizeof (DasdPartitionData));
698 +dasd_partition_destroy (PedPartition* part)
700 + PED_ASSERT (part != NULL, return);
702 + if (ped_partition_is_active (part))
703 + ped_free (part->disk_specific);
709 +dasd_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
712 + PedPartition* walk;
713 + DasdPartitionData* dasd_data;
714 + const PedFileSystemType* fs_type;
716 + PED_ASSERT (part != NULL, return 0);
717 + PED_ASSERT (part->disk_specific != NULL, return 0);
718 + dasd_data = part->disk_specific;
721 + case PED_PARTITION_RAID:
723 + dasd_data->lvm = 0;
725 + dasd_data->raid = state;
726 + return ped_partition_set_system (part, part->fs_type);
727 + case PED_PARTITION_LVM:
729 + dasd_data->raid = 0;
731 + dasd_data->lvm = state;
732 + return ped_partition_set_system (part, part->fs_type);
740 +dasd_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
742 + DasdPartitionData* dasd_data;
744 + PED_ASSERT (part != NULL, return 0);
745 + PED_ASSERT (part->disk_specific != NULL, return 0);
746 + dasd_data = part->disk_specific;
749 + case PED_PARTITION_RAID:
750 + return dasd_data->raid;
752 + case PED_PARTITION_LVM:
753 + return dasd_data->lvm;
761 +dasd_partition_is_flag_available (const PedPartition* part,
762 + PedPartitionFlag flag)
765 + case PED_PARTITION_RAID:
768 + case PED_PARTITION_LVM:
778 +dasd_get_max_primary_partition_count (const PedDisk* disk)
780 + DasdDiskSpecific* disk_specific;
782 + disk_specific = disk->disk_specific;
783 + /* If formated in LDL, maximum partition number is 1 */
784 + if (disk_specific->format_type == 1)
787 + return USABLE_PARTITIONS;
790 +static PedConstraint*
791 +_primary_constraint (PedDisk* disk)
793 + PedAlignment start_align;
794 + PedAlignment end_align;
795 + PedGeometry max_geom;
796 + PedSector sector_size;
797 + LinuxSpecific* arch_specific;
798 + DasdDiskSpecific* disk_specific;
802 + arch_specific = LINUX_SPECIFIC (disk->dev);
803 + disk_specific = disk->disk_specific;
804 + sector_size = disk_specific->real_sector_size / disk->dev->sector_size;
806 + if (!ped_alignment_init (&start_align, 0, disk->dev->hw_geom.sectors * sector_size))
808 + if (!ped_alignment_init (&end_align, -1, disk->dev->hw_geom.sectors * sector_size))
810 + if (!ped_geometry_init (&max_geom, disk->dev, 0, disk->dev->length))
813 + return ped_constraint_new (&start_align, &end_align, &max_geom,
814 + &max_geom, 1, disk->dev->length);
818 +dasd_partition_align (PedPartition* part, const PedConstraint* constraint)
820 + DasdDiskSpecific* disk_specific;
822 + PED_ASSERT (part != NULL, return 0);
824 + disk_specific = part->disk->disk_specific;
825 + /* If formated in LDL, ignore metadata partition */
826 + if (disk_specific->format_type == 1)
829 + if (_ped_partition_attempt_align (part, constraint,
830 + _primary_constraint (part->disk)))
833 +#ifndef DISCOVER_ONLY
834 + ped_exception_throw (
835 + PED_EXCEPTION_ERROR,
836 + PED_EXCEPTION_CANCEL,
837 + _("Unable to satisfy all constraints on the partition."));
844 +dasd_partition_enumerate (PedPartition* part)
849 + /* never change the partition numbers */
850 + if (part->num != -1)
852 + for (i = 1; i <= USABLE_PARTITIONS; i++) {
853 + p = ped_disk_get_partition (part->disk, i);
860 + /* failed to allocate a number */
861 + ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
862 + _("Unable to allocate a dasd disklabel slot"));
867 +dasd_partition_set_system (PedPartition* part,
868 + const PedFileSystemType* fs_type)
870 + DasdPartitionData* dasd_data = part->disk_specific;
871 + PedSector cyl_size = part->disk->dev->hw_geom.sectors * part->disk->dev->hw_geom.heads;
875 + part->fs_type = fs_type;
877 + if (dasd_data->lvm) {
878 + dasd_data->system = PARTITION_LINUX_LVM;
882 + if (dasd_data->raid) {
883 + dasd_data->system = PARTITION_LINUX_RAID;
888 + dasd_data->system = PARTITION_LINUX;
890 + } else if (!strcmp (fs_type->name, "linux-swap")) {
891 + dasd_data->system = PARTITION_LINUX_SWAP;
894 + dasd_data->system = PARTITION_LINUX;
902 +dasd_alloc_metadata (PedDisk* disk)
904 + PedPartition* new_part;
905 + PedConstraint* constraint_any = NULL;
906 + PedSector vtoc_end;
907 + LinuxSpecific* arch_specific;
908 + DasdDiskSpecific* disk_specific;
910 + PED_ASSERT (disk != NULL, goto error);
911 + PED_ASSERT (disk->dev != NULL, goto error);
913 + arch_specific = LINUX_SPECIFIC (disk->dev);
914 + disk_specific = disk->disk_specific;
916 + constraint_any = ped_constraint_any (disk->dev);
918 + /* If formated in LDL, the real partition starts at sector 24. */
919 + if (disk_specific->format_type == 1)
922 + /* Mark the start of the disk as metadata. */
923 + vtoc_end = (FIRST_USABLE_TRK * (long long) disk->dev->hw_geom.sectors
924 + * (long long) disk_specific->real_sector_size
925 + / (long long) disk->dev->sector_size) - 1;
926 + new_part = ped_partition_new (disk, PED_PARTITION_METADATA, NULL,
931 + if (!ped_disk_add_partition (disk, new_part, constraint_any)) {
932 + ped_partition_destroy (new_part);
936 + ped_constraint_destroy (constraint_any);
939 + ped_constraint_destroy (constraint_any);
942 diff -ruN --minimal parted-1.6.21.orig/libparted/fdasd.c parted-1.6.21/libparted/fdasd.c
943 --- parted-1.6.21.orig/libparted/fdasd.c 1969-12-31 19:00:00.000000000 -0500
944 +++ parted-1.6.21/libparted/fdasd.c 2005-01-21 15:00:40.428628348 -0500
947 + * File...........: arch/s390/tools/fdasd.c
948 + * Author(s)......: Volker Sameske <sameske@de.ibm.com>
949 + * Bugreports.to..: <Linux390@de.ibm.com>
950 + * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2001
952 + * History of changes (starts March 2001)
953 + * 2001-04-11 possibility to change volume serial added
954 + * possibility to change partition type added
955 + * some changes to DS4HPCHR and DS4DSREC
956 + * 2001-05-03 check for invalid partition numbers added
957 + * wrong free_space calculation bug fixed
958 + * 2001-06-26 '-a' option added, it is now possible to add a single
959 + * partition in non-interactive mode
960 + * 2001-06-26 long parameter support added
966 +#include <parted/parted.h>
968 +#include <libintl.h>
970 +# define _(String) dgettext (PACKAGE, String)
972 +# define _(String) (String)
973 +#endif /* ENABLE_NLS */
976 +#define GETARG(x) {int k=strlen(optarg);x=malloc(k);strncpy(x,optarg,k);}
979 +getpos (fdasd_anchor_t *anc, int dsn)
982 + return anc->partno[dsn];
986 +getdsn (fdasd_anchor_t *anc, int pos)
991 + for (i=0; i<USABLE_PARTITIONS; i++)
993 + if (anc->partno[i] == pos)
1001 +setpos (fdasd_anchor_t *anc, int dsn, int pos)
1004 + anc->partno[dsn] = pos;
1009 +fdasd_check_volser (char *s, int devno)
1014 + for (i = 0; i < 6; i++)
1016 + if ((s[i] < 0x20) || (s[i] > 0x7a) || ((s[i] >= 0x21) && (s[i] <= 0x22)) || /* !" */
1017 + ((s[i] >= 0x26) && (s[i] <= 0x2f)) || /* &'()*+,-./ */
1018 + ((s[i] >= 0x3a) && (s[i] <= 0x3f)) || /* :;<=>? */
1019 + ((s[i] >= 0x5b) && (s[i] <= 0x60))) /* \]^_´ */
1021 + s[i] = toupper (s[i]);
1025 + for (i = 0; i < 6; i++)
1028 + for (j = i; j < 6; j++)
1039 + printf ("Usage error, switching to default.\n");
1040 + sprintf (s, "0X%04x", devno);
1041 + for (i = 0; i < 6; i++)
1042 + s[i] = toupper (s[i]);
1050 +fdasd_cleanup (fdasd_anchor_t *anchor)
1054 + partition_info_t *p, *q;
1056 + if (anchor == NULL) return;
1058 + if (anchor->f4 != NULL) free(anchor->f4);
1059 + if (anchor->f5 != NULL) free(anchor->f5);
1060 + if (anchor->f7 != NULL) free(anchor->f7);
1061 + if (anchor->vlabel != NULL) free(anchor->vlabel);
1063 + p = anchor->first;
1067 + for (i=1; i <= USABLE_PARTITIONS; i++)
1082 +fdasd_error(fdasd_anchor_t *anc,
1083 + enum fdasd_failure why,
1087 + char error[2*LINE_LENGTH], *message = error;
1091 + case unable_to_open_disk:
1092 + sprintf(error, _("%s open error\n%s\n"),
1093 + FDASD_ERROR, str);
1095 + case unable_to_seek_disk:
1096 + sprintf(error, _("%s seek error\n%s\n"),
1097 + FDASD_ERROR, str);
1099 + case unable_to_read_disk:
1100 + sprintf(error, _("%s read error\n%s\n"),
1101 + FDASD_ERROR, str);
1103 + case read_only_disk:
1104 + sprintf(error, _("%s write error\n%s\n"),
1105 + FDASD_ERROR, str);
1107 + case unable_to_ioctl:
1108 + sprintf(error, _("%s IOCTL error\n%s\n"),
1109 + FDASD_ERROR, str);
1111 + case api_version_mismatch:
1112 + sprintf(error, _("%s API version mismatch\n%s\n"),
1113 + FDASD_ERROR, str);
1115 + case wrong_disk_type:
1116 + sprintf(error, _("%s Unsupported disk type\n%s\n"),
1117 + FDASD_ERROR, str);
1119 + case wrong_disk_format:
1120 + sprintf(error, _("%s Unsupported disk format\n%s\n"),
1121 + FDASD_ERROR, str);
1124 + sprintf(error, _("%s Disk in use\n%s\n"),
1125 + FDASD_ERROR, str);
1127 + case config_syntax_error:
1128 + sprintf(error, _("%s Config file syntax error\n%s\n"),
1129 + FDASD_ERROR, str);
1131 + case vlabel_corrupted:
1132 + sprintf(error, _("%s Volume label is corrupted.\n%s\n"),
1133 + FDASD_ERROR, str);
1135 + case dsname_corrupted:
1136 + sprintf(error, _("%s a data set name is corrupted.\n%s\n"),
1137 + FDASD_ERROR, str);
1139 + case malloc_failed:
1140 + sprintf(error, _("%s space allocation\n%s\n"),
1141 + FDASD_ERROR, str);
1143 + case device_verification_failed:
1144 + sprintf(error, _("%s device verification failed\n" \
1145 + "The specified device is not a valid DASD device\n"),
1149 + sprintf(error, _("%s Fatal error\n%s\n"),
1150 + FDASD_ERROR, str);
1153 + ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, message);
1158 + * converts cyl-cyl-head-head-blk to blk
1160 +static unsigned long
1161 +cchhb2blk (cchhb_t *p, struct fdasd_hd_geometry *geo)
1164 + return (unsigned long) (p->cc * geo->heads * geo->sectors +
1165 + p->hh * geo->sectors +
1173 +static char *fdasd_partition_type (char *str)
1176 + if (strncmp("NATIVE", str, 6) == 0)
1177 + strcpy(str, "Linux native");
1178 + else if (strncmp("NEW ", str, 6) == 0)
1179 + strcpy(str, "Linux native");
1180 + else if (strncmp("SWAP ", str, 6) == 0)
1181 + strcpy(str, "Linux swap");
1182 + else if (strncmp("RAID ", str, 6) == 0)
1183 + strcpy(str, "Linux Raid");
1185 + strcpy(str, "unknown");
1192 + * initializes the anchor structure and allocates some
1193 + * memory for the labels
1196 +fdasd_initialize_anchor (fdasd_anchor_t * anc)
1200 + volume_label_t *v;
1201 + partition_info_t *p = NULL;
1202 + partition_info_t *q = NULL;
1205 + anc->dev_type = 0;
1206 + anc->used_partitions = 0;
1210 + anc->big_disk = 0;
1211 + anc->volid_specified = 0;
1212 + anc->config_specified = 0;
1213 + anc->auto_partition = 0;
1214 + anc->devname_specified = 0;
1215 + anc->print_table = 0;
1217 + anc->option_reuse = 0;
1218 + anc->option_recreate = 0;
1220 + anc->vlabel_changed = 0;
1221 + anc->vtoc_changed = 0;
1223 + anc->fspace_trk = 0;
1224 + anc->label_pos = 0;
1226 + for (i=0; i<USABLE_PARTITIONS; i++)
1227 + setpos(anc, i, -1);
1229 + bzero(anc->confdata, sizeof(config_data_t));
1231 + anc->f4 = malloc(sizeof(format4_label_t));
1232 + if (anc->f4 == NULL)
1233 + fdasd_error(anc, malloc_failed,
1234 + "FMT4 DSCB memory allocation failed.");
1236 + anc->f5 = malloc(sizeof(format5_label_t));
1237 + if (anc->f5 == NULL)
1238 + fdasd_error(anc, malloc_failed,
1239 + "FMT5 DSCB memory allocation failed.");
1241 + anc->f7 = malloc(sizeof(format7_label_t));
1242 + if (anc->f7 == NULL)
1243 + fdasd_error(anc, malloc_failed,
1244 + "FMT7 DSCB memory allocation failed.");
1246 + bzero(anc->f4, sizeof(format4_label_t));
1247 + bzero(anc->f5, sizeof(format5_label_t));
1248 + bzero(anc->f7, sizeof(format7_label_t));
1250 + v = malloc(sizeof(volume_label_t));
1252 + fdasd_error(anc, malloc_failed,
1253 + "Volume label memory allocation failed.");
1254 + bzero(v, sizeof(volume_label_t));
1257 + for (i=1; i<=USABLE_PARTITIONS; i++)
1259 + p = malloc(sizeof(partition_info_t));
1261 + fdasd_error(anc, malloc_failed,
1262 + "Partition info memory allocation failed.");
1266 + p->fspace_trk = 0;
1269 + /* add p to double pointered list */
1275 + else if (i == USABLE_PARTITIONS)
1288 + p->f1 = malloc(sizeof(format1_label_t));
1289 + if (p->f1 == NULL)
1290 + fdasd_error(anc, malloc_failed,
1291 + "FMT1 DSCB memory allocation failed.");
1292 + bzero(p->f1, sizeof(format1_label_t));
1300 + * call IOCTL to re-read the partition table
1303 +fdasd_reread_partition_table (fdasd_anchor_t * anc, int fd)
1306 + char str[LINE_LENGTH];
1309 + if (ioctl (fd, BLKRRPART, NULL) != 0)
1310 + fdasd_error (anc, unable_to_ioctl, "Error while rereading "
1311 + "partition table.\nPlease reboot!");
1316 + * writes all changes to dasd
1319 +fdasd_write_vtoc_labels (fdasd_anchor_t * anc, int fd)
1322 + partition_info_t *p;
1324 + char dsno[6], s1[7], s2[45], *c1, *c2, *ch;
1327 + b = (cchhb2blk (&anc->vlabel->vtoc, &anc->geo) - 1) * anc->blksize;
1329 + fdasd_error (anc, vlabel_corrupted, "");
1331 + /* write FMT4 DSCB */
1332 + vtoc_write_label (fd, b, NULL, anc->f4, NULL, NULL);
1334 + /* write FMT5 DSCB */
1335 + b += anc->blksize;
1336 + vtoc_write_label (fd, b, NULL, NULL, anc->f5, NULL);
1338 + /* write FMT7 DSCB */
1339 + if (anc->big_disk)
1341 + b += anc->blksize;
1342 + vtoc_write_label (fd, b, NULL, NULL, NULL, anc->f7);
1345 + /* loop over all FMT1 DSCBs */
1347 + for (i = 0; i < USABLE_PARTITIONS; i++)
1349 + b += anc->blksize;
1351 + if (p->used != 0x01)
1353 + vtoc_write_label (fd, b, p->f1, NULL, NULL, NULL);
1357 + strncpy (p->f1->DS1DSSN, anc->vlabel->volid, 6);
1359 + ch = p->f1->DS1DSNAM;
1360 + vtoc_ebcdic_dec (ch, ch, 44);
1363 + if (getdsn (anc, i) > -1)
1365 + /* re-use the existing data set name */
1366 + c2 = strchr (c1, '.');
1368 + strncpy (s2, c2, 31);
1370 + fdasd_error (anc, dsname_corrupted, "");
1372 + strncpy (s1, anc->vlabel->volid, 6);
1373 + vtoc_ebcdic_dec (s1, s1, 6);
1375 + strncpy (c1, s1, 7);
1376 + c1 = strchr (ch, ' ');
1377 + strncpy (c1, s2, 31);
1381 + /* create a new data set name */
1382 + while (getpos (anc, k) > -1)
1385 + setpos (anc, k, i);
1387 + strncpy (s2, ch, 44);
1389 + vtoc_ebcdic_dec (s2, s2, 44);
1391 + strncpy (ch, "LINUX.V " " ", 44);
1393 + strncpy (s1, anc->vlabel->volid, 6);
1394 + vtoc_ebcdic_dec (s1, s1, 6);
1395 + strncpy (c1, s1, 6);
1397 + c1 = strchr (ch, ' ');
1398 + strncpy (c1, ".PART", 5);
1401 + sprintf (dsno, "%04d.", k + 1);
1402 + strncpy (c1, dsno, 5);
1406 + case PARTITION_LINUX_LVM:
1407 + strncpy(c1, PART_TYPE_LVM, 6);
1409 + case PARTITION_LINUX_RAID:
1410 + strncpy(c1, PART_TYPE_RAID, 6);
1412 + case PARTITION_LINUX:
1413 + strncpy(c1, PART_TYPE_NATIVE, 6);
1415 + case PARTITION_LINUX_SWAP:
1416 + strncpy(c1, PART_TYPE_SWAP, 6);
1419 + strncpy(c1, PART_TYPE_NATIVE, 6);
1423 + vtoc_ebcdic_enc (ch, ch, 44);
1425 + vtoc_write_label (fd, b, p->f1, NULL, NULL, NULL);
1432 + * writes all changes to dasd
1435 +fdasd_write_labels (fdasd_anchor_t * anc, int fd)
1438 + if (anc->vlabel_changed)
1440 + vtoc_write_volume_label (fd, anc->label_pos, anc->vlabel);
1443 + if (anc->vtoc_changed)
1444 + fdasd_write_vtoc_labels (anc, fd);
1447 + if ((anc->vtoc_changed) || (anc->vlabel_changed))
1448 + fdasd_reread_partition_table (anc, fd);
1457 + * writes all changes to dasd
1460 +fdasd_prepare_labels (fdasd_anchor_t *anc, int fd)
1463 + partition_info_t *p = anc->first;
1464 + char dsno[6], s1[7], s2[45], *c1, *c2, *ch;
1467 + /* loop over all FMT1 DSCBs */
1469 + for (i = 0; i < USABLE_PARTITIONS; i++)
1471 + strncpy (p->f1->DS1DSSN, anc->vlabel->volid, 6);
1473 + ch = p->f1->DS1DSNAM;
1474 + vtoc_ebcdic_dec (ch, ch, 44);
1477 + if (getdsn (anc, i) > -1)
1479 + /* re-use the existing data set name */
1480 + c2 = strchr (c1, '.');
1482 + strncpy (s2, c2, 31);
1484 + fdasd_error (anc, dsname_corrupted, "");
1486 + strncpy (s1, anc->vlabel->volid, 6);
1487 + vtoc_ebcdic_dec (s1, s1, 6);
1489 + strncpy (c1, s1, 7);
1490 + c1 = strchr (ch, ' ');
1491 + strncpy (c1, s2, 31);
1495 + /* create a new data set name */
1496 + while (getpos (anc, k) > -1)
1499 + setpos (anc, k, i);
1501 + strncpy (s2, ch, 44);
1503 + vtoc_ebcdic_dec (s2, s2, 44);
1505 + strncpy (ch, "LINUX.V " " ", 44);
1507 + strncpy (s1, anc->vlabel->volid, 6);
1508 + vtoc_ebcdic_dec (s1, s1, 6);
1509 + strncpy (c1, s1, 6);
1511 + c1 = strchr (ch, ' ');
1512 + strncpy (c1, ".PART", 5);
1515 + sprintf (dsno, "%04d.", k + 1);
1516 + strncpy (c1, dsno, 5);
1520 + case PARTITION_LINUX_LVM:
1521 + strncpy(c1, PART_TYPE_LVM, 6);
1523 + case PARTITION_LINUX_RAID:
1524 + strncpy(c1, PART_TYPE_RAID, 6);
1526 + case PARTITION_LINUX:
1527 + strncpy(c1, PART_TYPE_NATIVE, 6);
1529 + case PARTITION_LINUX_SWAP:
1530 + strncpy(c1, PART_TYPE_SWAP, 6);
1533 + strncpy(c1, PART_TYPE_NATIVE, 6);
1537 + vtoc_ebcdic_enc (ch, ch, 44);
1548 +fdasd_recreate_vtoc(fdasd_anchor_t *anc)
1551 + partition_info_t *p = anc->first;
1554 + vtoc_init_format4_label(anc->f4,
1555 + USABLE_PARTITIONS,
1556 + anc->geo.cylinders,
1562 + vtoc_init_format5_label(anc->f5);
1563 + vtoc_init_format7_label(anc->f7);
1564 + vtoc_set_freespace(anc->f4, anc->f5, anc->f7,
1565 + '+', anc->verbose,
1567 + anc->geo.cylinders * anc->geo.heads - 1,
1568 + anc->geo.cylinders, anc->geo.heads);
1570 + for (i = 0; i < USABLE_PARTITIONS; i++)
1572 + bzero(p->f1, sizeof(format1_label_t));
1577 + p->fspace_trk = 0;
1582 + anc->used_partitions = 0;
1583 + anc->fspace_trk = anc->geo.cylinders * anc->geo.heads - FIRST_USABLE_TRK;
1585 + for (i=0; i<USABLE_PARTITIONS; i++)
1586 + setpos(anc, i, -1);
1588 + anc->vtoc_changed++;
1593 + * changes the volume serial
1596 +fdasd_change_volser (fdasd_anchor_t *anc, char *line_ptr)
1601 + if (strcmp(line_ptr, "") != 0)
1605 + /* fill with blanks if necessary and remove the linebreak */
1606 + i = strlen(line_ptr);
1609 + strncpy(line_ptr + i - 1, " ", 6);
1612 + strncpy(str, line_ptr, 6);
1614 + for (i=0; i<6; i++) str[i] = toupper(str[i]);
1617 + fdasd_check_volser (str, anc->devno);
1618 + vtoc_volume_label_set_volser(anc->vlabel, str);
1620 + vtoc_set_cchhb(&anc->vlabel->vtoc, 0x0000, 0x0001, 0x01);
1621 + anc->vlabel_changed++;
1622 + anc->vtoc_changed++;
1628 + * sets some important partition data
1629 + * (like used, start_trk, end_trk, len_trk)
1630 + * by calculating these values with the
1631 + * information provided in the labels
1634 +fdasd_update_partition_info (fdasd_anchor_t *anc)
1637 + partition_info_t *q = NULL, *p = anc->first;
1638 + unsigned int h = anc->geo.heads;
1639 + unsigned long max = anc->geo.cylinders * h - 1;
1643 + anc->used_partitions = anc->geo.sectors - 2 - anc->f4->DS4DSREC;
1645 + for (i = 1; i <= USABLE_PARTITIONS; i++)
1647 + if (p->f1->DS1FMTID != 0xf1)
1650 + /* there is no partition at all */
1651 + anc->fspace_trk = max - FIRST_USABLE_TRK + 1;
1653 + /* previous partition was the last one */
1654 + q->fspace_trk = max - q->end_trk;
1658 + /* this is a valid format 1 label */
1660 + p->start_trk = p->f1->DS1EXT1.llimit.cc * h +
1661 + p->f1->DS1EXT1.llimit.hh;
1662 + p->end_trk = p->f1->DS1EXT1.ulimit.cc * h +
1663 + p->f1->DS1EXT1.ulimit.hh;
1664 + p->len_trk = p->end_trk - p->start_trk + 1;
1667 + /* first partition, there is at least one */
1668 + anc->fspace_trk = p->start_trk - FIRST_USABLE_TRK;
1671 + if (i == USABLE_PARTITIONS)
1672 + /* last possible partition */
1673 + p->fspace_trk = max - p->end_trk;
1675 + /* set free space values of previous partition */
1676 + q->fspace_trk = p->start_trk - q->end_trk - 1;
1679 + ch = p->f1->DS1DSNAM;
1680 + vtoc_ebcdic_dec (ch, ch, 44);
1681 + if (strstr(ch, PART_TYPE_LVM))
1682 + p->type = PARTITION_LINUX_LVM;
1683 + else if (strstr(ch, PART_TYPE_RAID))
1684 + p->type = PARTITION_LINUX_RAID;
1685 + else if (strstr(ch, PART_TYPE_NATIVE))
1686 + p->type = PARTITION_LINUX;
1687 + else if (strstr(ch, PART_TYPE_SWAP))
1688 + p->type = PARTITION_LINUX_SWAP;
1690 + p->type = PARTITION_LINUX;
1691 + vtoc_ebcdic_enc (ch, ch, 44);
1700 + * reorganizes all FMT1s, after that all used FMT1s should be right in
1701 + * front of all unused FMT1s
1704 +fdasd_reorganize_FMT1s (fdasd_anchor_t *anc)
1708 + format1_label_t *ltmp;
1709 + partition_info_t *ptmp;
1711 + for (i=1; i<=USABLE_PARTITIONS - 1; i++)
1713 + ptmp = anc->first;
1714 + for (j=1; j<=USABLE_PARTITIONS - i; j++)
1716 + if (ptmp->f1->DS1FMTID < ptmp->next->f1->DS1FMTID)
1719 + ptmp->f1 = ptmp->next->f1;
1720 + ptmp->next->f1 = ltmp;
1732 +fdasd_process_valid_vtoc (fdasd_anchor_t * anc, unsigned long b, int fd)
1735 + int f5_counter = 0, f7_counter = 0, f1_counter = 0, oldfmt = 0;
1736 + int i, n, f1size = sizeof (format1_label_t);
1737 + partition_info_t *p = anc->first;
1738 + format1_label_t q;
1741 + b += anc->blksize;
1743 + for (i = 1; i <= anc->geo.sectors; i++)
1745 + bzero (&q, f1size);
1746 + vtoc_read_label (fd, b, &q, NULL, NULL, NULL);
1748 + switch (q.DS1FMTID)
1753 + memcpy (p->f1, &q, f1size);
1756 + vtoc_ebcdic_dec (p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
1757 + ch = strstr (p->f1->DS1DSNAM, "PART");
1760 + strncpy (s, ch + 4, 4);
1765 + vtoc_ebcdic_enc (p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
1767 + /* this dasd has data set names 0000-0002
1768 + but we use now 0001-0003 */
1772 + if (((oldfmt == 0) && (n < 0)) || (n >= USABLE_PARTITIONS))
1777 + if (oldfmt) /* correct +1 */
1779 + setpos (anc, n + 1, f1_counter);
1782 + setpos (anc, n, f1_counter);
1789 + memcpy (anc->f5, &q, f1size);
1793 + if (f7_counter == 0)
1794 + memcpy (anc->f7, &q, f1size);
1798 + b += anc->blksize;
1803 + /* this is the old format PART0000 - PART0002 */
1804 + anc->vtoc_changed++;
1807 + if ((f5_counter == 0) || (anc->big_disk))
1808 + vtoc_init_format5_label (anc->f5);
1810 + if (f7_counter == 0)
1811 + vtoc_init_format7_label (anc->f7);
1813 + fdasd_reorganize_FMT1s (anc);
1814 + fdasd_update_partition_info (anc);
1822 +fdasd_valid_vtoc_pointer(fdasd_anchor_t *anc, unsigned long b, int fd)
1825 + char str[LINE_LENGTH];
1827 + /* VOL1 label contains valid VTOC pointer */
1828 + vtoc_read_label (fd, b, NULL, anc->f4, NULL, NULL);
1830 + if (anc->f4->DS4IDFMT != 0xf4)
1832 + if (strncmp (anc->vlabel->volkey, vtoc_ebcdic_enc ("LNX1", str, 4), 4) == 0)
1834 + /* format4 DSCB is invalid
1835 + printf(" invalid\ncreating new VTOC...\n"); */
1836 + fdasd_error(anc, wrong_disk_format, "Invalid VTOC");
1839 + fdasd_process_valid_vtoc (anc, b, fd);
1846 + * check the dasd for a volume label
1849 +fdasd_check_volume (fdasd_anchor_t *anc, int fd)
1852 + volume_label_t *v = anc->vlabel;
1853 + unsigned long b = -1;
1854 + char str[LINE_LENGTH];
1856 + vtoc_read_volume_label (fd, anc->label_pos, v);
1858 + if (strncmp (v->vollbl, vtoc_ebcdic_enc ("VOL1", str, 4), 4) == 0)
1860 + /* found VOL1 volume label */
1861 + b = (cchhb2blk (&v->vtoc, &anc->geo) - 1) * anc->blksize;
1865 + rc = fdasd_valid_vtoc_pointer (anc, b, fd);
1877 + else if (strncmp (v->volkey, vtoc_ebcdic_enc ("LNX1", str, 4), 4) == 0)
1887 + * checks the current API version with the API version of the dasd driver
1890 +fdasd_check_api_version (fdasd_anchor_t *anc, int f)
1894 + char s[LINE_LENGTH];
1896 + if (ioctl(f, DASDAPIVER, &api) != 0)
1898 + fdasd_error(anc, unable_to_ioctl,
1899 + "Could not retrieve API version.");
1902 + if (api != DASD_MIN_API_VERSION)
1904 + sprintf(s, "The current API version '%d' doesn't " \
1905 + "match dasd driver API version " \
1906 + "'%d'!", api, DASD_MIN_API_VERSION);
1907 + fdasd_error(anc, api_version_mismatch, s);
1913 + * reads dasd geometry data
1916 +fdasd_get_geometry (fdasd_anchor_t *anc, int f)
1920 + dasd_information_t dasd_info;
1921 + char s[LINE_LENGTH];
1923 + if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
1925 + fdasd_error(anc, unable_to_ioctl,
1926 + "Could not retrieve disk geometry information.");
1929 + if (ioctl(f, BLKSSZGET, &blksize) != 0)
1931 + fdasd_error(anc, unable_to_ioctl,
1932 + "Could not retrieve blocksize information.");
1935 + /* get disk type */
1936 + if (ioctl(f, BIODASDINFO, &dasd_info) != 0)
1938 + fdasd_error(anc, unable_to_ioctl,
1939 + "Could not retrieve disk information.");
1942 + if (strncmp(dasd_info.type, "ECKD", 4) != 0)
1944 + sprintf(s, "This is not an ECKD disk! This disk type " \
1945 + "is not supported!");
1946 + fdasd_error(anc,wrong_disk_type, s);
1949 + /* Disable FBA_layout check
1950 + if (dasd_info.FBA_layout)
1952 + if(!anc->silent) {
1953 + sprintf(s, "Device is not formatted with z/OS compatible " \
1955 + fdasd_error(anc,wrong_disk_format, s);
1960 + /* We do not write yet, so let this check go
1961 + if (dasd_info.open_count > 1)
1963 + sprintf(s, "Device is in use by another program. Exit all " \
1964 + "applications using this disk and/or unmount it.");
1965 + fdasd_error(anc,disk_in_use, s);
1969 + anc->dev_type = dasd_info.dev_type;
1970 + anc->blksize = blksize;
1971 + anc->label_pos = dasd_info.label_block * blksize;
1972 + anc->devno = dasd_info.devno;
1973 + anc->fspace_trk = anc->geo.cylinders * anc->geo.heads - FIRST_USABLE_TRK;
1977 + * returns unused partition info pointer if there
1978 + * is a free partition, otherwise NULL
1980 +static partition_info_t *
1981 +fdasd_get_empty_f1_label (fdasd_anchor_t * anc)
1984 + if (anc->used_partitions < USABLE_PARTITIONS)
1991 + * asks for and sets some important partition data
1994 +fdasd_get_partition_data (fdasd_anchor_t *anc,
1995 + extent_t *part_extent,
1996 + partition_info_t *p, unsigned int *start_ptr, unsigned int *stop_ptr)
1999 + unsigned int limit, cc, hh;
2000 + cchh_t llimit, ulimit;
2001 + partition_info_t *q;
2005 + unsigned int start = *start_ptr, stop = *stop_ptr;
2009 + if (anc->f4->DS4DEVCT.DS4DEVFG & ALTERNATE_CYLINDERS_USED)
2010 + c = anc->f4->DS4DEVCT.DS4DSCYL - (u_int16_t) anc->f4->DS4DEVAC;
2012 + c = anc->f4->DS4DEVCT.DS4DSCYL;
2014 + h = anc->f4->DS4DEVCT.DS4DSTRK;
2015 + limit = (h * c - 1);
2017 + /* check start value from user */
2019 + for (i = 0; i < USABLE_PARTITIONS; i++)
2021 + if ( q->next == NULL )
2023 + if (start >= q->start_trk && start <= q->end_trk)
2025 + /* start is within another partition */
2026 + start = q->end_trk + 1;
2027 + if (start > limit)
2029 + start = FIRST_USABLE_TRK;
2034 + printf("value within another partition, " \
2035 + "using %d instead\n", start);
2039 + if (start < q->start_trk)
2041 + limit = q->start_trk - 1;
2047 + if (start == limit)
2050 + /* update partition info */
2051 + p->len_trk = stop - start + 1;
2052 + p->start_trk = start;
2053 + p->end_trk = stop;
2055 + cc = start / anc->geo.heads;
2056 + hh = start - (cc * anc->geo.heads);
2057 + vtoc_set_cchh(&llimit, cc, hh);
2059 + /* check for cylinder boundary */
2065 + cc = stop / anc->geo.heads;
2066 + hh = stop - cc * anc->geo.heads;
2067 + vtoc_set_cchh(&ulimit, cc, hh);
2069 + /* it is always the 1st extent */
2072 + vtoc_set_extent(part_extent, b1, b2, &llimit, &ulimit);
2074 + *start_ptr = start;
2077 + ch = p->f1->DS1DSNAM;
2078 + vtoc_ebcdic_dec (ch, ch, 44);
2079 + if (strstr(ch, PART_TYPE_LVM))
2080 + p->type = PARTITION_LINUX_LVM;
2081 + else if (strstr(ch, PART_TYPE_RAID))
2082 + p->type = PARTITION_LINUX_RAID;
2083 + else if (strstr(ch, PART_TYPE_NATIVE))
2084 + p->type = PARTITION_LINUX;
2085 + else if (strstr(ch, PART_TYPE_SWAP))
2086 + p->type = PARTITION_LINUX_SWAP;
2088 + p->type = PARTITION_LINUX;
2089 + vtoc_ebcdic_enc (ch, ch, 44);
2099 +fdasd_enqueue_new_partition (fdasd_anchor_t *anc)
2102 + partition_info_t *q = anc->first, *p = anc->last;
2105 + for (i=1; i<USABLE_PARTITIONS; i++)
2107 + if ((q->end_trk == 0) ||
2108 + (p->start_trk < q->start_trk))
2117 + if (anc->first == q) anc->first = p;
2121 + anc->last->prev->next = NULL;
2122 + anc->last = anc->last->prev;
2125 + p->prev = q->prev;
2128 + if (p->prev != NULL)
2129 + p->prev->next = p;
2133 + p->type = PARTITION_LINUX;
2135 + for (i=0; i<USABLE_PARTITIONS; i++)
2137 + int j = getpos(anc, i);
2138 + if (j >= k) setpos(anc, i, j + 1);
2141 + /* update free-space counters */
2142 + if (anc->first == p)
2144 + /* partition is the first used partition */
2145 + if (p->start_trk == FIRST_USABLE_TRK)
2147 + /* partition starts right behind VTOC */
2148 + p->fspace_trk = anc->fspace_trk - p->len_trk;
2149 + anc->fspace_trk = 0;
2153 + /* there is some space between VTOC and partition */
2155 + p->fspace_trk = anc->fspace_trk -
2159 + anc->fspace_trk = p->start_trk - FIRST_USABLE_TRK;
2164 + /* there are partitons in front of the new one */
2165 + if (p->start_trk == p->prev->end_trk + 1)
2167 + /* new partition is right behind the previous one */
2168 + p->fspace_trk = p->prev->fspace_trk - p->len_trk;
2169 + p->prev->fspace_trk = 0;
2173 + /* there is some space between new and prev. part. */
2174 + p->fspace_trk = p->prev->fspace_trk -
2177 + p->prev->end_trk + 1;
2178 + p->prev->fspace_trk = p->start_trk -
2179 + p->prev->end_trk -
2187 + * adds a new partition to the 'partition table'
2190 +fdasd_add_partition (fdasd_anchor_t *anc, unsigned int start, unsigned int stop)
2194 + partition_info_t *p;
2200 + if ((p = fdasd_get_empty_f1_label(anc)) == NULL)
2207 + if (fdasd_get_partition_data(anc, &ext, p, &start, &stop) != 0)
2211 + vtoc_init_format1_label(anc->vlabel->volid,
2218 + fdasd_enqueue_new_partition(anc);
2221 + anc->used_partitions += 1;
2223 + i = anc->used_partitions + 2;
2224 + if (anc->big_disk) i++;
2227 + vtoc_set_cchhb(&hf1, VTOC_START_CC, VTOC_START_HH, i);
2229 + vtoc_update_format4_label(anc->f4, &hf1,
2230 + anc->f4->DS4DSREC - 1);
2234 + start = ext.llimit.cc * anc->geo.heads + ext.llimit.hh;
2235 + stop = ext.ulimit.cc * anc->geo.heads + ext.ulimit.hh;
2238 + vtoc_set_freespace(anc->f4, anc->f5, anc->f7,
2239 + '-', anc->verbose,
2241 + anc->geo.cylinders, anc->geo.heads);
2243 + anc->vtoc_changed++;
2248 diff -ruN --minimal parted-1.6.21.orig/libparted/fdasd.h parted-1.6.21/libparted/fdasd.h
2249 --- parted-1.6.21.orig/libparted/fdasd.h 1969-12-31 19:00:00.000000000 -0500
2250 +++ parted-1.6.21/libparted/fdasd.h 2005-01-21 15:00:40.429628321 -0500
2253 + * File...........: s390-tools/fdasd/fdasd.h
2254 + * Author(s)......: Volker Sameske <sameske@de.ibm.com>
2255 + * Horst Hummel <Horst.Hummel@de.ibm.com>
2256 + * Bugreports.to..: <Linux390@de.ibm.com>
2257 + * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2001-2002
2259 + * History of changes (starts March 2001)
2260 + * version 1.01 - menu entry 's' to show mapping devnode - DS name
2261 + * 1.02 - DS names count now from 0001 instead from 0000
2262 + * 1.03 - volser checks: 'AA AAA' to 'AAAAA '
2263 + * - removed dependency to kernel headers.
2264 + * 1.04 - added -p option
2265 + * 1.05 - new API policy, set it back to 0
2270 +/*****************************************************************************
2271 + * SECTION: Definitions needed for DASD-API (see dasd.h) *
2272 + *****************************************************************************/
2274 +#define DASD_IOCTL_LETTER 'D'
2276 +#define DASD_PARTN_BITS 2
2278 +#define PARTITION_LINUX_SWAP 0x82
2279 +#define PARTITION_LINUX 0x83
2280 +#define PARTITION_LINUX_EXT 0x85
2281 +#define PARTITION_LINUX_LVM 0x8e
2282 +#define PARTITION_LINUX_RAID 0xfd
2283 +#define PARTITION_LINUX_LVM_OLD 0xfe
2285 +#define PART_TYPE_NATIVE "NATIVE"
2286 +#define PART_TYPE_SWAP "SWAP "
2287 +#define PART_TYPE_RAID "RAID "
2288 +#define PART_TYPE_LVM "LVM "
2291 +#define PDEBUG fprintf(stderr, "%s:%d:%s\n", \
2294 + __PRETTY_FUNCTION__);
2300 + * struct dasd_information_t
2301 + * represents any data about the device, which is visible to userspace.
2302 + * including foramt and featueres.
2304 +typedef struct dasd_information_t {
2305 + unsigned int devno; /* S/390 devno */
2306 + unsigned int real_devno; /* for aliases */
2307 + unsigned int schid; /* S/390 subchannel identifier */
2308 + unsigned int cu_type : 16; /* from SenseID */
2309 + unsigned int cu_model : 8; /* from SenseID */
2310 + unsigned int dev_type : 16; /* from SenseID */
2311 + unsigned int dev_model : 8; /* from SenseID */
2312 + unsigned int open_count;
2313 + unsigned int req_queue_len;
2314 + unsigned int chanq_len; /* length of chanq */
2315 + char type[4]; /* from discipline.name, 'none' for */
2317 + unsigned int status; /* current device level */
2318 + unsigned int label_block; /* where to find the VOLSER */
2319 + unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
2320 + unsigned int characteristics_size;
2321 + unsigned int confdata_size;
2322 + char characteristics[64]; /* from read_device_characteristics */
2323 + char configuration_data[256]; /* from read_configuration_data */
2324 +} dasd_information_t;
2327 + * struct format_data_t
2328 + * represents all data necessary to format a dasd
2330 +typedef struct format_data_t {
2331 + int start_unit; /* from track */
2332 + int stop_unit; /* to track */
2333 + int blksize; /* sectorsize */
2338 + * values to be used for format_data_t.intensity
2339 + * 0/8: normal format
2340 + * 1/9: also write record zero
2341 + * 3/11: also write home address
2342 + * 4/12: invalidate track
2344 +#define DASD_FMT_INT_FMT_R0 1 /* write record zero */
2345 +#define DASD_FMT_INT_FMT_HA 2 /* write home address, also set FMT_R0 ! */
2346 +#define DASD_FMT_INT_INVAL 4 /* invalidate tracks */
2347 +#define DASD_FMT_INT_COMPAT 8 /* use OS/390 compatible disk layout */
2350 +/* Disable the volume (for Linux) */
2351 +#define BIODASDDISABLE _IO(DASD_IOCTL_LETTER,0)
2352 +/* Enable the volume (for Linux) */
2353 +#define BIODASDENABLE _IO(DASD_IOCTL_LETTER,1)
2355 +/* retrieve API version number */
2356 +#define DASDAPIVER _IOR(DASD_IOCTL_LETTER,0,int)
2357 +/* Get information on a dasd device (enhanced) */
2358 +#define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
2361 +/*****************************************************************************
2362 + * SECTION: Further IOCTL Definitions (see fs.h) *
2363 + *****************************************************************************/
2364 +/* re-read partition table */
2365 +#define BLKRRPART _IO(0x12,95)
2366 +/* get block device sector size */
2367 +#define BLKSSZGET _IO(0x12,104)
2369 +/*****************************************************************************
2370 + * SECTION: Definition from hdreq.h *
2371 + *****************************************************************************/
2373 +struct fdasd_hd_geometry {
2374 + unsigned char heads;
2375 + unsigned char sectors;
2376 + unsigned short cylinders;
2377 + unsigned long start;
2380 +/* get device geometry */
2381 +#define HDIO_GETGEO 0x0301
2383 +/*****************************************************************************
2384 + * SECTION: FDASD internal types *
2385 + *****************************************************************************/
2387 +#define DASD_MIN_API_VERSION 0
2389 +#define DEFAULT_FDASD_CONF "/etc/fdasd.conf" /* default config file */
2391 +#define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
2392 +#define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
2394 +#define FDASD_VERSION "1.05"
2395 +#define FDASD_ERROR "fdasd error: "
2396 +#define DEVICE "device"
2397 +#define DISC "disc"
2398 +#define PART "part"
2400 +#define ALTERNATE_CYLINDERS_USED 0x10
2402 +typedef struct partition_info {
2404 + unsigned long start_trk;
2405 + unsigned long end_trk;
2406 + unsigned long len_trk;
2407 + unsigned long fspace_trk;
2408 + format1_label_t * f1;
2409 + struct partition_info *next;
2410 + struct partition_info *prev;
2412 +} partition_info_t;
2415 +typedef struct config_data {
2416 + unsigned long start;
2417 + unsigned long stop;
2421 +typedef struct fdasd_anchor {
2422 + int vlabel_changed;
2424 + int devname_specified;
2425 + int volid_specified;
2426 + int config_specified;
2427 + int auto_partition;
2434 + int option_recreate;
2435 + int partno[USABLE_PARTITIONS];
2436 + u_int16_t dev_type;
2437 + unsigned int used_partitions;
2438 + unsigned long label_pos;
2439 + unsigned int blksize;
2440 + unsigned long fspace_trk;
2441 + format4_label_t *f4;
2442 + format5_label_t *f5;
2443 + format7_label_t *f7;
2444 + partition_info_t *first;
2445 + partition_info_t *last;
2446 + volume_label_t *vlabel;
2447 + config_data_t confdata[USABLE_PARTITIONS];
2448 + struct fdasd_hd_geometry geo;
2451 +enum offset {lower, upper};
2453 +enum fdasd_failure {
2454 + unable_to_open_disk,
2455 + unable_to_seek_disk,
2456 + unable_to_read_disk,
2459 + api_version_mismatch,
2461 + wrong_disk_format,
2463 + config_syntax_error,
2467 + device_verification_failed
2470 +void fdasd_cleanup (fdasd_anchor_t *anchor);
2471 +void fdasd_initialize_anchor (fdasd_anchor_t * anc);
2472 +void fdasd_get_geometry (fdasd_anchor_t *anc, int fd);
2473 +void fdasd_check_api_version (fdasd_anchor_t *anc, int fd);
2474 +int fdasd_check_volume (fdasd_anchor_t *anc, int fd);
2475 +int fdasd_write_labels (fdasd_anchor_t *anc, int fd);
2476 +int fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc);
2477 +void fdasd_recreate_vtoc(fdasd_anchor_t *anc);
2478 +partition_info_t * fdasd_add_partition (fdasd_anchor_t *anc, unsigned int start, unsigned int stop);
2479 +int fdasd_prepare_labels (fdasd_anchor_t *anc, int fd) ;
2481 +#endif /* FDASD_H */
2482 --- parted-1.6.23/libparted/libparted.c.orig 2005-03-29 02:01:22.000000000 +0200
2483 +++ parted-1.6.23/libparted/libparted.c 2005-07-18 20:57:09.847100720 +0200
2485 extern void ped_disk_pc98_init ();
2486 extern void ped_disk_sun_init ();
2487 extern void ped_disk_amiga_init ();
2488 +extern void ped_disk_dasd_init ();
2493 ped_disk_loop_init (); /* must be last in the probe list */
2495 +#if defined(__s390__) || defined(__s390x__)
2496 + ped_disk_dasd_init();
2499 ped_disk_sun_init ();
2501 ped_disk_pc98_init ();
2502 @@ -142,10 +147,14 @@
2503 extern void ped_disk_pc98_done ();
2504 extern void ped_disk_sun_done ();
2505 extern void ped_disk_amiga_done ();
2506 +extern void ped_disk_dasd_done ();
2511 +#if defined(__s390__) || defined(__s390x__)
2512 + ped_disk_dasd_done ();
2514 ped_disk_sun_done ();
2516 ped_disk_pc98_done ();
2521 + memset (mem, 0, size);
2523 - memset (mem, 0xff, size);
2524 + /* memset (mem, 0xff, size); */
2525 _check_dodgy_pointer (mem, size, 1);
2528 diff -ruN --minimal parted-1.6.21.orig/libparted/linux.c parted-1.6.21/libparted/linux.c
2529 --- parted-1.6.21.orig/libparted/linux.c 2005-01-15 20:01:57.000000000 -0500
2530 +++ parted-1.6.21/libparted/linux.c 2005-01-21 15:04:40.574398622 -0500
2532 #define HDIO_GETGEO 0x0301 /* get device geometry */
2533 #define HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
2538 struct hd_geometry {
2539 unsigned char heads;
2540 unsigned char sectors;
2542 #define I2O_MAJOR7 86
2543 #define I2O_MAJOR8 87
2545 +#define DASD_MAJOR 94
2547 #define SCSI_BLK_MAJOR(M) ( \
2548 (M) == SCSI_DISK0_MAJOR \
2549 || (M) == SCSI_CDROM_MAJOR \
2551 dev->type = PED_DEVICE_DAC960;
2552 } else if (dev_major == ATARAID_MAJOR && (dev_minor % 0x10 == 0)) {
2553 dev->type = PED_DEVICE_ATARAID;
2554 + } else if (dev_major == DASD_MAJOR && (dev_minor % 0x4 == 0)) {
2555 + dev->type = PED_DEVICE_DASD;
2556 } else if (_is_i2o_major (dev_major) && (dev_minor % 0x10 == 0)) {
2557 dev->type = PED_DEVICE_I2O;
2558 } else if (_is_cpqarray_major (dev_major) && (dev_minor % 0x10 == 0)) {
2559 @@ -363,6 +370,14 @@
2560 if (ioctl (arch_specific->fd, BLKSSZGET, §or_size))
2561 return PED_SECTOR_SIZE;
2564 + * We return PED_SECTOR_SIZE, cause, we do not want to fiddle around with b0rken
2565 + * parted and kernel for DASDs!!
2567 + if(dev->type == PED_DEVICE_DASD) {
2568 + return PED_SECTOR_SIZE;
2571 if (sector_size != PED_SECTOR_SIZE) {
2572 if (ped_exception_throw (
2574 @@ -696,6 +711,44 @@
2578 +init_dasd (PedDevice* dev, char* model_name)
2580 + struct stat dev_stat;
2581 + PedExceptionOption ex_status;
2582 + int f, blksize = 0;
2583 + dasd_information_t dasd_info;
2585 + struct hd_geometry geo;
2588 + if (!_device_stat (dev, &dev_stat))
2591 + if (!ped_device_open (dev))
2594 + LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
2596 + if (!_device_probe_geometry (dev))
2597 + goto error_close_dev;
2599 + dev->model = strdup (model_name);
2601 + ped_device_close (dev);
2605 + ped_exception_throw ( PED_EXCEPTION_ERROR,
2606 + PED_EXCEPTION_IGNORE_CANCEL,
2610 + ped_device_close (dev);
2616 init_generic (PedDevice* dev, char* model_name)
2618 struct stat dev_stat;
2620 PED_EXCEPTION_WARNING,
2621 PED_EXCEPTION_IGNORE_CANCEL,
2622 _("Unable to determine geometry of "
2623 - "file/device. You should not use Parted "
2624 - "unless you REALLY know what you're doing!"));
2625 + "file/device %s. You should not use Parted "
2626 + "unless you REALLY know what you're doing!"), dev->path);
2627 switch (ex_status) {
2628 case PED_EXCEPTION_CANCEL:
2629 goto error_close_dev;
2630 @@ -795,6 +848,11 @@
2631 goto error_free_arch_specific;
2634 + case PED_DEVICE_DASD:
2635 + if (!init_dasd (dev, _("IBM S390 DASD drive")))
2636 + goto error_free_arch_specific;
2639 case PED_DEVICE_CPQARRAY:
2640 if (!init_generic (dev, _("Compaq Smart Array")))
2641 goto error_free_arch_specific;
2642 @@ -1710,7 +1768,10 @@
2643 * created. Therefore, if using DevFS, we must get the kernel
2644 * to re-read and grok the partition table.
2646 - if (_have_blkpg () && !_have_devfs ()) {
2647 + /* Work around kernel dasd problem so we really do a
2649 + if (disk->dev->type != PED_DEVICE_DASD &&
2650 + _have_blkpg () && !_have_devfs ()) {
2651 if (_disk_sync_part_table (disk))
2654 diff -ruN --minimal parted-1.6.21.orig/libparted/vtoc.c parted-1.6.21/libparted/vtoc.c
2655 --- parted-1.6.21.orig/libparted/vtoc.c 1969-12-31 19:00:00.000000000 -0500
2656 +++ parted-1.6.21/libparted/vtoc.c 2005-01-21 15:00:40.454627663 -0500
2661 +#define PDEBUG fprintf(stderr, "%s:%d:%s\n", \
2664 + __PRETTY_FUNCTION__);
2669 +#include <parted/parted.h>
2671 +#include <libintl.h>
2673 +# define _(String) dgettext (PACKAGE, String)
2675 +# define _(String) (String)
2676 +#endif /* ENABLE_NLS */
2678 +static unsigned char EBCtoASC[256] =
2680 +/* 0x00 NUL SOH STX ETX *SEL HT *RNL DEL */
2681 + 0x00, 0x01, 0x02, 0x03, 0x07, 0x09, 0x07, 0x7F,
2682 +/* 0x08 -GE -SPS -RPT VT FF CR SO SI */
2683 + 0x07, 0x07, 0x07, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
2684 +/* 0x10 DLE DC1 DC2 DC3 -RES -NL BS -POC
2686 + 0x10, 0x11, 0x12, 0x13, 0x07, 0x0A, 0x08, 0x07,
2687 +/* 0x18 CAN EM -UBS -CU1 -IFS -IGS -IRS -ITB
2689 + 0x18, 0x19, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
2690 +/* 0x20 -DS -SOS FS -WUS -BYP LF ETB ESC
2692 + 0x07, 0x07, 0x1C, 0x07, 0x07, 0x0A, 0x17, 0x1B,
2693 +/* 0x28 -SA -SFE -SM -CSP -MFA ENQ ACK BEL
2695 + 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07,
2696 +/* 0x30 ---- ---- SYN -IR -PP -TRN -NBS EOT */
2697 + 0x07, 0x07, 0x16, 0x07, 0x07, 0x07, 0x07, 0x04,
2698 +/* 0x38 -SBS -IT -RFF -CU3 DC4 NAK ---- SUB */
2699 + 0x07, 0x07, 0x07, 0x07, 0x14, 0x15, 0x07, 0x1A,
2700 +/* 0x40 SP RSP ä ---- */
2701 + 0x20, 0xFF, 0x83, 0x84, 0x85, 0xA0, 0x07, 0x86,
2702 +/* 0x48 . < ( + | */
2703 + 0x87, 0xA4, 0x9B, 0x2E, 0x3C, 0x28, 0x2B, 0x7C,
2705 + 0x26, 0x82, 0x88, 0x89, 0x8A, 0xA1, 0x8C, 0x07,
2706 +/* 0x58 ß ! $ * ) ; */
2707 + 0x8D, 0xE1, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0xAA,
2708 +/* 0x60 - / ---- Ä ---- ---- ---- */
2709 + 0x2D, 0x2F, 0x07, 0x8E, 0x07, 0x07, 0x07, 0x8F,
2710 +/* 0x68 ---- , % _ > ? */
2711 + 0x80, 0xA5, 0x07, 0x2C, 0x25, 0x5F, 0x3E, 0x3F,
2712 +/* 0x70 --- ---- ---- ---- ---- ---- ---- */
2713 + 0x07, 0x90, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
2714 +/* 0x78 * ` : # @ ' = " */
2715 + 0x70, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22,
2716 +/* 0x80 * a b c d e f g */
2717 + 0x07, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
2718 +/* 0x88 h i ---- ---- ---- */
2719 + 0x68, 0x69, 0xAE, 0xAF, 0x07, 0x07, 0x07, 0xF1,
2720 +/* 0x90 ° j k l m n o p */
2721 + 0xF8, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,
2722 +/* 0x98 q r ---- ---- */
2723 + 0x71, 0x72, 0xA6, 0xA7, 0x91, 0x07, 0x92, 0x07,
2724 +/* 0xA0 ~ s t u v w x */
2725 + 0xE6, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
2726 +/* 0xA8 y z ---- ---- ---- ---- */
2727 + 0x79, 0x7A, 0xAD, 0xAB, 0x07, 0x07, 0x07, 0x07,
2728 +/* 0xB0 ^ ---- § ---- */
2729 + 0x5E, 0x9C, 0x9D, 0xFA, 0x07, 0x07, 0x07, 0xAC,
2730 +/* 0xB8 ---- [ ] ---- ---- ---- ---- */
2731 + 0xAB, 0x07, 0x5B, 0x5D, 0x07, 0x07, 0x07, 0x07,
2732 +/* 0xC0 { A B C D E F G */
2733 + 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
2734 +/* 0xC8 H I ---- ö ---- */
2735 + 0x48, 0x49, 0x07, 0x93, 0x94, 0x95, 0xA2, 0x07,
2736 +/* 0xD0 } J K L M N O P */
2737 + 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
2738 +/* 0xD8 Q R ---- ü */
2739 + 0x51, 0x52, 0x07, 0x96, 0x81, 0x97, 0xA3, 0x98,
2740 +/* 0xE0 \ S T U V W X */
2741 + 0x5C, 0xF6, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
2742 +/* 0xE8 Y Z ---- Ö ---- ---- ---- */
2743 + 0x59, 0x5A, 0xFD, 0x07, 0x99, 0x07, 0x07, 0x07,
2744 +/* 0xF0 0 1 2 3 4 5 6 7 */
2745 + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2746 +/* 0xF8 8 9 ---- ---- Ü ---- ---- ---- */
2747 + 0x38, 0x39, 0x07, 0x07, 0x9A, 0x07, 0x07, 0x07
2750 +static unsigned char ASCtoEBC[256] =
2752 + /*00 NL SH SX EX ET NQ AK BL */
2753 + 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F,
2754 + /*08 BS HT LF VT FF CR SO SI */
2755 + 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
2756 + /*10 DL D1 D2 D3 D4 NK SN EB */
2757 + 0x10, 0x11, 0x12, 0x13, 0x3C, 0x15, 0x32, 0x26,
2758 + /*18 CN EM SB EC FS GS RS US */
2759 + 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F,
2760 + /*20 SP ! " # $ % & ' */
2761 + 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D,
2762 + /*28 ( ) * + , - . / */
2763 + 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61,
2764 + /*30 0 1 2 3 4 5 6 7 */
2765 + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
2766 + /*38 8 9 : ; < = > ? */
2767 + 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F,
2768 + /*40 @ A B C D E F G */
2769 + 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
2770 + /*48 H I J K L M N O */
2771 + 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6,
2772 + /*50 P Q R S T U V W */
2773 + 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6,
2774 + /*58 X Y Z [ \ ] ^ _ */
2775 + 0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D,
2776 + /*60 ` a b c d e f g */
2777 + 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
2778 + /*68 h i j k l m n o */
2779 + 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
2780 + /*70 p q r s t u v w */
2781 + 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
2782 + /*78 x y z { | } ~ DL */
2783 + 0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07,
2784 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2785 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2786 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2787 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2788 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2789 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2790 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2791 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2792 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2793 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2794 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2795 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2796 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2797 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2798 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
2799 + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFF
2802 +enum failure {unable_to_open,
2807 +static char buffer[85];
2813 +vtoc_error(enum failure why, char *s1, char *s2)
2816 + char error[LINE_LENGTH];
2820 + case unable_to_open:
2821 + sprintf(error, _("%s opening device '%s' failed.\n%s\n"),
2822 + VTOC_ERROR, s1, s2);
2824 + case unable_to_seek:
2825 + sprintf(error, _("%s seeking device '%s' failed.\n%s\n"),
2826 + VTOC_ERROR, s1, s2);
2828 + case unable_to_write:
2829 + sprintf(error, _("%s writing to device '%s' failed,\n%s\n"),
2830 + VTOC_ERROR, s1, s2);
2832 + case unable_to_read:
2833 + sprintf(error, _("%s reading from device '%s' failed.\n%s\n"),
2834 + VTOC_ERROR, s1, s2);
2836 + default: sprintf(error, _("Fatal error\n"));
2839 + ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, error);
2847 +vtoc_ebcdic_enc (char source[LINE_LENGTH],
2848 + char target[LINE_LENGTH],
2854 + for (i = 0; i < l; i++)
2855 + target[i]=ASCtoEBC[(unsigned char)(source[i])];
2865 +vtoc_ebcdic_dec (char source[LINE_LENGTH],
2866 + char target[LINE_LENGTH],
2872 + for (i = 0; i < l; i++)
2873 + target[i]=EBCtoASC[(unsigned char)(source[i])];
2883 +vtoc_set_extent (extent_t *ext,
2890 + ext->typeind = typeind;
2891 + ext->seqno = seqno;
2892 + memcpy(&ext->llimit,lower,sizeof(cchh_t));
2893 + memcpy(&ext->ulimit,upper,sizeof(cchh_t));
2901 +vtoc_set_cchh (cchh_t *addr,
2915 +vtoc_set_ttr (ttr_t *addr,
2929 +vtoc_set_cchhb (cchhb_t *addr,
2957 + * initializes the volume label with EBCDIC spaces
2960 +vtoc_volume_label_init (volume_label_t *vlabel)
2963 + sprintf(buffer, "%84s", " ");
2964 + vtoc_ebcdic_enc(buffer, buffer, 84);
2965 + strncpy(vlabel->volkey, buffer, 84);
2970 + * reads the volume label from dasd
2973 +vtoc_read_volume_label (
2975 + unsigned long vlabel_start,
2976 + volume_label_t *vlabel)
2981 + if (lseek(f, vlabel_start, SEEK_SET) == -1)
2983 + vtoc_error(unable_to_seek, "vtoc_read_volume_label",
2984 + "Could not read volume label.");
2988 + rc = read(f, vlabel, sizeof(volume_label_t));
2989 + if (rc != sizeof(volume_label_t))
2991 + vtoc_error(unable_to_read, "vtoc_read_volume_label",
2992 + "Could not read volume label.");
3001 + * writes the volume label to dasd
3004 +vtoc_write_volume_label (
3006 + unsigned long vlabel_start,
3007 + volume_label_t *vlabel)
3012 + if (lseek(f, vlabel_start, SEEK_SET) == -1)
3014 + vtoc_error(unable_to_seek, "vtoc_write_volume_label",
3015 + "Could not write volume label.");
3018 + rc = write(f, vlabel, sizeof(volume_label_t));
3019 + if (rc != sizeof(volume_label_t))
3021 + vtoc_error(unable_to_write, "vtoc_write_volume_label",
3022 + "Could not write volume label.");
3029 + * takes a string as input, converts it to uppercase, translates
3030 + * it to EBCDIC and fills it up with spaces before it copies it
3031 + * as volume serial to the volume label
3034 +vtoc_volume_label_set_volser (
3035 + volume_label_t *vlabel,
3039 + int j, i = strlen(volser);
3040 + char s[VOLSER_LENGTH + 1];
3043 + vtoc_ebcdic_enc(s, s, VOLSER_LENGTH);
3044 + strncpy(vlabel->volid, s, VOLSER_LENGTH);
3046 + if (i > VOLSER_LENGTH) i = VOLSER_LENGTH;
3048 + strncpy(s, volser, i);
3049 + for (j=0; j<i; j++) {
3050 + s[j] = toupper(s[j]);
3053 + s[VOLSER_LENGTH] = 0x00;
3054 + vtoc_ebcdic_enc(s, s, i);
3055 + strncpy(vlabel->volid, s, i);
3062 + * returns the volume serial number right after it is translated
3066 +vtoc_volume_label_get_volser (
3067 + volume_label_t *vlabel,
3071 + vtoc_ebcdic_dec(vlabel->volid, volser, VOLSER_LENGTH);
3078 + * sets the volume label key right after
3079 + * it has been translated to EBCDIC
3082 +vtoc_volume_label_set_key (
3083 + volume_label_t *vlabel,
3089 + vtoc_ebcdic_enc(key, s, 4);
3090 + strncpy(vlabel->volkey, s, 4);
3097 + * sets the volume label identifier right
3098 + * after it has been translated to EBCDIC
3101 +vtoc_volume_label_set_label (
3102 + volume_label_t *vlabel,
3108 + vtoc_ebcdic_enc(lbl, s, 4);
3109 + strncpy(vlabel->vollbl, s, 4);
3116 + * returns the volume label key = the label identifier
3117 + * right after it has been translated to ASCII
3120 +vtoc_volume_label_get_label (
3121 + volume_label_t *vlabel,
3125 + vtoc_ebcdic_dec(vlabel->vollbl, lbl, 4);
3132 + * reads either a format4 label or a format1 label
3133 + * from the specified position
3136 +vtoc_read_label (int f,
3137 + unsigned long position,
3138 + format1_label_t *f1,
3139 + format4_label_t *f4,
3140 + format5_label_t *f5,
3141 + format7_label_t *f7)
3146 + if (lseek(f, position, SEEK_SET) == -1)
3148 + vtoc_error(unable_to_seek, "vtoc_read_label",
3149 + _("Could not read VTOC labels."));
3154 + t = sizeof(format1_label_t);
3155 + if (read(f, f1, t) != t)
3157 + vtoc_error(unable_to_read, "vtoc_read_label",
3158 + _("Could not read VTOC FMT1 DSCB."));
3164 + t = sizeof(format4_label_t);
3165 + if (read(f, f4, t) != t)
3167 + vtoc_error(unable_to_read, "vtoc_read_label",
3168 + _("Could not read VTOC FMT4 DSCB."));
3174 + t = sizeof(format5_label_t);
3175 + if (read(f, f5, t) != t)
3177 + vtoc_error(unable_to_read, "vtoc_read_label",
3178 + _("Could not read VTOC FMT5 DSCB."));
3184 + t = sizeof(format7_label_t);
3185 + if (read(f, f7, t) != t)
3187 + vtoc_error(unable_to_read, "vtoc_read_label",
3188 + _("Could not read VTOC FMT7 DSCB."));
3195 + * writes either a FMT1, FMT4 or FMT5 label
3196 + * to the specified position
3199 +vtoc_write_label (int f,
3200 + unsigned long position,
3201 + format1_label_t *f1,
3202 + format4_label_t *f4,
3203 + format5_label_t *f5,
3204 + format7_label_t *f7)
3209 + if (lseek(f, position, SEEK_SET) == -1)
3211 + vtoc_error(unable_to_seek, "vtoc_write_label",
3212 + _("Could not write VTOC labels."));
3217 + t = sizeof(format1_label_t);
3218 + if (write(f, f1, t) != t)
3220 + vtoc_error(unable_to_write, "vtoc_write_label",
3221 + _("Could not write VTOC FMT1 DSCB."));
3227 + t = sizeof(format4_label_t);
3228 + if (write(f, f4, t) != t)
3230 + vtoc_error(unable_to_write, "vtoc_write_label",
3231 + _("Could not write VTOC FMT4 DSCB."));
3237 + t = sizeof(format5_label_t);
3238 + if (write(f, f5, t) != t)
3240 + vtoc_error(unable_to_write, "vtoc_write_label",
3241 + _("Could not write VTOC FMT5 DSCB."));
3247 + t = sizeof(format7_label_t);
3248 + if (write(f, f7, t) != t)
3250 + vtoc_error(unable_to_write, "vtoc_write_label",
3251 + _("Could not write VTOC FMT7 DSCB."));
3259 + * initializes a format4 label
3262 +vtoc_init_format4_label (
3263 + format4_label_t *f4,
3264 + unsigned int usable_partitions,
3265 + unsigned int cylinders,
3266 + unsigned int tracks,
3267 + unsigned int blocks,
3268 + unsigned int blksize,
3269 + u_int16_t dev_type)
3274 + cchh_t lower = {VTOC_START_CC, VTOC_START_HH};
3275 + cchh_t upper = {VTOC_START_CC, VTOC_START_HH};
3277 + for (i=0; i<44; i++) f4->DS4KEYCD[i] = 0x04;
3278 + f4->DS4IDFMT = 0xf4;
3279 + vtoc_set_cchhb(&f4->DS4HPCHR, 0x0000, 0x0000, 0x00);
3280 + f4->DS4DSREC = blocks - 2;
3281 + /* free space starts right behind VTOC
3282 + vtoc_set_cchh(&f4->DS4HCCHH, VTOC_START_CC, VTOC_START_HH + 1);*/
3283 + vtoc_set_cchh(&f4->DS4HCCHH, 0x0000, 0x0000);
3284 + f4->DS4NOATK = 0x0000;
3285 + f4->DS4VTOCI = 0x00;
3286 + f4->DS4NOEXT = 0x01;
3287 + f4->DS4SMSFG = 0x00;
3288 + f4->DS4DEVAC = 0x00;
3290 + /* -- begin f4->DS4DEVCT -- */
3291 + f4->DS4DEVCT.DS4DSCYL = cylinders;
3292 + f4->DS4DEVCT.DS4DSTRK = tracks;
3296 + case DASD_3380_TYPE:
3297 + f4->DS4DEVCT.DS4DEVTK = DASD_3380_VALUE;
3299 + case DASD_3390_TYPE:
3300 + f4->DS4DEVCT.DS4DEVTK = DASD_3390_VALUE;
3302 + case DASD_9345_TYPE:
3303 + f4->DS4DEVCT.DS4DEVTK = DASD_9345_VALUE;
3306 + f4->DS4DEVCT.DS4DEVTK = blocks * blksize;;
3310 + f4->DS4DEVCT.DS4DEVI = 0x00;
3311 + f4->DS4DEVCT.DS4DEVL = 0x00;
3312 + f4->DS4DEVCT.DS4DEVK = 0x00;
3313 + f4->DS4DEVCT.DS4DEVFG = 0x30;
3314 + f4->DS4DEVCT.DS4DEVTL = 0x0000;
3315 + f4->DS4DEVCT.DS4DEVDT = blocks;
3316 + f4->DS4DEVCT.DS4DEVDB = 0x00;
3317 + /* -- end f4->DS4DEVCT -- */
3319 + bzero(f4->DS4AMTIM, sizeof(f4->DS4AMTIM));
3320 + bzero(f4->DS4AMCAT, sizeof(f4->DS4AMCAT));
3321 + bzero(f4->DS4R2TIM, sizeof(f4->DS4R2TIM));
3322 + bzero(f4->res1, sizeof(f4->res1));
3323 + bzero(f4->DS4F6PTR, sizeof(f4->DS4F6PTR));
3325 + /* -- begin f4lbl->DS4VTOCE -- */
3326 + vtoc_set_extent(&f4->DS4VTOCE, 0x01, 0x00, &lower, &upper);
3327 + /* -- end f4lbl->DS4VTOCE -- */
3329 + bzero(f4->res2, sizeof(f4->res2));
3330 + f4->DS4EFLVL = 0x00;
3331 + bzero(&f4->DS4EFPTR, sizeof(f4->DS4EFPTR));
3332 + bzero(f4->res3, sizeof(f4->res3));
3337 + * initializes a format5 label
3340 +vtoc_init_format5_label (format5_label_t *f5)
3345 + bzero(f5, sizeof(format5_label_t));
3346 + for (i=0; i<4; i++) f5->DS5KEYID[i] = 0x05;
3347 + f5->DS5FMTID = 0xf5;
3352 + * initializes a format7 label
3355 +vtoc_init_format7_label (format7_label_t *f7)
3360 + bzero(f7, sizeof(format7_label_t));
3361 + for (i=0; i<4; i++) f7->DS7KEYID[i] = 0x07;
3362 + f7->DS7FMTID = 0xf7;
3367 + * initializes a format1 label
3370 +vtoc_init_format1_label (
3372 + unsigned int blksize,
3373 + extent_t *part_extent,
3374 + format1_label_t *f1)
3377 + struct tm * creatime;
3381 + /* get actual date */
3383 + creatime = gmtime(&t);
3385 + bzero(f1->DS1DSNAM, sizeof(f1->DS1DSNAM));
3386 + sprintf(str, "PART .NEW ");
3387 + vtoc_ebcdic_enc(str, str, 44);
3388 + strncpy(f1->DS1DSNAM, str, 44);
3389 + f1->DS1FMTID = 0xf1;
3390 + strncpy(f1->DS1DSSN, " ", 6);
3391 + f1->DS1VOLSQ = 0x0001;
3393 + vtoc_set_date(&f1->DS1CREDT,
3394 + (u_int8_t) creatime->tm_year,
3395 + (u_int16_t) creatime->tm_yday);
3396 + /* expires never - 99 365 */
3397 + vtoc_set_date(&f1->DS1EXPDT,
3400 + f1->DS1NOEPV = 0x01;
3401 + f1->DS1NOBDB = 0x00;
3402 + f1->DS1FLAG1 = 0x00;
3403 + vtoc_ebcdic_enc("IBM LINUX ", str, 13);
3404 + strncpy(f1->DS1SYSCD, str, 13);
3405 + vtoc_set_date(&f1->DS1REFD,
3406 + (u_int8_t) creatime->tm_year,
3407 + (u_int16_t) creatime->tm_yday);
3408 + f1->DS1SMSFG = 0x00;
3409 + f1->DS1SCXTF = 0x00;
3410 + f1->DS1SCXTV = 0x0000;
3411 + f1->DS1DSRG1 = 0x00;
3412 + f1->DS1DSRG2 = 0x00;
3413 + f1->DS1RECFM = 0x88;
3414 + f1->DS1OPTCD = 0x00;
3415 + f1->DS1BLKL = blksize;
3416 + f1->DS1LRECL = blksize;
3417 + f1->DS1KEYL = 0x00;
3418 + f1->DS1RKP = 0x0000;
3419 + f1->DS1DSIND = 0x80; /* last volume for this dataset */
3420 + f1->DS1SCAL1 = 0x80;
3421 + bzero(&f1->DS1SCAL3, sizeof(f1->DS1SCAL3));
3422 + vtoc_set_ttr(&f1->DS1LSTAR,
3425 + f1->DS1TRBAL = 0x00;
3426 + bzero(&f1->res1, sizeof(f1->res1));
3427 + memcpy(&f1->DS1EXT1,
3429 + sizeof(extent_t));
3430 + bzero(&f1->DS1EXT2, sizeof(extent_t));
3431 + bzero(&f1->DS1EXT3, sizeof(extent_t));
3432 + vtoc_set_cchhb(&f1->DS1PTRDS,
3433 + 0x0000, 0x0000, 0x00);
3438 + * do some updates to the VTOC format4 label
3441 +vtoc_update_format4_label (
3442 + format4_label_t *f4,
3443 + cchhb_t *highest_f1,
3444 + u_int16_t unused_update)
3447 + /* update highest address of a format 1 label */
3448 + memcpy(&f4->DS4HPCHR, highest_f1, sizeof(cchhb_t));
3450 + /* update unused DSCB count */
3451 + f4->DS4DSREC = unused_update;
3456 + * reorganizes all extents within a FMT5 label
3459 +vtoc_reorganize_FMT5_extents (format5_label_t *f5)
3462 + ds5ext_t *ext, *last, tmp;
3465 + for (i=0; i<26; i++)
3468 + last = &f5->DS5AVEXT;
3469 + else if ((i > 0) && (i < 8))
3470 + last = &f5->DS5EXTAV[i-1];
3472 + last = &f5->DS5MAVET[i-8];
3474 + for (j=i; j<26; j++)
3477 + ext = &f5->DS5AVEXT;
3478 + else if ((j > 0) && (j < 8))
3479 + ext = &f5->DS5EXTAV[j-1];
3481 + ext = &f5->DS5MAVET[j-8];
3483 + if (((ext->t > 0) && (last->t == 0)) ||
3484 + ((ext->t > 0) && (ext->t < last->t)))
3487 + tmp.fc = last->fc;
3488 + tmp.ft = last->ft;
3490 + last->fc = ext->fc;
3491 + last->ft = ext->ft;
3502 + * add a free space extent description to the VTOC FMT5 DSCB
3505 +vtoc_update_format5_label_add (format5_label_t *f5,
3514 + ds5ext_t *ext = NULL, *tmp = NULL;
3517 + for (i=0; i<26; i++)
3520 + ext = &f5->DS5AVEXT;
3521 + else if ((i > 0) && (i < 8))
3522 + ext = &f5->DS5EXTAV[i-1];
3524 + ext = &f5->DS5MAVET[i-8];
3526 + if (((a < ext->t) && (a + b*trk + c > ext->t)) ||
3527 + ((a > ext->t) && (ext->t + ext->fc*trk + ext->ft > a)))
3529 + printf("BUG: overlapping free space extents " \
3530 + "in FMT5 DSCB!\nexiting...\n");
3534 + if ((ext->t + ext->fc + ext->ft) == 0x0000)
3541 + printf("FMT5 add extent: " \
3542 + "add new extent\n");
3549 + /* BUG: no free extent found */
3550 + printf("BUG: no free FMT5 DSCB extent found!\nexiting...\n");
3554 + for (i=0; i<26; i++)
3557 + ext = &f5->DS5AVEXT;
3558 + else if ((i > 0) && (i < 8))
3559 + ext = &f5->DS5EXTAV[i-1];
3561 + ext = &f5->DS5MAVET[i-8];
3563 + if ((ext->t + ext->fc + ext->ft) == 0x0000)
3566 + if ((ext->t + ext->fc*trk + ext->ft) == tmp->t)
3568 + /* this extent precedes the new one */
3569 + ext->fc += (tmp->fc + (tmp->ft + ext->ft)/trk);
3570 + ext->ft = (tmp->ft + ext->ft) % trk;
3571 + bzero(tmp, sizeof(ds5ext_t));
3574 + printf("FMT5 add extent: " \
3575 + "merge with predecessor\n");
3580 + if ((tmp->t + tmp->fc*trk + tmp->ft) == ext->t)
3582 + /* this extent succeeds the new one */
3584 + ext->fc += (tmp->fc + (tmp->ft + ext->ft)/trk);
3585 + ext->ft = (tmp->ft + ext->ft) % trk;
3586 + bzero(tmp, sizeof(ds5ext_t));
3589 + printf("FMT5 add extent: " \
3590 + "merge with successor\n");
3599 + * remove a free space extent description from the VTOC FMT5 DSCB
3602 +vtoc_update_format5_label_del (format5_label_t *f5,
3614 + for (i=0; i<26; i++)
3617 + ext = &f5->DS5AVEXT;
3618 + else if ((i > 0) && (i < 8))
3619 + ext = &f5->DS5EXTAV[i-1];
3621 + ext = &f5->DS5MAVET[i-8];
3623 + if ((a == ext->t) && (b == ext->fc) && (c == ext->ft))
3625 + /* fills up whole free space gap */
3626 + bzero(ext, sizeof(ds5ext_t));
3628 + printf("FMT5 del extent: fills whole gap\n");
3633 + if ((a == ext->t) && ((b < ext->fc) || (c < ext->ft)))
3635 + /* left-bounded in free space gap */
3636 + ext->t = ext->t + b*trk + c;
3639 + ext->fc -= (b + 1);
3640 + ext->ft -= (c - trk);
3648 + printf("FMT5 del extent: left bounded\n");
3653 + if ((ext->t < a) &&
3654 + ((ext->t + ext->fc*trk + ext->ft) == (a + b*trk + c)))
3656 + /* right-bounded in free space gap */
3659 + ext->fc -= (b + 1);
3660 + ext->ft -= (c - trk);
3668 + printf("FMT5 del extent: right bounded\n");
3673 + if ((a > ext->t) &&
3674 + ((ext->t + ext->fc*trk + ext->ft) > (a + b*trk + c)))
3676 + /* partition devides free space into 2 pieces */
3677 + u_int16_t x = a + b*trk + c;
3681 + w = (ext->t + ext->fc*trk + ext->ft) - (a + b*trk + c);
3685 + ext->fc = (a - ext->t) / trk;
3686 + ext->ft = (a - ext->t) % trk;
3688 + vtoc_update_format5_label_add(f5, verbose,
3689 + cyl, trk, x, y, z);
3692 + printf("FMT5 del extent: 2 pieces\n");
3697 + if ((a < ext->t) && (a + b*trk + c > ext->t) &&
3698 + (a + b*trk + c < ext->t + ext->fc*trk + ext->ft))
3700 + printf("BUG: corresponding free space extent " \
3701 + "doesn't match free space currently shown " \
3702 + "in FMT5 DSCB!\nexiting...\n");
3706 + if ((a > ext->t) && (a < ext->t + ext->fc*trk + ext->ft) &&
3707 + (a + b*trk + c > ext->t + ext->fc*trk + ext->ft))
3709 + printf("BUG: specified free space extent for " \
3710 + "deleting doesn't match free space " \
3711 + "currently shown in FMT5 DSCB!\n" \
3717 + if (counter > 0) return;
3719 + printf("BUG: specified free space extent for " \
3720 + "deleting not found in FMT5 DSCB!\n" \
3727 + * reorganizes all extents within a FMT7 label
3730 +vtoc_reorganize_FMT7_extents (format7_label_t *f7)
3733 + ds7ext_t *ext, *last, tmp;
3736 + for (i=0; i<16; i++)
3739 + last = &f7->DS7EXTNT[i];
3741 + last = &f7->DS7ADEXT[i-5];
3743 + for (j=i; j<16; j++)
3746 + ext = &f7->DS7EXTNT[j];
3748 + ext = &f7->DS7ADEXT[j-5];
3750 + if (((ext->a > 0) && (last->a == 0)) ||
3751 + ((ext->a > 0) && (ext->a < last->a)))
3766 + * add a free space extent description to the VTOC FMT7 DSCB
3769 +vtoc_update_format7_label_add (format7_label_t *f7, int verbose,
3770 + u_int32_t a, u_int32_t b)
3773 + ds7ext_t *ext = NULL, *tmp = NULL;
3776 + for (i=0; i<16; i++)
3779 + ext = &f7->DS7EXTNT[i];
3781 + ext = &f7->DS7ADEXT[i-5];
3783 + if (((a < ext->a) && (b > ext->a) && (b < ext->b)) ||
3784 + ((a > ext->a) && (a < ext->b) && (b > ext->b)))
3786 + printf("BUG: overlapping free space extents " \
3787 + "in FMT7 DSCB!\nexiting...\n");
3791 + if ((ext->a + ext->b) == 0x00000000)
3797 + printf("FMT7 add extent: " \
3798 + "add new extent\n");
3805 + /* BUG: no free extent found */
3806 + printf("BUG: no free FMT7 DSCB extent found!\nexiting...\n");
3810 + for (i=0; i<16; i++)
3813 + ext = &f7->DS7EXTNT[i];
3815 + ext = &f7->DS7ADEXT[i-5];
3817 + if ((ext->a + ext->b) == 0x00000000)
3820 + if ((ext->b + 1) == tmp->a)
3822 + /* this extent precedes the new one */
3824 + bzero(tmp, sizeof(ds7ext_t));
3827 + printf("FMT7 add extent: " \
3828 + "merge with predecessor\n");
3833 + if (ext->a == (tmp->b + 1))
3835 + /* this extent succeeds the new one */
3837 + bzero(tmp, sizeof(ds7ext_t));
3840 + printf("FMT7 add extent: " \
3841 + "merge with successor\n");
3850 + * remove a free space extent description from the VTOC FMT7 DSCB
3853 +vtoc_update_format7_label_del (format7_label_t *f7, int verbose,
3854 + u_int32_t a, u_int32_t b)
3860 + for (i=0; i<16; i++)
3863 + ext = &f7->DS7EXTNT[i];
3865 + ext = &f7->DS7ADEXT[i-5];
3867 + if ((a == ext->a) && (b == ext->b))
3869 + /* fills up whole free space gap */
3870 + bzero(ext, sizeof(ds7ext_t));
3872 + printf("FMT7 del extent: " \
3873 + "fills whole gap\n");
3878 + if ((a == ext->a) && (b < ext->b))
3880 + /* left-bounded in free space gap */
3883 + printf("FMT7 add extent: " \
3884 + "left-bounded\n");
3889 + if ((a > ext->a) && (b == ext->b))
3891 + /* right-bounded in free space gap */
3894 + printf("FMT7 add extent: " \
3895 + "right-bounded\n");
3900 + if ((a > ext->a) && (b < ext->b))
3902 + /* partition devides free space into 2 pieces */
3903 + vtoc_update_format7_label_add(f7, verbose,
3907 + printf("FMT7 add extent: " \
3913 + if (((a < ext->a) && (b > ext->a)) || ((a < ext->b) && (b > ext->b)))
3915 + printf ("BUG: specified free space extent for deleting "
3916 + "doesn't match free space currently shown in "
3917 + "FMT7 DSCB!\nexiting...\n");
3918 + printf ("%d %d %d %d\n", a, b, ext->a, ext->b);
3923 + if (counter > 0) return;
3925 + printf("BUG: specified free space extent for " \
3926 + "deleting not found in FMT7 DSCB!\n" \
3936 +vtoc_set_freespace(format4_label_t *f4,
3937 + format5_label_t *f5,
3938 + format7_label_t *f7,
3947 + if ((cyl * trk) > BIG_DISK_SIZE)
3951 + vtoc_update_format7_label_add(f7, verbose,
3954 + else if (ch == '-')
3956 + vtoc_update_format7_label_del(f7, verbose,
3961 + printf("BUG: syntax error in " \
3962 + "vtoc_set_freespace call\n");
3965 + vtoc_reorganize_FMT7_extents (f7);
3967 + f4->DS4VTOCI = 0xa0;
3968 + f4->DS4EFLVL = 0x07;
3969 + vtoc_set_cchhb(&f4->DS4EFPTR, 0x0000, 0x0001, 0x03);
3976 + x = (u_int16_t) start;
3977 + y = (u_int16_t) ((stop - start + 1) / trk);
3978 + z = (u_int8_t) ((stop - start + 1) % trk);
3982 + vtoc_update_format5_label_add(f5, verbose,
3986 + else if (ch == '-')
3988 + vtoc_update_format5_label_del(f5, verbose,
3994 + printf("BUG: syntax error in " \
3995 + "vtoc_set_freespace call\n");
3997 + vtoc_reorganize_FMT5_extents (f5);
4010 diff -ruN --minimal parted-1.6.21.orig/libparted/vtoc.h parted-1.6.21/libparted/vtoc.h
4011 --- parted-1.6.21.orig/libparted/vtoc.h 1969-12-31 19:00:00.000000000 -0500
4012 +++ parted-1.6.21/libparted/vtoc.h 2005-01-21 15:00:40.455627637 -0500
4015 + * File...........: s390-tools/dasdview/vtoc.h
4016 + * Author(s)......: Horst Hummel <horst.hummel@de.ibm.com>
4017 + * Bugreports.to..: <Linux390@de.ibm.com>
4019 + * This is a user-space copy of the kernel vtoc,h.
4021 + * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2002
4023 + * History of changes (starts March 2002)
4024 + * 2002-03-12 initial
4030 +#include <string.h>
4031 +#include <stdlib.h>
4037 +#include <unistd.h>
4039 +#include <sys/stat.h>
4040 +#include <sys/ioctl.h>
4042 +#define LINE_LENGTH 80
4043 +#define VTOC_START_CC 0x0
4044 +#define VTOC_START_HH 0x1
4045 +#define FIRST_USABLE_CYL 1
4046 +#define FIRST_USABLE_TRK 2
4048 +#define DASD_3380_TYPE 13148
4049 +#define DASD_3390_TYPE 13200
4050 +#define DASD_9345_TYPE 37701
4052 +#define DASD_3380_VALUE 0xbb60
4053 +#define DASD_3390_VALUE 0xe5a2
4054 +#define DASD_9345_VALUE 0xbc98
4056 +#define VOLSER_LENGTH 6
4057 +#define BIG_DISK_SIZE 0x10000
4059 +#define VTOC_ERROR "VTOC error:"
4066 +} __attribute__ ((packed)) ttr_t;
4068 +typedef struct cchhb
4073 +} __attribute__ ((packed)) cchhb_t;
4075 +typedef struct cchh
4079 +} __attribute__ ((packed)) cchh_t;
4081 +typedef struct labeldate
4085 +} __attribute__ ((packed)) labeldate_t;
4088 +typedef struct volume_label
4090 + char volkey[4]; /* volume key = volume label */
4091 + char vollbl[4]; /* volume label */
4092 + char volid[6]; /* volume identifier */
4093 + u_int8_t security; /* security byte */
4094 + cchhb_t vtoc; /* VTOC address */
4095 + char res1[5]; /* reserved */
4096 + char cisize[4]; /* CI-size for FBA,... */
4097 + /* ...blanks for CKD */
4098 + char blkperci[4]; /* no of blocks per CI (FBA), blanks for CKD */
4099 + char labperci[4]; /* no of labels per CI (FBA), blanks for CKD */
4100 + char res2[4]; /* reserved */
4101 + char lvtoc[14]; /* owner code for LVTOC */
4102 + char res3[29]; /* reserved */
4103 +} __attribute__ ((packed)) volume_label_t;
4106 +typedef struct extent
4108 + u_int8_t typeind; /* extent type indicator */
4109 + u_int8_t seqno; /* extent sequence number */
4110 + cchh_t llimit; /* starting point of this extent */
4111 + cchh_t ulimit; /* ending point of this extent */
4112 +} __attribute__ ((packed)) extent_t;
4115 +typedef struct dev_const
4117 + u_int16_t DS4DSCYL; /* number of logical cyls */
4118 + u_int16_t DS4DSTRK; /* number of tracks in a logical cylinder */
4119 + u_int16_t DS4DEVTK; /* device track length */
4120 + u_int8_t DS4DEVI; /* non-last keyed record overhead */
4121 + u_int8_t DS4DEVL; /* last keyed record overhead */
4122 + u_int8_t DS4DEVK; /* non-keyed record overhead differential */
4123 + u_int8_t DS4DEVFG; /* flag byte */
4124 + u_int16_t DS4DEVTL; /* device tolerance */
4125 + u_int8_t DS4DEVDT; /* number of DSCB's per track */
4126 + u_int8_t DS4DEVDB; /* number of directory blocks per track */
4127 +} __attribute__ ((packed)) dev_const_t;
4130 +typedef struct format1_label
4132 + char DS1DSNAM[44]; /* data set name */
4133 + u_int8_t DS1FMTID; /* format identifier */
4134 + char DS1DSSN[6]; /* data set serial number */
4135 + u_int16_t DS1VOLSQ; /* volume sequence number */
4136 + labeldate_t DS1CREDT; /* creation date: ydd */
4137 + labeldate_t DS1EXPDT; /* expiration date */
4138 + u_int8_t DS1NOEPV; /* number of extents on volume */
4139 + u_int8_t DS1NOBDB; /* no. of bytes used in last direction blk */
4140 + u_int8_t DS1FLAG1; /* flag 1 */
4141 + char DS1SYSCD[13]; /* system code */
4142 + labeldate_t DS1REFD; /* date last referenced */
4143 + u_int8_t DS1SMSFG; /* system managed storage indicators */
4144 + u_int8_t DS1SCXTF; /* sec. space extension flag byte */
4145 + u_int16_t DS1SCXTV; /* secondary space extension value */
4146 + u_int8_t DS1DSRG1; /* data set organisation byte 1 */
4147 + u_int8_t DS1DSRG2; /* data set organisation byte 2 */
4148 + u_int8_t DS1RECFM; /* record format */
4149 + u_int8_t DS1OPTCD; /* option code */
4150 + u_int16_t DS1BLKL; /* block length */
4151 + u_int16_t DS1LRECL; /* record length */
4152 + u_int8_t DS1KEYL; /* key length */
4153 + u_int16_t DS1RKP; /* relative key position */
4154 + u_int8_t DS1DSIND; /* data set indicators */
4155 + u_int8_t DS1SCAL1; /* secondary allocation flag byte */
4156 + char DS1SCAL3[3]; /* secondary allocation quantity */
4157 + ttr_t DS1LSTAR; /* last used track and block on track */
4158 + u_int16_t DS1TRBAL; /* space remaining on last used track */
4159 + u_int16_t res1; /* reserved */
4160 + extent_t DS1EXT1; /* first extent description */
4161 + extent_t DS1EXT2; /* second extent description */
4162 + extent_t DS1EXT3; /* third extent description */
4163 + cchhb_t DS1PTRDS; /* possible pointer to f2 or f3 DSCB */
4164 +} __attribute__ ((packed)) format1_label_t;
4167 +typedef struct format4_label
4169 + char DS4KEYCD[44]; /* key code for VTOC labels: 44 times 0x04 */
4170 + u_int8_t DS4IDFMT; /* format identifier */
4171 + cchhb_t DS4HPCHR; /* highest address of a format 1 DSCB */
4172 + u_int16_t DS4DSREC; /* number of available DSCB's */
4173 + cchh_t DS4HCCHH; /* CCHH of next available alternate track */
4174 + u_int16_t DS4NOATK; /* number of remaining alternate tracks */
4175 + u_int8_t DS4VTOCI; /* VTOC indicators */
4176 + u_int8_t DS4NOEXT; /* number of extents in VTOC */
4177 + u_int8_t DS4SMSFG; /* system managed storage indicators */
4178 + u_int8_t DS4DEVAC; /* number of alternate cylinders.
4179 + Subtract from first two bytes of
4180 + DS4DEVSZ to get number of usable
4181 + cylinders. can be zero. valid
4182 + only if DS4DEVAV on. */
4183 + dev_const_t DS4DEVCT; /* device constants */
4184 + char DS4AMTIM[8]; /* VSAM time stamp */
4185 + char DS4AMCAT[3]; /* VSAM catalog indicator */
4186 + char DS4R2TIM[8]; /* VSAM volume/catalog match time stamp */
4187 + char res1[5]; /* reserved */
4188 + char DS4F6PTR[5]; /* pointer to first format 6 DSCB */
4189 + extent_t DS4VTOCE; /* VTOC extent description */
4190 + char res2[10]; /* reserved */
4191 + u_int8_t DS4EFLVL; /* extended free-space management level */
4192 + cchhb_t DS4EFPTR; /* pointer to extended free-space info */
4193 + char res3[9]; /* reserved */
4194 +} __attribute__ ((packed)) format4_label_t;
4197 +typedef struct ds5ext
4199 + u_int16_t t; /* RTA of the first track of free extent */
4200 + u_int16_t fc; /* number of whole cylinders in free ext. */
4201 + u_int8_t ft; /* number of remaining free tracks */
4202 +} __attribute__ ((packed)) ds5ext_t;
4205 +typedef struct format5_label
4207 + char DS5KEYID[4]; /* key identifier */
4208 + ds5ext_t DS5AVEXT; /* first available (free-space) extent. */
4209 + ds5ext_t DS5EXTAV[7]; /* seven available extents */
4210 + u_int8_t DS5FMTID; /* format identifier */
4211 + ds5ext_t DS5MAVET[18]; /* eighteen available extents */
4212 + cchhb_t DS5PTRDS; /* pointer to next format5 DSCB */
4213 +} __attribute__ ((packed)) format5_label_t;
4216 +typedef struct ds7ext
4218 + u_int32_t a; /* starting RTA value */
4219 + u_int32_t b; /* ending RTA value + 1 */
4220 +} __attribute__ ((packed)) ds7ext_t;
4223 +typedef struct format7_label
4225 + char DS7KEYID[4]; /* key identifier */
4226 + ds7ext_t DS7EXTNT[5]; /* space for 5 extent descriptions */
4227 + u_int8_t DS7FMTID; /* format identifier */
4228 + ds7ext_t DS7ADEXT[11]; /* space for 11 extent descriptions */
4229 + char res1[2]; /* reserved */
4230 + cchhb_t DS7PTRDS; /* pointer to next FMT7 DSCB */
4231 +} __attribute__ ((packed)) format7_label_t;
4234 +char * vtoc_ebcdic_enc (
4235 + char source[LINE_LENGTH],
4236 + char target[LINE_LENGTH],
4238 +char * vtoc_ebcdic_dec (
4239 + char source[LINE_LENGTH],
4240 + char target[LINE_LENGTH],
4242 +void vtoc_set_extent (
4248 +void vtoc_set_cchh (
4252 +void vtoc_set_cchhb (
4257 +void vtoc_set_date (
4262 +void vtoc_volume_label_init (
4263 + volume_label_t *vlabel);
4265 +int vtoc_read_volume_label (
4267 + unsigned long vlabel_start,
4268 + volume_label_t * vlabel);
4270 +int vtoc_write_volume_label (
4272 + unsigned long vlabel_start,
4273 + volume_label_t *vlabel);
4275 +void vtoc_volume_label_set_volser (
4276 + volume_label_t *vlabel,
4279 +char *vtoc_volume_label_get_volser (
4280 + volume_label_t *vlabel,
4283 +void vtoc_volume_label_set_key (
4284 + volume_label_t *vlabel,
4287 +void vtoc_volume_label_set_label (
4288 + volume_label_t *vlabel,
4291 +char *vtoc_volume_label_get_label (
4292 + volume_label_t *vlabel,
4295 +void vtoc_read_label (
4297 + unsigned long position,
4298 + format1_label_t *f1,
4299 + format4_label_t *f4,
4300 + format5_label_t *f5,
4301 + format7_label_t *f7);
4303 +void vtoc_write_label (
4305 + unsigned long position,
4306 + format1_label_t *f1,
4307 + format4_label_t *f4,
4308 + format5_label_t *f5,
4309 + format7_label_t *f7);
4312 +void vtoc_init_format1_label (
4314 + unsigned int blksize,
4315 + extent_t *part_extent,
4316 + format1_label_t *f1);
4319 +void vtoc_init_format4_label (
4320 + format4_label_t *f4lbl,
4321 + unsigned int usable_partitions,
4322 + unsigned int cylinders,
4323 + unsigned int tracks,
4324 + unsigned int blocks,
4325 + unsigned int blksize,
4326 + u_int16_t dev_type);
4328 +void vtoc_update_format4_label (
4329 + format4_label_t *f4,
4330 + cchhb_t *highest_f1,
4331 + u_int16_t unused_update);
4334 +void vtoc_init_format5_label (
4335 + format5_label_t *f5);
4337 +void vtoc_update_format5_label_add (
4338 + format5_label_t *f5,
4346 +void vtoc_update_format5_label_del (
4347 + format5_label_t *f5,
4356 +void vtoc_init_format7_label (
4357 + format7_label_t *f7);
4359 +void vtoc_update_format7_label_add (
4360 + format7_label_t *f7,
4365 +void vtoc_update_format7_label_del (
4366 + format7_label_t *f7,
4372 +void vtoc_set_freespace(
4373 + format4_label_t *f4,
4374 + format5_label_t *f5,
4375 + format7_label_t *f7,
4384 +#endif /* VTOC_H */