Merge pull request #24020 from yuwata/network-rfkill
network: fix wlan interface handling when its RF is killed
This commit is contained in:
@@ -18,6 +18,7 @@ static inline int device_new_from_watch_handle(sd_device **ret, int wd) {
|
||||
}
|
||||
|
||||
int device_get_property_bool(sd_device *device, const char *key);
|
||||
int device_get_sysattr_bool(sd_device *device, const char *sysattr);
|
||||
int device_get_device_id(sd_device *device, const char **ret);
|
||||
int device_get_devlink_priority(sd_device *device, int *ret);
|
||||
int device_get_watch_handle(sd_device *device);
|
||||
@@ -25,6 +26,7 @@ int device_get_devnode_mode(sd_device *device, mode_t *ret);
|
||||
int device_get_devnode_uid(sd_device *device, uid_t *ret);
|
||||
int device_get_devnode_gid(sd_device *device, gid_t *ret);
|
||||
|
||||
void device_clear_sysattr_cache(sd_device *device);
|
||||
int device_cache_sysattr_value(sd_device *device, const char *key, char *value);
|
||||
int device_get_cached_sysattr_value(sd_device *device, const char *key, const char **ret_value);
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#include "macro.h"
|
||||
#include "set.h"
|
||||
|
||||
#define device_unref_and_replace(a, b) \
|
||||
unref_and_replace_full(a, b, sd_device_ref, sd_device_unref)
|
||||
|
||||
#define FOREACH_DEVICE_PROPERTY(device, key, value) \
|
||||
for (key = sd_device_get_property_first(device, &(value)); \
|
||||
key; \
|
||||
|
||||
@@ -2044,6 +2044,10 @@ _public_ int sd_device_get_trigger_uuid(sd_device *device, sd_id128_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void device_clear_sysattr_cache(sd_device *device) {
|
||||
device->sysattr_values = hashmap_free(device->sysattr_values);
|
||||
}
|
||||
|
||||
int device_cache_sysattr_value(sd_device *device, const char *key, char *value) {
|
||||
_unused_ _cleanup_free_ char *old_value = NULL;
|
||||
_cleanup_free_ char *new_key = NULL;
|
||||
@@ -2166,6 +2170,20 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int device_get_sysattr_bool(sd_device *device, const char *sysattr) {
|
||||
const char *value;
|
||||
int r;
|
||||
|
||||
assert(device);
|
||||
assert(sysattr);
|
||||
|
||||
r = sd_device_get_sysattr_value(device, sysattr, &value);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return parse_boolean(value);
|
||||
}
|
||||
|
||||
static void device_remove_cached_sysattr_value(sd_device *device, const char *_key) {
|
||||
_cleanup_free_ char *key = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user