mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 10:51:20 +03:00
udev: move global property handling from libudev to udevd
This commit is contained in:
parent
25e773eeb4
commit
41b848b0ea
@ -642,7 +642,6 @@ void udev_device_set_info_loaded(struct udev_device *device)
|
||||
struct udev_device *udev_device_new(struct udev *udev)
|
||||
{
|
||||
struct udev_device *udev_device;
|
||||
struct udev_list_entry *list_entry;
|
||||
|
||||
if (udev == NULL) {
|
||||
errno = EINVAL;
|
||||
@ -662,11 +661,7 @@ struct udev_device *udev_device_new(struct udev *udev)
|
||||
udev_list_init(udev, &udev_device->sysattr_list, false);
|
||||
udev_list_init(udev, &udev_device->tags_list, true);
|
||||
udev_device->watch_handle = -1;
|
||||
/* copy global properties */
|
||||
udev_list_entry_foreach(list_entry, udev_get_properties_list_entry(udev))
|
||||
udev_device_add_property(udev_device,
|
||||
udev_list_entry_get_name(list_entry),
|
||||
udev_list_entry_get_value(list_entry));
|
||||
|
||||
return udev_device;
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,7 @@
|
||||
#define WRITE_END 1
|
||||
|
||||
/* libudev.c */
|
||||
void udev_log(struct udev *udev,
|
||||
int priority, const char *file, int line, const char *fn,
|
||||
const char *format, ...) _printf_(6, 7);
|
||||
int udev_get_rules_path(struct udev *udev, char **path[], usec_t *ts_usec[]);
|
||||
struct udev_list_entry *udev_add_property(struct udev *udev, const char *key, const char *value);
|
||||
struct udev_list_entry *udev_get_properties_list_entry(struct udev *udev);
|
||||
|
||||
/* libudev-device.c */
|
||||
struct udev_device *udev_device_new(struct udev *udev);
|
||||
|
@ -50,7 +50,6 @@ struct udev {
|
||||
int priority, const char *file, int line, const char *fn,
|
||||
const char *format, va_list args);
|
||||
void *userdata;
|
||||
struct udev_list properties_list;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -100,7 +99,6 @@ _public_ struct udev *udev_new(void) {
|
||||
if (udev == NULL)
|
||||
return NULL;
|
||||
udev->refcount = 1;
|
||||
udev_list_init(udev, &udev->properties_list, true);
|
||||
|
||||
f = fopen("/etc/udev/udev.conf", "re");
|
||||
if (f != NULL) {
|
||||
@ -211,7 +209,6 @@ _public_ struct udev *udev_unref(struct udev *udev) {
|
||||
udev->refcount--;
|
||||
if (udev->refcount > 0)
|
||||
return udev;
|
||||
udev_list_cleanup(&udev->properties_list);
|
||||
free(udev);
|
||||
return NULL;
|
||||
}
|
||||
@ -253,20 +250,3 @@ _public_ int udev_get_log_priority(struct udev *udev) {
|
||||
_public_ void udev_set_log_priority(struct udev *udev, int priority) {
|
||||
log_set_max_level(priority);
|
||||
}
|
||||
|
||||
struct udev_list_entry *udev_add_property(struct udev *udev, const char *key, const char *value) {
|
||||
if (value == NULL) {
|
||||
struct udev_list_entry *list_entry;
|
||||
|
||||
list_entry = udev_get_properties_list_entry(udev);
|
||||
list_entry = udev_list_entry_get_by_name(list_entry, key);
|
||||
if (list_entry != NULL)
|
||||
udev_list_entry_delete(list_entry);
|
||||
return NULL;
|
||||
}
|
||||
return udev_list_entry_add(&udev->properties_list, key, value);
|
||||
}
|
||||
|
||||
struct udev_list_entry *udev_get_properties_list_entry(struct udev *udev) {
|
||||
return udev_list_get_entry(&udev->properties_list);
|
||||
}
|
||||
|
@ -35,10 +35,6 @@
|
||||
#include "udev.h"
|
||||
#include "udev-util.h"
|
||||
|
||||
void udev_main_log(struct udev *udev, int priority,
|
||||
const char *file, int line, const char *fn,
|
||||
const char *format, va_list args) {}
|
||||
|
||||
static int fake_filesystems(void) {
|
||||
static const struct fakefs {
|
||||
const char *src;
|
||||
|
@ -66,7 +66,7 @@ static int load_module(struct udev *udev, const char *alias) {
|
||||
_printf_(6,0)
|
||||
static void udev_kmod_log(void *data, int priority, const char *file, int line,
|
||||
const char *fn, const char *format, va_list args) {
|
||||
udev_main_log(data, priority, file, line, fn, format, args);
|
||||
log_metav(priority, file, line, fn, format, args);
|
||||
}
|
||||
|
||||
static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test) {
|
||||
|
@ -197,11 +197,6 @@ int udev_builtin_add_property(struct udev_device *dev, bool test, const char *ke
|
||||
int udev_builtin_hwdb_lookup(struct udev_device *dev, const char *prefix, const char *modalias,
|
||||
const char *filter, bool test);
|
||||
|
||||
/* udev logging */
|
||||
void udev_main_log(struct udev *udev, int priority,
|
||||
const char *file, int line, const char *fn,
|
||||
const char *format, va_list args) _printf_(6, 0);
|
||||
|
||||
/* udevadm commands */
|
||||
struct udevadm_cmd {
|
||||
const char *name;
|
||||
|
@ -26,12 +26,6 @@
|
||||
|
||||
#include "udev.h"
|
||||
|
||||
void udev_main_log(struct udev *udev, int priority,
|
||||
const char *file, int line, const char *fn,
|
||||
const char *format, va_list args) {
|
||||
log_metav(priority, file, line, fn, format, args);
|
||||
}
|
||||
|
||||
static int adm_version(struct udev *udev, int argc, char *argv[]) {
|
||||
printf("%s\n", VERSION);
|
||||
return 0;
|
||||
|
@ -54,12 +54,6 @@
|
||||
#include "dev-setup.h"
|
||||
#include "fileio.h"
|
||||
|
||||
void udev_main_log(struct udev *udev, int priority,
|
||||
const char *file, int line, const char *fn,
|
||||
const char *format, va_list args) {
|
||||
log_metav(priority, file, line, fn, format, args);
|
||||
}
|
||||
|
||||
static struct udev_rules *rules;
|
||||
static struct udev_ctrl *udev_ctrl;
|
||||
static struct udev_monitor *monitor;
|
||||
@ -82,6 +76,7 @@ static UDEV_LIST(event_list);
|
||||
static UDEV_LIST(worker_list);
|
||||
static char *udev_cgroup;
|
||||
static bool udev_exit;
|
||||
static struct udev_list properties_list;
|
||||
|
||||
enum event_state {
|
||||
EVENT_UNDEF,
|
||||
@ -676,10 +671,10 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl) {
|
||||
val = &val[1];
|
||||
if (val[0] == '\0') {
|
||||
log_debug("udevd message (ENV) received, unset '%s'", key);
|
||||
udev_add_property(udev, key, NULL);
|
||||
udev_list_entry_add(&properties_list, key, NULL);
|
||||
} else {
|
||||
log_debug("udevd message (ENV) received, set '%s=%s'", key, val);
|
||||
udev_add_property(udev, key, val);
|
||||
udev_list_entry_add(&properties_list, key, val);
|
||||
}
|
||||
} else {
|
||||
log_error("wrong key format '%s'", key);
|
||||
@ -1147,6 +1142,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
umask(022);
|
||||
|
||||
udev_list_init(udev, &properties_list, true);
|
||||
|
||||
r = mkdir("/run/udev", 0755);
|
||||
if (r < 0 && errno != EEXIST) {
|
||||
log_error("could not create /run/udev: %m");
|
||||
@ -1535,6 +1532,7 @@ exit_daemonize:
|
||||
udev_monitor_unref(monitor);
|
||||
udev_ctrl_connection_unref(ctrl_conn);
|
||||
udev_ctrl_unref(udev_ctrl);
|
||||
udev_list_cleanup(&properties_list);
|
||||
mac_selinux_finish();
|
||||
udev_unref(udev);
|
||||
log_close();
|
||||
|
Loading…
Reference in New Issue
Block a user