bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH parted 3/7] linux.c: add get_minimum_alignment() and get_optimum_


From: Hans de Goede
Subject: [PATCH parted 3/7] linux.c: add get_minimum_alignment() and get_optimum_alignment() functions
Date: Thu, 29 Oct 2009 16:26:18 +0100

---
 libparted/arch/linux.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 176e7da..3069c59 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2521,6 +2521,34 @@ linux_disk_commit (PedDisk* disk)
         return 1;
 }
 
+#if HAVE_BLKID_BLKID_H
+PedAlignment*
+linux_get_minimum_alignment(const PedDevice *dev)
+{
+        blkid_topology tp = LINUX_SPECIFIC(dev)->topology;
+
+        if (!tp)
+                return NULL; /* ped_alignment_none */
+
+        return ped_alignment_new(
+                blkid_topology_get_alignment_offset(tp) / dev->sector_size,
+                blkid_topology_get_minimum_io_size(tp) / dev->sector_size);
+}
+
+PedAlignment*
+linux_get_optimum_alignment(const PedDevice *dev)
+{
+        blkid_topology tp = LINUX_SPECIFIC(dev)->topology;
+
+        if (!tp)
+                return NULL; /* ped_alignment_none */
+
+        return ped_alignment_new(
+                blkid_topology_get_alignment_offset(tp) / dev->sector_size,
+                blkid_topology_get_optimal_io_size(tp) / dev->sector_size);
+}
+#endif
+
 static PedDeviceArchOps linux_dev_ops = {
         _new:           linux_new,
         destroy:        linux_destroy,
@@ -2534,7 +2562,11 @@ static PedDeviceArchOps linux_dev_ops = {
         check:          linux_check,
         sync:           linux_sync,
         sync_fast:      linux_sync_fast,
-        probe_all:      linux_probe_all
+        probe_all:      linux_probe_all,
+#if HAVE_BLKID_BLKID_H
+        get_minimum_alignment: linux_get_minimum_alignment,
+        get_optimum_alignment: linux_get_optimum_alignment,
+#endif
 };
 
 PedDiskArchOps linux_disk_ops =  {
-- 
1.6.5.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]