Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwlive.git;a=commitdiff;h=b94c231775930cf181cdc7a044c10ff0cd0dd4ce

commit b94c231775930cf181cdc7a044c10ff0cd0dd4ce
Author: James Buren <[email protected]>
Date:   Thu Nov 8 05:04:22 2012 -0600

add function for retrieving a disk's label type

diff --git a/src/block.c b/src/block.c
index 0eb4465..e66821b 100644
--- a/src/block.c
+++ b/src/block.c
@@ -562,6 +562,27 @@ extern struct disk *disk_open_empty(struct device 
*device,const char *type)
return memdup(&disk,sizeof(struct disk));
}

+extern const char *disk_get_type(struct disk *disk)
+{
+  const char *type = 0;
+
+  if(disk == 0)
+  {
+    errno = EINVAL;
+    error(strerror(errno));
+    return 0;
+  }
+
+  if(disk->type == DISK_TYPE_DOS)
+    type = "dos";
+  else if(disk->type == DISK_TYPE_GPT)
+    type = "gpt";
+  else
+    type = "unknown";
+
+  return type;
+}
+
extern void disk_new_table(struct disk *disk,const char *type)
{
struct device *device = 0;
diff --git a/src/local.h b/src/local.h
index 8aa592e..a0250a6 100644
--- a/src/local.h
+++ b/src/local.h
@@ -111,6 +111,7 @@ extern const char *device_get_type(struct device *device);
extern void device_close(struct device *device);
extern struct disk *disk_open(struct device *device);
extern struct disk *disk_open_empty(struct device *device,const char *type);
+extern const char *disk_get_type(struct disk *disk);
extern void disk_new_table(struct disk *disk,const char *type);
extern int disk_create_partition(struct disk *disk,long long size);
extern int disk_create_extended_partition(struct disk *disk);
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to