bootdisk/trunk/config/devel/parted-units.patch
hawk
cvs at pld-linux.org
Tue Nov 22 23:48:37 CET 2005
Author: hawk
Date: Tue Nov 22 23:48:34 2005
New Revision: 6560
Added:
bootdisk/trunk/config/devel/parted-units.patch
Log:
- patch for parted >= 1.6.23 changing default units used with print
command to same as in old versions
Added: bootdisk/trunk/config/devel/parted-units.patch
==============================================================================
--- (empty file)
+++ bootdisk/trunk/config/devel/parted-units.patch Tue Nov 22 23:48:34 2005
@@ -0,0 +1,71 @@
+diff -ur parted-1.6.25.1.orig/include/parted/unit.h parted-1.6.25.1.new/include/parted/unit.h
+--- parted-1.6.25.1.orig/include/parted/unit.h 2005-11-11 12:32:28.000000000 +0000
++++ parted-1.6.25.1.new/include/parted/unit.h 2005-11-22 20:44:49.626332104 +0000
+@@ -30,7 +30,7 @@
+ #define PED_MEGABYTE_SIZE 1000000LL
+ #define PED_GIGABYTE_SIZE 1000000000LL
+ #define PED_TERABYTE_SIZE 1000000000000LL
+-
++#define PED_MEGABYTE_SECTORS_SIZE ((1024 * 1024) / 512)
+
+ typedef enum {
+ PED_UNIT_SECTOR,
+@@ -42,11 +42,12 @@
+ PED_UNIT_COMPACT,
+ PED_UNIT_CYLINDER,
+ PED_UNIT_CHS,
+- PED_UNIT_PERCENT
++ PED_UNIT_PERCENT,
++ PED_UNIT_MEGABYTE_SECTORS
+ } PedUnit;
+
+ #define PED_UNIT_FIRST PED_UNIT_SECTOR
+-#define PED_UNIT_LAST PED_UNIT_PERCENT
++#define PED_UNIT_LAST PED_UNIT_MEGABYTE_SECTORS
+
+ extern long long ped_unit_get_size (PedDevice* dev, PedUnit unit);
+ extern const char* ped_unit_get_name (PedUnit unit);
+diff -ur parted-1.6.25.1.orig/libparted/unit.c parted-1.6.25.1.new/libparted/unit.c
+--- parted-1.6.25.1.orig/libparted/unit.c 2005-11-11 12:35:53.000000000 +0000
++++ parted-1.6.25.1.new/libparted/unit.c 2005-11-22 21:07:09.041710016 +0000
+@@ -33,7 +33,7 @@
+ #endif /* ENABLE_NLS */
+
+
+-static PedUnit default_unit = PED_UNIT_COMPACT;
++static PedUnit default_unit = PED_UNIT_MEGABYTE_SECTORS;
+ static const char* unit_names[] = {
+ "s",
+ "B",
+@@ -44,7 +44,8 @@
+ "compact",
+ "cyl",
+ "chs",
+- "%"
++ "%",
++ ""
+ };
+
+
+@@ -86,6 +87,7 @@
+ case PED_UNIT_TERABYTE: return PED_TERABYTE_SIZE;
+ case PED_UNIT_CYLINDER: return cyl_size * PED_SECTOR_SIZE;
+ case PED_UNIT_CHS: return PED_SECTOR_SIZE;
++ case PED_UNIT_MEGABYTE_SECTORS: return PED_MEGABYTE_SECTORS_SIZE;
+
+ case PED_UNIT_PERCENT:
+ return dev->length * PED_SECTOR_SIZE / 100;
+@@ -190,6 +192,13 @@
+ unit = PED_UNIT_KILOBYTE;
+ }
+
++ if (unit == PED_UNIT_MEGABYTE_SECTORS) {
++ snprintf (buf, 100, "%10.3f",
++ sector * 1.0
++ / ped_unit_get_size (dev, unit));
++ return ped_strdup (buf);
++ }
++
+ snprintf (buf, 100, "%lld%s",
+ ped_div_round_to_nearest (
+ sector * PED_SECTOR_SIZE,
More information about the pld-cvs-commit
mailing list