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

commit 8a3a5457a937d68fd4b9eb4598090d02c034354f
Author: James Buren <[email protected]>
Date:   Tue Sep 11 10:07:22 2012 -0500

add function abstraction for setting 'active' flag on DOS/GPT

diff --git a/src/local.h b/src/local.h
index 9d35b4e..4e35c6f 100644
--- a/src/local.h
+++ b/src/local.h
@@ -89,6 +89,8 @@ static inline bool is_normal_partition(PedPartitionType type)
}
}
extern bool parted_new_partition(struct parted *parted,const char *size);
+extern bool parted_partition_set_active(struct parted *parted,int n);
+extern bool parted_partition_unset_active(struct parted *parted,int n);
extern bool parted_delete_last_partition(struct parted *parted);
extern void parted_close(struct parted *parted);
extern int get_text_screen_width(const char *s);
diff --git a/src/utility.c b/src/utility.c
index ee37b28..21c7831 100644
--- a/src/utility.c
+++ b/src/utility.c
@@ -1,5 +1,30 @@
#include "local.h"

+static parted_partition_change_active(struct parted *parted,int n,bool state)
+{
+  PedPartition *part = 0;
+  PedPartitionFlag flag = 0;
+
+  if(parted == 0 || parted->device == 0 || parted->constraint == 0 || 
parted->disk == 0 || n < 1)
+  {
+    errno = EINVAL;
+    fprintf(logfile,"%s: %s\n",__func__,strerror(errno));
+    return false;
+  }
+
+  if((part = ped_disk_get_partition(parted->disk,n)) == 0)
+    return false;
+
+  if(parted->disk->type == g->doslabel)
+    flag = PED_PARTITION_BOOT;
+  else if(parted->disk->type == g->gptlabel)
+    flag = PED_PARTITION_LEGACY_BOOT;
+  else
+    return false;
+
+  return ped_partition_set_flag(part,flag,state);
+}
+
extern bool mkdir_recurse(const char *path)
{
char buf[PATH_MAX] = {0};
@@ -289,6 +314,16 @@ extern bool parted_new_partition(struct parted 
*parted,const char *size)
return true;
}

+extern bool parted_partition_set_active(struct parted *parted,int n)
+{
+  return parted_partition_change_active(parted,n,true);
+}
+
+extern bool parted_partition_unset_active(struct parted *parted,int n)
+{
+  return parted_partition_change_active(parted,n,false);
+}
+
extern bool parted_delete_last_partition(struct parted *parted)
{
PedPartition *part = 0;
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to