/* -*- Mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
libparted - a library for manipulating disk partitions
disk_amiga.c - libparted module to manipulate amiga RDB partition tables.
Copyright (C) 2000-2001, 2004, 2007-2010 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: Sven Luther <luther@debian.org>
*/
#include <config.h>
#include "pt-tools.h"
#ifndef MAX
# define MAX(a,b) ((a) < (b) ? (b) : (a))
#endif
#if ENABLE_NLS
# include <libintl.h>
#else
#endif /* ENABLE_NLS */
#include "misc.h"
/* String manipulation */
int i;
}
return cstr;
}
static const char *
switch (id) {
case IDNAME_RIGIDDISK :
return "RDSK";
case IDNAME_BADBLOCK :
return "BADB";
case IDNAME_PARTITION :
return "PART";
case IDNAME_FILESYSHEADER :
return "FSHD";
case IDNAME_LOADSEG :
return "LSEG";
case IDNAME_BOOT :
return "BOOT";
case IDNAME_FREE :
return "<free>";
default :
return "<unknown>";
}
}
struct AmigaIds {
};
static struct AmigaIds *
return 0;
return newid;
}
static void
}
}
static int
return 1;
}
return 0;
}
struct AmigaBlock {
};
static int
int i, end;
return sum;
}
static void
return;
}
static struct AmigaBlock *
{
return NULL;
return NULL;
if (_amiga_checksum (blk) != 0) {
switch (ped_exception_throw(PED_EXCEPTION_ERROR,
_("%s : Bad checksum on block %llu of type %s."),
{
case PED_EXCEPTION_CANCEL :
return NULL;
case PED_EXCEPTION_FIX :
return NULL;
case PED_EXCEPTION_IGNORE :
case PED_EXCEPTION_UNHANDLED :
default :
return blk;
}
}
return blk;
}
struct RigidDiskBlock {
/* block list heads */
/* physical drive characteristics */
/* logical drive characteristics */
/* (not including replacement bad blocks) */
/* drive identification */
};
static uint32_t
int i;
for (i = 0; i<RDB_LOCATION_LIMIT; i++) {
continue;
}
return i;
}
}
return AMIGA_RDB_NOT_FOUND;
}
struct PartitionBlock {
/* Size of the blocks in 32 bit words, usually 128 */
/* Disk sectors per block, used with SizeBlock, usually 1 */
};
struct LinkedBlock {
};
struct Linked2Block {
};
static int
{
return 0;
}
static PedDisk*
{
return NULL;
return NULL;
}
/* Upon failed assertion this does leak. That's fine, because
if the assertion fails, you have bigger problems than this leak. */
/* Block lists */
/* Physical drive characteristics */
/* Logical driver characteristics */
/* rdb_HighRDSKBlock will only be set when writing */
/* Driver identification */
/* And calculate the checksum */
return disk;
}
static PedDisk*
{
return NULL;
return new_disk;
}
static void
{
}
static int
{
uint32_t i;
for (i = 0; i < max; i++)
/* We are looping, let's stop. */
return 1;
}
return 0;
}
/* We have already allocated a rdb, we are now reading it from the disk */
static int
{
int i;
return 0);
_("%s : Didn't find rdb block, should never happen."), __func__);
return 0;
}
/* Let's copy the rdb read geometry to the dev */
/* FIXME: should this go into disk->dev->bios_geom instead? */
/* Remove all partitions in the former in memory table */
/* Let's allocate a partition block */
return 0;
/* We initialize the hardblock free list to detect loops */
{
/* Let's look for loops in the partition table */
break;
}
/* Let's allocate and read a partition block to get its geometry*/
return 0;
}
* cylblocks;
/* We can now construct a new partition */
return 0;
}
/* And copy over the partition block */
/* Let's probe what file system is present on the disk */
return 0;
}
}
return 1;
}
static int
{
switch (ped_exception_throw(PED_EXCEPTION_ERROR,
{
case PED_EXCEPTION_CANCEL :
return 0;
case PED_EXCEPTION_FIX :
/* TODO : Need to add fixing code */
case PED_EXCEPTION_IGNORE :
case PED_EXCEPTION_UNHANDLED :
default :
return 1;
}
}
return 0;
}
switch (ped_exception_throw(PED_EXCEPTION_ERROR,
_("%s : The %s list seems bad at block %s."),
{
/* TODO : to more subtile things here */
case PED_EXCEPTION_CANCEL :
case PED_EXCEPTION_UNHANDLED :
default :
return 0;
}
}
IDNAME_LOADSEG) == 0) return 0;
}
}
return 1;
}
static uint32_t
int i;
return i;
}
static PedPartition *
return next;
}
#ifndef DISCOVER_ONLY
static int
{
uint32_t i;
return 0;
/* Let's read the rdb */
rdb_num = 2;
/* Initialize only the part that won't be copied over
with a partition block in amiga_read. */
0, PED_SECTOR_SIZE_DEFAULT - pb_size);
} else {
}
/* Allocate a free block table and initialize it.
There must be room for at least RDB_NUM + 2 entries, since
the first RDB_NUM+1 entries get IDNAME_RIGIDDISK, and the
following one must have LINK_END to serve as sentinel. */
return 0;
for (i = 0; i <= rdb_num; i++)
table[i] = IDNAME_RIGIDDISK;
for ( ; i < tab_size; i++)
/* Let's allocate a partition block */
return 0;
}
/* And fill the free block table */
{
_("%s : Failed to list bad blocks."), __func__);
goto error_free_table;
}
{
_("%s : Failed to list partition blocks."), __func__);
goto error_free_table;
}
{
_("%s : Failed to list file system blocks."), __func__);
goto error_free_table;
}
{
_("%s : Failed to list boot blocks."), __func__);
goto error_free_table;
}
else
_("Failed to write partition block at %d."),
goto error_free_table;
/* WARNING : If we fail here, we stop everything,
* and the partition table is lost. A better
* solution should be found, using the second
* half of the hardblocks to not overwrite the
* old partition table. It becomes problematic
* if we use more than half of the hardblocks. */
}
}
goto error_free_table;
return 0;
}
#endif /* !DISCOVER_ONLY */
static PedPartition*
const PedFileSystemType* fs_type,
{
return NULL;
if (ped_partition_is_active (part)) {
return NULL;
}
/* TODO : use a scheme including the device name and the
* partition number, if it is possible */
} else {
}
return part;
}
static PedPartition*
{
if (!new_part)
return NULL;
return new_part;
}
static void
{
if (ped_partition_is_active (part)) {
}
}
static int
const PedFileSystemType* fs_type)
{
if (!fs_type)
else
return 1;
}
static int
{
switch (flag) {
case PED_PARTITION_BOOT:
return 1;
case PED_PARTITION_HIDDEN:
return 1;
case PED_PARTITION_RAID:
return 1;
case PED_PARTITION_LVM:
return 1;
default:
return 0;
}
}
static int
{
switch (flag) {
case PED_PARTITION_BOOT:
case PED_PARTITION_HIDDEN:
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
default:
return 0;
}
}
static int
{
switch (flag) {
case PED_PARTITION_BOOT:
case PED_PARTITION_HIDDEN:
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
return 1;
default:
return 0;
}
}
static void
{
}
static const char*
{
}
static PedAlignment*
{
return ped_alignment_new(0, cylinder_size);
}
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;
PedPartition* p;
/* never change the partition numbers */
return 1;
for (i = 1; i <= AMIGA_MAX_PARTITIONS; i++) {
if (!p) {
return 1;
}
}
/* failed to allocate a number */
#ifndef DISCOVER_ONLY
_("Unable to allocate a partition number."));
#endif
return 0;
}
static int
{
/* Allocate space for the RDB */
0, MAX_RDB_BLOCK);
if (!new_part)
goto error;
goto error;
}
return 1;
return 0;
}
static int
{
return AMIGA_MAX_PARTITIONS;
}
static bool
{
return true;
}
#include "pt-common.h"
};
.name = "amiga",
.ops = &amiga_disk_ops,
};
void
{
}
void
{
}