int
main(int argc, const char *const *argv)
{
- if (argc != 2) {
+ if (argc != 2 || strncmp(argv[1], "/dev/zd", 7) != 0) {
fprintf(stderr, "usage: %s /dev/zdX\n", argv[0]);
return (1);
}
return (1);
}
- unsigned int dev_part = minor(sb.st_rdev) % ZVOL_MINORS;
- if (dev_part != 0)
- sprintf(zvol_name + strlen(zvol_name), "-part%u", dev_part);
+ const char *dev_part = strrchr(dev_name, 'p');
+ if (dev_part != NULL) {
+ sprintf(zvol_name + strlen(zvol_name), "-part%s", dev_part + 1);
+ }
for (size_t i = 0; i < strlen(zvol_name); ++i)
if (isblank(zvol_name[i]))