mirror of
https://github.com/systemd/systemd.git
synced 2024-10-28 03:25:31 +03:00
device : reload when udev generates a "changed" event
This commit is contained in:
parent
f54bcca5c1
commit
0ffddc6e2c
@ -83,6 +83,12 @@
|
||||
the escaping logic used to convert a file system path to a unit
|
||||
name see
|
||||
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
|
||||
|
||||
<para>Device units will be reloaded by systemd whenever the
|
||||
corresponding device generates a <literal>changed</literal> event.
|
||||
Other units can use <varname>ReloadPropagatedFrom=</varname> to react
|
||||
to that event</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
|
@ -766,7 +766,27 @@ static int device_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (streq(action, "remove")) {
|
||||
if (streq(action, "change")) {
|
||||
_cleanup_free_ char *e = NULL;
|
||||
Unit *u;
|
||||
|
||||
r = unit_name_from_path(sysfs, ".device", &e);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to generate unit name from device path: %m");
|
||||
|
||||
u = manager_get_unit(m, e);
|
||||
if (!u) {
|
||||
log_error("Failed to get unit from sysfs name.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = manager_add_job(m, JOB_RELOAD, u, JOB_REPLACE, NULL, NULL);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to add job to manager : %m");
|
||||
return 0;
|
||||
}
|
||||
|
||||
} else if (streq(action, "remove")) {
|
||||
r = swap_process_device_remove(m, dev);
|
||||
if (r < 0)
|
||||
log_error_errno(r, "Failed to process swap device remove event: %m");
|
||||
|
Loading…
Reference in New Issue
Block a user