+ cur = 0;
+ while (cur < bufsize) {
+ count = buf_get_line(buf, bufsize, cur);
+ bufline = &buf[cur];
+ cur += count+1;
+
+ switch(bufline[0]) {
+ case 'P':
+ if (count > sizeof(path))
+ count = sizeof(path);
+ memcpy(path, &bufline[2], count-2);
+ path[count-2] = '\0';
+ break;
+ case 'N':
+ case 'S':
+ if (count > sizeof(nodename))
+ count = sizeof(nodename);
+ memcpy(nodename, &bufline[2], count-2);
+ nodename[count-2] = '\0';
+ dbg("compare '%s' '%s'", nodename, name);
+ if (strcmp(nodename, name) == 0) {
+ strlcpy(devpath, nodename, len);
+ devpath[count-2] = '\0';
+ file_unmap(buf, bufsize);
+ closedir(dir);
+ return 0;
+ }
+ break;
+ default:
+ continue;