int loop_cleanup(struct mkfs_opts *mop)
{
char cmd[150];
- int ret = 1;
+ int ret = 0;
+
if ((mop->mo_flags & MO_IS_LOOP) && *mop->mo_loopdev) {
+ int tries;
+
sprintf(cmd, "losetup -d %s", mop->mo_loopdev);
- ret = run_command(cmd, sizeof(cmd));
+ for (tries = 0; tries < 3; tries++) {
+ ret = run_command(cmd, sizeof(cmd));
+ if (ret == 0)
+ break;
+ sleep(1);
+ }
}
+
+ if (ret != 0)
+ fprintf(stderr, "cannot cleanup %s: rc = %d\n",
+ mop->mo_loopdev, ret);
return ret;
}
{
int fd;
- if (mop->mo_device_sz == 0) {
+ if (mop->mo_device_kb == 0) {
fatal();
fprintf(stderr, "loop device requires a --device-size= "
"param\n");
return errno;
}
- if (ftruncate(fd, mop->mo_device_sz * 1024) != 0) {
+ if (ftruncate(fd, mop->mo_device_kb * 1024) != 0) {
close(fd);
fatal();
fprintf(stderr, "%s: Unable to truncate backing store: %s\n",
*/
size_max = (off_t)1 << (_FILE_OFFSET_BITS - 1 - 10);
if (size >= size_max) {
- fprintf(stderr, "%s: %llu KB: Backing store size must be "
- "smaller than %llu KB\n", progname, size, size_max);
+ fprintf(stderr, "%s: "LPU64" KB: Backing store size must be "
+ "smaller than "LPU64" KB\n", progname, size, size_max);
return EFBIG;
}