Commit Graph

34 Commits

Author SHA1 Message Date
Lennart Poettering bac0bfc1d0 udev-util: make use of sd-event's NULL callback support 2020-10-07 09:40:12 +02:00
Lennart Poettering fabf877705
Merge pull request #17154 from keszybz/crypttab-commas
Allow escaping commas in crypttab
2020-10-01 10:26:24 +02:00
Lennart Poettering b9daaedbb9 udev-util: simplify device_is_renaming() error handling 2020-09-28 18:45:54 +02:00
Zbigniew Jędrzejewski-Szmek fe79f107ef tree-wide: drop assignments to r when we only need errno
If the whole call is simple and we don't need to look at the return value
apart from the conditional, let's use a form without assignment of the return
value. When the function call is more complicated, it still makes sense to
use a temporary variable.
2020-09-24 16:36:43 +02:00
Luca Boccassi ce5eef6530 shared/udev-util: fix sd_device leak in device_wait_for_initialization
If the caller doesn't pass a return pointer, or if sd_event_loop fails
after the device was found and referenced, it never gets dereferenced.
2020-08-14 15:26:04 +01:00
Luca Boccassi 030a0d79ff udev-util: add device_wait_for_devlink
Allows to wait for an event by matching on the devlink that gets
created.
2020-08-14 15:26:04 +01:00
Lennart Poettering 39cf0351c5 tree-wide: make use of new relative time events in sd-event.h 2020-07-28 11:24:55 +02:00
Michal Sekletár e209926778 udev: make signal that we use to kill workers on timeout configurable 2020-06-05 11:09:17 +02:00
Zbigniew Jędrzejewski-Szmek d7921114d7 udev: warn when we fail to parse udev.conf
This should be like any other parse error and a warning should be emitted.
Let's use log_syntax() so we get the CONFIG_FILE= set.
2019-07-04 10:36:19 +02:00
Yu Watanabe 1b47436e0e util: make device_wait_for_initialization() optionally takes timeout value 2019-06-04 01:19:43 +09:00
Yu Watanabe f822c5d59e util: make argument "subsystem" in device_wait_for_initialization() optional 2019-06-04 01:19:43 +09:00
Yu Watanabe 25de7aa7b9 udev: modernize udev-rules.c
This does the following:
- rename enum udev_builtin_cmd -> UdevBuiltinCmd
- rename struct udev_builtin -> UdevBuiltin
- move type definitions to udev-rules.h
- move prototypes of functions defined in udev-rules.c to udev-rules.h
- drop to use strbuf
- propagate critical errors in applying rules,
- drop limitation for number of tokens per line.
2019-06-02 14:15:26 +09:00
Lennart Poettering fc40bfa7e2 udev-util: allocate an event loop of our own for waiting
We can't use the per-thread default one here, as it might already be
running (for example, that's the case in portabled), and our event loops
are not recursive, hence running them a second time is not OK.
2019-04-04 02:15:14 +09:00
Yu Watanabe a707c65b70 util: introduce device_for_action()
It will be used in later commits.
2019-03-12 03:49:53 +09:00
Yu Watanabe 90ba130f00 util: introduce device_is_renaming()
It will be used in the later commit.
2019-03-05 10:33:41 +09:00
Zbigniew Jędrzejewski-Szmek ed435031a5 rfkill: move wait_for_initialized() to shared/
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.
2018-12-17 13:50:51 +01:00
Lennart Poettering 686d13b9f2 util-lib: split out env file parsing code into env-file.c
It's quite complex, let's split this out.

No code changes, just some file rearranging.
2018-12-02 13:22:29 +01:00
Yu Watanabe 9b2934cb81 udev-util: read resolve_names from udev.conf
Fixes CID#1396866.
2018-11-16 09:21:58 +01:00
Lennart Poettering 13df9c398d fileio: automatically add NULL sentinel to parse_env_file()
Let's modernize things a bit.
2018-11-14 17:01:55 +01:00
Lennart Poettering aa8fbc74e3 fileio: drop "newline" parameter for env file parsers
Now that we don't (mis-)use the env file parser to parse kernel command
lines there's no need anymore to override the used newline character
set. Let's hence drop the argument and just "\n\r" always. This nicely
simplifies our code.
2018-11-14 17:01:54 +01:00
Zbigniew Jędrzejewski-Szmek a14e7af162 udev: also allow resolve_names= to be specified in udev.conf 2018-11-13 14:35:36 +01:00
Zbigniew Jędrzejewski-Szmek bc768f0475 udev: move ResolveNameTiming definition and parsers to udev-util.h
Follow-up for c4d44cba4d. No functional change,
but the parser is moved to libsystemd-shared.so.
2018-11-13 14:04:29 +01:00
Zbigniew Jędrzejewski-Szmek 4b3ca79ea9 udevd: allow more parameters to be set through udev.conf
Rebooting to set change the kernel command line to set some udev parameters is
inconvenient. Let's allow setting more stuff in the config file.

Also drop quotes from around "info" in udev.conf. We need to accept them for
compatibility, but there is no reason to use them.
2018-11-13 14:03:47 +01:00
Yu Watanabe 152d0efa2b udev: move udev cleanup functions from udev-util.h to udev.h 2018-08-23 04:57:39 +09:00
Yu Watanabe 05becb11e8 udev-util: drop unused function udev_device_new_from_stat_rdev() 2018-08-23 04:57:39 +09:00
Yu Watanabe 3938f568a2 libudev: accept NULL as the argument 'struct udev*' for udev_monitor_new() or friends
As udev_monitor struct or friends are now almost independent of udev
struct. So, generating these objects without udev struct is reasonable.
2018-08-23 04:57:39 +09:00
Zbigniew Jędrzejewski-Szmek 0cd41d4dff Drop my copyright headers
perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
2018-06-14 13:03:20 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
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.
2018-06-14 10:20:20 +02:00
Lennart Poettering e5ca27b772 udev: add helper udev_device_new_from_stat_rdev()
This is a simple wrapper around udev_device_new_from_devnum(), and uses
the data from a struct stat's .st_rdev field to derive the udev_device
object.
2018-06-07 13:36:19 +02:00
Lennart Poettering 1a5a177eaf fileio: accept FILE* in addition to path in parse_env_file()
Most our other parsing functions do this, let's do this here too,
internally we accept that anyway. Also, the closely related
load_env_file() and load_env_file_pairs() also do this, so let's be
systematic.
2018-05-24 17:01:57 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
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.
2018-04-06 18:58:55 +02:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Zbigniew Jędrzejewski-Szmek b237a168df Rip out setting of the log level from udev_new and put it in a new function
This function is internal to systemd code, so external users of libudev
will not see those log messages. I think this is better. If we want to
allow that, the function could be put in libudev and exported.

v2: check that the string is more than one char before stripping quotes
2017-05-07 22:49:12 -04:00