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

commit 35d1ff10f268c03bdcbde72ea811d4a8f0cd3ce2
Author: James Buren <[email protected]>
Date:   Tue Aug 14 22:57:51 2012 -0500

cache logical and physical sector size

diff --git a/fwsetup.h b/fwsetup.h
index 3e8919f..b731d42 100644
--- a/fwsetup.h
+++ b/fwsetup.h
@@ -109,7 +109,9 @@ struct device
struct device *prev;
struct device *next;
char *path;
-  unsigned long long sector_size;
+  unsigned long long logical_sector_size;
+  unsigned long long physical_sector_size;
+  unsigned long long sectors;
enum devicetype type;
char *label;
char *uuid;
diff --git a/utility.c b/utility.c
index c059988..e73a005 100644
--- a/utility.c
+++ b/utility.c
@@ -1,6 +1,6 @@
#include "fwsetup.h"

-#define INVALID_TABLE_TEXT _("This unsupported partition table (%s) cannot be 
written to %s.\n")
+#define INVALID_PARTITION_TEXT _("A partition with invalid data for a %s 
partition table was rejected.\n")

struct list
{
@@ -321,7 +321,9 @@ extern struct device *device_read_data(const char *path)
int fd = -1;
blkid_probe probe = 0;
blkid_topology topology = 0;
-  unsigned long long sector_size = 0;
+  unsigned long long logical_sector_size = 0;
+  unsigned long long physical_sector_size = 0;
+  blkid_loff_t size = 0;
struct stat st;
enum devicetype type = 0;
struct device *device = 0;
@@ -365,9 +367,19 @@ extern struct device *device_read_data(const char *path)
if(topology == 0)
goto bail;

-  sector_size = blkid_topology_get_physical_sector_size(topology);
+  logical_sector_size = blkid_topology_get_logical_sector_size(topology);

-  if(sector_size == 0)
+  if(logical_sector_size == 0)
+    goto bail;
+
+  physical_sector_size = blkid_topology_get_physical_sector_size(topology);
+
+  if(physical_sector_size == 0)
+    goto bail;
+
+  size = blkid_probe_get_size(probe);
+
+  if(size <= 0 || (size % logical_sector_size) != 0)
goto bail;

if(fstat(fd,&st) != 0)
@@ -480,7 +492,11 @@ extern struct device *device_read_data(const char *path)

device->path = strdup(path);

-  device->sector_size = sector_size;
+  device->logical_sector_size = logical_sector_size;
+
+  device->physical_sector_size = physical_sector_size;
+
+  device->sectors = (size % logical_sector_size);

device->type = type;

@@ -549,11 +565,6 @@ extern bool device_write_data(const struct device *device)

snprintf_append(cmd,sizeof(cmd)," %s",device->path);
}
-  else
-  {
-    eprintf(INVALID_TABLE_TEXT,device->label,device->path);
-    return false;
-  }

eprintf(EXECUTE_START_TEXT,cmd);
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to