aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/parted
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2011-02-23 21:07:22 +0000
committerTom Rini <tom_rini@mentor.com>2011-02-23 14:08:28 -0700
commitd25f6c9a8cc9687264eef4e2d640d2c4de22982a (patch)
treeac9187d2d9a9405261299096333bcd6b510f45d1 /recipes/parted
parent33d0e6d0ae64c4f922596531713c0e70f1069d17 (diff)
downloadopenembedded-d25f6c9a8cc9687264eef4e2d640d2c4de22982a.tar.gz
parted: fix MiB handling
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Tom Rini <tom_rini@mentor.com>
Diffstat (limited to 'recipes/parted')
-rw-r--r--recipes/parted/files/fix-MiB-handling.patch130
-rw-r--r--recipes/parted/parted_2.3.bb2
2 files changed, 132 insertions, 0 deletions
diff --git a/recipes/parted/files/fix-MiB-handling.patch b/recipes/parted/files/fix-MiB-handling.patch
new file mode 100644
index 0000000000..db4945f9f3
--- /dev/null
+++ b/recipes/parted/files/fix-MiB-handling.patch
@@ -0,0 +1,130 @@
+Delivered-To: otavio.salvador@gmail.com
+Received: by 10.204.59.147 with SMTP id l19cs132424bkh;
+ Sun, 16 Jan 2011 04:26:09 -0800 (PST)
+Received: by 10.90.113.8 with SMTP id l8mr1322981agc.21.1295180768845;
+ Sun, 16 Jan 2011 04:26:08 -0800 (PST)
+Return-Path: <bug-parted-bounces+otavio=debian.org@gnu.org>
+Received: from master.debian.org (master.debian.org [70.103.162.29])
+ by mx.google.com with ESMTPS id c36si6867598ana.168.2011.01.16.04.26.08
+ (version=TLSv1/SSLv3 cipher=RC4-MD5);
+ Sun, 16 Jan 2011 04:26:08 -0800 (PST)
+Received-SPF: softfail (google.com: domain of transitioning bug-parted-bounces+otavio=debian.org@gnu.org does not designate 70.103.162.29 as permitted sender) client-ip=70.103.162.29;
+Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning bug-parted-bounces+otavio=debian.org@gnu.org does not designate 70.103.162.29 as permitted sender) smtp.mail=bug-parted-bounces+otavio=debian.org@gnu.org
+Received: from lists.gnu.org ([199.232.76.165])
+ by master.debian.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
+ (Exim 4.69)
+ (envelope-from <bug-parted-bounces+otavio=debian.org@gnu.org>)
+ id 1PeRgN-00069u-NM
+ for otavio.salvador@gmail.com; Sun, 16 Jan 2011 12:26:08 +0000
+Received: from localhost ([127.0.0.1]:34642 helo=lists.gnu.org)
+ by lists.gnu.org with esmtp (Exim 4.43)
+ id 1PeRgL-0007eS-Ku
+ for otavio@debian.org; Sun, 16 Jan 2011 07:26:05 -0500
+Received: from [140.186.70.92] (port=41438 helo=eggs.gnu.org)
+ by lists.gnu.org with esmtp (Exim 4.43) id 1PeRgG-0007cP-GQ
+ for bug-parted@gnu.org; Sun, 16 Jan 2011 07:26:01 -0500
+Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
+ (envelope-from <jim@meyering.net>) id 1PeRgF-0003PP-7D
+ for bug-parted@gnu.org; Sun, 16 Jan 2011 07:26:00 -0500
+Received: from mx.meyering.net ([82.230.74.64]:52182)
+ by eggs.gnu.org with esmtp (Exim 4.71)
+ (envelope-from <jim@meyering.net>) id 1PeRgF-0003PL-0K
+ for bug-parted@gnu.org; Sun, 16 Jan 2011 07:25:59 -0500
+Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000)
+ id 5C38F60466; Sun, 16 Jan 2011 13:25:56 +0100 (CET)
+From: Jim Meyering <jim@meyering.net>
+To: bug-parted@gnu.org
+Date: Sun, 16 Jan 2011 13:25:56 +0100
+Message-ID: <8762tpox0r.fsf@meyering.net>
+Lines: 67
+MIME-Version: 1.0
+Content-Type: text/plain
+X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
+Subject: treat "1MiB" like "1048576B"
+X-BeenThere: bug-parted@gnu.org
+X-Mailman-Version: 2.1.5
+Precedence: list
+List-Id: Bug reports for the GNU Parted disk partition editor
+ <bug-parted.gnu.org>
+List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-parted>,
+ <mailto:bug-parted-request@gnu.org?subject=unsubscribe>
+List-Archive: <http://lists.gnu.org/archive/html/bug-parted>
+List-Post: <mailto:bug-parted@gnu.org>
+List-Help: <mailto:bug-parted-request@gnu.org?subject=help>
+List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-parted>,
+ <mailto:bug-parted-request@gnu.org?subject=subscribe>
+Sender: bug-parted-bounces+otavio=debian.org@gnu.org
+Errors-To: bug-parted-bounces+otavio=debian.org@gnu.org
+
+[ I noticed that using a starting address of "1MiB" evokes a warning,
+ along with the obviously unintended start sector of 34:
+
+ parted -s -- $dev mklabel gpt mkpart PARTITION-NAME 1MiB -34s
+ Warning: The resulting partition is not properly aligned for best performance.
+
+ While the following, with "1048576B", works fine and creates the partition
+ starting at the desired 1MiB address:
+
+ parted -s -- $dev mklabel gpt mkpart PARTITION-NAME 1048576B -34s
+ ]
+
+I made parted tell me why it was treating "1MiB" differently from
+"1048576B". Bottom line is that if you use a large unit, like MiB, it
+assumes you're being sloppy, but if you specify bytes or sectors, you
+require exactness (radius = 0). That may have made sense when people
+used sloppy units like MB (1,000,000), but obviously does not hold for
+most people who bother to type "MiB".
+
+Here's a proposed patch to make the command I gave work the way I
+intended. Opinions welcome. On one hand, I don't particularly like
+treating 1MiB differently from 1MB, but if someone is using 1MB and
+intends 1MiB, they need a little wake up call (or some RTFM).
+[the full patch will include a documentation update as well as
+a couple of tests to illustrate/exercise the difference. ]
+
+In the mean time, to get the proper 1MiB alignment, you'll have to
+use an explicit byte or sector count. I prefer byte counts, in spite of
+the greater number of digits, because that works the same regardless
+of a disk's sector size:
+
+ dev=...
+ k=1024 m=$((k*k))
+ parted -s -- $dev mklabel gpt mkpart P-NAME ${m}B -34s
+
+
+diff --git a/libparted/unit.c b/libparted/unit.c
+index 2670c38..59a9644 100644
+--- a/libparted/unit.c
++++ b/libparted/unit.c
+@@ -480,6 +480,12 @@ parse_unit_suffix (const char* suffix, PedUnit suggested_unit)
+ return suggested_unit;
+ }
+
++static bool
++is_power_of_2 (long long n)
++{
++ return (n & (n - 1)) == 0;
++}
++
+ /**
+ * If \p str contains a valid description of a location on \p dev, then
+ * \p *sector is modified to describe the location and a geometry is created
+@@ -530,6 +536,13 @@ ped_unit_parse_custom (const char* str, const PedDevice* dev, PedUnit unit,
+ radius = ped_div_round_up (unit_size, dev->sector_size) - 1;
+ if (radius < 0)
+ radius = 0;
++ /* If the user specified units in a power of 2, e.g., 1MiB, as in
++ parted -s -- $dev mklabel gpt mkpart P-NAME 1MiB -34s
++ do not use 1MiB as the range. Rather, presume that they
++ are specifying precisely the starting or ending number,
++ and treat "1MiB" just as we would treat "1048576B". */
++ if (is_power_of_2 (unit_size))
++ radius = 0;
+
+ *sector = num * unit_size / dev->sector_size;
+ /* negative numbers count from the end */
+
+_______________________________________________
+bug-parted mailing list
+bug-parted@gnu.org
+http://lists.gnu.org/mailman/listinfo/bug-parted
diff --git a/recipes/parted/parted_2.3.bb b/recipes/parted/parted_2.3.bb
index d2ac30300d..f3b596ca55 100644
--- a/recipes/parted/parted_2.3.bb
+++ b/recipes/parted/parted_2.3.bb
@@ -3,9 +3,11 @@ HOMEPAGE = "http://www.gnu.org/software/parted/parted.html"
LICENSE = "GPLv3"
SECTION = "console/tools"
DEPENDS = "readline util-linux-ng lvm2"
+PR = "r1"
SRC_URI = "${GNU_MIRROR}/parted/parted-${PV}.tar.gz \
file://use_llseek_syscall.patch \
+ file://fix-MiB-handling.patch \
"
EXTRA_OECONF = "--disable-Werror ac_cv_func_calloc_0_nonnull=yes"