sun.c revision 7e7bd3dccbfe8f79e25e5c1554b5bc3a9aaca321
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
libparted - a library for manipulating disk partitions
Copyright (C) 2000, 2001, 2005, 2007 Free Software Foundation, Inc.
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contributor: Ben Collins <bcollins@debian.org>
*/
#include <config.h>
#if ENABLE_NLS
# include <libintl.h>
#else
#endif /* ENABLE_NLS */
/* Most of this came from util-linux's sun support, which was mostly done
by Jakub Jelinek. */
#define SUN_DISK_MAXPARTITIONS 8
#define WHOLE_DISK_ID 0x05
#define LINUX_SWAP_ID 0x82
typedef struct _SunRawPartition SunRawPartition;
typedef struct _SunPartitionInfo SunPartitionInfo;
typedef struct _SunRawLabel SunRawLabel;
typedef struct _SunPartitionData SunPartitionData;
typedef struct _SunDiskData SunDiskData;
#if defined(__sun)
#endif
#ifdef __sun
#define __attribute__(X) /*nothing*/
#endif /* __sun */
#ifdef __sun
#pragma pack(1)
#endif
};
};
};
#ifdef __sun
#pragma pack()
#endif
struct _SunPartitionData {
int is_boot;
int is_root;
int is_lvm;
};
struct _SunDiskData {
};
static PedDiskType sun_disk_type;
/* Checksum computation */
static void
{
}
/* Checksum Verification */
static int
{
return !csum;
}
static int
{
return 0;
return 0;
/* check magic */
return 0;
#ifndef DISCOVER_ONLY
if (!sun_verify_checksum(&label)) {
_("Corrupted Sun disk label detected."));
return 0;
}
#endif
return 1;
}
#ifndef DISCOVER_ONLY
static int
{
return 0;
}
#endif /* !DISCOVER_ONLY */
static PedDisk*
{
if (!disk)
goto error;
if (!disk->disk_specific)
goto error_free_disk;
/* #gentoo-sparc people agree that nacyl = 0 is the best option */
/* Add a whole disk partition at a minimum */
/* Now a neato string to describe this label */
"GNU Parted Custom cyl %d alt %d hd %d sec %d",
return disk;
return NULL;
}
static PedDisk*
{
if (!new_disk)
return NULL;
return new_disk;
}
static void
{
}
static int
{
#ifndef DISCOVER_ONLY
if (ped_exception_throw (
_("The disk CHS geometry (%d,%d,%d) reported "
"by the operating system does not match "
"the geometry stored on the disk label "
"(%d,%d,%d)."),
return 0;
#endif
if (ped_exception_throw (
_("The disk label describes a disk bigger than "
"%s."),
return 0;
}
}
return 1;
}
static int
{
int i;
goto error;
goto error;
for (i = 0; i < SUN_DISK_MAXPARTITIONS; i++) {
continue;
continue;
continue;
* block;
if (!part)
goto error;
goto error;
}
return 1;
return 0;
}
#ifndef DISCOVER_ONLY
static void
{
return;
}
static int
{
int i;
sizeof (SunRawPartition) * SUN_DISK_MAXPARTITIONS);
sizeof (SunPartitionInfo) * SUN_DISK_MAXPARTITIONS);
for (i = 0; i < SUN_DISK_MAXPARTITIONS; i++) {
if (!part && i == WHOLE_DISK_PART) {
/* Ok, nothing explicitly in the whole disk
partition, so let's put it there for safety
sake. */
continue;
}
if (!part)
continue;
}
/* We assume the harddrive is always right, and that the label may
be wrong. I don't think this will cause any problems, since the
cylinder count is always enforced by our alignment, and we
worst that could happen here is that the drive seems bigger or
smaller than it really is, but we'll have that problem even if we
don't do this. */
_("The disk has %d cylinders, which is greater than "
"the maximum of 65536."),
}
goto error;
return 0;
}
#endif /* !DISCOVER_ONLY */
static PedPartition*
const PedFileSystemType* fs_type,
{
if (!part)
goto error;
if (ped_partition_is_active (part)) {
if (!sun_data)
goto error_free_part;
} else {
}
return part;
return NULL;
}
static PedPartition*
{
if (!new_part)
return NULL;
return new_part;
}
static void
{
if (ped_partition_is_active (part))
}
static int
{
return 1;
}
return 1;
}
return 1;
}
if (fs_type) {
}
return 1;
}
static int
{
switch (flag) {
case PED_PARTITION_BOOT:
if (state)
case PED_PARTITION_ROOT:
if (state)
case PED_PARTITION_LVM:
if (state)
default:
return 0;
}
}
static int
{
switch (flag) {
case PED_PARTITION_BOOT:
case PED_PARTITION_ROOT:
case PED_PARTITION_LVM:
default:
return 0;
}
}
static int
{
switch (flag) {
case PED_PARTITION_BOOT:
case PED_PARTITION_ROOT:
case PED_PARTITION_LVM:
return 1;
default:
return 0;
}
}
static int
{
return SUN_DISK_MAXPARTITIONS;
}
static PedConstraint*
{
return NULL;
return NULL;
return NULL;
}
static PedConstraint*
{
return NULL;
return NULL;
}
/* _get_strict_constraint() will align the partition to the end of the cylinder.
* This isn't required, but since partitions must start at the start of the
* cylinder, space between the end of a partition and the end of a cylinder
* is unusable, so there's no point wasting space!
* However, if they really insist (via constraint)... which they will
* if they're reading a weird table of the disk... then we allow the end to
* be anywhere, with _get_lax_constraint()
*/
static int
{
return 1;
return 1;
#ifndef DISCOVER_ONLY
_("Unable to satisfy all constraints on the partition."));
#endif
return 0;
}
static int
{
int i;
PedPartition* p;
/* never change the partition numbers */
return 1;
for (i = 1; i <= SUN_DISK_MAXPARTITIONS; i++) {
/* skip the Whole Disk partition for now */
if (i == WHOLE_DISK_PART + 1)
continue;
if (!p) {
return 1;
}
}
#ifndef DISCOVER_ONLY
/* Ok, now allocate the Whole disk if it isn't already */
if (!p) {
int j = ped_exception_throw (
_("The Whole Disk partition is the only "
"available one left. Generally, it is not a "
"good idea to overwrite this partition with "
"a real one. Solaris may not be able to "
"boot without it, and SILO (the sparc boot "
"loader) appreciates it as well."));
if (j == PED_EXCEPTION_IGNORE) {
/* bad bad bad...you will suffer your own fate */
return 1;
}
}
/* failed to allocate a number, this means we are full */
_("Sun disk label is full."));
#endif
return 0;
}
static int
{
/* Sun disk label does not need to allocate a sector. The disk
label is contained within the first 512 bytes, which should not
be overwritten by any boot loader or superblock. It is safe for
most partitions to start at sector 0. We do however, allocate
the space used by alt-cyl's, since we cannot use those. Put them
at the end of the disk. */
goto error;
if (!new_part)
goto error;
goto error;
}
return 1;
return 0;
}
static PedDiskOps sun_disk_ops = {
#ifndef DISCOVER_ONLY
.clobber = sun_clobber,
#else
#endif
#ifndef DISCOVER_ONLY
#else
#endif
};
static PedDiskType sun_disk_type = {
.name = "sun",
.ops = &sun_disk_ops,
.features = 0
};
void
{
}
void
{
}