bug-parted
[Top][All Lists]
Advanced

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

[PATCH parted 3/7] linux: add get_xxx_alignment() functions


From: Hans de Goede
Subject: [PATCH parted 3/7] linux: add get_xxx_alignment() functions
Date: Fri, 30 Oct 2009 12:59:01 +0100

* libparted/arch/linux.c (get_minimum_alignment): New function.
(get_optimum_alignment): New function.
---
 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 a03c80d..a87f7e2 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2523,6 +2523,34 @@ linux_disk_commit (PedDisk* disk)
         return 1;
 }
 
+#if USE_BLKID
+PedAlignment*
+linux_get_minimum_alignment(const PedDevice *dev)
+{
+        blkid_topology tp = LINUX_SPECIFIC(dev)->topology;
+
+        if (!tp || blkid_topology_get_minimum_io_size(tp) == 0)
+                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 || blkid_topology_get_optimal_io_size(tp) == 0)
+                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,
@@ -2536,7 +2564,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 USE_BLKID
+        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]