1 /* -*- Mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3 libparted - a library for manipulating disk partitions
4 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 Contributor: Matt Wilson <msw@redhat.com>
25 #include <parted/parted.h>
26 #include <parted/debug.h>
27 #include <parted/endian.h>
31 # define _(String) dgettext (PACKAGE, String)
33 # define _(String) (String)
34 #endif /* ENABLE_NLS */
37 unsigned int magic; /* expect AIX_LABEL_MAGIC */
38 unsigned int fillbytes[127];
41 #define AIX_LABEL_MAGIC 0xc9c2d4c1
43 static PedDiskType aix_disk_type;
46 aix_probe (const PedDevice *dev)
48 PedDiskType* disk_type;
52 PED_ASSERT (dev != NULL, return 0);
54 if (!ped_device_read (dev, &label, 0, 1))
57 if (PED_BE32_TO_CPU (label.magic) != AIX_LABEL_MAGIC)
65 aix_clobber (PedDevice* dev)
69 PED_ASSERT (dev != NULL, return 0);
70 PED_ASSERT (aix_probe (dev), return 0);
72 if (!ped_device_read (dev, &label, 0, 1))
76 return ped_device_write (dev, &label, 0, 1);
78 #endif /* !DISCOVER_ONLY */
81 aix_alloc (const PedDevice* dev)
85 disk = _ped_disk_alloc (dev, &aix_disk_type);
93 aix_duplicate (const PedDisk* disk)
97 new_disk = ped_disk_new_fresh (disk->dev, &aix_disk_type);
105 aix_free (PedDisk *disk)
107 _ped_disk_free (disk);
111 aix_read (PedDisk* disk)
113 ped_disk_delete_all (disk);
114 ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
115 PED_EXCEPTION_CANCEL,
116 _("Support for reading AIX disk labels is "
117 "is not implemented yet."));
121 #ifndef DISCOVER_ONLY
123 aix_write (PedDisk* disk)
125 ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
126 PED_EXCEPTION_CANCEL,
127 _("Support for writing AIX disk labels is "
128 "is not implemented yet."));
131 #endif /* !DISCOVER_ONLY */
134 aix_partition_new (const PedDisk* disk, PedPartitionType part_type,
135 const PedFileSystemType* fs_type,
136 PedSector start, PedSector end)
140 ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
141 PED_EXCEPTION_CANCEL,
142 _("Support for adding partitions to AIX disk "
143 "labels is not implemented yet."));
148 aix_partition_duplicate (const PedPartition* part)
150 PedPartition* new_part;
152 ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
153 PED_EXCEPTION_CANCEL,
154 _("Support for duplicating partitions in AIX "
155 "disk labels is not implemented yet."));
160 aix_partition_destroy (PedPartition* part)
162 PED_ASSERT (part != NULL, return);
164 _ped_partition_free (part);
168 aix_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
170 ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
171 PED_EXCEPTION_CANCEL,
172 _("Support for setting system type of partitions "
173 "in AIX disk labels is not implemented yet."));
178 aix_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
180 ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
181 PED_EXCEPTION_CANCEL,
182 _("Support for setting flags "
183 "in AIX disk labels is not implemented yet."));
188 aix_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
195 aix_partition_is_flag_available (const PedPartition* part,
196 PedPartitionFlag flag)
203 aix_get_max_primary_partition_count (const PedDisk* disk)
209 aix_partition_align (PedPartition* part, const PedConstraint* constraint)
211 PED_ASSERT (part != NULL, return 0);
217 aix_partition_enumerate (PedPartition* part)
223 aix_alloc_metadata (PedDisk* disk)
228 static PedDiskOps aix_disk_ops = {
230 #ifndef DISCOVER_ONLY
231 clobber: aix_clobber,
236 duplicate: aix_duplicate,
239 #ifndef DISCOVER_ONLY
245 partition_new: aix_partition_new,
246 partition_duplicate: aix_partition_duplicate,
247 partition_destroy: aix_partition_destroy,
248 partition_set_system: aix_partition_set_system,
249 partition_set_flag: aix_partition_set_flag,
250 partition_get_flag: aix_partition_get_flag,
251 partition_is_flag_available: aix_partition_is_flag_available,
252 partition_align: aix_partition_align,
253 partition_enumerate: aix_partition_enumerate,
254 alloc_metadata: aix_alloc_metadata,
255 get_max_primary_partition_count:
256 aix_get_max_primary_partition_count,
258 partition_set_name: NULL,
259 partition_get_name: NULL,
262 static PedDiskType aix_disk_type = {
272 PED_ASSERT (sizeof (AixLabel) == 512, return);
273 ped_disk_type_register (&aix_disk_type);
279 ped_disk_type_unregister (&aix_disk_type);