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);
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);
{
return foreach_block_device(add_partitions);
}
-
-int
-do_mkfs (char *fstype, char *device)
-{
- char *err;
- int r;
-
- RESOLVE_DEVICE (device, return -1);
-
- 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;
-}