X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_db.c;h=e9ae799132a1be4282e1bbc016d59293091a893a;hp=e2b7b4d9214e6a40b53f27eca451b41e71e56ea0;hb=cdb5ecb8cf77f2a831022d14b1dcdaae2432c862;hpb=fc55cf68ca0c0db5172a9de7e827c6c3f7c2a308 diff --git a/udev_db.c b/udev_db.c index e2b7b4d92..e9ae79913 100644 --- a/udev_db.c +++ b/udev_db.c @@ -30,11 +30,7 @@ #include #include -#include "libsysfs/sysfs/libsysfs.h" -#include "udev_libc_wrapper.h" #include "udev.h" -#include "udev_utils.h" -#include "logging.h" static int devpath_to_db_path(const char *devpath, char *filename, size_t len) @@ -43,8 +39,7 @@ static int devpath_to_db_path(const char *devpath, char *filename, size_t len) /* add location of db files */ strlcpy(filename, udev_root, len); - strlcat(filename, "/", len); - start = strlcat(filename, DB_DIR, len); + start = strlcat(filename, "/"DB_DIR, 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 */ - 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; } - devpath_to_db_path(udev->devpath, filename, sizeof(filename)); + devpath_to_db_path(udev->dev->devpath, 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; } - dbg("storing data for device '%s' in '%s'", udev->devpath, filename); + dbg("storing data for device '%s' in '%s'", udev->dev->devpath, filename); fprintf(f, "N:%s\n", udev->name); list_for_each_entry(name_loop, &udev->symlink_list, node) @@ -133,7 +128,7 @@ int udev_db_get_device(struct udevice *udev, const char *devpath) return -1; } - strlcpy(udev->devpath, devpath, sizeof(udev->devpath)); + strlcpy(udev->dev->devpath, devpath, sizeof(udev->dev->devpath)); 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]; - devpath_to_db_path(udev->devpath, filename, sizeof(filename)); + devpath_to_db_path(udev->dev->devpath, filename, sizeof(filename)); unlink(filename); return 0; @@ -210,11 +205,10 @@ int udev_db_lookup_name(const char *name, char *devpath, size_t len) int found = 0; strlcpy(dbpath, udev_root, sizeof(dbpath)); - strlcat(dbpath, "/", sizeof(dbpath)); - strlcat(dbpath, DB_DIR, sizeof(dbpath)); + strlcat(dbpath, "/"DB_DIR, sizeof(dbpath)); dir = opendir(dbpath); if (dir == NULL) { - err("unable to open udev_db '%s': %s", dbpath, strerror(errno)); + info("no udev_db available '%s': %s", dbpath, strerror(errno)); return -1; } @@ -282,11 +276,10 @@ int udev_db_get_all_entries(struct list_head *name_list) DIR *dir; strlcpy(dbpath, udev_root, sizeof(dbpath)); - strlcat(dbpath, "/", sizeof(dbpath)); - strlcat(dbpath, DB_DIR, sizeof(dbpath)); + strlcat(dbpath, "/"DB_DIR, sizeof(dbpath)); dir = opendir(dbpath); if (dir == NULL) { - err("unable to open udev_db '%s': %s", dbpath, strerror(errno)); + info("no udev_db available '%s': %s", dbpath, strerror(errno)); return -1; }