chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
man pages: fix typos
[elogind.git]
/
udev_db.c
diff --git
a/udev_db.c
b/udev_db.c
index f00308bd2f49bf3cd57f81f3b5121c660290aa04..e9ae799132a1be4282e1bbc016d59293091a893a 100644
(file)
--- a/
udev_db.c
+++ b/
udev_db.c
@@
-30,21
+30,16
@@
#include <errno.h>
#include <dirent.h>
#include <errno.h>
#include <dirent.h>
-#include "libsysfs/sysfs/libsysfs.h"
-#include "udev_libc_wrapper.h"
#include "udev.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;
@@
-84,21
+79,21
@@
int udev_db_add_device(struct udevice *udev)
/* don't write anything if udev created only the node with the
* kernel name without any interesting data to remember
*/
/* don't write anything if udev created only the node with the
* kernel name without any interesting data to remember
*/
- if (strcmp(udev->name, udev->kernel_name) == 0 &&
+ if (strcmp(udev->name, udev->
dev->
kernel_name) == 0 &&
list_empty(&udev->symlink_list) && list_empty(&udev->env_list) &&
!udev->partitions && !udev->ignore_remove) {
dbg("nothing interesting to store in udevdb, skip");
goto exit;
}
list_empty(&udev->symlink_list) && list_empty(&udev->env_list) &&
!udev->partitions && !udev->ignore_remove) {
dbg("nothing interesting to store in udevdb, skip");
goto exit;
}
- devpath_to_db_path(udev->devpath, filename, sizeof(filename));
+ devpath_to_db_path(udev->dev
->dev
path, filename, sizeof(filename));
create_path(filename);
f = fopen(filename, "w");
if (f == NULL) {
err("unable to create db file '%s': %s", filename, strerror(errno));
return -1;
}
create_path(filename);
f = fopen(filename, "w");
if (f == NULL) {
err("unable to create db file '%s': %s", filename, strerror(errno));
return -1;
}
- dbg("storing data for device '%s' in '%s'", udev->devpath, filename);
+ dbg("storing data for device '%s' in '%s'", udev->dev
->dev
path, filename);
fprintf(f, "N:%s\n", udev->name);
list_for_each_entry(name_loop, &udev->symlink_list, node)
fprintf(f, "N:%s\n", udev->name);
list_for_each_entry(name_loop, &udev->symlink_list, node)
@@
-129,11
+124,11
@@
int udev_db_get_device(struct udevice *udev, const char *devpath)
devpath_to_db_path(devpath, filename, sizeof(filename));
if (file_map(filename, &buf, &bufsize) != 0) {
devpath_to_db_path(devpath, filename, sizeof(filename));
if (file_map(filename, &buf, &bufsize) != 0) {
-
dbg
("no db file to read %s: %s", filename, strerror(errno));
+
info
("no db file to read %s: %s", filename, strerror(errno));
return -1;
}
return -1;
}
- strlcpy(udev->dev
path, devpath, sizeof(u
dev->devpath));
+ strlcpy(udev->dev
->devpath, devpath, sizeof(udev->
dev->devpath));
cur = 0;
while (cur < bufsize) {
count = buf_get_line(buf, bufsize, cur);
cur = 0;
while (cur < bufsize) {
count = buf_get_line(buf, bufsize, cur);
@@
-197,7
+192,7
@@
int udev_db_delete_device(struct udevice *udev)
{
char filename[PATH_SIZE];
{
char filename[PATH_SIZE];
- devpath_to_db_path(udev->devpath, filename, sizeof(filename));
+ devpath_to_db_path(udev->dev
->dev
path, filename, sizeof(filename));
unlink(filename);
return 0;
unlink(filename);
return 0;
@@
-205,12
+200,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));
+
info("no udev_db available '%s': %s", db
path, strerror(errno));
return -1;
}
return -1;
}
@@
-230,7
+228,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
+272,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));
+
info("no udev_db available '%s': %s", db
path, strerror(errno));
return -1;
}
return -1;
}