libudev: device - add devtype support
PATCH 1/1 libudev: device - add devtype support
Hi Kay,
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements udev_device_get_devtype() and also udev_device_get_parent_with_devtype(). Please double check that I did it the right way.
Regards
Marcel
From 9a1f276ac8f47e082512a938deb2f04b62b63f5c Mon Sep 17 00:00:00 2001
From: Marcel Holtmann <[email protected]>
Date: Fri, 2 Jan 2009 04:14:47 +0100
Subject: [PATCH] libudev: device - add devtype support
--- udev/lib/exported_symbols | 2 + udev/lib/libudev-device.c | 53 +++++++++++++++++++++++++++++++++++++++++++- udev/lib/libudev-monitor.c | 2 + udev/lib/libudev-private.h | 1 + udev/lib/libudev.h | 2 + udev/lib/test-libudev.c | 4 +++ 6 files changed, 63 insertions(+), 1 deletions(-)
udev/lib/exported_symbols +2 -0
@@ -17,6 +17,7 @@ udev_device_new_from_devnum udev_device_new_from_subsystem_sysname udev_device_get_parent udev_device_get_parent_with_subsystem +udev_device_get_parent_with_devtype udev_device_ref udev_device_unref udev_device_get_udev
@@ -26,6 +27,7 @@ udev_device_get_devnode udev_device_get_sysname udev_device_get_sysnum udev_device_get_subsystem +udev_device_get_devtype udev_device_get_devlinks_list_entry udev_device_get_properties_list_entry udev_device_get_action
udev/lib/libudev-device.c +52 -1
95 lines not on this page · raw message
udev/lib/libudev-monitor.c +2 -0
@@ -325,6 +325,8 @@ struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monito }else if (strncmp (key,"SUBSYSTEM=" ,10 ) ==0 ) {udev_device_set_subsystem (udev_device, &key[10 ]); subsystem_set =1 ; + }else if (strncmp (key,"DEVTYPE=" ,8 ) ==0 ) { +udev_device_set_devtype (udev_device, &key[8 ]); }else if (strncmp (key,"DEVNAME=" ,8 ) ==0 ) {udev_device_set_devnode (udev_device, &key[8 ]); }else if (strncmp (key,"DEVLINKS=" ,9 ) ==0 ) {
udev/lib/libudev-private.h +1 -0
@@ -56,6 +56,7 @@ extern struct udev_list_entry *udev_get_properties_list_entry(struct udev *udev)/* libudev-device */ extern int udev_device_set_syspath (struct udev_device *udev_device,const char *syspath);extern int udev_device_set_subsystem (struct udev_device *udev_device,const char *subsystem); +extern int udev_device_set_devtype (struct udev_device *udev_device,const char *devtype);extern int udev_device_set_devnode (struct udev_device *udev_device,const char *devnode);extern int udev_device_add_devlink (struct udev_device *udev_device,const char *devlink);extern void udev_device_cleanup_devlinks_list (struct udev_device *udev_device);
udev/lib/libudev.h +2 -0
@@ -63,11 +63,13 @@ extern struct udev_device *udev_device_new_from_devnum(struct udev *udev, char textern struct udev_device *udev_device_new_from_subsystem_sysname (struct udev *udev,const char *subsystem,const char *sysname);extern struct udev_device *udev_device_get_parent (struct udev_device *udev_device);extern struct udev_device *udev_device_get_parent_with_subsystem (struct udev_device *udev_device,const char *subsystem); +extern struct udev_device *udev_device_get_parent_with_devtype (struct udev_device *udev_device,const char *devtype);extern struct udev_device *udev_device_ref (struct udev_device *udev_device);extern void udev_device_unref (struct udev_device *udev_device);extern struct udev *udev_device_get_udev (struct udev_device *udev_device);extern const char *udev_device_get_devpath (struct udev_device *udev_device);extern const char *udev_device_get_subsystem (struct udev_device *udev_device); +extern const char *udev_device_get_devtype (struct udev_device *udev_device);extern const char *udev_device_get_syspath (struct udev_device *udev_device);extern const char *udev_device_get_sysname (struct udev_device *udev_device);extern const char *udev_device_get_sysnum (struct udev_device *udev_device);
udev/lib/test-libudev.c +4 -0
@@ -67,6 +67,10 @@ static void print_device(struct udev_device *device)if (str !=NULL )printf ("subsystem: '%s'\n" , str); + str =udev_device_get_devtype (device); +if (str !=NULL ) +printf ("devtype: '%s'\n" , str); + str =udev_device_get_driver (device);if (str !=NULL )printf ("driver: '%s'\n" , str);
Signature · 1 line
1.5.6.3
Quoted 7 lines · Marcel Holtmann
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.
Looks good. Applied.
Thanks,
Kay
Hi Kay,
Quoted 9 lines
Quoted 7 lines
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.Looks good. Applied.
one minor thing that came to my mind is that DEVTYPE and subsystem are actually kinda coupled. So a DEVTYPE="host" has a different semantic for USB than for Bluetooth subsystem for example. Not sure if we actually care or just add a udev_device_get_parent_with_subsystem_devtype() function to give applications a choice if they wanna care.
Regards
Marcel
Quoted 8 lines · Marcel Holtmann
Quoted 8 lines
Quoted 7 lines
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.
Quoted 7 lines
Quoted 1 line
Looks good. Applied.
one minor thing that came to my mind is that DEVTYPE and subsystem are actually kinda coupled. So a DEVTYPE="host" has a different semantic for USB than for Bluetooth subsystem for example. Not sure if we actually care or just add a
udev_device_get_parent_with_subsystem_devtype()function to give applications a choice if they wanna care.
You mean replacing:
udev_device_get_parent_with_devtype(..., *devtype)
by:
udev_device_get_parent_with_subsystem_devtype(..., *subsystem, *devtype)
?
Sounds sensible, because in most cases you don't want to check for parents of a different subsystem. As you are using it, want to send a patch?
Thanks,
Kay
Hi Kay,
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.Quoted 7 lines
Quoted 1 line
Looks good. Applied.
one minor thing that came to my mind is that DEVTYPE and subsystem are actually kinda coupled. So a DEVTYPE="host" has a different semantic for USB than for Bluetooth subsystem for example. Not sure if we actually care or just add a
udev_device_get_parent_with_subsystem_devtype()function to give applications a choice if they wanna care.You mean replacing:
udev_device_get_parent_with_devtype(..., *devtype)
by:
udev_device_get_parent_with_subsystem_devtype(..., *subsystem, *devtype)
?
Quoted 3 lines
Sounds sensible, because in most cases you don't want to check for parents of a different subsystem. As you are using it, want to send a patch?
I am thinking of keeping both. So just adding ...subsystem_devtype() and keeping also the original one. My reason for it is that in some case you already know the subsystem you are looking at (or don't care in). So no point in doing a lookup with two checks.
And yes, I can write a patch for it.
Regards
Marcel
Quoted 22 lines · Marcel Holtmann
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.Quoted 7 lines
Quoted 1 line
Looks good. Applied.
one minor thing that came to my mind is that DEVTYPE and subsystem are actually kinda coupled. So a DEVTYPE="host" has a different semantic for USB than for Bluetooth subsystem for example. Not sure if we actually care or just add a
udev_device_get_parent_with_subsystem_devtype()function to give applications a choice if they wanna care.You mean replacing:
udev_device_get_parent_with_devtype(..., *devtype)
by:
udev_device_get_parent_with_subsystem_devtype(..., *subsystem, *devtype)
?
Quoted 8 lines
Quoted 3 lines
Sounds sensible, because in most cases you don't want to check for parents of a different subsystem. As you are using it, want to send a patch?
I am thinking of keeping both. So just adding ...subsystem_devtype() and keeping also the original one. My reason for it is that in some case you already know the subsystem you are looking at (or don't care in). So no point in doing a lookup with two checks.
We could make it accept NULL for the subsystem in that case?
Kay
Quoted 10 lines · Marcel Holtmann
Hi Kay,
Quoted 8 lines
Quoted 7 lines
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.
Quoted 7 lines
Quoted 1 line
Looks good. Applied.
one minor thing that came to my mind is that DEVTYPE and subsystem are actually kinda coupled. So a DEVTYPE="host" has a different semantic for USB than for Bluetooth subsystem for example. Not sure if we actually care or just add a
udev_device_get_parent_with_subsystem_devtype()function to give applications a choice if they wanna care.
Isn't DEVTYPE in the environment already? If so, just use the new API added here
http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;hð89350234e39b868a5e3df71a8f8c036aaae4fd
instead of Marcel's patch?
David
Quoted 11 lines · David Zeuthen
Quoted 10 lines · Marcel Holtmann
Quoted 9 lines
Quoted 7 lines
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.Looks good. Applied.
Quoted 7 lines
Quoted 5 lines
one minor thing that came to my mind is that DEVTYPE and subsystem are actually kinda coupled. So a DEVTYPE="host" has a different semantic for USB than for Bluetooth subsystem for example. Not sure if we actually care or just add a
udev_device_get_parent_with_subsystem_devtype()function to give applications a choice if they wanna care.Isn't DEVTYPE in the environment already?
Yeah, it's a property, just like SUBSYSTEM is. But It's a "core property", like a "subsystem subtype" which sounds fine to support in the API.
Quoted 5 lines
If so, just use the new API added here
http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;hð89350234e39b868a5e3df71a8f8c036aaae4fd
instead of Marcel's patch?
In many cases you just walk along the parent devices, and lookup a specific device, without introducing dependencies on the specific devpath position, like the "two directories up"-crap many tools do. The enumeration API, which searches over all /sys devices does not really fit here.
Kay
Hi David,
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.Quoted 7 lines
Quoted 1 line
Looks good. Applied.
one minor thing that came to my mind is that DEVTYPE and subsystem are actually kinda coupled. So a DEVTYPE="host" has a different semantic for USB than for Bluetooth subsystem for example. Not sure if we actually care or just add a
udev_device_get_parent_with_subsystem_devtype()function to give applications a choice if they wanna care.
Quoted 6 lines
Isn't DEVTYPE in the environment already? If so, just use the new API added here
http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;hð89350234e39b868a5e3df71a8f8c036aaae4fd
instead of Marcel's patch?
the use case here is different. You need udev_device_get_parent... ones if you are receiving your device via a monitor. Using the enumeration API only produces overhead.
The other main issue was that DEVTYPE has to be read from the uevent sysfs file like MAJOR and MINOR in some cases.
An example where this is useful is for all the USB and SDIO composite devices where you have to apply different policies if they share the same parent. One example is a WiFi/WiMAX combo where the actual physical radio is shared and thus only one can be active at a time. For the kernel these two look like independent device, but in userspace we have to apply certain policies. Otherwise nothing will work.
Also the problem with USB is that the parent is most times from DEVTYPE usb_interface and that doesn't help. You have to go all up to usb_device before you know that it is actually the same physical device.
Regards
Marcel
Quoted 27 lines · Kay Sievers
Quoted 26 lines · Marcel Holtmann
Quoted 25 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.Quoted 7 lines
Quoted 1 line
Looks good. Applied.
one minor thing that came to my mind is that DEVTYPE and subsystem are actually kinda coupled. So a DEVTYPE="host" has a different semantic for USB than for Bluetooth subsystem for example. Not sure if we actually care or just add a
udev_device_get_parent_with_subsystem_devtype()function to give applications a choice if they wanna care.You mean replacing:
udev_device_get_parent_with_devtype(..., *devtype)
by:
udev_device_get_parent_with_subsystem_devtype(..., *subsystem, *devtype)
?Sounds sensible, because in most cases you don't want to check for parents of a different subsystem. As you are using it, want to send a patch?
Quoted 6 lines
Quoted 4 lines
I am thinking of keeping both. So just adding ...subsystem_devtype() and keeping also the original one. My reason for it is that in some case you already know the subsystem you are looking at (or don't care in). So no point in doing a lookup with two checks.
We could make it accept NULL for the subsystem in that case?
I guess, we should just have udev_device_get_parent_with_subsystem_devtype(), and drop the both other ones, and accept NULL as parameters, if you want to match only one. You are right that subsystem and devtype belong together, so we should probably reflect that in the API. Any problems with such change?
Thanks,
Kay
Hi Kay,
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.Quoted 7 lines
Quoted 1 line
Looks good. Applied.
one minor thing that came to my mind is that DEVTYPE and subsystem are actually kinda coupled. So a DEVTYPE="host" has a different semantic for USB than for Bluetooth subsystem for example. Not sure if we actually care or just add a
udev_device_get_parent_with_subsystem_devtype()function to give applications a choice if they wanna care.You mean replacing:
udev_device_get_parent_with_devtype(..., *devtype)
by:
udev_device_get_parent_with_subsystem_devtype(..., *subsystem, *devtype)
?Quoted 3 lines
Sounds sensible, because in most cases you don't want to check for parents of a different subsystem. As you are using it, want to send a patch?
I am thinking of keeping both. So just adding ...subsystem_devtype() and keeping also the original one. My reason for it is that in some case you already know the subsystem you are looking at (or don't care in). So no point in doing a lookup with two checks.
Quoted 8 lines
Quoted 1 line
We could make it accept NULL for the subsystem in that case?
I guess, we should just have
udev_device_get_parent_with_subsystem_devtype(), and drop the both other ones, and accept NULL as parameters, if you want to match only one. You are right that subsystem and devtype belong together, so we should probably reflect that in the API. Any problems with such change?
I think that make sense. So I opted for allowing devtype being NULL while subsystem is required. I tried to come up with a good reason why you would look for devtype and not subsystem and couldn't find it right now. The USB case is double information since they prefixed their devtypes with "usb_", but that is really an USB subsystem problem. For Bluetooth I am not doing this at all and neither does SCSI. In future no subsystem should.
So patch 0001 renames ..with_devtype() into ..with_subsystem_devtype() and then patch 0002 removes ..with_subsystem() and replaces its usage.
Regards
Marcel
From 53eb85ecb5bff49449b79174734f7d32d85c5af6 Mon Sep 17 00:00:00 2001
From: Marcel Holtmann <[email protected]>
Date: Sat, 3 Jan 2009 11:10:10 +0100
Subject: [PATCH] libudev: device - lookup subsystem and devtype together
--- udev/lib/exported_symbols | 2 +- udev/lib/libudev-device.c | 17 +++++++++++++---- udev/lib/libudev.h | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-)
udev/lib/exported_symbols +1 -1
@@ -17,7 +17,7 @@ udev_device_new_from_devnum udev_device_new_from_subsystem_sysname udev_device_get_parent udev_device_get_parent_with_subsystem -udev_device_get_parent_with_devtype +udev_device_get_parent_with_subsystem_devtype udev_device_ref udev_device_unref udev_device_get_udev
udev/lib/libudev-device.c +13 -4
@@ -557,17 +557,26 @@ struct udev_device *udev_device_get_parent_with_subsystem(struct udev_device *udreturn parent; } -struct udev_device *udev_device_get_parent_with_devtype (struct udev_device *udev_device,const char *devtype) +struct udev_device *udev_device_get_parent_with_subsystem_devtype (struct udev_device *udev_device,const char *subsystem,const char *devtype) {struct udev_device *parent; +if (subsystem ==NULL ) +return NULL ; + parent =udev_device_get_parent (udev_device);while (parent !=NULL ) { +const char *parent_subsystem;const char *parent_devtype; - parent_devtype =udev_device_get_devtype (parent); -if (parent_devtype !=NULL &&strcmp (parent_devtype, devtype) ==0 ) -break ; + parent_subsystem =udev_device_get_subsystem (parent); +if (parent_subsystem !=NULL &&strcmp (parent_subsystem, subsystem) ==0 ) { +if (devtype ==NULL ) +break ; + parent_devtype =udev_device_get_devtype (parent); +if (parent_devtype !=NULL &&strcmp (parent_devtype, devtype) ==0 ) +break ; + } parent =udev_device_get_parent (parent); }return parent;
udev/lib/libudev.h +1 -1
@@ -63,7 +63,7 @@ extern struct udev_device *udev_device_new_from_devnum(struct udev *udev, char textern struct udev_device *udev_device_new_from_subsystem_sysname (struct udev *udev,const char *subsystem,const char *sysname);extern struct udev_device *udev_device_get_parent (struct udev_device *udev_device);extern struct udev_device *udev_device_get_parent_with_subsystem (struct udev_device *udev_device,const char *subsystem); -extern struct udev_device *udev_device_get_parent_with_devtype (struct udev_device *udev_device,const char *devtype); +extern struct udev_device *udev_device_get_parent_with_subsytem_devtype (struct udev_device *udev_device,const char *subsystem,const char *devtype);extern struct udev_device *udev_device_ref (struct udev_device *udev_device);extern void udev_device_unref (struct udev_device *udev_device);extern struct udev *udev_device_get_udev (struct udev_device *udev_device);
Signature · 1 line
1.5.6.3
From 9ad3a8779559099a0b55c361b46a861a407786db Mon Sep 17 00:00:00 2001
From: Marcel Holtmann <[email protected]>
Date: Sat, 3 Jan 2009 11:13:51 +0100
Subject: [PATCH] libudev: device - remove udev_device_get_parent_with_subsystem
--- extras/usb_id/usb_id.c | 6 +++--- udev/lib/exported_symbols | 1 - udev/lib/libudev-device.c | 16 ---------------- udev/lib/libudev.h | 1 - 4 files changed, 3 insertions(+), 21 deletions(-)
extras/usb_id/usb_id.c +3 -3
@@ -192,7 +192,7 @@ static int usb_id(struct udev_device *dev)dbg (udev,"syspath %s\n" ,udev_device_get_syspath (dev));/* usb interface directory */ - dev_interface =udev_device_get_parent_with_subsystem (dev,"usb" ); + dev_interface =udev_device_get_parent_with_subsystem_devtype (dev,"usb" ,NULL );if (dev_interface ==NULL ) {info (udev,"unable to access usb_interface device of '%s'\n" ,udev_device_get_syspath (dev));
@@ -218,7 +218,7 @@ static int usb_id(struct udev_device *dev) udev_device_get_syspath(dev_interface), if_class_num, protocol);/* usb device directory */ - dev_usb =udev_device_get_parent_with_subsystem (dev_interface,"usb" ); + dev_usb =udev_device_get_parent_with_subsystem_devtype (dev_interface,"usb" ,NULL );if (!dev_usb) {info (udev,"unable to find parent 'usb' device of '%s'\n" ,udev_device_get_syspath (dev));
@@ -232,7 +232,7 @@ static int usb_id(struct udev_device *dev)int host, bus, target, lun;/* get scsi device */ - dev_scsi =udev_device_get_parent_with_subsystem (dev,"scsi" ); + dev_scsi =udev_device_get_parent_with_subsystem_devtype (dev,"scsi" ,NULL );if (dev_scsi ==NULL ) {info (udev,"unable to find parent 'scsi' device of '%s'\n" ,udev_device_get_syspath (dev));
udev/lib/exported_symbols +0 -1
@@ -16,7 +16,6 @@ udev_device_new_from_syspath udev_device_new_from_devnum udev_device_new_from_subsystem_sysname udev_device_get_parent -udev_device_get_parent_with_subsystem udev_device_get_parent_with_subsystem_devtype udev_device_ref udev_device_unref
udev/lib/libudev-device.c +0 -16
@@ -541,22 +541,6 @@ struct udev_device *udev_device_get_parent(struct udev_device *udev_device)return udev_device->parent_device; } -struct udev_device *udev_device_get_parent_with_subsystem (struct udev_device *udev_device,const char *subsystem) -{ -struct udev_device *parent; - - parent =udev_device_get_parent (udev_device); -while (parent !=NULL ) { -const char *parent_subsystem; - - parent_subsystem =udev_device_get_subsystem (parent); -if (parent_subsystem !=NULL &&strcmp (parent_subsystem, subsystem) ==0 ) -break ; - parent =udev_device_get_parent (parent); - } -return parent; -} -struct udev_device *udev_device_get_parent_with_subsystem_devtype (struct udev_device *udev_device,const char *subsystem,const char *devtype) {struct udev_device *parent;
udev/lib/libudev.h +0 -1
@@ -62,7 +62,6 @@ extern struct udev_device *udev_device_new_from_syspath(struct udev *udev, constextern struct udev_device *udev_device_new_from_devnum (struct udev *udev,char type,dev_t devnum);extern struct udev_device *udev_device_new_from_subsystem_sysname (struct udev *udev,const char *subsystem,const char *sysname);extern struct udev_device *udev_device_get_parent (struct udev_device *udev_device); -extern struct udev_device *udev_device_get_parent_with_subsystem (struct udev_device *udev_device,const char *subsystem);extern struct udev_device *udev_device_get_parent_with_subsytem_devtype (struct udev_device *udev_device,const char *subsystem,const char *devtype);extern struct udev_device *udev_device_ref (struct udev_device *udev_device);extern void udev_device_unref (struct udev_device *udev_device);
Signature · 1 line
1.5.6.3
Quoted 40 lines · Marcel Holtmann
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.Quoted 7 lines
Quoted 1 line
Looks good. Applied.
one minor thing that came to my mind is that DEVTYPE and subsystem are actually kinda coupled. So a DEVTYPE="host" has a different semantic for USB than for Bluetooth subsystem for example. Not sure if we actually care or just add a
udev_device_get_parent_with_subsystem_devtype()function to give applications a choice if they wanna care.You mean replacing:
udev_device_get_parent_with_devtype(..., *devtype)
by:
udev_device_get_parent_with_subsystem_devtype(..., *subsystem, *devtype)
?Quoted 3 lines
Sounds sensible, because in most cases you don't want to check for parents of a different subsystem. As you are using it, want to send a patch?
I am thinking of keeping both. So just adding ...subsystem_devtype() and keeping also the original one. My reason for it is that in some case you already know the subsystem you are looking at (or don't care in). So no point in doing a lookup with two checks.
Quoted 8 lines
Quoted 1 line
We could make it accept NULL for the subsystem in that case?
I guess, we should just have
udev_device_get_parent_with_subsystem_devtype(), and drop the both other ones, and accept NULL as parameters, if you want to match only one. You are right that subsystem and devtype belong together, so we should probably reflect that in the API. Any problems with such change?
Quoted 7 lines
I think that make sense. So I opted for allowing devtype being NULL while subsystem is required. I tried to come up with a good reason why you would look for devtype and not subsystem and couldn't find it right now. The USB case is double information since they prefixed their devtypes with "
usb_", but that is really an USB subsystem problem. For Bluetooth I am not doing this at all and neither does SCSI. In future no subsystem should.
Yeah, sounds all fine. Patches are applied.
Thanks a lot,
Kay
Hi Kay,
Quoted 48 lines
Quoted 40 lines
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
I was playing a little bit with libudev and I actually need the DEVTYPE from uevent for various tasks. Especially with USB and Bluetooth, the subsystem value is too generic.
Attached is a patch that implements
udev_device_get_devtype()and alsoudev_device_get_parent_with_devtype(). Please double check that I did it the right way.Quoted 7 lines
Quoted 1 line
Looks good. Applied.
one minor thing that came to my mind is that DEVTYPE and subsystem are actually kinda coupled. So a DEVTYPE="host" has a different semantic for USB than for Bluetooth subsystem for example. Not sure if we actually care or just add a
udev_device_get_parent_with_subsystem_devtype()function to give applications a choice if they wanna care.You mean replacing:
udev_device_get_parent_with_devtype(..., *devtype)
by:
udev_device_get_parent_with_subsystem_devtype(..., *subsystem, *devtype)
?Quoted 3 lines
Sounds sensible, because in most cases you don't want to check for parents of a different subsystem. As you are using it, want to send a patch?
I am thinking of keeping both. So just adding ...subsystem_devtype() and keeping also the original one. My reason for it is that in some case you already know the subsystem you are looking at (or don't care in). So no point in doing a lookup with two checks.
Quoted 8 lines
Quoted 1 line
We could make it accept NULL for the subsystem in that case?
I guess, we should just have
udev_device_get_parent_with_subsystem_devtype(), and drop the both other ones, and accept NULL as parameters, if you want to match only one. You are right that subsystem and devtype belong together, so we should probably reflect that in the API. Any problems with such change?Quoted 7 lines
I think that make sense. So I opted for allowing devtype being NULL while subsystem is required. I tried to come up with a good reason why you would look for devtype and not subsystem and couldn't find it right now. The USB case is double information since they prefixed their devtypes with "
usb_", but that is really an USB subsystem problem. For Bluetooth I am not doing this at all and neither does SCSI. In future no subsystem should.
Quoted 1 line
Yeah, sounds all fine. Patches are applied.
you even fixed my typo. Just found that one a few minutes ago. Thanks :)
Regards
Marcel