pc98.c revision 7e7bd3dccbfe8f79e25e5c1554b5bc3a9aaca321
/*
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/>.
*/
#include <config.h>
#if ENABLE_NLS
# include <libintl.h>
#else
#endif /* ENABLE_NLS */
/* hacked from Linux/98 source: fs/partitions/nec98.h
*
* See also:
*
* Partition types:
*
* id0(mid):
* bit 7: 1=bootable, 0=not bootable
* # Linux uses this flag to make a distinction between ext2 and swap.
* bit 6--0:
* 00H : N88-BASIC(data)?, PC-UX(data)?
* 04H : PC-UX(data)
* 06H : N88-BASIC
* 10H : N88-BASIC
* 14H : *BSD, PC-UX
* 20H : DOS(data), Windows95/98/NT, Linux
* 21H..2FH : DOS(system#1 .. system#15)
* 40H : Minix
*
* id1(sid):
* bit 7: 1=active, 0=sleep(hidden)
* # PC-UX uses this flag to make a distinction between its file system
* # and its swap.
* bit 6--0:
* 01H: FAT12
* 11H: FAT16, <32MB [accessible to DOS 3.3]
* 21H: FAT16, >=32MB [Large Partition]
* 31H: NTFS
* 61H: FAT32
* 04H: PC-UX
* 06H: N88-BASIC
* 44H: *BSD
* 62H: ext2, linux-swap
*/
#define MAX_PART_COUNT 16
#define PC9800_EXTFMT_MAGIC 0xAA55
#define BIT(x) (1 << (x))
typedef struct _PC98RawPartition PC98RawPartition;
typedef struct _PC98RawTable PC98RawTable;
#ifdef __sun
#define __attribute__(X) /*nothing*/
#endif /* __sun */
/* ripped from Linux/98 source */
#ifdef __sun
#pragma pack(1)
#endif
struct _PC98RawPartition {
char name[16];
} __attribute__((packed));
struct _PC98RawTable {
} __attribute__((packed));
#ifdef __sun
#pragma pack()
#endif
typedef struct {
int system;
int boot;
int hidden;
char name [17];
/* this MBR boot code is dummy */
static const unsigned char MBR_BOOT_CODE[] = {
0xcb, /* retf */
0x00, 0x00, 0x00, /* */
0x49, 0x50, 0x4c, 0x31 /* "IPL1" */
};
static PedDiskType pc98_disk_type;
int* c, int* h, int* s);
/* magic(?) check */
static int
{
/* check "extended-format" (have partition table?) */
return 0;
return 1;
}
static int
{
}
static int
const PC98RawPartition* raw_part)
{
#if 0
#endif
return 0;
return 1;
}
static int
{
int empty;
const PC98RawPartition* p;
return 0;
return 0;
/* check magic */
if (!pc98_check_magic (&part_table))
return 0;
/* check consistency */
empty = 1;
for (p = part_table.partitions;
p++)
{
continue;
empty = 0;
if (!check_partition_consistency (dev, p))
return 0;
}
/* check boot loader */
if (pc98_check_ipl_signature (&part_table))
return 1;
return 0;
/* Not to mistake msdos disk map for PC-9800's empty disk map */
if (empty)
return 0;
return 1;
}
#ifndef DISCOVER_ONLY
static int
{
return 0;
if (pc98_check_ipl_signature (&table))
return 0;
return ped_device_sync (dev);
}
#endif /* !DISCOVER_ONLY */
static PedDisk*
{
}
static PedDisk*
{
}
static void
{
}
static PedSector
{
}
static void
{
PED_ASSERT (c != NULL, return);
PED_ASSERT (h != NULL, return);
PED_ASSERT (s != NULL, return);
}
static PedSector
{
}
static PedSector
{
} else {
}
}
static int
{
|| raw_part->end_sector
return 0;
return 1;
}
static int
{
int i;
goto error;
if (!pc98_check_magic(&table)) {
if (ped_exception_throw (
_("Invalid partition table on %s."),
goto error;
}
for (i = 0; i < MAX_PART_COUNT; i++) {
if (is_unused_partition(raw_part))
continue;
if (!part)
goto error;
/* hack */
pc98_data->ipl_sector = 0;
goto error;
_("Partition %d isn't aligned to cylinder "
"boundaries. This is still unsupported."),
goto error;
}
}
return 1;
return 0;
}
static int
{
return read_table (disk);
}
#ifndef DISCOVER_ONLY
static int
{
int c, h, s;
const char* name;
if (pc98_data->ipl_sector) {
&c, &h, &s);
} else {
}
_("Partition %d isn't aligned to cylinder "
"boundaries. This is still unsupported."),
return 0;
}
#if 0
raw_part->end_sector = s;
#else
raw_part->end_sector = 0;
#endif
return 1;
}
static int
{
int i;
return 0;
if (!pc98_check_ipl_signature (&table)) {
}
for (i = 1; i <= MAX_PART_COUNT; i++) {
if (!part)
continue;
return 0;
}
return 0;
}
#endif /* !DISCOVER_ONLY */
static PedPartition*
{
if (!part)
goto error;
if (ped_partition_is_active (part)) {
if (!pc98_data)
goto error_free_part;
pc98_data->ipl_sector = 0;
} else {
}
return part;
return 0;
}
static PedPartition*
{
if (!new_part)
return NULL;
/* ugly, but C is ugly :p */
return new_part;
}
static void
{
if (ped_partition_is_active (part))
}
static int
{
if (fs_type) {
else
} else { /* ext2, reiser, xfs, etc. */
/* ext2 partitions must be marked boot */
}
}
return 1;
}
static int
{
switch (flag) {
case PED_PARTITION_HIDDEN:
case PED_PARTITION_BOOT:
default:
return 0;
}
}
static int
{
switch (flag) {
case PED_PARTITION_HIDDEN:
case PED_PARTITION_BOOT:
default:
return 0;
}
}
static int
{
switch (flag) {
case PED_PARTITION_HIDDEN:
case PED_PARTITION_BOOT:
return 1;
default:
return 0;
}
}
static void
{
int i;
}
static const char*
{
}
static PedConstraint*
{
return NULL;
return NULL;
return NULL;
}
static int
{
return 1;
#ifndef DISCOVER_ONLY
_("Unable to satisfy all constraints on the partition."));
#endif
return 0;
}
static int
{
int i;
for (i=1; i<=MAX_PART_COUNT; i++) {
if (!ped_disk_get_partition (disk, i))
return i;
}
return 0;
}
static int
{
/* don't re-number a partition */
return 1;
_("Can't add another partition."));
return 0;
}
return 1;
}
static int
{
0, cyl_size - 1);
if (!new_part)
goto error;
goto error;
}
return 1;
return 0;
}
static int
{
return MAX_PART_COUNT;
}
static PedDiskOps pc98_disk_ops = {
.probe = pc98_probe,
#ifndef DISCOVER_ONLY
.clobber = pc98_clobber,
#else
#endif
.alloc = pc98_alloc,
#ifndef DISCOVER_ONLY
.write = pc98_write,
#else
#endif
};
static PedDiskType pc98_disk_type = {
.name = "pc98",
.ops = &pc98_disk_ops,
};
void
{
}
void
{
}