summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-device/device-enumerator.c
AgeCommit message (Collapse)Author
2016-06-26sd-device: enumerator - do not abort enumeration if a device failsTom Gundersen
Collect the errors and return to the caller, but continue enumerating all devices.
2015-11-27tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering
GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-27util-lib: introduce dirent-util.[ch] for directory entry callsLennart Poettering
Also, move a couple of more path-related functions to path-util.c.
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-09-30tree-wide: remove a number of invocations of strerror() and replace by %mLennart Poettering
Let's clean up our tree a bit, and reduce invocations of the thread-unsafe strerror() by replacing it with printf()'s %m specifier.
2015-08-22sd-device: fix enumeration of devices without subsystemMaxim Mikityanskiy
Prior to commit c32eb440bab953a0169cd207dfef5cad16dfb340, libudev's function udev_enumerate_scan_devices() had behaved differently. If parent match was added with udev_enumerate_add_match_parent(), udev_enumerate_scan_devices() did not return error if some child devices had no subsystem symlink in sysfs. An example of such devices is USB endpoints /sys/bus/usb/devices/*/ep_*. If there was a parent match against USB device, old implementation of udev_enumerate_scan_devices() did not treat ep_* device directories without subsystem symlink as error and just ignored them, but new implementation returns -ENOENT (also ignoring these devices) though correctly enumerates all other matching devices. To compare, you could look at 96df036fe3d25525a44f5efdb2fc8560e82e6cfd, in src/libudev/libudev-enumerate.c, function parent_add_child(): if (!match_subsystem(enumerate, udev_device_get_subsystem(dev))) goto nomatch; udev_device_get_subsystem() was returning NULL, match_subsystem() was returning false, and USB endpoint device was ignored. New parent_add_child() from src/libsystemd/sd-device/device-enumerator.c checks return value of sd_device_get_subsystem() and fails if subsystem was not found. Absence of subsystem symlink should not be really treated as error because all enumerations of children of USB devices will fail with -ENOENT. This new behavior also breaks system-config-printer. So restore old behavior and treat absence of subsystem symlink as no match.
2015-06-03libudev: enumerate - accept NULL parameters in add_match()Tom Gundersen
This was a regression introduced when moving to sd-device.
2015-05-28sd-device: enumerator - fix matching on properties and sysattrsTom Gundersen
This was a regression that broke $ udevadm trigger -nv --property-match=DEVNAME=/dev/sda1 --attr-match=size=409600 Reported by David Reisner.
2015-05-20sd-device: fix return codes on errorZbigniew Jędrzejewski-Szmek
asprintf() does not set errno.
2015-04-17sd-device: simplify enumerator hacksDavid Herrmann
Boolean arithmetic is great, use it! if (a && !b) return 1; if (!a && b) return -1, is equivalent to if (a != b) return a - b; Furthermore: r = false; if (condition) r = true; is equivalent to: r = condition;
2015-04-17sd-device: uniformly handle missing devicesTom Gundersen
sd_device_new_from_* now returns -ENODEV when the device does not exist, and the enumerator silently drops these errors as missing devices is exepected.
2015-04-17sd-device: enumerator - match only on initialized devices by defaultTom Gundersen
It is still possible to include uninitialized ones, but now that is opt-in. In most cases people only want initialized devices. Exception is if you want to work without udev running. Suggested by David Herrmann.
2015-04-17sd-device: enumerator - don't expose add_device()Tom Gundersen
This is rarely, if ever, used. Drop it from the new public API and only keep it for the legacy API. Suggested by David Herrmann.
2015-04-16sd-device: add device-enumerator libraryTom Gundersen