Index: uspace/lib/gpt/global.c
===================================================================
--- uspace/lib/gpt/global.c	(revision 44c488656656806dc143099d9a82d6bb2b1bf293)
+++ uspace/lib/gpt/global.c	(revision 52f2c892e44995718a1719829ff88c8843672a97)
@@ -41,66 +41,69 @@
 
 const struct partition_type gpt_ptypes[] = {
-	{ "Unused entry",					"00000000-0000-0000-0000-000000000000" },
-	{ "MBR partition scheme",			"024DEE41-33E7-11D3-9D69-0008C781F39F" },
-	{ "EFI System",						"C12A7328-F81F-11D2-BA4B-00A0C93EC93B" },
-	{ "BIOS Boot",						"21686148-6449-6E6F-744E-656564454649" },
-	{ "Windows Reserved",				"E3C9E316-0B5C-4DB8-817D-F92DF00215AE" },
-	{ "Windows Basic data",				"EBD0A0A2-B9E5-4433-87C0-68B6B72699C7" },
-	{ "Windows LDM metadata", 			"5808C8AA-7E8F-42E0-85D2-E1E90434CFB3" },
-	{ "Windows LDM data", 				"AF9B60A0-1431-4F62-BC68-3311714A69AD" },
-	{ "Windows Recovery Environment",	"DE94BBA4-06D1-4D40-A16A-BFD50179D6AC" },
-	{ "Windows IBM GPFS",				"37AFFC90-EF7D-4E96-91C3-2D7AE055B174" },
-	{ "Windows Cluster metadata",		"DB97DBA9-0840-4BAE-97F0-FFB9A327C7E1" },
-	{ "HP-UX Data",						"75894C1E-3AEB-11D3-B7C1-7B03A0000000" },
-	{ "HP-UX Service",					"E2A1E728-32E3-11D6-A682-7B03A0000000" },
-	{ "Linux filesystem data",			"EBD0A0A2-B9E5-4433-87C0-68B6B72699C7" },
-	{ "Linux filesystem data",			"0FC63DAF-8483-4772-8E79-3D69D8477DE4" },
-	{ "Linux RAID",						"A19D880F-05FC-4D3B-A006-743F0F84911E" },
-	{ "Linux Swap",						"0657FD6D-A4AB-43C4-84E5-0933C84B4F4F" },
-	{ "Linux LVM",						"E6D6D379-F507-44C2-A23C-238F2A3DF928" },
-	{ "Linux Reserved",					"8DA63339-0007-60C0-C436-083AC8230908" },
-	{ "FreeBSD Boot",					"83BD6B9D-7F41-11DC-BE0B-001560B84F0F" },
-	{ "FreeBSD Data",					"516E7CB4-6ECF-11D6-8FF8-00022D09712B" },
-	{ "FreeBSD Swap",					"516E7CB5-6ECF-11D6-8FF8-00022D09712B" },
-	{ "FreeBSD UFS", 					"516E7CB6-6ECF-11D6-8FF8-00022D09712B" },
-	{ "FreeBSD Vinum VM",				"516E7CB8-6ECF-11D6-8FF8-00022D09712B" },
-	{ "FreeBSD ZFS",					"516E7CBA-6ECF-11D6-8FF8-00022D09712B" },
-	{ "Mac OS X HFS+",					"48465300-0000-11AA-AA11-00306543ECAC" },
-	{ "Mac OS X UFS",					"55465300-0000-11AA-AA11-00306543ECAC" },
-	{ "Mac OS X ZFS",					"6A898CC3-1DD2-11B2-99A6-080020736631" },
-	{ "Mac OS X RAID",					"52414944-0000-11AA-AA11-00306543ECAC" },
-	{ "Mac OS X RAID, offline",			"52414944-5F4F-11AA-AA11-00306543ECAC" },
-	{ "Mac OS X Boot",					"426F6F74-0000-11AA-AA11-00306543ECAC" },
-	{ "Mac OS X Label",					"4C616265-6C00-11AA-AA11-00306543ECAC" },
-	{ "Mac OS X TV Recovery",			"5265636F-7665-11AA-AA11-00306543ECAC" },
-	{ "Mac OS X Core Storage",			"53746F72-6167-11AA-AA11-00306543ECAC" },
-	{ "Solaris Boot",					"6A82CB45-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris Root",					"6A85CF4D-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris Swap",					"6A87C46F-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris Backup",					"6A8B642B-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris /usr",					"6A898CC3-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris /var",					"6A8EF2E9-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris /home",					"6A90BA39-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris Alternate sector",		"6A9283A5-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris Reserved",				"6A945A3B-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris Reserved",				"6A9630D1-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris Reserved",				"6A980767-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris Reserved",				"6A96237F-1DD2-11B2-99A6-080020736631" },
-	{ "Solaris Reserved",				"6A8D2AC7-1DD2-11B2-99A6-080020736631" },
-	{ "NetBSD Swap",					"49F48D32-B10E-11DC-B99B-0019D1879648" },
-	{ "NetBSD FFS",						"49F48D5A-B10E-11DC-B99B-0019D1879648" },
-	{ "NetBSD LFS",						"49F48D82-B10E-11DC-B99B-0019D1879648" },
-	{ "NetBSD RAID",					"49F48DAA-B10E-11DC-B99B-0019D1879648" },
-	{ "NetBSD Concatenated",			"2DB519C4-B10F-11DC-B99B-0019D1879648" },
-	{ "NetBSD Encrypted",				"2DB519EC-B10F-11DC-B99B-0019D1879648" },
-	{ "ChromeOS ChromeOS kernel",		"FE3A2A5D-4F32-41A7-B725-ACCC3285A309" },
-	{ "ChromeOS rootfs",				"3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC" },
-	{ "ChromeOS future use",			"2E0A753D-9E48-43B0-8337-B15192CB1B5E" },
-	{ "MidnightBSD Boot",				"85D5E45E-237C-11E1-B4B3-E89A8F7FC3A7" },
-	{ "MidnightBSD Data",				"85D5E45A-237C-11E1-B4B3-E89A8F7FC3A7" },
-	{ "MidnightBSD Swap",				"85D5E45B-237C-11E1-B4B3-E89A8F7FC3A7" },
-	{ "MidnightBSD UFS",				"0394Ef8B-237E-11E1-B4B3-E89A8F7FC3A7" },
-	{ "MidnightBSD Vinum VM",			"85D5E45C-237C-11E1-B4B3-E89A8F7FC3A7" },
-	{ "MidnightBSD ZFS",				"85D5E45D-237C-11E1-B4B3-E89A8F7FC3A7" },
-	{ "Uknown", NULL}	// keep this as the last one! gpt_get_part_type depends on it!
+	{ "Unused entry",					"00000000" "0000" "0000" "0000" "000000000000" },
+	{ "MBR partition scheme",			"024DEE41" "33E7" "11D3" "9D69" "0008C781F39F" },
+	{ "EFI System",						"C12A7328" "F81F" "11D2" "BA4B" "00A0C93EC93B" },
+	{ "BIOS Boot",						"21686148" "6449" "6E6F" "744E" "656564454649" },
+	{ "Windows Reserved",				"E3C9E316" "0B5C" "4DB8" "817D" "F92DF00215AE" },
+	{ "Windows Basic data",				"EBD0A0A2" "B9E5" "4433" "87C0" "68B6B72699C7" },
+	{ "Windows LDM metadata", 			"5808C8AA" "7E8F" "42E0" "85D2" "E1E90434CFB3" },
+	{ "Windows LDM data", 				"AF9B60A0" "1431" "4F62" "BC68" "3311714A69AD" },
+	{ "Windows Recovery Environment",	"DE94BBA4" "06D1" "4D40" "A16A" "BFD50179D6AC" },
+	{ "Windows IBM GPFS",				"37AFFC90" "EF7D" "4E96" "91C3" "2D7AE055B174" },
+	{ "Windows Cluster metadata",		"DB97DBA9" "0840" "4BAE" "97F0" "FFB9A327C7E1" },
+	{ "HP-UX Data",						"75894C1E" "3AEB" "11D3" "B7C1" "7B03A0000000" },
+	{ "HP-UX Service",					"E2A1E728" "32E3" "11D6" "A682" "7B03A0000000" },
+	{ "Linux filesystem data",			"EBD0A0A2" "B9E5" "4433" "87C0" "68B6B72699C7" },
+	{ "Linux filesystem data",			"0FC63DAF" "8483" "4772" "8E79" "3D69D8477DE4" },
+	{ "Linux RAID",						"A19D880F" "05FC" "4D3B" "A006" "743F0F84911E" },
+	{ "Linux Swap",						"0657FD6D" "A4AB" "43C4" "84E5" "0933C84B4F4F" },
+	{ "Linux LVM",						"E6D6D379" "F507" "44C2" "A23C" "238F2A3DF928" },
+	{ "Linux Reserved",					"8DA63339" "0007" "60C0" "C436" "083AC8230908" },
+	{ "FreeBSD Boot",					"83BD6B9D" "7F41" "11DC" "BE0B" "001560B84F0F" },
+	{ "FreeBSD Data",					"516E7CB4" "6ECF" "11D6" "8FF8" "00022D09712B" },
+	{ "FreeBSD Swap",					"516E7CB5" "6ECF" "11D6" "8FF8" "00022D09712B" },
+	{ "FreeBSD UFS", 					"516E7CB6" "6ECF" "11D6" "8FF8" "00022D09712B" },
+	{ "FreeBSD Vinum VM",				"516E7CB8" "6ECF" "11D6" "8FF8" "00022D09712B" },
+	{ "FreeBSD ZFS",					"516E7CBA" "6ECF" "11D6" "8FF8" "00022D09712B" },
+	{ "Mac OS X HFS+",					"48465300" "0000" "11AA" "AA11" "00306543ECAC" },
+	{ "Mac OS X UFS",					"55465300" "0000" "11AA" "AA11" "00306543ECAC" },
+	{ "Mac OS X ZFS",					"6A898CC3" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Mac OS X RAID",					"52414944" "0000" "11AA" "AA11" "00306543ECAC" },
+	{ "Mac OS X RAID, offline",			"52414944" "5F4F" "11AA" "AA11" "00306543ECAC" },
+	{ "Mac OS X Boot",					"426F6F74" "0000" "11AA" "AA11" "00306543ECAC" },
+	{ "Mac OS X Label",					"4C616265" "6C00" "11AA" "AA11" "00306543ECAC" },
+	{ "Mac OS X TV Recovery",			"5265636F" "7665" "11AA" "AA11" "00306543ECAC" },
+	{ "Mac OS X Core Storage",			"53746F72" "6167" "11AA" "AA11" "00306543ECAC" },
+	{ "Solaris Boot",					"6A82CB45" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris Root",					"6A85CF4D" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris Swap",					"6A87C46F" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris Backup",					"6A8B642B" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris /usr",					"6A898CC3" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris /var",					"6A8EF2E9" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris /home",					"6A90BA39" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris Alternate sector",		"6A9283A5" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris Reserved",				"6A945A3B" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris Reserved",				"6A9630D1" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris Reserved",				"6A980767" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris Reserved",				"6A96237F" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "Solaris Reserved",				"6A8D2AC7" "1DD2" "11B2" "99A6" "080020736631" },
+	{ "NetBSD Swap",					"49F48D32" "B10E" "11DC" "B99B" "0019D1879648" },
+	{ "NetBSD FFS",						"49F48D5A" "B10E" "11DC" "B99B" "0019D1879648" },
+	{ "NetBSD LFS",						"49F48D82" "B10E" "11DC" "B99B" "0019D1879648" },
+	{ "NetBSD RAID",					"49F48DAA" "B10E" "11DC" "B99B" "0019D1879648" },
+	{ "NetBSD Concatenated",			"2DB519C4" "B10F" "11DC" "B99B" "0019D1879648" },
+	{ "NetBSD Encrypted",				"2DB519EC" "B10F" "11DC" "B99B" "0019D1879648" },
+	{ "ChromeOS ChromeOS kernel",		"FE3A2A5D" "4F32" "41A7" "B725" "ACCC3285A309" },
+	{ "ChromeOS rootfs",				"3CB8E202" "3B7E" "47DD" "8A3C" "7FF2A13CFCEC" },
+	{ "ChromeOS future use",			"2E0A753D" "9E48" "43B0" "8337" "B15192CB1B5E" },
+	{ "MidnightBSD Boot",				"85D5E45E" "237C" "11E1" "B4B3" "E89A8F7FC3A7" },
+	{ "MidnightBSD Data",				"85D5E45A" "237C" "11E1" "B4B3" "E89A8F7FC3A7" },
+	{ "MidnightBSD Swap",				"85D5E45B" "237C" "11E1" "B4B3" "E89A8F7FC3A7" },
+	{ "MidnightBSD UFS",				"0394Ef8B" "237E" "11E1" "B4B3" "E89A8F7FC3A7" },
+	{ "MidnightBSD Vinum VM",			"85D5E45C" "237C" "11E1" "B4B3" "E89A8F7FC3A7" },
+	{ "MidnightBSD ZFS",				"85D5E45D" "237C" "11E1" "B4B3" "E89A8F7FC3A7" },
+	{ "Uknown", NULL} /* keep this as the last one! gpt_get_part_type depends on it! */
 };
+
+
+
Index: uspace/lib/gpt/libgpt.c
===================================================================
--- uspace/lib/gpt/libgpt.c	(revision 44c488656656806dc143099d9a82d6bb2b1bf293)
+++ uspace/lib/gpt/libgpt.c	(revision 52f2c892e44995718a1719829ff88c8843672a97)
@@ -51,10 +51,10 @@
 #include "libgpt.h"
 
-static int load_and_check_header(service_id_t handle, aoff64_t addr, size_t b_size, gpt_header_t * header);
+static int load_and_check_header(service_id_t handle, aoff64_t addr, size_t b_size, gpt_header_t *header);
 static gpt_partitions_t * alloc_part_array(uint32_t num);
-static int extend_part_array(gpt_partitions_t * p);
-static int reduce_part_array(gpt_partitions_t * p);
+static int extend_part_array(gpt_partitions_t *);
+static int reduce_part_array(gpt_partitions_t *);
 static long long nearest_larger_int(double a);
-
+static uint8_t get_byte(const char *);
 
 /** Allocate memory for gpt label */
@@ -179,5 +179,5 @@
 
 	rc = block_init(EXCHANGE_ATOMIC, dev_handle, b_size);
-	if (rc != EOK)
+	if (rc != EOK && rc != EEXIST)
 		return rc;
 
@@ -300,18 +300,29 @@
 	size_t b_size;
 	uint32_t e_size = uint32_t_le2host(label->gpt->header->entry_size);
-
+	size_t fill = label->parts->fill > GPT_MIN_PART_NUM ? label->parts->fill : GPT_MIN_PART_NUM;
+	
 	label->gpt->header->pe_array_crc32 = compute_crc32(
 	                               (uint8_t *) label->parts->part_array,
-	                               label->parts->fill * e_size);
+	                               fill * e_size);
 	
 	/* comm_size of 4096 is ignored */
 	rc = block_init(EXCHANGE_ATOMIC, dev_handle, 4096);
-	if (rc != EOK)
-		return rc;
-
+	if (rc != EOK && rc != EEXIST)
+		return rc;
+	
 	rc = block_get_bsize(dev_handle, &b_size);
 	if (rc != EOK)
 		goto fail;
-
+	
+	aoff64_t n_blocks;
+	rc = block_get_nblocks(dev_handle, &n_blocks);
+	if (rc != EOK)
+		goto fail;
+	
+	/* Write to backup GPT partition array location */
+	//rc = block_write_direct(dev_handle, n_blocks - 1, GPT_HDR_BS, header->raw_data);
+	if (rc != EOK)
+		goto fail;
+	
 	/* Write to main GPT partition array location */
 	rc = block_write_direct(dev_handle, uint64_t_le2host(label->gpt->header->entry_lba),
@@ -320,17 +331,5 @@
 	if (rc != EOK)
 		goto fail;
-
-	aoff64_t n_blocks;
-	rc = block_get_nblocks(dev_handle, &n_blocks);
-	if (rc != EOK)
-		goto fail;
-
-	/* Write to backup GPT partition array location */
-	//rc = block_write_direct(dev_handle, n_blocks - 1, GPT_HDR_BS, header->raw_data);
-	block_fini(dev_handle);
-	if (rc != EOK)
-		goto fail;
-
-
+	
 	return gpt_write_header(label, dev_handle);
 	
@@ -347,5 +346,5 @@
  * This returns a memory block (zero-filled) and needs gpt_add_partition()
  * to be called to insert it into a partition array.
- * Requires you to call gpt_free_partition after use.
+ * Requires you to call gpt_free_partition afterwards.
  */
 gpt_part_t * gpt_alloc_partition(void)
@@ -367,16 +366,51 @@
  *
  * Note: use either gpt_alloc_partition or gpt_get_partition.
- * This one return a pointer to a structure already inside the array, so
- * there's no need to call gpt_add_partition(). 
+ * This one returns a pointer to the first empty structure already
+ * inside the array, so don't call gpt_add_partition() afterwards.
  * This is the one you will usually want.
  */
 gpt_part_t * gpt_get_partition(gpt_label_t *label)
 {
-	if (label->parts->fill == label->parts->arr_size) {
-		if (extend_part_array(label->parts) == -1)
-			return NULL;
-	}
-
-	return label->parts->part_array + label->parts->fill++;
+	gpt_part_t *p;
+	
+	/* Find the first empty entry */
+	do {
+		if (label->parts->fill == label->parts->arr_size) {
+			if (extend_part_array(label->parts) == -1)
+				return NULL;
+		}
+		
+		p = label->parts->part_array + label->parts->fill++;
+		
+	} while (gpt_get_part_type(p) != GPT_PTE_UNUSED);
+	
+	return p;
+}
+
+/** Get partition already inside the label
+ *
+ * @param label   label to carrying the partition
+ * @param idx     index of the partition
+ *
+ * @return        returns pointer to the partition
+ *                or NULL when out of range
+ *
+ * Note: For new partitions use either gpt_alloc_partition or
+ * gpt_get_partition unless you want a partition at a specific place.
+ * This returns a pointer to a structure already inside the array,
+ * so don't call gpt_add_partition() afterwards.
+ * This function is handy when you want to change already existing
+ * partition or to simply write somewhere in the middle. This works only
+ * for indexes smaller than either 128 or the actual number of filled
+ * entries.
+ */
+gpt_part_t * gpt_get_partition_at(gpt_label_t *label, size_t idx)
+{
+	return NULL;
+	
+	if (idx >= GPT_MIN_PART_NUM && idx >= label->parts->fill)
+		return NULL;
+	
+	return label->parts->part_array + idx;
 }
 
@@ -415,13 +449,18 @@
 int gpt_remove_partition(gpt_label_t *label, size_t idx)
 {
-	if (idx != label->parts->fill - 1) {
-		memmove(label->parts->part_array + idx,
-		        label->parts->part_array + idx + 1,
-		        (label->parts->fill - 1) * sizeof(gpt_entry_t));
-		label->parts->fill -= 1;
-	}
-	
-	/* FIXME: This probably shouldn't be here, but instead
-	 * in reduce_part_array() or similar */
+	if (idx >= label->parts->fill)
+		return EINVAL;
+	
+	/* FIXME! 
+	 * If we allow blank spots, we break the array. If we have more than
+	 * 128 partitions in the array and then remove something from
+	 * the first 128 partitions, we would forget to write the last one.*/
+	memset(label->parts->part_array + idx, 0, sizeof(gpt_entry_t));
+	
+	label->parts->fill -= 1;
+	
+	/* FIXME!
+	 * We cannot reduce the array so simply. We may have some partitions
+	 * there since we allow blank spots.*/
 	if (label->parts->fill < (label->parts->arr_size / 2) - GPT_IGNORE_FILL_NUM) {
 		if (reduce_part_array(label->parts) == ENOMEM)
@@ -448,9 +487,28 @@
 {
 	size_t i;
+	
 	for (i = 0; gpt_ptypes[i].guid != NULL; i++) {
-		if (bcmp(p->part_type, gpt_ptypes[i].guid, 16) == 0) {
-			break;
-		}
-	}
+		if (p->part_type[3] == get_byte(gpt_ptypes[i].guid +0) &&
+			p->part_type[2] == get_byte(gpt_ptypes[i].guid +2) &&
+			p->part_type[1] == get_byte(gpt_ptypes[i].guid +4) &&
+			p->part_type[0] == get_byte(gpt_ptypes[i].guid +6) &&
+			
+			p->part_type[5] == get_byte(gpt_ptypes[i].guid +8) &&
+			p->part_type[4] == get_byte(gpt_ptypes[i].guid +10) &&
+			
+			p->part_type[7] == get_byte(gpt_ptypes[i].guid +12) &&
+			p->part_type[6] == get_byte(gpt_ptypes[i].guid +14) &&
+			
+			p->part_type[8] == get_byte(gpt_ptypes[i].guid +16) &&
+			p->part_type[9] == get_byte(gpt_ptypes[i].guid +18) &&
+			p->part_type[10] == get_byte(gpt_ptypes[i].guid +20) &&
+			p->part_type[11] == get_byte(gpt_ptypes[i].guid +22) &&
+			p->part_type[12] == get_byte(gpt_ptypes[i].guid +24) &&
+			p->part_type[13] == get_byte(gpt_ptypes[i].guid +26) &&
+			p->part_type[14] == get_byte(gpt_ptypes[i].guid +28) &&
+			p->part_type[15] == get_byte(gpt_ptypes[i].guid +30))
+				break;
+	}
+	
 	return i;
 }
@@ -516,5 +574,5 @@
 
 /** Copy partition name */
-void gpt_set_part_name(gpt_part_t * p, char * name[], size_t length)
+void gpt_set_part_name(gpt_part_t *p, char *name, size_t length)
 {
 	if (length >= 72)
@@ -645,7 +703,14 @@
 }
 
-
-
-
-
-
+static uint8_t get_byte(const char * c)
+{
+	uint8_t val = 0;
+	char hex[3] = {*c, *(c+1), 0};
+	
+	errno = str_uint8_t(hex, NULL, 16, false, &val);
+	return val;
+}
+
+
+
+
Index: uspace/lib/gpt/libgpt.h
===================================================================
--- uspace/lib/gpt/libgpt.h	(revision 44c488656656806dc143099d9a82d6bb2b1bf293)
+++ uspace/lib/gpt/libgpt.h	(revision 52f2c892e44995718a1719829ff88c8843672a97)
@@ -52,4 +52,7 @@
 /** How much fill we ignore before resizing partition array */
 #define GPT_IGNORE_FILL_NUM 10
+
+/** Unused partition entry */
+#define GPT_PTE_UNUSED 0
 
 /** GPT header signature ("EFI PART" in ASCII) */
@@ -149,4 +152,5 @@
 extern gpt_part_t *    gpt_alloc_partition (void);
 extern gpt_part_t *    gpt_get_partition   (gpt_label_t *);
+extern gpt_part_t *    gpt_get_partition_at(gpt_label_t *, size_t);
 extern int             gpt_add_partition   (gpt_label_t *, gpt_part_t *);
 extern int             gpt_remove_partition(gpt_label_t *, size_t);
@@ -159,5 +163,5 @@
 extern uint64_t        gpt_get_end_lba  (gpt_part_t *);
 extern unsigned char * gpt_get_part_name(gpt_part_t *);
-extern void            gpt_set_part_name(gpt_part_t *, char *[], size_t);
+extern void            gpt_set_part_name(gpt_part_t *, char *, size_t);
 extern bool            gpt_get_flag     (gpt_part_t *, GPT_ATTR);
 extern void            gpt_set_flag     (gpt_part_t *, GPT_ATTR, bool);
@@ -165,7 +169,7 @@
 
 
-#define gpt_part_foreach(parts, iterator) \
-		for(gpt_part_t * iterator = (parts)->part_array; \
-		    iterator < (parts)->part_array + (parts)->fill; ++iterator)
+#define gpt_part_foreach(label, iterator) \
+		for(gpt_part_t * iterator = (label)->parts->part_array; \
+		    iterator < (label)->parts->part_array + (label)->parts->fill; ++iterator)
 
 extern void gpt_free_gpt(gpt_t *);
