summaryrefslogtreecommitdiff
path: root/src/rfkill
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use -EBADF moreYu Watanabe2022-12-211-1/+1
|
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* tree-wide: Use correct format specifiersJan Janssen2022-08-301-7/+7
| | | | gcc will complain about all these with -Wformat-signedness.
* errno-util: add ERRNO_IS_DEVICE_ABSENT() macroLennart Poettering2022-03-241-1/+1
| | | | Inspired by: https://github.com/systemd/systemd/pull/22717#discussion_r834254495
* list: make LIST_FOREACH() and LIST_FOREACH_BACKWARDS() saferYu Watanabe2022-03-191-1/+1
|
* list: declare iterator of LIST_FOREACH() in the loopYu Watanabe2022-03-191-4/+1
|
* tree-wide: warn when sd_notify fails with READY=1 or FDSTOREREMOVE=1Zbigniew Jędrzejewski-Szmek2021-11-031-1/+4
| | | | | | | | Most sd_notify() calls are like log_info() — the result is only informative and if they fail, it's best ignore this. But if a call with READY=1 fails, the unit may enter a failed state, so we should warn about this. Similarly for FSTOREREMOVE=1: the manager may be left with a stale fd, at least wasting resources.
* rfkill: add some casts to silence -Werror=sign-compareLuca Boccassi2021-04-141-4/+4
|
* rfkill: use short writes and accept long readsZbigniew Jędrzejewski-Szmek2021-02-181-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm seeing the following with kernel-core-5.10.16-200.fc33.x86_64: $ sudo SYSTEMD_LOG_LEVEL=debug build/systemd-rfkill Reading struct rfkill_event: got 8 bytes. A new rfkill device has been added with index 0 and type bluetooth. Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy Found container virtualization none. rfkill0: Operating on rfkill device 'tpacpi_bluetooth_sw'. Writing struct rfkill_event successful (8 of 9 bytes). Loaded state '0' from /var/lib/systemd/rfkill/platform-thinkpad_acpi:bluetooth. Reading struct rfkill_event: got 8 bytes. A new rfkill device has been added with index 1 and type wwan. rfkill1: Operating on rfkill device 'tpacpi_wwan_sw'. Writing struct rfkill_event successful (8 of 9 bytes). Loaded state '0' from /var/lib/systemd/rfkill/platform-thinkpad_acpi:wwan. Reading struct rfkill_event: got 8 bytes. A new rfkill device has been added with index 2 and type bluetooth. rfkill2: Operating on rfkill device 'hci0'. Writing struct rfkill_event successful (8 of 9 bytes). Loaded state '0' from /var/lib/systemd/rfkill/pci-0000:00:14.0-usb-0:7:1.0:bluetooth. Reading struct rfkill_event: got 8 bytes. A new rfkill device has been added with index 3 and type wlan. rfkill3: Operating on rfkill device 'phy0'. Writing struct rfkill_event successful (8 of 9 bytes). Loaded state '0' from /var/lib/systemd/rfkill/pci-0000:04:00.0:wlan. All events read and idle, exiting. We were expecting a read of exactly RFKILL_EVENT_SIZE_V1==8 bytes. But the structure has 9 after [1]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=14486c82612a177cb910980c70ba900827ca0894 For some reason the kernel does not accept the full structure size, but cuts the write short after 8 bytes: static ssize_t rfkill_fop_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { struct rfkill_event ev; /* we don't need the 'hard' variable but accept it */ if (count < RFKILL_EVENT_SIZE_V1 - 1) return -EINVAL; /* * Copy as much data as we can accept into our 'ev' buffer, * but tell userspace how much we've copied so it can determine * our API version even in a write() call, if it cares. */ count = min(count, sizeof(ev)); if (copy_from_user(&ev, buf, count)) return -EFAULT; ... so it should accept the full size. I'm not sure what is going on here. But we don't care about the extra fields, so let's accept a write as long as it's at least RFKILL_EVENT_SIZE_V1. Fixes #18677.
* rfkill: improve error loggingZbigniew Jędrzejewski-Szmek2021-02-181-36/+30
| | | | If we get something of unexpected size, log the sizes. Also, don't log twice.
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-02-011-1/+1
| | | | It may be useful when debugging daemons.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* util-lib: move shall_restore_state() to shared/reboot-utilZbigniew Jędrzejewski-Szmek2019-09-161-2/+2
| | | | | It's just a small function, but it is higher-level functionality. I don't see a good place for it, reboot-util.[ch] seems least bad
* util: make device_wait_for_initialization() optionally takes timeout valueYu Watanabe2019-06-041-1/+1
|
* tree-wide: make use of the new WRITE_STRING_FILE_MKDIR_0755 flagLennart Poettering2019-05-081-6/+2
|
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+4
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* Detect file truncation earlier in a few placesTopi Miettinen2019-02-021-2/+2
| | | | | Users of read_one_line_file() for APIVFS entries are ignored as they are assumed to never get truncated.
* rfkill: move wait_for_initialized() to shared/Zbigniew Jędrzejewski-Szmek2018-12-171-84/+2
| | | | | | | | | | | | | | | | | | The function interface is the same, except that the output pointer may be NULL. The implementation is slightly simplified by taking advantage of changes in ancestor commit 'sd-device: attempt to read db again if it wasn't found', by not creating a new sd_device object before re-checking the is_initialized status. v2: - In v1, the old object was always used and the device received back from the sd_device_monitor_start callback was ignored. I *think* the result will be equivalent in both cases, because by the time we the callback gets called, the db entry in the filesystem will also exist, and any subsequent access to properties of the object would trigger a read of the database from disk. But I'm not certain, and anyway, using the device object received in the callback seems cleaner.
* rfkill: define main through macroYu Watanabe2018-11-231-39/+21
|
* rfkill: store write queue and rfkill fd in struct ContextYu Watanabe2018-11-231-62/+53
|
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-4/+3
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* log: introduce new helper call log_setup_service()Lennart Poettering2018-11-201-3/+1
| | | | | Let's reduce the common boilerplate and have a single setup function used by all service code to setup logging.
* sd-device: drop priority and description from ↵Yu Watanabe2018-11-101-2/+2
| | | | | | | sd_device_monitor_attach_event() and sd_device_monitor_start() Now we have sd_device_monitor_get_event_soruce(). So, it is not necessary to include these parameters in the functions for sd_device_monitor.
* sd-device: make sd_device_get_is_initialized() returns is_initialized by ↵Yu Watanabe2018-10-291-3/+3
| | | | return value
* rfkill: use log_device_*()Yu Watanabe2018-10-231-2/+3
|
* rfkill: replace udev_monitor by sd_device_monitorYu Watanabe2018-10-171-39/+47
|
* tree-wide: use streq() instead of streq_ptr()Yu Watanabe2018-09-231-1/+1
|
* rfkill: replace udev_device by sd_deviceYu Watanabe2018-08-231-63/+41
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-04-251-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | This drops a good number of type-specific _cleanup_ macros, and patches all users to just use the generic ones. In most recent code we abstained from defining type-specific macros, and this basically removes all those added already, with the exception of the really low-level ones. Having explicit macros for this is not too useful, as the expression without the extra macro is generally just 2ch wider. We should generally emphesize generic code, unless there are really good reasons for specific code, hence let's follow this in this case too. Note that _cleanup_free_ and similar really low-level, libc'ish, Linux API'ish macros continue to be defined, only the really high-level OO ones are dropped. From now on this should really be the rule: for really low-level stuff, such as memory allocation, fd handling and so one, go ahead and define explicit per-type macros, but for high-level, specific program code, just use the generic _cleanup_() macro directly, in order to keep things simple and as readable as possible for the uninitiated. Note that before this patch some of the APIs (notable libudev ones) were already used with the high-level macros at some places and with the generic _cleanup_ macro at others. With this patch we hence unify on the latter.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* rfkill: treat ENXIO/ENODEV the same way as ENOENTLennart Poettering2018-04-051-4/+5
| | | | | | | | | | | If an rfkill device disappears between the time we get notified about the existance and we fully opened it we might get ENXIO or ENODEV (i.e. the two kinds of "device not found" errors, which are typically generated when for example a device node has no actual backing device behind it). let's handle that the same way as ENOENT, and downgrade the log message to LOG_DEBUG. Fixes: #8586
* rfkill: use our usual style for writing destructorsLennart Poettering2018-04-051-4/+4
| | | | Let's accept NULL values gracefully, and let's return NULL.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-051-2/+1
|
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* rfkill: include the device name in error messageZbigniew Jędrzejewski-Szmek2017-10-181-2/+4
|
* rfkill: Delay writes until exit (#5768)Benjamin Berg2017-09-011-5/+99
| | | | | | | | | | | | | | | On thinkpads there are two rfkill devices for bluetooth. The first is an ACPI switch which powers down the USB dongle and the second one is the USB dongle itself. So when userspace decides to enable rfkill on all devices systemd would randomly save the soft block state of the USB dongle. This later causes issue when re-enabling the devie as systemd-rfkill would put the USB dongle into soft block state right after the ACPI rfkill switch is unblocked by userspace. The simple way to avoid this is to not store rfkill changes for devices that disappear shortly after. That way only the "main" ACPI switch will get stored and systemd-rfkill will not end up blocking the device right after it is being added back again.
* rfkill: Lookup device in determine_state_fileBenjamin Berg2017-08-311-14/+7
| | | | | None of the callers actually need the device itself. So it makes sense to do the lookup inside determine_state_file instead.
* rfkill: fix typo (#6574)Xiang Fan2017-08-091-1/+1
|
* rfkill: fix erroneous behavior when polling the udev monitor (#6489)S. Fan2017-07-311-2/+6
| | | | | | | Comparing udev_device_get_sysname(device) and sysname will always return true. We need to check the device received from udev monitor instead. Also, fd_wait_for_event() sometimes never exits. Better set a timeout here.
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-2/+2
| | | | | | | | | | | | | This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tree-wide: group include of libudev.h with sd-*Thomas Hindoe Paaboel Andersen2015-11-171-1/+1
|
* tree-wide: sort includesThomas Hindoe Paaboel Andersen2015-11-161-1/+1
| | | | Sort the includes accoding to the new coding style.
* proc-cmdline: return proper errors from shall_restore_state()Lennart Poettering2015-11-021-1/+1
| | | | | Let's not eat up errors in shall_restore_state(), but in the consumers instead, just for the sake of keeping the library calls generic.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: move /proc/cmdline parsing code to proc-cmdline.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: move string table stuff into its own string-table.[ch]Lennart Poettering2015-10-271-0/+1
|