]> err.no Git - util-linux/commitdiff
libblkid: add blkid_partition_set_type()
authorKarel Zak <kzak@redhat.com>
Thu, 18 Feb 2010 21:28:41 +0000 (22:28 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 18 Feb 2010 21:28:41 +0000 (22:28 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/partitions/bsd.c
shlibs/blkid/src/partitions/dos.c
shlibs/blkid/src/partitions/gpt.c
shlibs/blkid/src/partitions/mac.c
shlibs/blkid/src/partitions/minix.c
shlibs/blkid/src/partitions/partitions.c
shlibs/blkid/src/partitions/partitions.h
shlibs/blkid/src/partitions/sgi.c
shlibs/blkid/src/partitions/solaris_x86.c
shlibs/blkid/src/partitions/sun.c
shlibs/blkid/src/partitions/unixware.c

index 9d0d7e5ef08a74f40ca448cbcb1c71a7f4450256..ee15ad2fe9709dff7e17dafc1cac2627aed0ff9a 100644 (file)
@@ -164,6 +164,7 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag)
                        le16_to_cpu(l->d_npartitions) - BSD_MAXPARTITIONS));
 
        for (i = 0, p = l->d_partitions; i < nparts; i++, p++) {
+               blkid_partition par;
                uint32_t start, size;
 
                /* TODO: in fdisk-mode returns all non-zero (p_size) partitions */
@@ -180,8 +181,11 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag)
                        continue;
                }
 
-               if (!blkid_partlist_add_partition(ls, tab, p->p_fstype, start, size))
+               par = blkid_partlist_add_partition(ls, tab, start, size);
+               if (!par)
                        goto err;
+
+               blkid_partition_set_type(par, p->p_fstype);
        }
 
        return 0;
index f3e8a19839db1348791297f6ccb196d6fa948917..8bf3a8b66a8ff6cf16d92904000ec78b6c68bc6e 100644 (file)
@@ -75,6 +75,7 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab,
                /* Parse data partition */
                for (p = p0, i = 0; i < 4; i++, p++) {
                        uint32_t abs_start;
+                       blkid_partition par;
 
                        /* the start is relative to the parental ext.partition */
                        start = dos_partition_start(p) * ssf;
@@ -93,10 +94,12 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab,
                                if (abs_start + size > ex_start + ex_size)
                                        continue;
                        }
-                       if (!blkid_partlist_add_partition(ls, tab, p->sys_type,
-                                               abs_start, size))
+
+                       par = blkid_partlist_add_partition(ls, tab, abs_start, size);
+                       if (!par)
                                goto err;
 
+                       blkid_partition_set_type(par, p->sys_type);
                        ct_nodata = 0;
                }
                /* The first nested ext.partition should be a link to the next
@@ -194,14 +197,19 @@ static int probe_dos_pt(blkid_probe pr, const struct blkid_idmag *mag)
 
        /* Parse primary partitions */
        for (p = p0, i = 0; i < 4; i++, p++) {
+               blkid_partition par;
+
                start = dos_partition_start(p) * ssf;
                size = dos_partition_size(p) * ssf;
 
                if (!size)
                        continue;
-               if (!blkid_partlist_add_partition(ls, tab, p->sys_type,
-                                                       start, size))
+
+               par = blkid_partlist_add_partition(ls, tab, start, size);
+               if (!par)
                        goto err;
+
+               blkid_partition_set_type(par, p->sys_type);
        }
 
        /* Linux uses partition numbers greater than 4
index 2c3a3267fd1f4f75eda986d7368e00c5753c1034..eba8803bc9e49b5f4c07281baf55454454f77067 100644 (file)
@@ -339,8 +339,8 @@ static int probe_gpt_pt(blkid_probe pr, const struct blkid_idmag *mag)
                        continue;
                }
 
-               par = blkid_partlist_add_partition(ls, tab, 0,
-                                               start * ssf, size * ssf);
+               par = blkid_partlist_add_partition(ls, tab,
+                                       start * ssf, size * ssf);
                if (!par)
                        goto err;
 
index 7f4a30b0a21ba22ece10ef3f8417a50743a6d433..538b272708ed06eabceae127405288f9b9a631b8 100644 (file)
@@ -144,7 +144,7 @@ static int probe_mac_pt(blkid_probe pr, const struct blkid_idmag *mag)
                start = be32_to_cpu(p->start_block) * ssf;
                size = be32_to_cpu(p->block_count) * ssf;
 
-               par = blkid_partlist_add_partition(ls, tab, 0, start, size);
+               par = blkid_partlist_add_partition(ls, tab, start, size);
                if (!par)
                        goto err;
 
index e2f9140f44f8838a589c94b4c78ff78e66eb6011..91cb87ce92794e8fc4ac3959b32ef26443c0e656 100644 (file)
@@ -58,6 +58,7 @@ static int probe_minix_pt(blkid_probe pr, const struct blkid_idmag *mag)
 
        for (i = 0; i < MINIX_MAXPARTITIONS; i++, p++) {
                uint32_t start, size;
+               blkid_partition par;
 
                if (p->sys_type != BLKID_MINIX_PARTITION)
                        continue;
@@ -72,9 +73,11 @@ static int probe_minix_pt(blkid_probe pr, const struct blkid_idmag *mag)
                        continue;
                }
 
-               if (!blkid_partlist_add_partition(ls, tab,
-                                       p->sys_type, start, size))
+               par = blkid_partlist_add_partition(ls, tab, start, size);
+               if (!par)
                        goto err;
+
+               blkid_partition_set_type(par, p->sys_type);
        }
 
        return 0;
index 21b6645a238ae28ba7955d44327b8f5c405f6073..579e16901171f0e9febb8a6e71ac46af8a603402 100644 (file)
@@ -426,7 +426,7 @@ static blkid_partition new_partition(blkid_partlist ls, blkid_parttable tab)
 }
 
 blkid_partition blkid_partlist_add_partition(blkid_partlist ls,
-                                       blkid_parttable tab, int type,
+                                       blkid_parttable tab,
                                        blkid_loff_t start, blkid_loff_t size)
 {
        blkid_partition par = new_partition(ls, tab);
@@ -434,17 +434,13 @@ blkid_partition blkid_partlist_add_partition(blkid_partlist ls,
        if (!par)
                return NULL;
 
-       par->type = type;
        par->start = start;
        par->size = size;
 
        DBG(DEBUG_LOWPROBE,
-               printf("parts: add partition (%p type=0x%x, "
-                       "start=%llu, size=%llu, table=%p)\n",
-                       par, par->type,
-                       (unsigned long long) par->start,
-                       (unsigned long long) par->size,
-                       tab));
+               printf("parts: add partition (%p start=%llu, size=%llu, table=%p)\n",
+                       par, (unsigned long long) par->start,
+                       (unsigned long long) par->size, tab));
        return par;
 }
 
@@ -828,6 +824,14 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
        return NULL;
 }
 
+int blkid_partition_set_type(blkid_partition par, int type)
+{
+       if (!par)
+               return -1;
+       par->type = type;
+       return 0;
+}
+
 /**
  * blkid_parttable_get_type:
  * @tab: partition table
index e017768a14504d9b30c3efd97ac44c364a4ef9e8..c007def84275fa57b3b0663970a51d6a976a197c 100644 (file)
@@ -10,7 +10,7 @@ extern blkid_parttable blkid_partlist_new_parttable(blkid_partlist ls,
                                const char *type, blkid_loff_t offset);
 
 extern blkid_partition blkid_partlist_add_partition(blkid_partlist ls,
-                               blkid_parttable tab, int type,
+                               blkid_parttable tab,
                                blkid_loff_t start, blkid_loff_t size);
 
 extern int blkid_partlist_set_partno(blkid_partlist ls, int partno);
@@ -32,6 +32,8 @@ extern int blkid_partition_set_utf8name(blkid_partition par,
 extern int blkid_partition_set_uuid(blkid_partition par,
                const unsigned char *uuid);
 
+extern int blkid_partition_set_type(blkid_partition par, int type);
+
 extern int blkid_partition_set_type_string(blkid_partition par,
                 const unsigned char *type, size_t len);
 
index c1094b7866869f22ce5dc8737966ac56002a5ae4..3a9cd0a76922000f89b6dfc44a4314b7341f48aa 100644 (file)
@@ -123,13 +123,17 @@ static int probe_sgi_pt(blkid_probe pr, const struct blkid_idmag *mag)
                uint32_t size = be32_to_cpu(p->num_blocks);
                uint32_t start = be32_to_cpu(p->first_block);
                uint32_t type = be32_to_cpu(p->type);
+               blkid_partition par;
 
                if (size == 0 || type == SGI_TYPE_VOLULME ||
                                 type == SGI_TYPE_VOLHDR)
                        continue;
 
-               if (!blkid_partlist_add_partition(ls, tab, type, start, size))
+               par = blkid_partlist_add_partition(ls, tab, start, size);
+               if (!par)
                        goto err;
+
+               blkid_partition_set_type(par, type);
        }
 
        return 0;
index fe39a10363e7120e7e4a5222abb871bff6d2ede8..e62eb4685a63a55196396ed3b71836f3894613d3 100644 (file)
@@ -100,6 +100,7 @@ static int probe_solaris_pt(blkid_probe pr, const struct blkid_idmag *mag)
 
                uint32_t start = le32_to_cpu(p->s_start);
                uint32_t size = le32_to_cpu(p->s_size);
+               blkid_partition par;
 
                if (size == 0 || le16_to_cpu(p->s_tag) == SOLARIS_TAG_WHOLEDISK)
                        continue;
@@ -116,9 +117,11 @@ static int probe_solaris_pt(blkid_probe pr, const struct blkid_idmag *mag)
                        continue;
                }
 
-               if (!blkid_partlist_add_partition(ls, tab,
-                               le16_to_cpu(p->s_tag), start, size))
+               par = blkid_partlist_add_partition(ls, tab, start, size);
+               if (!par)
                        goto err;
+
+               blkid_partition_set_type(par, le16_to_cpu(p->s_tag));
        }
 
        return 0;
index 4ff000f398017994af1a99a164dd8c58447c1d36..30fe4ea70e6d731f24f33fb6102421e4138d7c5d 100644 (file)
@@ -132,6 +132,7 @@ static int probe_sun_pt(blkid_probe pr, const struct blkid_idmag *mag)
                blkid_loff_t start;
                blkid_loff_t size;
                uint16_t type = infos ? be16_to_cpu(infos[i].id) : 0;
+               blkid_partition par;
 
                 start = be32_to_cpu(p->start_cylinder) * spc;
                size = be32_to_cpu(p->num_sectors);
@@ -139,8 +140,11 @@ static int probe_sun_pt(blkid_probe pr, const struct blkid_idmag *mag)
                if (type == SUN_TAG_WHOLEDISK || !size)
                        continue;
 
-               if (!blkid_partlist_add_partition(ls, tab, type, start, size))
+               par = blkid_partlist_add_partition(ls, tab, start, size);
+               if (!par)
                        goto err;
+
+               blkid_partition_set_type(par, type);
        }
        return 0;
 
index 62dba76479a6142a7d74b4f3a0d75a4f1501b491..2a36b93876d9985036f33ac48ddc857550cef557 100644 (file)
@@ -132,6 +132,7 @@ static int probe_unixware_pt(blkid_probe pr, const struct blkid_idmag *mag)
 
                uint32_t start, size;
                uint16_t tag, flg;
+               blkid_partition par;
 
                tag = le16_to_cpu(p->s_label);
                flg = le16_to_cpu(p->s_flags);
@@ -151,8 +152,11 @@ static int probe_unixware_pt(blkid_probe pr, const struct blkid_idmag *mag)
                        continue;
                }
 
-               if (!blkid_partlist_add_partition(ls, tab, tag, start, size))
+               par = blkid_partlist_add_partition(ls, tab, start, size);
+               if (!par)
                        goto err;
+
+               blkid_partition_set_type(par, tag);
        }
 
        return 0;