X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fdevsparts.c;h=60e7aa8caa8da8b9f6175fd23f51e1ea04aeaed4;hp=b4ea57880733fc80ab962168b0a9a25c87ce982d;hb=4b753c62089be663ac722e4a875bb061d259e87d;hpb=84fc760439e82e6b3616abd0d1f9bd7d7eb01ec0 diff --git a/daemon/devsparts.c b/daemon/devsparts.c index b4ea578..60e7aa8 100644 --- a/daemon/devsparts.c +++ b/daemon/devsparts.c @@ -53,10 +53,10 @@ 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); @@ -153,7 +153,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); @@ -186,20 +186,3 @@ do_list_partitions (void) { return foreach_block_device(add_partitions); } - -int -do_mkfs (const char *fstype, const char *device) -{ - char *err; - int r; - - r = command (NULL, &err, "/sbin/mkfs", "-t", fstype, device, NULL); - if (r == -1) { - reply_with_error ("mkfs: %s", err); - free (err); - return -1; - } - - free (err); - return 0; -}