1 /* -*- Mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3 libparted - a library for manipulating disk partitions
4 Copyright (C) 2000-2001, 2005, 2007-2011 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 Contributor: Ben Collins <bcollins@debian.org>
24 #include <parted/parted.h>
25 #include <parted/debug.h>
26 #include <parted/endian.h>
31 # define _(String) dgettext (PACKAGE, String)
33 # define _(String) (String)
34 #endif /* ENABLE_NLS */
40 /* Most of this came from util-linux's sun support, which was mostly done
43 #define SUN_DISK_MAGIC 0xDABE /* Disk magic number */
44 #define SUN_DISK_MAXPARTITIONS 8
46 #define SUN_VTOC_VERSION 1
47 #define SUN_VTOC_SANITY 0x600DDEEE
49 #define WHOLE_DISK_ID 0x05
50 #define WHOLE_DISK_PART 2 /* as in 0, 1, 2 (3rd partition) */
51 #define LINUX_SWAP_ID 0x82
53 typedef struct _SunRawPartition SunRawPartition;
54 typedef struct _SunPartitionInfo SunPartitionInfo;
55 typedef struct _SunRawLabel SunRawLabel;
56 typedef struct _SunPartitionData SunPartitionData;
57 typedef struct _SunDiskData SunDiskData;
59 struct __attribute__ ((packed)) _SunRawPartition {
60 u_int32_t start_cylinder; /* where the part starts... */
61 u_int32_t num_sectors; /* ...and it's length */
64 struct __attribute__ ((packed)) _SunPartitionInfo {
66 u_int8_t id; /* Partition type */
68 u_int8_t flags; /* Partition flags */
71 struct __attribute__ ((packed)) _SunRawLabel {
72 char info[128]; /* Informative text string */
73 u_int32_t version; /* Layout version */
74 u_int8_t volume[8]; /* Volume name */
75 u_int16_t nparts; /* Number of partitions */
76 SunPartitionInfo infos[SUN_DISK_MAXPARTITIONS];
77 u_int16_t padding; /* Alignment padding */
78 u_int32_t bootinfo[3]; /* Info needed by mboot */
79 u_int32_t sanity; /* To verify vtoc sanity */
80 u_int32_t reserved[10]; /* Free space */
81 u_int32_t timestamp[8]; /* Partition timestamp */
82 u_int32_t write_reinstruct; /* sectors to skip, writes */
83 u_int32_t read_reinstruct; /* sectors to skip, reads */
84 u_int8_t spare1[148]; /* Padding */
85 u_int16_t rspeed; /* Disk rotational speed */
86 u_int16_t pcylcount; /* Physical cylinder count */
87 u_int16_t sparecyl; /* extra sects per cylinder */
88 u_int8_t spare2[4]; /* More magic... */
89 u_int16_t ilfact; /* Interleave factor */
90 u_int16_t ncyl; /* Data cylinder count */
91 u_int16_t nacyl; /* Alt. cylinder count */
92 u_int16_t ntrks; /* Tracks per cylinder */
93 u_int16_t nsect; /* Sectors per track */
94 u_int8_t spare3[4]; /* Even more magic... */
95 SunRawPartition partitions[SUN_DISK_MAXPARTITIONS];
96 u_int16_t magic; /* Magic number */
97 u_int16_t csum; /* Label xor'd checksum */
100 struct _SunPartitionData {
108 struct _SunDiskData {
109 PedSector length; /* This is based on cyl - alt-cyl */
110 SunRawLabel raw_label;
113 static PedDiskType sun_disk_type;
115 /* Checksum computation */
117 sun_compute_checksum (SunRawLabel *label)
119 u_int16_t *ush = (u_int16_t *)label;
122 while(ush < (u_int16_t *)(&label->csum))
127 /* Checksum Verification */
129 sun_verify_checksum (SunRawLabel const *label)
131 u_int16_t *ush = ((u_int16_t *)(label + 1)) - 1;
134 while (ush >= (u_int16_t *)label)
141 sun_probe (const PedDevice *dev)
143 PED_ASSERT (dev != NULL);
146 if (!ptt_read_sector (dev, 0, &s0))
148 SunRawLabel const *label = (void const *) s0;
152 if (PED_BE16_TO_CPU (label->magic) != SUN_DISK_MAGIC) {
155 #ifndef DISCOVER_ONLY
156 if (!sun_verify_checksum(label)) {
158 ped_exception_throw (
160 PED_EXCEPTION_CANCEL,
161 _("Corrupted Sun disk label detected."));
171 sun_alloc (const PedDevice* dev)
175 SunDiskData* sun_specific;
176 const PedCHSGeometry* bios_geom = &dev->bios_geom;
177 PedSector cyl_size = bios_geom->sectors * bios_geom->heads;
178 PED_ASSERT (cyl_size != 0);
180 disk = _ped_disk_alloc (dev, &sun_disk_type);
184 disk->disk_specific = (SunDiskData*) ped_malloc (sizeof (SunDiskData));
185 if (!disk->disk_specific)
186 goto error_free_disk;
187 sun_specific = (SunDiskData*) disk->disk_specific;
189 PED_ASSERT (bios_geom->cylinders == (PedSector) (dev->length / cyl_size));
190 sun_specific->length = ped_round_down_to (dev->length, cyl_size);
192 label = &sun_specific->raw_label;
193 memset(label, 0, sizeof(SunRawLabel));
195 /* #gentoo-sparc people agree that nacyl = 0 is the best option */
196 label->magic = PED_CPU_TO_BE16 (SUN_DISK_MAGIC);
198 label->pcylcount = PED_CPU_TO_BE16 (bios_geom->cylinders);
199 label->rspeed = PED_CPU_TO_BE16 (5400);
200 label->ilfact = PED_CPU_TO_BE16 (1);
202 label->ntrks = PED_CPU_TO_BE16 (bios_geom->heads);
203 label->nsect = PED_CPU_TO_BE16 (bios_geom->sectors);
204 label->ncyl = PED_CPU_TO_BE16 (dev->length / cyl_size);
206 label->sanity = PED_CPU_TO_BE32 (SUN_VTOC_SANITY);
207 label->version = PED_CPU_TO_BE32 (SUN_VTOC_VERSION);
208 label->nparts = PED_CPU_TO_BE16 (SUN_DISK_MAXPARTITIONS);
210 /* Add a whole disk partition at a minimum */
211 label->infos[WHOLE_DISK_PART].id = WHOLE_DISK_ID;
212 label->partitions[WHOLE_DISK_PART].start_cylinder = 0;
213 label->partitions[WHOLE_DISK_PART].num_sectors =
214 PED_CPU_TO_BE32(sun_specific->length);
216 /* Now a neato string to describe this label */
217 snprintf(label->info, sizeof(label->info) - 1,
218 "GNU Parted Custom cyl %d alt %d hd %d sec %d",
219 PED_BE16_TO_CPU(label->ncyl),
220 PED_BE16_TO_CPU(label->nacyl),
221 PED_BE16_TO_CPU(label->ntrks),
222 PED_BE16_TO_CPU(label->nsect));
224 sun_compute_checksum(label);
228 _ped_disk_free (disk);
234 sun_duplicate (const PedDisk* disk)
237 SunDiskData* new_sun_data;
238 SunDiskData* old_sun_data = (SunDiskData*) disk->disk_specific;
240 new_disk = ped_disk_new_fresh (disk->dev, &sun_disk_type);
244 new_sun_data = (SunDiskData*) new_disk->disk_specific;
245 memcpy (new_sun_data, old_sun_data, sizeof (SunDiskData));
250 sun_free (PedDisk *disk)
252 free (disk->disk_specific);
253 _ped_disk_free (disk);
257 _check_geometry_sanity (PedDisk* disk, SunRawLabel* label)
259 PedDevice* dev = disk->dev;
261 if (PED_BE16_TO_CPU(label->nsect) == dev->hw_geom.sectors &&
262 PED_BE16_TO_CPU(label->ntrks) == dev->hw_geom.heads)
263 dev->bios_geom = dev->hw_geom;
265 if (!!PED_BE16_TO_CPU(label->pcylcount)
266 * !!PED_BE16_TO_CPU(label->ntrks)
267 * !!PED_BE16_TO_CPU(label->nsect) == 0)
270 if (PED_BE16_TO_CPU(label->nsect) != dev->bios_geom.sectors ||
271 PED_BE16_TO_CPU(label->ntrks) != dev->bios_geom.heads) {
272 #ifndef DISCOVER_ONLY
273 if (ped_exception_throw (
274 PED_EXCEPTION_WARNING,
275 PED_EXCEPTION_IGNORE_CANCEL,
276 _("The disk CHS geometry (%d,%d,%d) reported "
277 "by the operating system does not match "
278 "the geometry stored on the disk label "
280 dev->bios_geom.cylinders,
281 dev->bios_geom.heads,
282 dev->bios_geom.sectors,
283 PED_BE16_TO_CPU(label->pcylcount),
284 PED_BE16_TO_CPU(label->ntrks),
285 PED_BE16_TO_CPU(label->nsect))
286 == PED_EXCEPTION_CANCEL)
289 dev->bios_geom.sectors = PED_BE16_TO_CPU(label->nsect);
290 dev->bios_geom.heads = PED_BE16_TO_CPU(label->ntrks);
291 dev->bios_geom.cylinders = PED_BE16_TO_CPU(label->pcylcount);
293 if (dev->bios_geom.sectors * dev->bios_geom.heads
294 * dev->bios_geom.cylinders > dev->length) {
295 if (ped_exception_throw (
296 PED_EXCEPTION_WARNING,
297 PED_EXCEPTION_IGNORE_CANCEL,
298 _("The disk label describes a disk bigger than "
301 != PED_EXCEPTION_IGNORE)
309 sun_read (PedDisk* disk)
311 SunPartitionData* sun_data;
312 SunDiskData* disk_data;
315 PedSector end, start, block;
317 PED_ASSERT (disk != NULL);
318 PED_ASSERT (disk->dev != NULL);
319 PED_ASSERT (disk->disk_specific != NULL);
321 disk_data = (SunDiskData*) disk->disk_specific;
323 ped_disk_delete_all (disk);
326 if (!ptt_read_sector (disk->dev, 0, &s0))
329 SunRawLabel *label = &disk_data->raw_label;
330 verify (sizeof (*label) == 512);
331 memcpy (label, s0, sizeof (*label));
334 if (!_check_geometry_sanity (disk, label))
337 block = disk->dev->bios_geom.sectors * disk->dev->bios_geom.heads;
338 disk_data->length = block * disk->dev->bios_geom.cylinders;
340 for (i = 0; i < SUN_DISK_MAXPARTITIONS; i++) {
341 if (!PED_BE32_TO_CPU(label->partitions[i].num_sectors))
343 if (!label->infos[i].id)
345 if (label->infos[i].id == WHOLE_DISK_ID)
348 start = PED_BE32_TO_CPU(label->partitions[i].start_cylinder)
351 + PED_BE32_TO_CPU(label->partitions[i].num_sectors) - 1;
353 part = ped_partition_new (disk, PED_PARTITION_NORMAL, NULL,
358 sun_data = part->disk_specific;
359 sun_data->type = label->infos[i].id;
360 sun_data->is_boot = sun_data->type == 0x1;
361 sun_data->is_root = sun_data->type == 0x2;
362 sun_data->is_lvm = sun_data->type == 0x8e;
363 sun_data->is_raid = sun_data->type == 0xfd;
366 part->fs_type = ped_file_system_probe (&part->geom);
368 PedConstraint *constraint_exact
369 = ped_constraint_exact (&part->geom);
370 if (constraint_exact == NULL)
372 bool ok = ped_disk_add_partition (disk, part, constraint_exact);
373 ped_constraint_destroy (constraint_exact);
384 #ifndef DISCOVER_ONLY
386 _use_old_info (const PedDisk* disk, const void *sector_0)
388 SunRawLabel const *old_label = sector_0;
390 if (old_label->info[0]
391 && PED_BE16_TO_CPU (old_label->magic) == SUN_DISK_MAGIC) {
392 SunDiskData *sun_specific = disk->disk_specific;
393 memcpy (&sun_specific->raw_label, sector_0,
394 sizeof (sun_specific->raw_label));
395 verify (sizeof (sun_specific->raw_label) == 512);
402 sun_write (const PedDisk* disk)
405 SunPartitionData* sun_data;
406 SunDiskData* disk_data;
410 PED_ASSERT (disk != NULL);
411 PED_ASSERT (disk->dev != NULL);
414 if (!ptt_read_sector (disk->dev, 0, &s0))
417 /* Calling _use_old_info here in sun_write
418 above seems wrong, because it modifies *DISK.
419 FIXME: maybe later. */
420 if (!_use_old_info (disk, s0)) {
425 disk_data = (SunDiskData*) disk->disk_specific;
426 label = &disk_data->raw_label;
428 memset (label->partitions, 0,
429 sizeof (SunRawPartition) * SUN_DISK_MAXPARTITIONS);
430 memset (label->infos, 0,
431 sizeof (SunPartitionInfo) * SUN_DISK_MAXPARTITIONS);
433 for (i = 0; i < SUN_DISK_MAXPARTITIONS; i++) {
434 part = ped_disk_get_partition (disk, i + 1);
436 if (!part && i == WHOLE_DISK_PART) {
437 /* Ok, nothing explicitly in the whole disk
438 partition, so let's put it there for safety
441 label->infos[i].id = WHOLE_DISK_ID;
442 label->partitions[i].start_cylinder = 0;
443 label->partitions[i].num_sectors =
444 PED_CPU_TO_BE32(disk_data->length);
450 sun_data = part->disk_specific;
451 label->infos[i].id = sun_data->type;
452 label->partitions[i].start_cylinder
453 = PED_CPU_TO_BE32 (part->geom.start
454 / (disk->dev->bios_geom.sectors
455 * disk->dev->bios_geom.heads));
456 label->partitions[i].num_sectors
457 = PED_CPU_TO_BE32 (part->geom.end
458 - part->geom.start + 1);
461 /* We assume the harddrive is always right, and that the label may
462 be wrong. I don't think this will cause any problems, since the
463 cylinder count is always enforced by our alignment, and we
464 sanity checked the sectors/heads when we detected the device. The
465 worst that could happen here is that the drive seems bigger or
466 smaller than it really is, but we'll have that problem even if we
469 if (disk->dev->bios_geom.cylinders > 65536) {
470 ped_exception_throw (
471 PED_EXCEPTION_WARNING,
472 PED_EXCEPTION_IGNORE,
473 _("The disk has %d cylinders, which is greater than "
474 "the maximum of 65536."),
475 disk->dev->bios_geom.cylinders);
478 label->pcylcount = PED_CPU_TO_BE16 (disk->dev->bios_geom.cylinders);
479 label->ncyl = PED_CPU_TO_BE16 (disk->dev->bios_geom.cylinders
480 - PED_BE16_TO_CPU (label->nacyl));
482 sun_compute_checksum (label);
484 verify (sizeof *label == 512);
485 memcpy (s0, label, sizeof *label);
486 int write_ok = ped_device_write (disk->dev, s0, 0, 1);
490 return ped_device_sync (disk->dev);
494 #endif /* !DISCOVER_ONLY */
497 sun_partition_new (const PedDisk* disk, PedPartitionType part_type,
498 const PedFileSystemType* fs_type,
499 PedSector start, PedSector end)
502 SunPartitionData* sun_data;
504 part = _ped_partition_alloc (disk, part_type, fs_type, start, end);
508 if (ped_partition_is_active (part)) {
510 = sun_data = ped_malloc (sizeof (SunPartitionData));
512 goto error_free_part;
514 sun_data->is_boot = 0;
515 sun_data->is_root = 0;
516 sun_data->is_lvm = 0;
517 sun_data->is_raid = 0;
519 part->disk_specific = NULL;
531 sun_partition_duplicate (const PedPartition* part)
533 PedPartition* new_part;
534 SunPartitionData* new_sun_data;
535 SunPartitionData* old_sun_data;
537 new_part = ped_partition_new (part->disk, part->type,
538 part->fs_type, part->geom.start,
542 new_part->num = part->num;
544 old_sun_data = (SunPartitionData*) part->disk_specific;
545 new_sun_data = (SunPartitionData*) new_part->disk_specific;
546 new_sun_data->type = old_sun_data->type;
547 new_sun_data->is_boot = old_sun_data->is_boot;
548 new_sun_data->is_root = old_sun_data->is_root;
549 new_sun_data->is_lvm = old_sun_data->is_lvm;
550 new_sun_data->is_raid = old_sun_data->is_raid;
555 sun_partition_destroy (PedPartition* part)
557 PED_ASSERT (part != NULL);
559 if (ped_partition_is_active (part))
560 free (part->disk_specific);
565 sun_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
567 SunPartitionData* sun_data = part->disk_specific;
569 part->fs_type = fs_type;
571 if (sun_data->is_boot) {
572 sun_data->type = 0x1;
575 if (sun_data->is_root) {
576 sun_data->type = 0x2;
579 if (sun_data->is_lvm) {
580 sun_data->type = 0x8e;
583 if (sun_data->is_raid) {
584 sun_data->type = 0xfd;
588 sun_data->type = 0x83;
590 if (is_linux_swap (fs_type->name))
591 sun_data->type = 0x82;
592 else if (!strcmp (fs_type->name, "ufs"))
593 sun_data->type = 0x6;
600 sun_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
602 SunPartitionData* sun_data;
604 PED_ASSERT (part != NULL);
605 PED_ASSERT (part->disk_specific != NULL);
606 PED_ASSERT (ped_partition_is_flag_available (part, flag));
608 sun_data = part->disk_specific;
611 case PED_PARTITION_BOOT:
612 sun_data->is_boot = state;
614 sun_data->is_lvm = 0;
615 sun_data->is_raid = 0;
616 sun_data->is_root = 0;
618 return ped_partition_set_system (part, part->fs_type);
620 case PED_PARTITION_ROOT:
621 sun_data->is_root = state;
623 sun_data->is_boot = 0;
624 sun_data->is_lvm = 0;
625 sun_data->is_raid = 0;
627 return ped_partition_set_system (part, part->fs_type);
629 case PED_PARTITION_LVM:
630 sun_data->is_lvm = state;
632 sun_data->is_boot = 0;
633 sun_data->is_raid = 0;
634 sun_data->is_root = 0;
636 return ped_partition_set_system (part, part->fs_type);
638 case PED_PARTITION_RAID:
639 sun_data->is_raid = state;
641 sun_data->is_boot = 0;
642 sun_data->is_lvm = 0;
643 sun_data->is_root = 0;
645 return ped_partition_set_system (part, part->fs_type);
654 sun_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
656 SunPartitionData* sun_data;
658 PED_ASSERT (part != NULL);
659 PED_ASSERT (part->disk_specific != NULL);
661 sun_data = part->disk_specific;
664 case PED_PARTITION_BOOT:
665 return sun_data->is_boot;
666 case PED_PARTITION_ROOT:
667 return sun_data->is_root;
668 case PED_PARTITION_LVM:
669 return sun_data->is_lvm;
670 case PED_PARTITION_RAID:
671 return sun_data->is_raid;
680 sun_partition_is_flag_available (const PedPartition* part,
681 PedPartitionFlag flag)
684 case PED_PARTITION_BOOT:
685 case PED_PARTITION_ROOT:
686 case PED_PARTITION_LVM:
687 case PED_PARTITION_RAID:
696 sun_get_max_supported_partition_count (const PedDisk* disk, int *max_n)
698 *max_n = SUN_DISK_MAXPARTITIONS;
703 sun_get_max_primary_partition_count (const PedDisk* disk)
705 return SUN_DISK_MAXPARTITIONS;
709 sun_get_partition_alignment(const PedDisk *disk)
712 disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
714 return ped_alignment_new(0, block);
717 static PedConstraint*
718 _get_strict_constraint (PedDisk* disk)
720 PedDevice* dev = disk->dev;
721 PedAlignment start_align;
722 PedAlignment end_align;
723 PedGeometry max_geom;
724 SunDiskData* disk_data = disk->disk_specific;
725 PedSector block = dev->bios_geom.sectors * dev->bios_geom.heads;
727 if (!ped_alignment_init (&start_align, 0, block))
729 if (!ped_alignment_init (&end_align, -1, block))
731 if (!ped_geometry_init (&max_geom, dev, 0, disk_data->length))
734 return ped_constraint_new (&start_align, &end_align, &max_geom,
735 &max_geom, 1, dev->length);
738 static PedConstraint*
739 _get_lax_constraint (PedDisk* disk)
741 PedDevice* dev = disk->dev;
742 PedAlignment start_align;
743 PedGeometry max_geom;
744 SunDiskData* disk_data = disk->disk_specific;
745 PedSector block = dev->bios_geom.sectors * dev->bios_geom.heads;
747 if (!ped_alignment_init (&start_align, 0, block))
749 if (!ped_geometry_init (&max_geom, dev, 0, disk_data->length))
752 return ped_constraint_new (&start_align, ped_alignment_any, &max_geom,
753 &max_geom, 1, dev->length);
756 /* _get_strict_constraint() will align the partition to the end of the cylinder.
757 * This isn't required, but since partitions must start at the start of the
758 * cylinder, space between the end of a partition and the end of a cylinder
759 * is unusable, so there's no point wasting space!
760 * However, if they really insist (via constraint)... which they will
761 * if they're reading a weird table of the disk... then we allow the end to
762 * be anywhere, with _get_lax_constraint()
765 sun_partition_align (PedPartition* part, const PedConstraint* constraint)
767 PED_ASSERT (part != NULL);
769 if (_ped_partition_attempt_align (part, constraint,
770 _get_strict_constraint (part->disk)))
772 if (_ped_partition_attempt_align (part, constraint,
773 _get_lax_constraint (part->disk)))
776 #ifndef DISCOVER_ONLY
777 ped_exception_throw (
779 PED_EXCEPTION_CANCEL,
780 _("Unable to satisfy all constraints on the partition."));
786 sun_partition_enumerate (PedPartition* part)
791 /* never change the partition numbers */
794 for (i = 1; i <= SUN_DISK_MAXPARTITIONS; i++) {
795 /* skip the Whole Disk partition for now */
796 if (i == WHOLE_DISK_PART + 1)
798 p = ped_disk_get_partition (part->disk, i);
805 #ifndef DISCOVER_ONLY
806 /* Ok, now allocate the Whole disk if it isn't already */
807 p = ped_disk_get_partition (part->disk, WHOLE_DISK_PART + 1);
809 int j = ped_exception_throw (
810 PED_EXCEPTION_WARNING,
811 PED_EXCEPTION_IGNORE_CANCEL,
812 _("The Whole Disk partition is the only "
813 "available one left. Generally, it is not a "
814 "good idea to overwrite this partition with "
815 "a real one. Solaris may not be able to "
816 "boot without it, and SILO (the sparc boot "
817 "loader) appreciates it as well."));
818 if (j == PED_EXCEPTION_IGNORE) {
819 /* bad bad bad...you will suffer your own fate */
820 part->num = WHOLE_DISK_PART + 1;
825 /* failed to allocate a number, this means we are full */
826 ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
827 _("Sun disk label is full."));
833 sun_alloc_metadata (PedDisk* disk)
835 PedPartition* new_part;
836 SunDiskData* disk_data;
837 PedConstraint* constraint_any;
839 PED_ASSERT (disk != NULL);
840 PED_ASSERT (disk->disk_specific != NULL);
841 PED_ASSERT (disk->dev != NULL);
843 constraint_any = ped_constraint_any (disk->dev);
845 /* Sun disk label does not need to allocate a sector. The disk
846 label is contained within the first 512 bytes, which should not
847 be overwritten by any boot loader or superblock. It is safe for
848 most partitions to start at sector 0. We do however, allocate
849 the space used by alt-cyl's, since we cannot use those. Put them
850 at the end of the disk. */
852 disk_data = disk->disk_specific;
854 if (disk->dev->length <= 0 ||
855 disk_data->length <= 0 ||
856 disk->dev->length == disk_data->length)
859 new_part = ped_partition_new (disk, PED_PARTITION_METADATA, NULL,
860 disk_data->length, disk->dev->length - 1);
864 if (!ped_disk_add_partition (disk, new_part, constraint_any)) {
865 ped_partition_destroy (new_part);
869 ped_constraint_destroy (constraint_any);
872 ped_constraint_destroy (constraint_any);
876 #include "pt-common.h"
877 PT_define_limit_functions (sun)
879 static PedDiskOps sun_disk_ops = {
881 write: NULL_IF_DISCOVER_ONLY (sun_write),
883 get_partition_alignment: sun_get_partition_alignment,
885 partition_set_name: NULL,
886 partition_get_name: NULL,
888 PT_op_function_initializers (sun)
891 static PedDiskType sun_disk_type = {
901 PED_ASSERT (sizeof (SunRawLabel) == 512);
902 ped_disk_type_register (&sun_disk_type);
908 ped_disk_type_unregister (&sun_disk_type);