[systemd-devel] unbinding using libudev
Lennart Poettering
lennart at poettering.net
Fri Jan 10 09:05:13 UTC 2020
On Do, 09.01.20 20:17, Michael K (vk2bea at yahoo.com) wrote:
> I'm trying to use libudev to unbind a usb device from usb-storage driver ..This does not seem to work. Can I even do what I'm trying to do or am I just doing it wrong ?In the shell # echo -n "1-1.1:1.0" > /sys/bus/usb/drivers/usb-storage/unbind works but this doesn't ...
> gchar *sTestUFD= "1-1.1:1.0";
> struct udev *udev = udev_new(); struct udev_device *device; if( (device = udev_device_new_from_syspath( udev, "/sys/bus/usb/drivers/usb-storage" )) != NULL ) { if( udev_device_set_sysattr_value( device, "unbind", sTestUFD ) < 0 ) { sd_journal_print( LOG_NOTICE, "Cannot unbind %s", sTestUFD ); } udev_device_unref( device ); } else { sd_journal_perror( "Cannot get /sys/bus/usb/drivers/usb-storage" ); } udev_unref( udev );
Please send proper ASCII emails, the above is just really borked.
The code looks roughly OK, but maybe strace it to see if it does the
right things.
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list