/* 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)
{
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) {
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) {
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);
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);
}
/* 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: