Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwlive.git;a=commitdiff;h=ab2238765261f657694e08bce413013b524a9c40

commit ab2238765261f657694e08bce413013b524a9c40
Author: James Buren <[email protected]>
Date:   Fri Nov 9 16:07:35 2012 -0600

add function for retrieving the free space on a disk

diff --git a/src/block.c b/src/block.c
index dbf5f49..333c41d 100644
--- a/src/block.c
+++ b/src/block.c
@@ -583,6 +583,27 @@ extern const char *disk_get_type(struct disk *disk)
return type;
}

+extern long long disk_get_free_size(struct disk *disk)
+{
+  long long size = 0;
+
+  if(disk == 0)
+  {
+    errno = EINVAL;
+    error(strerror(errno));
+    return 0;
+  }
+
+  size = disk->sectors;
+
+  if(disk->size > 0)
+    size -= disk->table[disk->size].end;
+
+  size *= disk->device->sectorsize;
+
+  return size;
+}
+
extern void disk_new_table(struct disk *disk,const char *type)
{
struct device *device = 0;
diff --git a/src/local.h b/src/local.h
index a0250a6..fc9d360 100644
--- a/src/local.h
+++ b/src/local.h
@@ -112,6 +112,7 @@ extern void device_close(struct device *device);
extern struct disk *disk_open(struct device *device);
extern struct disk *disk_open_empty(struct device *device,const char *type);
extern const char *disk_get_type(struct disk *disk);
+extern long long disk_get_free_size(struct disk *disk);
extern void disk_new_table(struct disk *disk,const char *type);
extern int disk_create_partition(struct disk *disk,long long size);
extern int disk_create_extended_partition(struct disk *disk);
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to