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

commit 15f479231304a5d37bbdc18d0cea68e539fb881f
Author: James Buren <[email protected]>
Date:   Sun Sep 30 22:09:20 2012 -0500

now use getuuid to get disk's UUID

diff --git a/src/block.c b/src/block.c
index 849b919..e032194 100644
--- a/src/block.c
+++ b/src/block.c
@@ -102,6 +102,7 @@ static bool getuuid(struct disk *disk)
char line[LINE_MAX] = {0};
bool outputsuccess = false;
bool exitsuccess = false;
+  char *p = 0;

if(disk->type == DISKTYPE_DOS)
snprintf(command,_POSIX_ARG_MAX,"export LC_ALL=C;yes | fdisk -l '%s' 2> 
/dev/null | sed -rn 's|^Disk identifier: 
0x([0-9a-fA-F]+)$|\1|p'",disk->device->path);
@@ -120,15 +121,22 @@ static bool getuuid(struct disk *disk)

exitsuccess = (pclose(pipe) != -1);

+  if((p = strchr(line,'\n')) != 0)
+    *p = 0;
+
if(outputsuccess && exitsuccess)
{
if(disk->type == DISKTYPE_DOS)
disk->dosuuid = strtoul(line,0,16);
else if(disk->type == DISKTYPE_GPT)
snprintf(disk->gptuuid,37,"%s",line);
+    return true;
+  }
+  else
+  {
+    fprintf(logfile,"%s: %s\n",__func__,strerror(errno));
+    return false;
}
-
-  return (outputsuccess && exitsuccess);
}

extern struct device *device_open(const char *path)
@@ -283,6 +291,9 @@ extern struct disk *disk_open(struct device *device)
goto bail;
}

+  if(!getuuid(&disk))
+    goto bail;
+
if((j = blkid_partlist_numof_partitions(partlist)) > 0)
{
if((disk.type == DISKTYPE_DOS && j > 60) || (disk.type == DISKTYPE_GPT && j > 
128))
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to