summaryrefslogtreecommitdiff
path: root/src/libudev
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2012-04-16 17:21:22 +0200
committerKay Sievers <kay@vrfy.org>2012-04-16 19:20:57 +0200
commit6ada823a9a0979ea145fd70add1007c21caa45c0 (patch)
tree3eff7319e77b9cdffda502cb373a1eae6c6488bb /src/libudev
parent8fef0ff25c9fd7e5bb99d66f43c6357e4996a3cc (diff)
udev: remove configuration options for /dev, /sys, /run directories
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/libudev-device-private.c11
-rw-r--r--src/libudev/libudev-device.c69
-rw-r--r--src/libudev/libudev-enumerate.c25
-rw-r--r--src/libudev/libudev-private.h6
-rw-r--r--src/libudev/libudev-queue-private.c16
-rw-r--r--src/libudev/libudev-queue.c8
-rw-r--r--src/libudev/libudev-selinux-private.c2
-rw-r--r--src/libudev/libudev.c119
8 files changed, 63 insertions, 193 deletions
diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c
index 91fd06c025..c58cde2ff6 100644
--- a/src/libudev/libudev-device-private.c
+++ b/src/libudev/libudev-device-private.c
@@ -31,7 +31,7 @@ static void udev_device_tag(struct udev_device *dev, const char *tag, bool add)
id = udev_device_get_id_filename(dev);
if (id == NULL)
return;
- util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev), "/tags/", tag, "/", id, NULL);
+ util_strscpyl(filename, sizeof(filename), TEST_PREFIX "/run/udev/tags/", tag, "/", id, NULL);
if (add) {
int fd;
@@ -108,7 +108,7 @@ int udev_device_update_db(struct udev_device *udev_device)
return -1;
has_info = device_has_info(udev_device);
- util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev), "/data/", id, NULL);
+ util_strscpyl(filename, sizeof(filename), TEST_PREFIX "/run/udev/data/", id, NULL);
/* do not store anything for otherwise empty devices */
if (!has_info &&
@@ -138,10 +138,8 @@ int udev_device_update_db(struct udev_device *udev_device)
struct udev_list_entry *list_entry;
if (major(udev_device_get_devnum(udev_device)) > 0) {
- size_t devlen = strlen(udev_get_dev_path(udev))+1;
-
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(udev_device))
- fprintf(f, "S:%s\n", &udev_list_entry_get_name(list_entry)[devlen]);
+ fprintf(f, "S:%s\n", udev_list_entry_get_name(list_entry) + strlen(TEST_PREFIX "/dev/"));
if (udev_device_get_devlink_priority(udev_device) != 0)
fprintf(f, "L:%i\n", udev_device_get_devlink_priority(udev_device));
if (udev_device_get_watch_handle(udev_device) >= 0)
@@ -173,13 +171,12 @@ int udev_device_update_db(struct udev_device *udev_device)
int udev_device_delete_db(struct udev_device *udev_device)
{
const char *id;
- struct udev *udev = udev_device_get_udev(udev_device);
char filename[UTIL_PATH_SIZE];
id = udev_device_get_id_filename(udev_device);
if (id == NULL)
return -1;
- util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev), "/data/", id, NULL);
+ util_strscpyl(filename, sizeof(filename), TEST_PREFIX "/run/udev/data/", id, NULL);
unlink(filename);
return 0;
}
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index 257d6355fe..212163bb92 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -356,7 +356,7 @@ void udev_device_add_property_from_string_parse(struct udev_device *udev_device,
if (strncmp(property, "DEVPATH=", 8) == 0) {
char path[UTIL_PATH_SIZE];
- util_strscpyl(path, sizeof(path), udev_get_sys_path(udev_device->udev), &property[8], NULL);
+ util_strscpyl(path, sizeof(path), TEST_PREFIX "/sys", &property[8], NULL);
udev_device_set_syspath(udev_device, path);
} else if (strncmp(property, "SUBSYSTEM=", 10) == 0) {
udev_device_set_subsystem(udev_device, &property[10]);
@@ -473,7 +473,7 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile)
id = udev_device_get_id_filename(udev_device);
if (id == NULL)
return -1;
- util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev_device->udev), "/data/", id, NULL);
+ util_strscpyl(filename, sizeof(filename), TEST_PREFIX "/run/udev/data/", id, NULL);
dbfile = filename;
}
@@ -496,7 +496,7 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile)
val = &line[2];
switch(line[0]) {
case 'S':
- util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_device->udev), "/", val, NULL);
+ util_strscpyl(filename, sizeof(filename), TEST_PREFIX "/dev/", val, NULL);
udev_device_add_devlink(udev_device, filename, 0);
break;
case 'L':
@@ -624,7 +624,6 @@ struct udev_device *udev_device_new(struct udev *udev)
**/
_public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath)
{
- size_t len;
const char *subdir;
char path[UTIL_PATH_SIZE];
char *pos;
@@ -637,14 +636,13 @@ _public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, con
return NULL;
/* path starts in sys */
- len = strlen(udev_get_sys_path(udev));
- if (strncmp(syspath, udev_get_sys_path(udev), len) != 0) {
+ if (strncmp(syspath, TEST_PREFIX "/sys", strlen(TEST_PREFIX "/sys")) != 0) {
dbg(udev, "not in sys :%s\n", syspath);
return NULL;
}
/* path is not a root directory */
- subdir = &syspath[len+1];
+ subdir = syspath + strlen(TEST_PREFIX "/sys");
pos = strrchr(subdir, '/');
if (pos == NULL || pos[1] == '\0' || pos < &subdir[2])
return NULL;
@@ -653,7 +651,7 @@ _public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, con
util_strscpy(path, sizeof(path), syspath);
util_resolve_sys_link(udev, path, sizeof(path));
- if (strncmp(&path[len], "/devices/", 9) == 0) {
+ if (strncmp(path + strlen(TEST_PREFIX "/sys"), "/devices/", 9) == 0) {
char file[UTIL_PATH_SIZE];
/* all "devices" require a "uevent" file */
@@ -705,8 +703,8 @@ _public_ struct udev_device *udev_device_new_from_devnum(struct udev *udev, char
return NULL;
/* use /sys/dev/{block,char}/<maj>:<min> link */
- snprintf(path, sizeof(path), "%s/dev/%s/%u:%u",
- udev_get_sys_path(udev), type_str, major(devnum), minor(devnum));
+ snprintf(path, sizeof(path), TEST_PREFIX "/sys/dev/%s/%u:%u",
+ type_str, major(devnum), minor(devnum));
return udev_device_new_from_syspath(udev, path);
}
@@ -782,32 +780,27 @@ struct udev_device *udev_device_new_from_id_filename(struct udev *udev, char *id
**/
_public_ struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname)
{
- char path_full[UTIL_PATH_SIZE];
- char *path;
- size_t l;
+ char path[UTIL_PATH_SIZE];
struct stat statbuf;
- path = path_full;
- l = util_strpcpyl(&path, sizeof(path_full), udev_get_sys_path(udev), NULL);
-
if (strcmp(subsystem, "subsystem") == 0) {
- util_strscpyl(path, l, "/subsystem/", sysname, NULL);
- if (stat(path_full, &statbuf) == 0)
+ util_strscpyl(path, sizeof(path), TEST_PREFIX "/sys/subsystem/", sysname, NULL);
+ if (stat(path, &statbuf) == 0)
goto found;
- util_strscpyl(path, l, "/bus/", sysname, NULL);
- if (stat(path_full, &statbuf) == 0)
+ util_strscpyl(path, sizeof(path), TEST_PREFIX "/sys/bus/", sysname, NULL);
+ if (stat(path, &statbuf) == 0)
goto found;
- util_strscpyl(path, l, "/class/", sysname, NULL);
- if (stat(path_full, &statbuf) == 0)
+ util_strscpyl(path, sizeof(path), TEST_PREFIX "/sys/class/", sysname, NULL);
+ if (stat(path, &statbuf) == 0)
goto found;
goto out;
}
if (strcmp(subsystem, "module") == 0) {
- util_strscpyl(path, l, "/module/", sysname, NULL);
- if (stat(path_full, &statbuf) == 0)
+ util_strscpyl(path, sizeof(path), TEST_PREFIX "/sys/module/", sysname, NULL);
+ if (stat(path, &statbuf) == 0)
goto found;
goto out;
}
@@ -822,32 +815,32 @@ _public_ struct udev_device *udev_device_new_from_subsystem_sysname(struct udev
driver[0] = '\0';
driver = &driver[1];
- util_strscpyl(path, l, "/subsystem/", subsys, "/drivers/", driver, NULL);
- if (stat(path_full, &statbuf) == 0)
+ util_strscpyl(path, sizeof(path), TEST_PREFIX "/sys/subsystem/", subsys, "/drivers/", driver, NULL);
+ if (stat(path, &statbuf) == 0)
goto found;
- util_strscpyl(path, l, "/bus/", subsys, "/drivers/", driver, NULL);
- if (stat(path_full, &statbuf) == 0)
+ util_strscpyl(path, sizeof(path), TEST_PREFIX "/sys/bus/", subsys, "/drivers/", driver, NULL);
+ if (stat(path, &statbuf) == 0)
goto found;
}
goto out;
}
- util_strscpyl(path, l, "/subsystem/", subsystem, "/devices/", sysname, NULL);
- if (stat(path_full, &statbuf) == 0)
+ util_strscpyl(path, sizeof(path), TEST_PREFIX "/sys/subsystem/", subsystem, "/devices/", sysname, NULL);
+ if (stat(path, &statbuf) == 0)
goto found;
- util_strscpyl(path, l, "/bus/", subsystem, "/devices/", sysname, NULL);
- if (stat(path_full, &statbuf) == 0)
+ util_strscpyl(path, sizeof(path), TEST_PREFIX "/sys/bus/", subsystem, "/devices/", sysname, NULL);
+ if (stat(path, &statbuf) == 0)
goto found;
- util_strscpyl(path, l, "/class/", subsystem, "/", sysname, NULL);
- if (stat(path_full, &statbuf) == 0)
+ util_strscpyl(path, sizeof(path), TEST_PREFIX "/sys/class/", subsystem, "/", sysname, NULL);
+ if (stat(path, &statbuf) == 0)
goto found;
out:
return NULL;
found:
- return udev_device_new_from_syspath(udev, path_full);
+ return udev_device_new_from_syspath(udev, path);
}
/**
@@ -893,7 +886,7 @@ static struct udev_device *device_new_from_parent(struct udev_device *udev_devic
const char *subdir;
util_strscpy(path, sizeof(path), udev_device->syspath);
- subdir = &path[strlen(udev_get_sys_path(udev_device->udev))+1];
+ subdir = path + strlen(TEST_PREFIX "/sys/");
for (;;) {
char *pos;
@@ -1438,7 +1431,7 @@ int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath
udev_device->syspath = strdup(syspath);
if (udev_device->syspath == NULL)
return -ENOMEM;
- udev_device->devpath = &udev_device->syspath[strlen(udev_get_sys_path(udev_device->udev))];
+ udev_device->devpath = udev_device->syspath + strlen(TEST_PREFIX "/sys");
udev_device_add_property(udev_device, "DEVPATH", udev_device->devpath);
pos = strrchr(udev_device->syspath, '/');
@@ -1471,7 +1464,7 @@ int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode
{
free(udev_device->devnode);
if (devnode[0] != '/') {
- if (asprintf(&udev_device->devnode, "%s/%s", udev_get_dev_path(udev_device->udev), devnode) < 0)
+ if (asprintf(&udev_device->devnode, TEST_PREFIX "/dev/%s", devnode) < 0)
udev_device->devnode = NULL;
} else {
udev_device->devnode = strdup(devnode);
diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c
index 7b9a732ce6..ed4f62c66c 100644
--- a/src/libudev/libudev-enumerate.c
+++ b/src/libudev/libudev-enumerate.c
@@ -204,12 +204,10 @@ static bool devices_delay_end(struct udev *udev, const char *syspath)
"/block/dm-",
NULL
};
- size_t len;
int i;
- len = strlen(udev_get_sys_path(udev));
for (i = 0; delay_device_list[i] != NULL; i++) {
- if (strstr(&syspath[len], delay_device_list[i]) != NULL)
+ if (strstr(syspath + strlen("/sys"), delay_device_list[i]) != NULL)
return true;
}
return false;
@@ -624,7 +622,6 @@ static bool match_sysname(struct udev_enumerate *udev_enumerate, const char *sys
static int scan_dir_and_add_devices(struct udev_enumerate *udev_enumerate,
const char *basedir, const char *subdir1, const char *subdir2)
{
- struct udev *udev = udev_enumerate_get_udev(udev_enumerate);
char path[UTIL_PATH_SIZE];
size_t l;
char *s;
@@ -632,7 +629,7 @@ static int scan_dir_and_add_devices(struct udev_enumerate *udev_enumerate,
struct dirent *dent;
s = path;
- l = util_strpcpyl(&s, sizeof(path), udev_get_sys_path(udev), "/", basedir, NULL);
+ l = util_strpcpyl(&s, sizeof(path), "/sys/", basedir, NULL);
if (subdir1 != NULL)
l = util_strpcpyl(&s, l, "/", subdir1, NULL);
if (subdir2 != NULL)
@@ -707,13 +704,11 @@ static bool match_subsystem(struct udev_enumerate *udev_enumerate, const char *s
static int scan_dir(struct udev_enumerate *udev_enumerate, const char *basedir, const char *subdir, const char *subsystem)
{
- struct udev *udev = udev_enumerate_get_udev(udev_enumerate);
-
char path[UTIL_PATH_SIZE];
DIR *dir;
struct dirent *dent;
- util_strscpyl(path, sizeof(path), udev_get_sys_path(udev), "/", basedir, NULL);
+ util_strscpyl(path, sizeof(path), "/sys/", basedir, NULL);
dir = opendir(path);
if (dir == NULL)
return -1;
@@ -756,7 +751,6 @@ _public_ int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, c
static int scan_devices_tags(struct udev_enumerate *udev_enumerate)
{
- struct udev *udev = udev_enumerate_get_udev(udev_enumerate);
struct udev_list_entry *list_entry;
/* scan only tagged devices, use tags reverse-index, instead of searching all devices in /sys */
@@ -765,8 +759,7 @@ static int scan_devices_tags(struct udev_enumerate *udev_enumerate)
struct dirent *dent;
char path[UTIL_PATH_SIZE];
- util_strscpyl(path, sizeof(path), udev_get_run_path(udev), "/tags/",
- udev_list_entry_get_name(list_entry), NULL);
+ util_strscpyl(path, sizeof(path), "/run/udev/tags/", udev_list_entry_get_name(list_entry), NULL);
dir = opendir(path);
if (dir == NULL)
continue;
@@ -861,12 +854,9 @@ static int scan_devices_children(struct udev_enumerate *enumerate)
static int scan_devices_all(struct udev_enumerate *udev_enumerate)
{
- struct udev *udev = udev_enumerate_get_udev(udev_enumerate);
- char base[UTIL_PATH_SIZE];
struct stat statbuf;
- util_strscpyl(base, sizeof(base), udev_get_sys_path(udev), "/subsystem", NULL);
- if (stat(base, &statbuf) == 0) {
+ if (stat("/sys/subsystem", &statbuf) == 0) {
/* we have /subsystem/, forget all the old stuff */
scan_dir(udev_enumerate, "subsystem", "devices", NULL);
} else {
@@ -907,8 +897,6 @@ _public_ int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate)
**/
_public_ int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate)
{
- struct udev *udev = udev_enumerate_get_udev(udev_enumerate);
- char base[UTIL_PATH_SIZE];
struct stat statbuf;
const char *subsysdir;
@@ -919,8 +907,7 @@ _public_ int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerat
if (match_subsystem(udev_enumerate, "module"))
scan_dir_and_add_devices(udev_enumerate, "module", NULL, NULL);
- util_strscpyl(base, sizeof(base), udev_get_sys_path(udev), "/subsystem", NULL);
- if (stat(base, &statbuf) == 0)
+ if (stat("/sys/subsystem", &statbuf) == 0)
subsysdir = "subsystem";
else
subsysdir = "bus";
diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h
index 91f92264dd..986c40c91e 100644
--- a/src/libudev/libudev-private.h
+++ b/src/libudev/libudev-private.h
@@ -19,9 +19,13 @@
#include "macro.h"
#include "libudev.h"
-#define READ_END 0
+#define READ_END 0
#define WRITE_END 1
+#ifndef TEST_PREFIX
+#define TEST_PREFIX ""
+#endif
+
/* avoid (sometimes expensive) calculations of parameters for debug output */
#define udev_log_cond(udev, prio, arg...) \
do { \
diff --git a/src/libudev/libudev-queue-private.c b/src/libudev/libudev-queue-private.c
index ca6d229a2c..f653e6db4c 100644
--- a/src/libudev/libudev-queue-private.c
+++ b/src/libudev/libudev-queue-private.c
@@ -101,14 +101,10 @@ struct udev_queue_export *udev_queue_export_unref(struct udev_queue_export *udev
void udev_queue_export_cleanup(struct udev_queue_export *udev_queue_export)
{
- char filename[UTIL_PATH_SIZE];
-
if (udev_queue_export == NULL)
return;
- util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev_queue_export->udev), "/queue.tmp", NULL);
- unlink(filename);
- util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev_queue_export->udev), "/queue.bin", NULL);
- unlink(filename);
+ unlink("/run/udev/queue.tmp");
+ unlink("/run/udev/queue.bin");
}
static int skip_to(FILE *file, long offset)
@@ -201,8 +197,6 @@ static int rebuild_queue_file(struct udev_queue_export *udev_queue_export)
{
unsigned long long int seqnum;
struct queue_devpaths *devpaths = NULL;
- char filename[UTIL_PATH_SIZE];
- char filename_tmp[UTIL_PATH_SIZE];
FILE *new_queue_file = NULL;
unsigned int i;
@@ -218,8 +212,7 @@ static int rebuild_queue_file(struct udev_queue_export *udev_queue_export)
}
/* create new queue file */
- util_strscpyl(filename_tmp, sizeof(filename_tmp), udev_get_run_path(udev_queue_export->udev), "/queue.tmp", NULL);
- new_queue_file = fopen(filename_tmp, "w+");
+ new_queue_file = fopen("/run/udev/queue.tmp", "w+");
if (new_queue_file == NULL)
goto error;
seqnum = udev_queue_export->seqnum_max;
@@ -252,8 +245,7 @@ static int rebuild_queue_file(struct udev_queue_export *udev_queue_export)
goto error;
/* rename the new file on top of the old one */
- util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev_queue_export->udev), "/queue.bin", NULL);
- if (rename(filename_tmp, filename) != 0)
+ if (rename("/run/udev/queue.tmp", "/run/udev/queue.bin") != 0)
goto error;
if (udev_queue_export->queue_file != NULL)
diff --git a/src/libudev/libudev-queue.c b/src/libudev/libudev-queue.c
index 0e0df8597d..ca23002307 100644
--- a/src/libudev/libudev-queue.c
+++ b/src/libudev/libudev-queue.c
@@ -121,14 +121,12 @@ _public_ struct udev *udev_queue_get_udev(struct udev_queue *udev_queue)
unsigned long long int udev_get_kernel_seqnum(struct udev *udev)
{
- char filename[UTIL_PATH_SIZE];
unsigned long long int seqnum;
int fd;
char buf[32];
ssize_t len;
- util_strscpyl(filename, sizeof(filename), udev_get_sys_path(udev), "/kernel/uevent_seqnum", NULL);
- fd = open(filename, O_RDONLY|O_CLOEXEC);
+ fd = open("/sys/kernel/uevent_seqnum", O_RDONLY|O_CLOEXEC);
if (fd < 0)
return 0;
len = read(fd, buf, sizeof(buf));
@@ -210,7 +208,7 @@ static FILE *open_queue_file(struct udev_queue *udev_queue, unsigned long long i
char filename[UTIL_PATH_SIZE];
FILE *queue_file;
- util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev_queue->udev), "/queue.bin", NULL);
+ util_strscpyl(filename, sizeof(filename), "/run/udev/queue.bin", NULL);
queue_file = fopen(filename, "re");
if (queue_file == NULL)
return NULL;
@@ -437,7 +435,7 @@ _public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_qu
snprintf(seqnum_str, sizeof(seqnum_str), "%llu", seqnum);
s = syspath;
- l = util_strpcpyl(&s, sizeof(syspath), udev_get_sys_path(udev_queue->udev), NULL);
+ l = util_strpcpy(&s, sizeof(syspath), "/sys");
len = udev_queue_read_devpath(queue_file, s, l);
if (len < 0)
break;
diff --git a/src/libudev/libudev-selinux-private.c b/src/libudev/libudev-selinux-private.c
index d68097f991..e9e65ad41d 100644
--- a/src/libudev/libudev-selinux-private.c
+++ b/src/libudev/libudev-selinux-private.c
@@ -29,7 +29,7 @@ void udev_selinux_init(struct udev *udev)
dbg(udev, "selinux=%i\n", selinux_enabled);
if (!selinux_enabled)
return;
- matchpathcon_init_prefix(NULL, udev_get_dev_path(udev));
+ matchpathcon_init_prefix(NULL, TEST_PREFIX "/dev");
if (getfscreatecon(&selinux_prev_scontext) < 0) {
err(udev, "getfscreatecon failed\n");
selinux_prev_scontext = NULL;
diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c
index 74b53cbf1b..212c5fdd75 100644
--- a/src/libudev/libudev.c
+++ b/src/libudev/libudev.c
@@ -41,12 +41,6 @@ struct udev {
int priority, const char *file, int line, const char *fn,
const char *format, va_list args);
void *userdata;
- char *sys_path;
- char *dev_path;
- char *rules_path[4];
- unsigned long long rules_path_ts[4];
- int rules_path_count;
- char *run_path;
struct udev_list properties_list;
int log_priority;
};
@@ -100,14 +94,6 @@ _public_ void udev_set_userdata(struct udev *udev, void *userdata)
udev->userdata = userdata;
}
-static char *set_value(char **s, const char *v)
-{
- free(*s);
- *s = strdup(v);
- util_remove_trailing_chars(*s, '/');
- return *s;
-}
-
/**
* udev_new:
*
@@ -123,7 +109,6 @@ _public_ struct udev *udev_new(void)
{
struct udev *udev;
const char *env;
- char *config_file = NULL;
FILE *f;
udev = calloc(1, sizeof(struct udev));
@@ -134,21 +119,7 @@ _public_ struct udev *udev_new(void)
udev->log_priority = LOG_ERR;
udev_list_init(udev, &udev->properties_list, true);
- /* custom config file */
- env = getenv("UDEV_CONFIG_FILE");
- if (env != NULL) {
- if (set_value(&config_file, env) == NULL)
- goto err;
- udev_add_property(udev, "UDEV_CONFIG_FILE", config_file);
- }
-
- /* default config file */
- if (config_file == NULL)
- config_file = strdup(SYSCONFDIR "/udev/udev.conf");
- if (config_file == NULL)
- goto err;
-
- f = fopen(config_file, "re");
+ f = fopen(SYSCONFDIR "/udev/udev.conf", "re");
if (f != NULL) {
char line[UTIL_LINE_SIZE];
int line_nr = 0;
@@ -172,7 +143,7 @@ _public_ struct udev *udev_new(void)
/* split key/value */
val = strchr(key, '=');
if (val == NULL) {
- err(udev, "missing <key>=<value> in '%s'[%i], skip line\n", config_file, line_nr);
+ err(udev, "missing <key>=<value> in " SYSCONFDIR "/udev/udev.conf[%i]; skip line\n", line_nr);
continue;
}
val[0] = '\0';
@@ -204,7 +175,7 @@ _public_ struct udev *udev_new(void)
/* unquote */
if (val[0] == '"' || val[0] == '\'') {
if (val[len-1] != val[0]) {
- err(udev, "inconsistent quoting in '%s'[%i], skip line\n", config_file, line_nr);
+ err(udev, "inconsistent quoting in " SYSCONFDIR "/udev/udev.conf[%i]; skip line\n", line_nr);
continue;
}
val[len-1] = '\0';
@@ -215,23 +186,6 @@ _public_ struct udev *udev_new(void)
udev_set_log_priority(udev, util_log_priority(val));
continue;
}
- if (strcmp(key, "udev_root") == 0) {
- set_value(&udev->dev_path, val);
- continue;
- }
- if (strcmp(key, "udev_run") == 0) {
- set_value(&udev->run_path, val);
- continue;
- }
- if (strcmp(key, "udev_sys") == 0) {
- set_value(&udev->sys_path, val);
- continue;
- }
- if (strcmp(key, "udev_rules") == 0) {
- set_value(&udev->rules_path[0], val);
- udev->rules_path_count = 1;
- continue;
- }
}
fclose(f);
}
@@ -241,44 +195,7 @@ _public_ struct udev *udev_new(void)
if (env != NULL)
udev_set_log_priority(udev, util_log_priority(env));
- /* set defaults */
- if (udev->dev_path == NULL)
- if (set_value(&udev->dev_path, "/dev") == NULL)
- goto err;
-
- if (udev->sys_path == NULL)
- if (set_value(&udev->sys_path, "/sys") == NULL)
- goto err;
-
- if (udev->run_path == NULL)
- if (set_value(&udev->run_path, "/run/udev") == NULL)
- goto err;
-
- if (udev->rules_path[0] == NULL) {
- /* /usr/lib/udev -- system rules */
- udev->rules_path[0] = strdup(UDEVLIBEXECDIR "/rules.d");
- if (!udev->rules_path[0])
- goto err;
-
- /* /run/udev -- runtime rules */
- if (asprintf(&udev->rules_path[1], "%s/rules.d", udev->run_path) < 0)
- goto err;
-
- /* /etc/udev -- local administration rules */
- udev->rules_path[2] = strdup(SYSCONFDIR "/udev/rules.d");
- if (!udev->rules_path[2])
- goto err;
-
- udev->rules_path_count = 3;
- }
-
- free(config_file);
return udev;
-err:
- free(config_file);
- err(udev, "context creation failed\n");
- udev_unref(udev);
- return NULL;
}
/**
@@ -313,12 +230,6 @@ _public_ void udev_unref(struct udev *udev)
if (udev->refcount > 0)
return;
udev_list_cleanup(&udev->properties_list);
- free(udev->dev_path);
- free(udev->sys_path);
- free(udev->rules_path[0]);
- free(udev->rules_path[1]);
- free(udev->rules_path[2]);
- free(udev->run_path);
free(udev);
}
@@ -372,21 +283,11 @@ _public_ void udev_set_log_priority(struct udev *udev, int priority)
udev_add_property(udev, "UDEV_LOG", num);
}
-int udev_get_rules_path(struct udev *udev, char **path[], unsigned long long *stamp_usec[])
-{
- *path = udev->rules_path;
- if (stamp_usec)
- *stamp_usec = udev->rules_path_ts;
- return udev->rules_path_count;
-}
-
/**
* udev_get_sys_path:
* @udev: udev library context
*
- * Retrieve the sysfs mount point. The default is "/sys". For
- * testing purposes, it can be overridden with udev_sys=
- * in the udev configuration file.
+ * Returns always "/sys"; deprecated, will be removed in a future version.
*
* Returns: the sys mount point
**/
@@ -394,16 +295,14 @@ _public_ const char *udev_get_sys_path(struct udev *udev)
{
if (udev == NULL)
return NULL;
- return udev->sys_path;
+ return "/sys";
}
/**
* udev_get_dev_path:
* @udev: udev library context
*
- * Retrieve the device directory path. The default value is "/dev",
- * the actual value may be overridden in the udev configuration
- * file.
+ * Returns always "/dev"; deprecated, will be removed in a future version.
*
* Returns: the device directory path
**/
@@ -411,14 +310,14 @@ _public_ const char *udev_get_dev_path(struct udev *udev)
{
if (udev == NULL)
return NULL;
- return udev->dev_path;
+ return "/dev";
}
/**
* udev_get_run_path:
* @udev: udev library context
*
- * Retrieve the udev runtime directory path. The default is "/run/udev".
+ * Returns always "/run/udev"; deprecated, will be removed in a future version.
*
* Returns: the runtime directory path
**/
@@ -426,7 +325,7 @@ _public_ const char *udev_get_run_path(struct udev *udev)
{
if (udev == NULL)
return NULL;
- return udev->run_path;
+ return "/run/udev";
}
struct udev_list_entry *udev_add_property(struct udev *udev, const char *key, const char *value)