Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=555fc74ab8505f38cf3409fd0e27b505086a3f42

commit 555fc74ab8505f38cf3409fd0e27b505086a3f42
Author: James Buren <[email protected]>
Date:   Tue Oct 9 06:18:10 2012 -0500

add a function for retrieving if a partition is "active"

diff --git a/src/block.c b/src/block.c
index ca06a1f..f66b753 100644
--- a/src/block.c
+++ b/src/block.c
@@ -3,6 +3,7 @@
#include "local.h"

#define EMPTY_PARTITION &(struct partition) {0}
+#define GPT_BOOT_FLAG (1ULL << 2ULL)

#define DOS_DATA     0x83
#define DOS_SWAP     0x82
@@ -560,6 +561,28 @@ extern const char *disk_partition_get_purpose(struct disk 
*disk,int n)
return purpose;
}

+extern bool disk_partition_get_active(struct disk *disk,int n)
+{
+  struct partition *part = 0;
+  bool active = false;
+
+  if(disk == 0 || n <= 0 || n > disk->size)
+  {
+    errno = EINVAL;
+    fprintf(logfile,"%s: %s\n",__func__,strerror(errno));
+    return false;
+  }
+
+  part = &disk->table[n];
+
+  if(disk->type == DISKTYPE_DOS)
+    active = part->dosactive;
+  else if(disk->type == DISKTYPE_GPT)
+    active = (part->gptflags & GPT_BOOT_FLAG) != 0;
+
+  return active;
+}
+
extern void disk_close(struct disk *disk)
{
if(disk == 0)
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to