/*
libparted - a library for manipulating disk partitions
- Copyright (C) 2000, 2002, 2004, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2004, 2007-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ 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,
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, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
+#include <config.h>
#include <parted/parted.h>
#include <parted/debug.h>
#include <parted/endian.h>
+#include <stdbool.h>
#if ENABLE_NLS
# include <libintl.h>
# define _(String) (String)
#endif /* ENABLE_NLS */
+#include "misc.h"
+
/* struct's hacked from Linux source: fs/partitions/mac.h
* I believe it was originally written by Paul Mackerras (from comments in
* Quik source)
if (part_map_size == 0)
part_map_size = 64;
- new_part = ped_partition_new (disk, 0, NULL, 1, part_map_size - 1);
+ new_part = ped_partition_new (disk, PED_PARTITION_NORMAL, NULL,
+ 1, part_map_size - 1);
if (!new_part)
goto error;
MacDiskData* mac_disk_data = disk->disk_specific;
_ped_disk_free (disk);
- ped_free (mac_disk_data);
+ free (mac_disk_data);
}
#ifndef DISCOVER_ONLY
#endif /* !DISCOVER_ONLY */
static int
-_rawpart_cmp_type (MacRawPartition* raw_part, char* type)
+_rawpart_cmp_type (const MacRawPartition* raw_part, const char* type)
{
return strncasecmp (raw_part->type, type, 32) == 0;
}
static int
-_rawpart_cmp_name (MacRawPartition* raw_part, char* name)
+_rawpart_cmp_name (const MacRawPartition* raw_part, const char* name)
{
return strncasecmp (raw_part->name, name, 32) == 0;
}
static int
-_rawpart_is_partition_map (MacRawPartition* raw_part)
+_rawpart_is_partition_map (const MacRawPartition* raw_part)
{
return _rawpart_cmp_type (raw_part, "Apple_partition_map");
}
}
static int
-_rawpart_is_boot (MacRawPartition* raw_part)
+_rawpart_is_boot (const MacRawPartition* raw_part)
{
if (!strcasecmp(raw_part->type, "Apple_Bootstrap"))
return 1;
}
static int
-_rawpart_is_driver (MacRawPartition* raw_part)
+_rawpart_is_driver (const MacRawPartition* raw_part)
{
if (strncmp (raw_part->type, "Apple_", 6) != 0)
return 0;
}
static int
-_rawpart_has_driver (MacRawPartition* raw_part, MacDiskData* mac_disk_data)
+_rawpart_has_driver (const MacRawPartition* raw_part, MacDiskData* mac_disk_data)
{
MacDeviceDriver *driverlist;
uint16_t i, bsz;
#endif
return NULL;
}
- part = ped_partition_new (disk, 0, NULL, start, start + length - 1);
+ part = ped_partition_new (disk, PED_PARTITION_NORMAL, NULL,
+ start, start + length - 1);
if (!part)
goto error;
if (!ped_device_write (disk->dev, part_map, 1,
mac_disk_data->part_map_entry_count))
goto error_free_part_map;
- ped_free (part_map);
+ free (part_map);
return write_block_zero (disk, mac_driverdata);
error_free_part_map:
- ped_free (part_map);
+ free (part_map);
error_free_driverdata:
- ped_free (mac_driverdata);
+ free (mac_driverdata);
error:
return 0;
}
}
return part;
- ped_free (mac_data);
+ free (mac_data);
error_free_part:
- ped_free (part);
+ free (part);
error:
return 0;
}
PED_ASSERT (part != NULL, return);
if (ped_partition_is_active (part))
- ped_free (part->disk_specific);
- ped_free (part);
+ free (part->disk_specific);
+ free (part);
}
static int
part->fs_type = fs_type;
- if (fs_type && !strcmp (fs_type->name, "linux-swap"))
+ if (fs_type && is_linux_swap (fs_type->name))
ped_partition_set_flag (part, PED_PARTITION_SWAP, 1);
if (mac_data->is_boot) {
- mac_disk_data->free_part_entry_count + 1;
}
+static bool
+mac_get_max_supported_partition_count (const PedDisk* disk, int *max_n)
+{
+ *max_n = 65536;
+ return true;
+}
+
static PedDiskOps mac_disk_ops = {
probe: mac_probe,
#ifndef DISCOVER_ONLY
alloc_metadata: mac_alloc_metadata,
get_max_primary_partition_count:
- mac_get_max_primary_partition_count
+ mac_get_max_primary_partition_count,
+ get_max_supported_partition_count:
+ mac_get_max_supported_partition_count
};
static PedDiskType mac_disk_type = {