OSDN Git Service

rename all "support" parameters; avoid new compiler warnings
[android-x86/external-parted.git] / libparted / labels / mac.c
index 32b98b0..e89dc20 100644 (file)
@@ -1,10 +1,10 @@
 /*
     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>
@@ -30,6 +30,8 @@
 #  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)
@@ -233,7 +235,8 @@ _disk_add_part_map_entry (PedDisk* disk, int warn)
        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;
 
@@ -338,7 +341,7 @@ mac_free (PedDisk* disk)
        MacDiskData*    mac_disk_data = disk->disk_specific;
 
        _ped_disk_free (disk);
-       ped_free (mac_disk_data);
+       free (mac_disk_data);
 }
 
 #ifndef DISCOVER_ONLY
@@ -377,19 +380,19 @@ mac_clobber (PedDevice* dev)
 #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");
 }
@@ -409,7 +412,7 @@ strncasestr (const char* haystack, const char* needle, int n)
 }
 
 static int
-_rawpart_is_boot (MacRawPartition* raw_part)
+_rawpart_is_boot (const MacRawPartition* raw_part)
 {
        if (!strcasecmp(raw_part->type, "Apple_Bootstrap"))
                return 1;
@@ -421,7 +424,7 @@ _rawpart_is_boot (MacRawPartition* raw_part)
 }
 
 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;
@@ -431,7 +434,7 @@ _rawpart_is_driver (MacRawPartition* raw_part)
 }
 
 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;
@@ -552,7 +555,8 @@ _rawpart_analyse (MacRawPartition* raw_part, PedDisk* disk, int num)
 #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;
 
@@ -1105,13 +1109,13 @@ mac_write (PedDisk* disk)
        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;
 }
@@ -1142,9 +1146,9 @@ mac_partition_new (
        }
        return part;
 
-       ped_free (mac_data);
+       free (mac_data);
 error_free_part:
-       ped_free (part);
+       free (part);
 error:
        return 0;
 }
@@ -1177,8 +1181,8 @@ mac_partition_destroy (PedPartition* part)
        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
@@ -1188,7 +1192,7 @@ mac_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
 
        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) {
@@ -1560,6 +1564,13 @@ mac_get_max_primary_partition_count (const PedDisk* disk)
                - 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
@@ -1593,7 +1604,9 @@ static PedDiskOps mac_disk_ops = {
 
        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 = {