bsd.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, 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: Matt Wilson <msw@redhat.com>
*/
#include <config.h>
#if ENABLE_NLS
# include <libintl.h>
#else
#endif /* ENABLE_NLS */
/* struct's & #define's stolen from libfdisk, which probably came from
* Linux...
*/
#define BSD_MAXPARTITIONS 8
#define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */
#define BSD_LABEL_OFFSET 64
typedef struct _BSDRawPartition BSDRawPartition;
typedef struct _BSDRawLabel BSDRawLabel;
#ifdef __sun
#define __attribute__(X) /*nothing*/
#endif /* __sun */
#ifdef __sun
#pragma pack(1)
#endif
struct _BSDRawPartition { /* the partition table */
} __attribute__((packed));
#ifdef __sun
#pragma pack()
#endif
#ifdef __sun
#pragma pack(1)
#endif
struct _BSDRawLabel {
#define NDDATA 5
#define NSPARE 5
/* file system and partition information: */
} __attribute__((packed));
#ifdef __sun
#pragma pack()
#endif
typedef struct {
char boot_code [512];
} BSDDiskData;
typedef struct {
static PedDiskType bsd_disk_type;
/* XXX fixme: endian? */
static unsigned short
unsigned short sum = 0;
lp->d_checksum = 0;
return sum;
}
/* XXX fixme: endian? */
static void
alpha_bootblock_checksum (char *boot) {
int i;
sum = 0;
for (i = 0; i < 63; i++)
}
static int
{
char boot[512];
return 0;
return 0;
/* check magic */
return 0;
return 1;
}
static PedDisk*
{
if (!disk)
goto error;
if (!bsd_specific)
goto error_free_disk;
/* Initialize the first byte to zero, so that the code in bsd_write
knows to call _probe_and_add_boot_code. Initializing all of the
remaining buffer is a little wasteful, but the alternative is to
figure out why a block at offset 340 would otherwise be used
uninitialized. */
label->d_trackskew = 0;
label->d_headswitch = 0;
label->d_npartitions = 0;
return disk;
return NULL;
}
static PedDisk*
{
if (!new_disk)
return NULL;
return new_disk;
}
static void
{
}
#ifndef DISCOVER_ONLY
static int
{
char boot [512];
return 0;
}
#endif /* !DISCOVER_ONLY */
static int
{
int i;
goto error;
for (i = 1; i <= BSD_MAXPARTITIONS; i++) {
continue;
if (!part)
goto error;
goto error;
}
return 1;
return 0;
}
static void
{
char old_boot_code [512];
return;
if (old_boot_code [0]
}
#ifndef DISCOVER_ONLY
static int
{
int i;
int max_part = 0;
if (!bsd_specific->boot_code [0])
sizeof (BSDRawPartition) * BSD_MAXPARTITIONS);
for (i = 1; i <= BSD_MAXPARTITIONS; i++) {
if (!part)
continue;
max_part = i;
}
0, 1))
goto error;
return 0;
}
#endif /* !DISCOVER_ONLY */
static PedPartition*
const PedFileSystemType* fs_type,
{
if (!part)
goto error;
if (ped_partition_is_active (part)) {
if (!bsd_data)
goto error_free_part;
} else {
}
return part;
return 0;
}
static PedPartition*
{
if (!new_part)
return NULL;
return new_part;
}
static void
{
if (ped_partition_is_active (part))
}
static int
{
if (!fs_type)
else
return 1;
}
static int
{
/* no flags for bsd */
return 0;
}
static int
{
/* no flags for bsd */
return 0;
}
static int
{
/* no flags for bsd */
return 0;
}
static int
{
return BSD_MAXPARTITIONS;
}
static PedConstraint*
{
return ped_constraint_new_from_max (&max);
}
static int
{
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 <= BSD_MAXPARTITIONS; i++) {
if (!p) {
return 1;
}
}
/* failed to allocate a number */
#ifndef DISCOVER_ONLY
_("Unable to allocate a bsd disklabel slot."));
#endif
return 0;
}
static int
{
/* allocate 1 sector for the disk label at the start */
if (!new_part)
goto error;
goto error;
}
return 1;
return 0;
}
static PedDiskOps bsd_disk_ops = {
#ifndef DISCOVER_ONLY
.clobber = bsd_clobber,
#else
#endif
#ifndef DISCOVER_ONLY
#else
#endif
};
static PedDiskType bsd_disk_type = {
.name = "bsd",
.ops = &bsd_disk_ops,
.features = 0
};
void
{
}
void
{
}