bug-parted
[Top][All Lists]
Advanced

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

[PATCH parted 1/7] linux: Fixup phys_sector_size setting


From: Hans de Goede
Subject: [PATCH parted 1/7] linux: Fixup phys_sector_size setting
Date: Sat, 30 Jan 2010 17:53:47 +0100

1) Use the logical sector size as physical sector size instead of 512
   when not compiled with libblkid support, this fixes problems
   with logical sector size > physical sector size.
2) blkid_topology_get_physical_sector_size() can return 0 when it could
   not determine the physical sector size, handle this.
* libparted/arch/linux.c (_device_set_sector_size): Fixup
phys_sector_size setting.
---
 NEWS                   |    3 +++
 libparted/arch/linux.c |   17 +++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index ea6caa1..d94b0db 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ GNU parted NEWS                                    -*- outline 
-*-
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Bug Fixes
+
+ Fix physical sector size being 0 or smaller then the logical sector size.
 
 * Noteworthy changes in release 2.1 (2009-12-20) [stable]
 
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index f3b54f0..4b7b9f5 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -654,22 +654,27 @@ _device_set_sector_size (PedDevice* dev)
                         dev->path, strerror (errno), PED_SECTOR_SIZE_DEFAULT);
         } else {
                 dev->sector_size = (long long)sector_size;
+                dev->phys_sector_size = dev->sector_size;
         }
 
 #if USE_BLKID
         get_blkid_topology(arch_specific);
         if (!arch_specific->topology) {
-                ped_exception_throw (
-                        PED_EXCEPTION_WARNING,
-                        PED_EXCEPTION_OK,
-                        _("Could not determine minimum io size for %s: %s.\n"
-                          "Using the default size (%lld)."),
-                        dev->path, strerror (errno), PED_SECTOR_SIZE_DEFAULT);
+                dev->phys_sector_size = 0;
         } else {
                 dev->phys_sector_size =
                         blkid_topology_get_physical_sector_size(
                                 arch_specific->topology);
         }
+        if (dev->phys_sector_size == 0) {
+                ped_exception_throw (
+                        PED_EXCEPTION_WARNING,
+                        PED_EXCEPTION_OK,
+                        _("Could not determine physical sector size for %s.\n"
+                          "Using the logical sector size (%lld)."),
+                        dev->path, dev->sector_size);
+                dev->phys_sector_size = dev->sector_size;
+        }
 #endif
 
 #if defined __s390__ || defined __s390x__
-- 
1.6.6





reply via email to

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