- if (strncmp (d->d_name, "sd", 2) == 0 ||
- strncmp (d->d_name, "hd", 2) == 0 ||
- strncmp (d->d_name, "vd", 2) == 0) {
- strncpy (devname, d->d_name, sizeof devname);
- devname[sizeof devname - 1] = '\0';
-
- snprintf (buf, sizeof buf, "/sys/block/%s", devname);
-
- dir2 = opendir (buf);
- if (!dir2) {
- reply_with_perror ("opendir: %s", buf);
- free_stringslen (r, size);
- return NULL;
- }
- while ((d = readdir (dir2)) != NULL) {
- if (strncmp (d->d_name, devname, strlen (devname)) == 0) {
- snprintf (buf, sizeof buf, "/dev/%s", d->d_name);
-
- if (add_string (&r, &size, &alloc, buf) == -1) {
- closedir (dir2);
- closedir (dir);
- return NULL;
- }
- }
- }
+ if (STREQLEN (d->d_name, device, strlen (device))) {
+ char part[256];
+ snprintf (part, sizeof part, "/dev/%s", d->d_name);