1N/A/* -*- Mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
1N/A
1N/A libparted - a library for manipulating disk partitions
1N/A Copyright (C) 2000-2001, 2007-2010 Free Software Foundation, Inc.
1N/A
1N/A This program is free software; you can redistribute it and/or modify
1N/A it under the terms of the GNU General Public License as published by
1N/A the Free Software Foundation; either version 3 of the License, or
1N/A (at your option) any later version.
1N/A
1N/A This program is distributed in the hope that it will be useful,
1N/A but WITHOUT ANY WARRANTY; without even the implied warranty of
1N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1N/A GNU General Public License for more details.
1N/A
1N/A You should have received a copy of the GNU General Public License
1N/A along with this program. If not, see <http://www.gnu.org/licenses/>.
1N/A
1N/A Contributor: Matt Wilson <msw@redhat.com>
1N/A*/
1N/A
1N/A#include <config.h>
1N/A
1N/A#include <parted/parted.h>
1N/A#include <parted/debug.h>
1N/A#include <parted/endian.h>
1N/A#include <stdbool.h>
1N/A#include "pt-tools.h"
1N/A
1N/A#if ENABLE_NLS
1N/A# include <libintl.h>
1N/A# define _(String) dgettext (PACKAGE, String)
1N/A#else
1N/A# define _(String) (String)
1N/A#endif /* ENABLE_NLS */
1N/A
1N/A#define AIX_LABEL_MAGIC 0xc9c2d4c1
1N/A#define MAX_TOTAL_PART 16
1N/A
1N/Astatic PedDiskType aix_disk_type;
1N/A
1N/Astatic inline int
1N/Aaix_label_magic_get (const char *label)
1N/A{
1N/A return *(unsigned int *)label;
1N/A}
1N/A
1N/Astatic inline void
1N/Aaix_label_magic_set (char *label, int magic_val)
1N/A{
1N/A *(unsigned int *)label = magic_val;
1N/A}
1N/A
1N/Astatic int
1N/Aaix_probe (const PedDevice *dev)
1N/A{
1N/A PED_ASSERT (dev != NULL, return 0);
1N/A
1N/A void *label;
1N/A if (!ptt_read_sector (dev, 0, &label))
1N/A return 0;
1N/A unsigned int magic = aix_label_magic_get (label);
1N/A free (label);
1N/A return magic == AIX_LABEL_MAGIC;
1N/A}
1N/A
1N/Astatic PedDisk*
1N/Aaix_alloc (const PedDevice* dev)
1N/A{
1N/A PedDisk* disk;
1N/A
1N/A disk = _ped_disk_alloc (dev, &aix_disk_type);
1N/A if (!disk)
1N/A return NULL;
1N/A
1N/A return disk;
1N/A}
1N/A
1N/Astatic PedDisk*
1N/Aaix_duplicate (const PedDisk* disk)
1N/A{
1N/A PedDisk* new_disk;
1N/A
1N/A new_disk = ped_disk_new_fresh (disk->dev, &aix_disk_type);
1N/A if (!new_disk)
1N/A return NULL;
1N/A
1N/A return new_disk;
1N/A}
1N/A
1N/Astatic void
1N/Aaix_free (PedDisk *disk)
1N/A{
1N/A _ped_disk_free (disk);
1N/A}
1N/A
1N/Astatic int
1N/Aaix_read (PedDisk* disk)
1N/A{
1N/A ped_disk_delete_all (disk);
1N/A ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
1N/A PED_EXCEPTION_CANCEL,
1N/A _("Support for reading AIX disk labels is "
1N/A "is not implemented yet."));
1N/A return 0;
1N/A}
1N/A
1N/A#ifndef DISCOVER_ONLY
1N/Astatic int
1N/Aaix_write (const PedDisk* disk)
1N/A{
1N/A ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
1N/A PED_EXCEPTION_CANCEL,
1N/A _("Support for writing AIX disk labels is "
1N/A "is not implemented yet."));
1N/A return 0;
1N/A}
1N/A#endif /* !DISCOVER_ONLY */
1N/A
1N/Astatic PedPartition*
1N/Aaix_partition_new (const PedDisk* disk, PedPartitionType part_type,
1N/A const PedFileSystemType* fs_type,
1N/A PedSector start, PedSector end)
1N/A{
1N/A ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
1N/A PED_EXCEPTION_CANCEL,
1N/A _("Support for adding partitions to AIX disk "
1N/A "labels is not implemented yet."));
1N/A return NULL;
1N/A}
1N/A
1N/Astatic PedPartition*
1N/Aaix_partition_duplicate (const PedPartition* part)
1N/A{
1N/A ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
1N/A PED_EXCEPTION_CANCEL,
1N/A _("Support for duplicating partitions in AIX "
1N/A "disk labels is not implemented yet."));
1N/A return NULL;
1N/A}
1N/A
1N/Astatic void
1N/Aaix_partition_destroy (PedPartition* part)
1N/A{
1N/A PED_ASSERT (part != NULL, return);
1N/A
1N/A _ped_partition_free (part);
1N/A}
1N/A
1N/Astatic int
1N/Aaix_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
1N/A{
1N/A ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
1N/A PED_EXCEPTION_CANCEL,
1N/A _("Support for setting system type of partitions "
1N/A "in AIX disk labels is not implemented yet."));
1N/A return 0;
1N/A}
1N/A
1N/Astatic int
1N/Aaix_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
1N/A{
1N/A ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
1N/A PED_EXCEPTION_CANCEL,
1N/A _("Support for setting flags "
1N/A "in AIX disk labels is not implemented yet."));
1N/A return 0;
1N/A}
1N/A
1N/Astatic int
1N/Aaix_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
1N/A{
1N/A return 0;
1N/A}
1N/A
1N/A
1N/Astatic int
1N/Aaix_partition_is_flag_available (const PedPartition* part,
1N/A PedPartitionFlag flag)
1N/A{
1N/A return 0;
1N/A}
1N/A
1N/A
1N/Astatic int
1N/Aaix_get_max_primary_partition_count (const PedDisk* disk)
1N/A{
1N/A return 4;
1N/A}
1N/A
1N/Astatic bool
1N/Aaix_get_max_supported_partition_count (const PedDisk* disk, int *max_n)
1N/A{
1N/A *max_n = MAX_TOTAL_PART;
1N/A return true;
1N/A}
1N/A
1N/Astatic int
1N/Aaix_partition_align (PedPartition* part, const PedConstraint* constraint)
1N/A{
1N/A PED_ASSERT (part != NULL, return 0);
1N/A
1N/A return 1;
1N/A}
1N/A
1N/Astatic int
1N/Aaix_partition_enumerate (PedPartition* part)
1N/A{
1N/A return 1;
1N/A}
1N/A
1N/Astatic int
1N/Aaix_alloc_metadata (PedDisk* disk)
1N/A{
1N/A return 1;
1N/A}
1N/A
1N/A#include "pt-common.h"
1N/APT_define_limit_functions (aix)
1N/A
1N/Astatic PedDiskOps aix_disk_ops = {
1N/A .clobber = NULL,
1N/A .write = NULL_IF_DISCOVER_ONLY (aix_write),
1N/A
1N/A .partition_set_name = NULL,
1N/A .partition_get_name = NULL,
1N/A
1N/A PT_op_function_initializers (aix)
1N/A};
1N/A
1N/Astatic PedDiskType aix_disk_type = {
1N/A .next = NULL,
1N/A .name = "aix",
1N/A .ops = &aix_disk_ops,
1N/A .features = 0
1N/A};
1N/A
1N/Avoid
1N/Aped_disk_aix_init ()
1N/A{
1N/A ped_disk_type_register (&aix_disk_type);
1N/A}
1N/A
1N/Avoid
1N/Aped_disk_aix_done ()
1N/A{
1N/A ped_disk_type_unregister (&aix_disk_type);
1N/A}