X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fdevsparts.c;h=95e4a6828e6d1767c9147afbe39ed41a4eb57783;hb=6a87e0af24e957398ddae7db3c37da5d23f6686c;hp=76852cca972c3c69cdb1fa797d61143dd2fb2f01;hpb=a61bccecfba1c9501910d28de24bac945e95001f;p=libguestfs.git diff --git a/daemon/devsparts.c b/daemon/devsparts.c index 76852cc..95e4a68 100644 --- a/daemon/devsparts.c +++ b/daemon/devsparts.c @@ -53,13 +53,17 @@ foreach_block_device (block_dev_func_t func) struct dirent *d = readdir(dir); if(NULL == d) break; - if (strncmp (d->d_name, "sd", 2) == 0 || - strncmp (d->d_name, "hd", 2) == 0 || - strncmp (d->d_name, "vd", 2) == 0 || - strncmp (d->d_name, "sr", 2) == 0) { + if (STREQLEN (d->d_name, "sd", 2) || + STREQLEN (d->d_name, "hd", 2) || + STREQLEN (d->d_name, "vd", 2) || + STREQLEN (d->d_name, "sr", 2)) { char dev_path[256]; snprintf (dev_path, sizeof dev_path, "/dev/%s", d->d_name); + /* Ignore the root device. */ + if (is_root_device (dev_path)) + continue; + /* RHBZ#514505: Some versions of qemu <= 0.10 add a * CD-ROM device even though we didn't request it. Try to * detect this by seeing if the device contains media. @@ -153,7 +157,7 @@ add_partitions(const char *device, errno = 0; struct dirent *d; while ((d = readdir (dir)) != NULL) { - if (strncmp (d->d_name, device, strlen (device)) == 0) { + if (STREQLEN (d->d_name, device, strlen (device))) { char part[256]; snprintf (part, sizeof part, "/dev/%s", d->d_name);