- strfieldcpy(temp, devpath);
- pos = strchr(&temp[1], '/');
- while (pos) {
- pos[0] = PATH_TO_NAME_CHAR;
- pos = strchr(&pos[1], '/');
- }
- snprintf(filename, len, "%s%s", udev_db_path, temp);
- filename[len-1] = '\0';
+ for (i = start+1; i < end; i++)
+ if (filename[i] == '/')
+ filename[i] = PATH_TO_NAME_CHAR;
+
+ return 0;
+}
+
+static int db_file_to_devpath(const char *filename, char *devpath, size_t len)
+{
+ size_t end, i;
+
+ strlcpy(devpath, "/", len);
+ end = strlcat(devpath, filename, len);
+
+ /* replace PATH_TO_NAME_CHAR to transform name into devpath */
+ for (i = 1; i < end; i++)
+ if (devpath[i] == PATH_TO_NAME_CHAR)
+ devpath[i] = '/';