chiark / gitweb /
[PATCH] udevinfo patch
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Thu, 1 Apr 2004 07:00:45 +0000 (23:00 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:35:13 +0000 (21:35 -0700)
On Fri, Mar 26, 2004 at 06:36:32PM +0500, Ananth N Mavinakayanahalli wrote:
> On Fri, Mar 26, 2004 at 11:24:39AM +0100, Kay Sievers wrote:
> > On Fri, Mar 26, 2004 at 11:21:29AM +0500, Ananth N Mavinakayanahalli wrote:
> > > On Fri, Mar 26, 2004 at 04:47:35AM +0100, Kay Sievers wrote:
> > > > On Fri, Mar 26, 2004 at 01:26:46AM +0100, Carl-Daniel Hailfinger wrote:
> > > > > Greg KH wrote:
> > > > > > On Tue, Mar 23, 2004 at 01:51:01PM -0800, Daniel Stekloff wrote:
> > > >
> > > > No, it breaks the net device handling. I think we should change
> > > > libsysfs instead, not to return a class device for '/block', if
> > > > we want to fix it.
> > >
> > > /sys/block is considered a sysfs "class" and not a class_device. So,
> > > going by udevinfo's help, -p expects path to a class_device and _not_
> > > a class itself and hence option /sys/block with -p is not a valid query.
> > >
> > > Kay?
> >
> > Yes, it's invalid, but we shouldn't print major minor for a invalid
> > path. sysfs_open_class_device_path("/block") returns a device. If this is
> > the right behavior for libsysfs, I will change the get_device_type("/block")
> > not to return a 'b'-type.
>
> Libsysfs validates the path given to it for opening a class_device to be
> a valid directory; it does not however validate if the path is a valid
> class_device path. So, in the case of udevinfo, a 'b' type should not
> be returned if the path is just /sys/block or /sys/block/

This may prevent it.

udev_lib.c

index e9c16c863a3407ac0705923c375b8264441b3f39..db1096ebf7b7254847c98f521d44e462cd373961 100644 (file)
@@ -86,17 +86,28 @@ char *get_subsystem(char *subsystem)
        return subsystem;
 }
 
        return subsystem;
 }
 
+#define BLOCK_PATH             "/block/"
+#define CLASS_PATH             "/class/"
+#define NET_PATH               "/class/net/"
+
 char get_device_type(const char *path, const char *subsystem)
 {
 char get_device_type(const char *path, const char *subsystem)
 {
-       if (strcmp(subsystem, "block") == 0 ||
-           strstr(path, "/block/") != NULL)
+       if (strcmp(subsystem, "block") == 0)
+               return 'b';
+
+       if (strcmp(subsystem, "net") == 0)
+               return 'n';
+
+       if (strncmp(path, BLOCK_PATH, strlen(BLOCK_PATH)) == 0 &&
+           strlen(path) > strlen(BLOCK_PATH))
                return 'b';
 
                return 'b';
 
-       if (strcmp(subsystem, "net") == 0 ||
-           strstr(path, "/class/net/") != NULL)
+       if (strncmp(path, NET_PATH, strlen(NET_PATH)) == 0 &&
+           strlen(path) > strlen(NET_PATH))
                return 'n';
 
                return 'n';
 
-       if (strstr(path, "/class/") != NULL)
+       if (strncmp(path, CLASS_PATH, strlen(CLASS_PATH)) == 0 &&
+           strlen(path) > strlen(CLASS_PATH))
                return 'c';
 
        return '\0';
                return 'c';
 
        return '\0';