break;
case 'c':
act = A_SET_CAPACITY;
- if (loopcxt_set_device(&lc, optarg))
+ if (!is_loopdev(optarg) ||
+ loopcxt_set_device(&lc, optarg))
err(EXIT_FAILURE, _("%s: failed to use device"),
optarg);
break;
break;
case 'd':
act = A_DELETE;
- if (loopcxt_set_device(&lc, optarg))
+ if (!is_loopdev(optarg) ||
+ loopcxt_set_device(&lc, optarg))
err(EXIT_FAILURE, _("%s: failed to use device"),
optarg);
break;
* losetup [--list] <device>
*/
act = A_SHOW_ONE;
- if (loopcxt_set_device(&lc, argv[optind]))
+ if (!is_loopdev(argv[optind]) ||
+ loopcxt_set_device(&lc, argv[optind]))
err(EXIT_FAILURE, _("%s: failed to use device"),
argv[optind]);
optind++;
if (optind >= argc)
errx(EXIT_FAILURE, _("no loop device specified"));
+ /* don't use is_loopdev() here, the device does not have exist yet */
if (loopcxt_set_device(&lc, argv[optind]))
err(EXIT_FAILURE, _("%s: failed to use device"),
argv[optind]);
case A_DELETE:
res = delete_loop(&lc);
while (optind < argc) {
- if (loopcxt_set_device(&lc, argv[optind]))
+ if (!is_loopdev(argv[optind]) ||
+ loopcxt_set_device(&lc, argv[optind]))
warn(_("%s: failed to use device"),
argv[optind]);
optind++;