chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
optimize SELinux path match
[elogind.git]
/
udev_db.c
diff --git
a/udev_db.c
b/udev_db.c
index 5caf3fda8049094aeefcbba3b8402baa4810fea9..6e9a1187d03f4c94d0d19e1c609da5c6a65a97c1 100644
(file)
--- a/
udev_db.c
+++ b/
udev_db.c
@@
-35,16
+35,15
@@
#include "udev.h"
#include "udev_utils.h"
#include "logging.h"
#include "udev.h"
#include "udev_utils.h"
#include "logging.h"
-#include "udev_db.h"
-#define PATH_TO_NAME_CHAR '@'
static int devpath_to_db_path(const char *devpath, char *filename, size_t len)
{
size_t start, end, i;
/* add location of db files */
static int devpath_to_db_path(const char *devpath, char *filename, size_t len)
{
size_t start, end, i;
/* add location of db files */
- start = strlcpy(filename, udev_db_path, len);
+ strlcpy(filename, udev_root, len);
+ start = strlcat(filename, "/"DB_DIR, len);
end = strlcat(filename, devpath, len);
if (end > len)
end = len;
end = strlcat(filename, devpath, len);
if (end > len)
end = len;
@@
-205,12
+204,15
@@
int udev_db_delete_device(struct udevice *udev)
int udev_db_lookup_name(const char *name, char *devpath, size_t len)
{
int udev_db_lookup_name(const char *name, char *devpath, size_t len)
{
+ char dbpath[PATH_MAX];
DIR *dir;
int found = 0;
DIR *dir;
int found = 0;
- dir = opendir(udev_db_path);
+ strlcpy(dbpath, udev_root, sizeof(dbpath));
+ strlcat(dbpath, "/"DB_DIR, sizeof(dbpath));
+ dir = opendir(dbpath);
if (dir == NULL) {
if (dir == NULL) {
- err("unable to open udev_db '%s': %s",
udev_db_
path, strerror(errno));
+ err("unable to open udev_db '%s': %s",
db
path, strerror(errno));
return -1;
}
return -1;
}
@@
-230,7
+232,7
@@
int udev_db_lookup_name(const char *name, char *devpath, size_t len)
if (ent->d_name[0] == '.')
continue;
if (ent->d_name[0] == '.')
continue;
- snprintf(filename, sizeof(filename), "%s/%s",
udev_db_
path, ent->d_name);
+ snprintf(filename, sizeof(filename), "%s/%s",
db
path, ent->d_name);
filename[sizeof(filename)-1] = '\0';
dbg("looking at '%s'", filename);
filename[sizeof(filename)-1] = '\0';
dbg("looking at '%s'", filename);
@@
-274,11
+276,14
@@
int udev_db_lookup_name(const char *name, char *devpath, size_t len)
int udev_db_get_all_entries(struct list_head *name_list)
{
int udev_db_get_all_entries(struct list_head *name_list)
{
+ char dbpath[PATH_MAX];
DIR *dir;
DIR *dir;
- dir = opendir(udev_db_path);
+ strlcpy(dbpath, udev_root, sizeof(dbpath));
+ strlcat(dbpath, "/"DB_DIR, sizeof(dbpath));
+ dir = opendir(dbpath);
if (dir == NULL) {
if (dir == NULL) {
- err("unable to open udev_db '%s': %s",
udev_db_
path, strerror(errno));
+ err("unable to open udev_db '%s': %s",
db
path, strerror(errno));
return -1;
}
return -1;
}