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

commit 98cc7dd8d3345e0a0f3b492210fb8a6bf6f098b3
Author: James Buren <[email protected]>
Date:   Tue Sep 11 10:23:53 2012 -0500

add get_active function

diff --git a/src/local.h b/src/local.h
index 4e35c6f..ce033fa 100644
--- a/src/local.h
+++ b/src/local.h
@@ -89,6 +89,7 @@ static inline bool is_normal_partition(PedPartitionType type)
}
}
extern bool parted_new_partition(struct parted *parted,const char *size);
+extern bool parted_partition_get_active(struct parted *parted,int n);
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);
diff --git a/src/utility.c b/src/utility.c
index 21c7831..e729ce0 100644
--- a/src/utility.c
+++ b/src/utility.c
@@ -1,6 +1,6 @@
#include "local.h"

-static parted_partition_change_active(struct parted *parted,int n,bool state)
+static bool parted_partition_change_active(struct parted *parted,int n,bool 
state)
{
PedPartition *part = 0;
PedPartitionFlag flag = 0;
@@ -22,6 +22,8 @@ static parted_partition_change_active(struct parted 
*parted,int n,bool state)
else
return false;

+  parted->modified = true;
+
return ped_partition_set_flag(part,flag,state);
}

@@ -314,6 +316,31 @@ extern bool parted_new_partition(struct parted 
*parted,const char *size)
return true;
}

+extern bool parted_partition_get_active(struct parted *parted,int n)
+{
+  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_get_flag(part,flag);
+}
+
extern bool parted_partition_set_active(struct parted *parted,int n)
{
return parted_partition_change_active(parted,n,true);
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to