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

commit 6615213652314bc894f5635cb35b0a95a4e299e7
Author: James Buren <[email protected]>
Date:   Tue Oct 9 07:09:35 2012 -0500

add function for setting a partition's active status

diff --git a/src/block.c b/src/block.c
index ed5f4ce..640522b 100644
--- a/src/block.c
+++ b/src/block.c
@@ -517,7 +517,7 @@ extern void disk_partition_set_purpose(struct disk 
*disk,int n,const char *purpo
{
struct partition *part = 0;

-  if(disk == 0 || n < 0 || n > disk->size)
+  if(disk == 0 || n < 0 || n > disk->size || purpose == 0)
{
errno = EINVAL;
fprintf(logfile,"%s: %s\n",__func__,strerror(errno));
@@ -560,6 +560,32 @@ extern void disk_partition_set_purpose(struct disk 
*disk,int n,const char *purpo
disk->modified = true;
}

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

Reply via email to