[Parted-maintainers] Bug#311664: parted: still broken with udev and devfs.rules

Colin Watson Colin Watson <cjwatson@debian.org>, 311664@bugs.debian.org
Thu, 2 Jun 2005 15:44:08 +0100


--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Package: parted
Version: 1.6.21-1
Severity: normal
Tags: patch

(Originally noticed as
https://bugzilla.ubuntu.com/show_bug.cgi?id=11426)

parted still breaks with udev and devfs.rules. Sorry I didn't notice
this earlier; I looked at this line in libparted/linux.c:

        if (_have_devfs() && !strcmp (dev->path + path_len - 5, "/disc")) {

... and it looked sufficiently similar to what I'd done earlier that I
didn't notice that the test was &&, not ||. (Of course, || would be
wrong too, since the code inside that if branch assumes that the strcmp
matched.)

I suggest the attached patch. The _have_devfs() test is basically
pointless; the traditional Linux device naming scheme doesn't have any
devices that end with "/disc", so you might as well just test for that
unconditionally.

Cheers,

-- 
Colin Watson                                       [cjwatson@debian.org]

--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="udev-devfs-rules.dpatch"

#! /bin/sh /usr/share/dpatch/dpatch-run
## udev-devfs-rules.dpatch by Colin Watson <cjwatson@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Check for devfs-style /disc => /partN transformation
## DP: unconditionally; the system might be using udev with devfs rules, and
## DP: if not the test is harmless.

@DPATCH@
diff -urNad parted-1.6.21/libparted/linux.c /tmp/dpep.MJvQsa/parted-1.6.21/libparted/linux.c
--- parted-1.6.21/libparted/linux.c	2005-01-16 01:01:57.000000000 +0000
+++ /tmp/dpep.MJvQsa/parted-1.6.21/libparted/linux.c	2005-06-02 15:29:26.104229608 +0100
@@ -1443,7 +1443,7 @@
 		return NULL;
 
 	/* FIXME: how do we know if a device is devfs or not? */
-	if (_have_devfs() && !strcmp (dev->path + path_len - 5, "/disc")) {
+	if (!strcmp (dev->path + path_len - 5, "/disc")) {
 		/* replace /disc with /path%d */
 		strcpy (result, dev->path);
 	        snprintf (result + path_len - 5, 16, "/part%d", num);

--0OAP2g/MAC+5xKAE--