summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-device
AgeCommit message (Collapse)Author
2015-07-15sd-device: never return NULL+0David Herrmann
It is highly confusing if a getter function returns 0, but the value is set to NULL. This, right now, triggers assertions as code relies on the returned values to be non-NULL. Like with sd-bus-creds and friends, return 0 only if a value is actually available. Discussed with Tom, and actually fixes real bugs as in #512.
2015-06-14hashmap: fix iterators to not skip entriesDavid Herrmann
Currently, the HASHMAP iterators stop at the first NULL entry in a hashmap. This is non-obvious and breaks users like sd-device, which legitimately store NULL values in a hashmap. Fix all the iterators by taking a pointer to the value storage, instead of returning it. The iterators now return a boolean that tells whether the end of the list was reached. Current users of HASHMAP_FOREACH() are *NOT* changed to explicitly check for NULL. If it turns out, there were users that inserted NULL into hashmaps, but didn't properly check for it during iteration, then we really want to find those and fix them.
2015-06-03libudev: enumerate - accept NULL parameters in add_match()Tom Gundersen
This was a regression introduced when moving to sd-device.
2015-06-02fix double semicolon typoThomas Hindoe Paaboel Andersen
2015-06-02sd-device: get_driver - remember if a device does not have a driverTom Gundersen
Don't try to read it again.
2015-06-02sd-device: get_subsystem - don't complain if a device does not have a subsystemTom Gundersen
2015-06-01sd-device: ensure update_properties_buf() is a noop on failureTom Gundersen
Don't clobber the sd_device struct, and don't leak memory when memory allocation fails.
2015-06-01sd-device: fix invalid property strv pointersMartin Pitt
In device_update_properties_bufs(), the strv is built from pointers into the single nul-terminated buf_nulstr string, to avoid allocating the key=value strings twice. However, we must not do that while building and GREEDY_REALLOC0()'ing buf_nulstr, as each time when this actually reallocates memory the pointers we wrote into buf_strv so far become invalid. So change the logic to first completely build the new buf_nulstr, and then iterate over it to pick out the pointers to the individual key=value strings for properties_strv. This fixes invalid environment for udev callouts.
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-27sd-device: fix device_get_properties_strv()Tom Gundersen
A NULL pointer was inserted as the first element of the strv. This had the effect of always passing the empty environment to processes spawned by udev. Reported by Michał Bartoszkiewicz.
2015-05-20sd-device: fix return codes on errorZbigniew Jędrzejewski-Szmek
asprintf() does not set errno.
2015-04-26sd-device: don't retry loading uevent/db files more than onceTom Gundersen
If for whatever reason there was nothing to load or loading failed, don't keep trying.
2015-04-26sd-device: don't complain if the uevent file is missingTom Gundersen
Only 'real' devices are required to have an uevent file.
2015-04-23udevd: fix REMOVE handlingTom Gundersen
This reverts b67f944. Lazy loading of device properties does not work for devices that are received over netlink, as these are sealed. Reinstate the unconditional loading of the device db. Reported by: Mantas Mikulėnas <grawity@gmail.com>.
2015-04-21sd-device: set_syspath - return ENODEV when passed something that is not a ↵Tom Gundersen
device
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
2015-04-14sd-device: fix typoZbigniew Jędrzejewski-Szmek
2015-04-14sd-devcie: fix typoTom Gundersen
2015-04-14sd-device: fix reading of subsystemTom Gundersen
2015-04-14sd-device: allow uevent files to be write-onlyTom Gundersen
2015-04-07device: fix sysattr newline cutterDavid Herrmann
Right now, we always drop the last character of all values we write to sysfs. Fix this!
2015-04-05sd-device: don't use alloca() within loopsTom Gundersen
I shall not use alloca() within loops I shall not use alloca() within loops I shall not use alloca() within loops I shall not use alloca() within loops ...
2015-04-03sd-device,udevd: fix spelling /ammend/amend/Tom Gundersen
2015-04-03sd-device: fix deserialization from netlinkTom Gundersen
Use the standard FOREACH_WORD* macros. The current code was broken in the devlink case so the last one received was being dropped, causing https://bugs.freedesktop.org/show_bug.cgi?id=89894
2015-04-03sd-device: get_properties_{nulstr,strv} - don't recreate the buffer ↵Tom Gundersen
unnecessarily
2015-04-03sd-device: get_sysattr_value - don't leak returned valueTom Gundersen
This was getting leaked as a copy was added to the hashmap, simply add the returned value instead. This should fix CID #1292806.
2015-04-03sd-device: initialize variableTom Gundersen
sysnum would not be initialized if sysname had no trailing digits.
2015-04-02libsystemd: add sd-device libraryTom Gundersen
This provides equivalent functionality to libudev-device, but in the systemd style. The public API only caters to creating sd_device objects from for devices that already exist in /sys, there is no support for listening for monitoring events or creating devices received over the udev netlink protocol. The private API contains the necessary functionality to make sd-device a drop-in replacement for libudev-device, but which we would not otherwise want to export.