Lennart Poettering
683a1e7fd9
Merge pull request #11594 from yuwata/udev-rule-cleanups
...
udev-rule, ethtool: several coding style cleanups
2019-02-15 11:37:11 +01:00
Yu Watanabe
6e2efb6c73
udev-rule: make rule_add_key() return negative errno when too much tokens
...
As OPTIONS= rule introduce multiple tokens.
Fixes oss-fuzz#12980.
2019-02-13 04:14:21 +09:00
Yu Watanabe
76b9bdd96f
udev-rule: check function retun value is negative or not, instead of non-zero
...
One exception is udev_event_spawn(), which returns negative or positive
value on failure.
2019-02-12 11:03:40 +09:00
Yu Watanabe
605aa52f83
udev-rule: make match_key() and match_attr() return boolean value
2019-02-12 11:03:40 +09:00
Yu Watanabe
bb175a0338
udev-rule: drop unnecessary parentheses
2019-02-12 11:03:40 +09:00
Yu Watanabe
704dbfb279
udev-rule: make get_key() return negative errno
2019-02-12 11:03:40 +09:00
Yu Watanabe
1f362ff185
udev-rule: drop unnecessary assignments
2019-02-12 11:03:39 +09:00
Yu Watanabe
ef660d072f
udev-rule: propagate error cause in add_token()
2019-02-12 11:03:39 +09:00
Zbigniew Jędrzejewski-Szmek
a6ca3c1921
udev: do logging before setting variables to NULL
...
gcc-9 diagnoses this as an error.
Reported by Jeff Law.
2019-01-15 13:58:45 +01:00
Topi Miettinen
a1e92eee3e
Remove 'inline' attributes from static functions in .c files ( #11426 )
...
Let the compiler perform inlining (see #11397 ).
2019-01-15 08:12:28 +01:00
Zbigniew Jędrzejewski-Szmek
a75211421f
udev: rework how we handle the return value from spawned programs
...
When running PROGRAM="...", we would log
systemd-udevd[447]: Failed to wait spawned command '...': Input/output error
no matter why the program actually failed, at error level.
The code wouldn't distinguish between an internal failure and a failure in the
program being called and run sd_event_exit(..., -EIO) on any kind of error. EIO
is rather misleading here, becuase it suggests a serious error.
on_spawn_sigchld is updated to set the return code to distinguish failure to
spawn, including the program being killed by a signal (a negative return value),
and the program failing (positive return value).
The logging levels are adjusted, so that for PROGRAM= calls, which are
essentially "if" statements, we only log at debug level (unless we get a
timeout or segfault or another unexpected error).
2019-01-07 18:36:04 +01:00
Zbigniew Jędrzejewski-Szmek
2e08871534
udev: use typedef for struct udev_event
2018-12-17 09:27:24 +01:00
Zbigniew Jędrzejewski-Szmek
9a07157dd5
udev: use typedef for struct udev_rules
2018-12-17 09:27:21 +01:00
Zbigniew Jędrzejewski-Szmek
1d79128121
udev: make udev_rules_new() return a proper error code
2018-12-14 10:20:43 +01:00
Yu Watanabe
e924c60f69
udev: use hashmap_clear_free_key() and hashmap_free_free_key()
2018-12-02 12:18:54 +01:00
Yu Watanabe
49c603bd5e
udev: drop duplicate whitespaces
2018-11-26 11:53:21 +09:00
Yu Watanabe
b4ba2fe3f1
udev-rules: include device sysname in log messages
2018-11-26 11:37:29 +09:00
Yu Watanabe
8c19dc54d3
udev-rules: update log messages
2018-11-23 01:15:42 +09:00
Yu Watanabe
20e97dd3de
meson: add option for debugging udev
2018-11-23 00:28:27 +09:00
Yu Watanabe
67e4b38563
udev-rules: trivial coding style cleanups
2018-11-23 00:22:09 +09:00
Yu Watanabe
981fae90df
udev: rename udev_rules_unref() to udev_rules_free()
...
As udev_rules do not have a reference counter.
2018-11-23 00:07:40 +09:00
Zbigniew Jędrzejewski-Szmek
baaa35ad70
coccinelle: make use of SYNTHETIC_ERRNO
...
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.
2018-11-22 10:54:38 +01:00
Yu Watanabe
3839535a53
libudev: make util_resolve_subsys_kernel() return negative errno
...
This also replaces udev_device by sd_device in the function.
2018-11-21 17:31:16 +09:00
Yu Watanabe
5ea78a39e5
libudev-list: move libudev-list related definitions to libudev-list-internal.h
...
This also rename libudev-private.h to libudev-util.h, and cleanups
several unnecessary headers from udev.h and libudev-util.h
2018-11-20 14:38:35 +09:00
Yu Watanabe
a6da77b71b
udev-rules: fix possible assertion
...
On 'remove' action, event->dev_db_clone is NULL. So, `IMPORT{db}` rule
on 'remove' action triggers assertion. This fixes the issue.
2018-11-15 15:50:27 +01:00
Lennart Poettering
042cad5737
Merge pull request #10753 from keszybz/pager-no-interrupt
...
Add mode in journalctl where ^C is handled by the pager
2018-11-14 20:09:39 +01:00
Zbigniew Jędrzejewski-Szmek
fde32028a4
Move LONG_LINE_MAX definition to fileio.h
...
All users of the macro (except for one, in serialize.c), use the macro in
connection with read_line(), so they must include fileio.h. Let's not play
libc games and require multiple header file to be included for the most common
use of a function.
The removal of def.h includes is not exact. I mostly went over the commits that
switch over to use read_line() and add def.h at the same time and reverted the
addition of def.h in those files.
2018-11-14 16:25:32 +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
66f737b415
udev: do not pass timeout_warn_usec around, calculate it on demand
...
It was always set to one third of timeout_usec, so let's simplify things by
calculating it using a helper function right before it is used.
Before 9d9264ba39
, udevd.c would avoid setting
timeout_warn_usec to 0, using 1 instead. This wasn't necessary, because when
timeout_warn_usec is finally used in spawn_wait(), it is ignored if
timeout_usec is 0 or timeout_warn_usec is 0. So there was no need to handle
this case specially.
2018-11-13 14:00:32 +01:00
Yu Watanabe
c4d44cba4d
udev: introduce enum ResolveNameTiming for --resolve-names argument
2018-11-12 23:20:53 +09:00
Yu Watanabe
cf28ad4689
udev-event: make udev_event_new() take sd_device instead of udev_device
2018-11-07 13:35:03 +09:00
Yu Watanabe
cf697ec00e
udev-rules: replace udev_device by sd_device in udev_rules_apply_to_event()
2018-11-07 13:35:03 +09:00
Yu Watanabe
dbea7f24d2
udev-rules: replace two udev_list_entry_foreach() by corresponding FOREACH_DEVICE_*() macros
2018-11-07 13:35:03 +09:00
Yu Watanabe
1017d66bf5
udev-rules: use structured initializer
2018-11-07 13:35:03 +09:00
Yu Watanabe
92b80c6baa
udev-rules: drop unused member file_list in struct udev_rules
2018-11-07 13:35:03 +09:00
Yu Watanabe
1ce7fecb4f
udev-rules: make import_parent_into_properties() take sd_device
2018-11-07 13:35:03 +09:00
Yu Watanabe
13c7b75f2f
udev-rules: make import_file_into_properties() take sd_device
2018-11-07 13:35:03 +09:00
Yu Watanabe
29b5eb5adf
udev-rules: make import_property_from_string() take sd_device
...
Also, this makes the function return negative errno, though its
return value is always ignored.
2018-11-07 13:35:03 +09:00
Yu Watanabe
f3d241feb2
udev: use sd_device for udev_event.dev_parent
2018-11-07 13:35:03 +09:00
Yu Watanabe
5ba7e79885
udev-rules: make match_attr() take sd_device instead of udev_device
2018-11-07 13:35:03 +09:00
Yu Watanabe
480ecb7d28
udev: use sd_device for udev_event.dev_db
...
Also, this adds sd_device_unref for the object in udev_event_free()
for safety and readability of code.
2018-11-07 13:35:03 +09:00
Yu Watanabe
d354690e7d
udev-builtin: propagate negative errno
2018-10-23 18:29:25 +09:00
Yu Watanabe
c45b369dd1
udev-builtin: modernize code a bit
...
- introduce _UDEV_BUILTIN_INVALID,
- use _UDEV_BUILTIN_MAX where applicable,
- add several assertions.
2018-10-23 18:28:38 +09:00
Yu Watanabe
3d6194e83e
udev: make udev_builtin_run take sd_device
2018-10-23 18:28:38 +09:00
Yu Watanabe
14cb109d45
tree-wide: replace 'unsigned int' with 'unsigned'
2018-10-19 22:19:12 +02:00
Yu Watanabe
218b4609d0
Merge pull request #10447 from poettering/fgets-excorcism
...
let's get rid of fgets()
2018-10-19 08:36:01 +09:00
Lennart Poettering
b33fa02b2d
util: drop const_int_one/const_int_zero again
...
There's only a single user remaining now that we have setsockopt_int(),
let's define those variables locally.
This more or less reverts 6d5e65f645
.
2018-10-18 19:50:29 +02:00
Lennart Poettering
fae0f8a047
udev-rules: fgets() excorcism
2018-10-18 13:41:09 +02:00
Yu Watanabe
9b5150b63e
udev: use Hashmap for storing global properties
2018-10-17 06:50:12 +09:00
Yu Watanabe
29448498c7
udev: use Hashmap for storing PROGRAM or BUILTIN
2018-10-17 06:49:56 +09:00