]> err.no Git - systemd/commitdiff
store devpath with the usual leading slash
authorKay Sievers <kay.sievers@vrfy.org>
Fri, 16 Mar 2007 02:09:02 +0000 (03:09 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Fri, 16 Mar 2007 02:09:02 +0000 (03:09 +0100)
udev_db.c
udevd.c
udevtrigger.c

index c07588db24b427f9cf4159dd220b3a8d06c20e3a..13d96894afdd6c9b7cd4effe679285f8f0d1f1b5 100644 (file)
--- a/udev_db.c
+++ b/udev_db.c
@@ -39,19 +39,11 @@ static size_t devpath_to_db_path(const char *devpath, char *filename, size_t len
 
        /* add location of db files */
        strlcpy(filename, udev_root, len);
-       start = strlcat(filename, "/"DB_DIR, len);
+       start = strlcat(filename, "/"DB_DIR"/", len);
        strlcat(filename, devpath, len);
-       return path_encode(&filename[start+1], len - (start+1));
+       return path_encode(&filename[start], len - start);
 }
 
-static size_t db_file_to_devpath(const char *filename, char *devpath, size_t len)
-{
-       strlcpy(devpath, "/", len);
-       strlcat(devpath, filename, len);
-       return path_decode(devpath);
-}
-
-
 /* reverse mapping from the device file name to the devpath */
 static int name_index(const char *devpath, const char *name, int add)
 {
@@ -64,10 +56,11 @@ static int name_index(const char *devpath, const char *name, int add)
        strlcpy(filename, udev_root, sizeof(filename));
        start = strlcat(filename, "/"DB_NAME_INDEX_DIR"/", sizeof(filename));
        strlcat(filename, name, sizeof(filename));
-       path_encode(&filename[start+1], sizeof(filename) - (start+1));
+       path_encode(&filename[start], sizeof(filename) - start);
        /* entry with the devpath */
        strlcpy(device, devpath, sizeof(device));
-       path_encode(&device[1], sizeof(device)-1);
+       path_encode(device, sizeof(device));
+       strlcat(filename, "/", sizeof(filename));
        strlcat(filename, device, sizeof(filename));
 
        if (add) {
@@ -261,7 +254,7 @@ int udev_db_lookup_name(const char *name, char *devpath, size_t len)
        strlcpy(dirname, udev_root, sizeof(dirname));
        start = strlcat(dirname, "/"DB_NAME_INDEX_DIR"/", sizeof(dirname));
        strlcat(dirname, name, sizeof(dirname));
-       path_encode(&dirname[start+1], sizeof(dirname) - (start+1));
+       path_encode(&dirname[start], sizeof(dirname) - start);
 
        dir = opendir(dirname);
        if (dir == NULL) {
@@ -282,8 +275,7 @@ int udev_db_lookup_name(const char *name, char *devpath, size_t len)
                if (ent->d_name[0] == '.')
                        continue;
 
-               strlcpy(device, "/", len);
-               strlcat(device, ent->d_name, sizeof(device));
+               strlcpy(device, ent->d_name, sizeof(device));
                path_decode(device);
 
                dbg("looking at '%s'", device);
@@ -326,7 +318,8 @@ int udev_db_get_all_entries(struct list_head *name_list)
                if (ent->d_name[0] == '.')
                        continue;
 
-               db_file_to_devpath(ent->d_name, device, sizeof(device));
+               strlcpy(device, ent->d_name, sizeof(device));
+               path_decode(device);
                name_list_add(name_list, device, 1);
                dbg("added '%s'", device);
        }
diff --git a/udevd.c b/udevd.c
index efb24ff6517ca9ad3607badf3fd82a24bff0e6cb..2c92590dcd2e46e30cf4969db672335bca164d2c 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -174,16 +174,16 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st
        /* add location of queue files */
        strlcpy(filename, udev_root, sizeof(filename));
        strlcat(filename, "/", sizeof(filename));
-       start = strlcat(filename, EVENT_QUEUE_DIR, sizeof(filename));
+       start = strlcat(filename, EVENT_QUEUE_DIR"/", sizeof(filename));
        strlcat(filename, msg->devpath, sizeof(filename));
-       path_encode(&filename[start+1], sizeof(filename) - (start+1));
+       path_encode(&filename[start], sizeof(filename) - start);
 
        /* add location of failed files */
        strlcpy(filename_failed, udev_root, sizeof(filename_failed));
        strlcat(filename_failed, "/", sizeof(filename_failed));
-       start = strlcat(filename_failed, EVENT_FAILED_DIR, sizeof(filename_failed));
+       start = strlcat(filename_failed, EVENT_FAILED_DIR"/", sizeof(filename_failed));
        strlcat(filename_failed, msg->devpath, sizeof(filename_failed));
-       path_encode(&filename_failed[start+1], sizeof(filename) - (start+1));
+       path_encode(&filename_failed[start], sizeof(filename) - start);
 
        switch (state) {
        case EVENT_QUEUED:
index 2bdd0c8d07a0b561bb63e6866f1f2ba0894115e5..7577c5f15ffd4232bbc6fdc92ecf3405ff064019 100644 (file)
@@ -412,8 +412,7 @@ static void scan_failed(void)
                        if (dent->d_name[0] == '.')
                                continue;
 
-                       strlcpy(device, sysfs_path, sizeof(device));
-                       start = strlcat(device, "/", sizeof(device));
+                       start = strlcpy(device, sysfs_path, sizeof(device));
                        strlcat(device, dent->d_name, sizeof(device));
                        path_decode(&device[start]);
                        device_list_insert(device);