]> err.no Git - util-linux/commitdiff
libblkid: add support for partition flags/attributes
authorKarel Zak <kzak@redhat.com>
Thu, 18 Feb 2010 21:53:44 +0000 (22:53 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 18 Feb 2010 21:53:44 +0000 (22:53 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/blkid.h.in
shlibs/blkid/src/blkid.sym
shlibs/blkid/src/partitions/dos.c
shlibs/blkid/src/partitions/gpt.c
shlibs/blkid/src/partitions/minix.c
shlibs/blkid/src/partitions/partitions.c
shlibs/blkid/src/partitions/partitions.h
shlibs/blkid/src/partitions/solaris_x86.c
shlibs/blkid/src/partitions/sun.c
shlibs/blkid/src/partitions/unixware.c

index 59c05ab4bbb20ba6262fdd70a33b5f042b23a3a5..edeb8b571765dc1f7b97a7b014e218ef8e04289f 100644 (file)
@@ -279,6 +279,7 @@ extern blkid_loff_t blkid_partition_get_start(blkid_partition par);
 extern blkid_loff_t blkid_partition_get_size(blkid_partition par);
 extern int blkid_partition_get_type(blkid_partition par);
 extern const char *blkid_partition_get_type_string(blkid_partition par);
+extern unsigned long long blkid_partition_get_flags(blkid_partition par);
 extern int blkid_partition_is_logical(blkid_partition par);
 extern int blkid_partition_is_extended(blkid_partition par);
 extern int blkid_partition_is_primary(blkid_partition par);
index ea674f75848d334c83cf6bd09146887d1617a33e..dfde68913e6e2e315e6f30441fb145300b4036aa 100644 (file)
@@ -122,4 +122,5 @@ BLKID_2.18 {
 global:
        blkid_probe_all_removable;
        blkid_partlist_devno_to_partition;
+       blkid_partition_get_flags;
 } BLKID_2.17;
index 8bf3a8b66a8ff6cf16d92904000ec78b6c68bc6e..c9865b75ded322bb24eb422d267adba50655d602 100644 (file)
@@ -100,6 +100,7 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab,
                                goto err;
 
                        blkid_partition_set_type(par, p->sys_type);
+                       blkid_partition_set_flags(par, p->boot_ind);
                        ct_nodata = 0;
                }
                /* The first nested ext.partition should be a link to the next
@@ -210,6 +211,7 @@ static int probe_dos_pt(blkid_probe pr, const struct blkid_idmag *mag)
                        goto err;
 
                blkid_partition_set_type(par, p->sys_type);
+               blkid_partition_set_flags(par, p->boot_ind);
        }
 
        /* Linux uses partition numbers greater than 4
index eba8803bc9e49b5f4c07281baf55454454f77067..569490131191604419f3959fc10ec10ef02ba73f 100644 (file)
@@ -353,6 +353,8 @@ static int probe_gpt_pt(blkid_probe pr, const struct blkid_idmag *mag)
 
                blkid_partition_set_type_uuid(par,
                        (const unsigned char *) &e->partition_type_guid);
+
+               blkid_partition_set_flags(par, e->attributes);
        }
 
        return 0;
index 91cb87ce92794e8fc4ac3959b32ef26443c0e656..0887d1a3b53930cd55408f9696c324494335a936 100644 (file)
@@ -78,6 +78,7 @@ static int probe_minix_pt(blkid_probe pr, const struct blkid_idmag *mag)
                        goto err;
 
                blkid_partition_set_type(par, p->sys_type);
+               blkid_partition_set_flags(par, p->boot_ind);
        }
 
        return 0;
index 579e16901171f0e9febb8a6e71ac46af8a603402..d3ba6f2943d05572708dcdbd1de5d0bbc731bffb 100644 (file)
@@ -39,6 +39,8 @@
  *
  * @PART_ENTRY_TYPE: partition type, 0xNN (e.g 0x82) or type UUID (gpt only)
  *
+ * @PART_ENTRY_FLAGS: partition flags (e.g. boot_ind) or  attributes (e.g. gpt attributes)
+ *
  * Example:
  *
  * <informalexample>
@@ -158,6 +160,8 @@ struct blkid_struct_partition {
        int             type;           /* partition type */
        char            typestr[37];    /* partition type string (GPT and Mac) */
 
+       unsigned long long flags;       /* partition flags / attributes */
+
        int             partno;         /* partition number */
        char            uuid[37];       /* UUID (when supported by PT), e.g GPT */
        unsigned char   name[128];      /* Partition in UTF8 name (when supporte by PT), e.g. Mac */
@@ -727,7 +731,11 @@ static int blkid_partitions_probe_partition(blkid_probe pr)
                                (unsigned char *) v, strlen(v) + 1);
                else
                        blkid_probe_sprintf_value(pr, "PART_ENTRY_TYPE",
-                               "0x%02x", blkid_partition_get_type(par));
+                               "0x%x", blkid_partition_get_type(par));
+
+               if (blkid_partition_get_flags(par))
+                       blkid_probe_sprintf_value(pr, "PART_ENTRY_FLAGS",
+                               "0x%llx", blkid_partition_get_flags(par));
        }
        rc = 0;
 nothing:
@@ -1156,3 +1164,23 @@ const char *blkid_partition_get_type_string(blkid_partition par)
        return par && *par->typestr ? par->typestr : NULL;
 }
 
+
+int blkid_partition_set_flags(blkid_partition par, unsigned long long flags)
+{
+       if (!par)
+               return -1;
+       par->flags = flags;
+       return 0;
+}
+
+/**
+ * blkid_partition_get_flags
+ * @par: partition
+ *
+ * Returns: partition flags (or attributes for gpt).
+ */
+unsigned long long blkid_partition_get_flags(blkid_partition par)
+{
+       return par ? par->flags : 0;
+}
+
index c007def84275fa57b3b0663970a51d6a976a197c..190918f9e4f5d177191af7e0966cfcb67123266f 100644 (file)
@@ -40,6 +40,8 @@ extern int blkid_partition_set_type_string(blkid_partition par,
 extern int blkid_partition_set_type_uuid(blkid_partition par,
                const unsigned char *uuid);
 
+extern int blkid_partition_set_flags(blkid_partition par, unsigned long long flags);
+
 /*
  * partition probers
  */
index e62eb4685a63a55196396ed3b71836f3894613d3..ce102bd8f7a2ecf3c534b901dbe817a8e0e59022 100644 (file)
@@ -122,6 +122,7 @@ static int probe_solaris_pt(blkid_probe pr, const struct blkid_idmag *mag)
                        goto err;
 
                blkid_partition_set_type(par, le16_to_cpu(p->s_tag));
+               blkid_partition_set_flags(par, le16_to_cpu(p->s_flag));
        }
 
        return 0;
index 30fe4ea70e6d731f24f33fb6102421e4138d7c5d..10c555ab80e9da46b94986959fd5668041b6ef94 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;
+               uint16_t flags = infos ? be16_to_cpu(infos[i].flags) : 0;
                blkid_partition par;
 
                 start = be32_to_cpu(p->start_cylinder) * spc;
@@ -145,6 +146,7 @@ static int probe_sun_pt(blkid_probe pr, const struct blkid_idmag *mag)
                        goto err;
 
                blkid_partition_set_type(par, type);
+               blkid_partition_set_flags(par, flags);
        }
        return 0;
 
index 2a36b93876d9985036f33ac48ddc857550cef557..ac11a46d31e48a7f5b02b1dfa2d5ee21b9873537 100644 (file)
@@ -157,6 +157,7 @@ static int probe_unixware_pt(blkid_probe pr, const struct blkid_idmag *mag)
                        goto err;
 
                blkid_partition_set_type(par, tag);
+               blkid_partition_set_flags(par, flg);
        }
 
        return 0;