mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-07 17:17:44 +03:00
sd-device-monitor: introduce sd_device_monitor_{set,get}_description()
This commit is contained in:
parent
edf6cbc30f
commit
39f11aa422
@ -785,6 +785,8 @@ global:
|
|||||||
sd_bus_error_setfv;
|
sd_bus_error_setfv;
|
||||||
|
|
||||||
sd_device_new_child;
|
sd_device_new_child;
|
||||||
|
sd_device_monitor_set_description;
|
||||||
|
sd_device_monitor_get_description;
|
||||||
|
|
||||||
sd_id128_string_equal;
|
sd_id128_string_equal;
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ struct sd_device_monitor {
|
|||||||
|
|
||||||
sd_event *event;
|
sd_event *event;
|
||||||
sd_event_source *event_source;
|
sd_event_source *event_source;
|
||||||
|
char *description;
|
||||||
sd_device_monitor_handler_t callback;
|
sd_device_monitor_handler_t callback;
|
||||||
void *userdata;
|
void *userdata;
|
||||||
};
|
};
|
||||||
@ -263,7 +264,7 @@ _public_ int sd_device_monitor_start(sd_device_monitor *m, sd_device_monitor_han
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
(void) sd_event_source_set_description(m->event_source, "sd-device-monitor");
|
(void) sd_event_source_set_description(m->event_source, m->description ?: "sd-device-monitor");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -306,6 +307,29 @@ _public_ sd_event_source *sd_device_monitor_get_event_source(sd_device_monitor *
|
|||||||
return m->event_source;
|
return m->event_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_public_ int sd_device_monitor_set_description(sd_device_monitor *m, const char *description) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert_return(m, -EINVAL);
|
||||||
|
|
||||||
|
r = free_and_strdup(&m->description, description);
|
||||||
|
if (r <= 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (m->event_source)
|
||||||
|
(void) sd_event_source_set_description(m->event_source, description);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
_public_ int sd_device_monitor_get_description(sd_device_monitor *m, const char **ret) {
|
||||||
|
assert_return(m, -EINVAL);
|
||||||
|
assert_return(ret, -EINVAL);
|
||||||
|
|
||||||
|
*ret = m->description;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int device_monitor_enable_receiving(sd_device_monitor *m) {
|
int device_monitor_enable_receiving(sd_device_monitor *m) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -339,6 +363,7 @@ static sd_device_monitor *device_monitor_free(sd_device_monitor *m) {
|
|||||||
|
|
||||||
(void) sd_device_monitor_detach_event(m);
|
(void) sd_device_monitor_detach_event(m);
|
||||||
|
|
||||||
|
free(m->description);
|
||||||
hashmap_free(m->subsystem_filter);
|
hashmap_free(m->subsystem_filter);
|
||||||
set_free(m->tag_filter);
|
set_free(m->tag_filter);
|
||||||
hashmap_free(m->match_sysattr_filter);
|
hashmap_free(m->match_sysattr_filter);
|
||||||
|
@ -144,6 +144,8 @@ int sd_device_monitor_attach_event(sd_device_monitor *m, sd_event *event);
|
|||||||
int sd_device_monitor_detach_event(sd_device_monitor *m);
|
int sd_device_monitor_detach_event(sd_device_monitor *m);
|
||||||
sd_event *sd_device_monitor_get_event(sd_device_monitor *m);
|
sd_event *sd_device_monitor_get_event(sd_device_monitor *m);
|
||||||
sd_event_source *sd_device_monitor_get_event_source(sd_device_monitor *m);
|
sd_event_source *sd_device_monitor_get_event_source(sd_device_monitor *m);
|
||||||
|
int sd_device_monitor_set_description(sd_device_monitor *m, const char *description);
|
||||||
|
int sd_device_monitor_get_description(sd_device_monitor *m, const char **ret);
|
||||||
int sd_device_monitor_start(sd_device_monitor *m, sd_device_monitor_handler_t callback, void *userdata);
|
int sd_device_monitor_start(sd_device_monitor *m, sd_device_monitor_handler_t callback, void *userdata);
|
||||||
int sd_device_monitor_stop(sd_device_monitor *m);
|
int sd_device_monitor_stop(sd_device_monitor *m);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user