util_strscpy(p, sizeof(p), path);
pos = strrchr(p, '/');
- if (pos == p || pos == NULL)
+ if (pos == NULL)
return 0;
-
- while (pos[-1] == '/')
+ while (pos != p && pos[-1] == '/')
pos--;
+ if (pos == p)
+ return 0;
pos[0] = '\0';
dbg(udev, "stat '%s'\n", p);
char *pos;
int retval;
+ if (path[0] == '/')
+ while(path[1] == '/')
+ path++;
util_strscpy(p, sizeof(p), path);
pos = strrchr(p, '/');
if (pos == p || pos == NULL)