Lars Ekman writes:
authorEric Andersen <andersen@codepoet.org>
Wed, 30 Jul 2003 08:55:59 +0000 (08:55 -0000)
committerEric Andersen <andersen@codepoet.org>
Wed, 30 Jul 2003 08:55:59 +0000 (08:55 -0000)
When using "losetup" the device is always setup as Read-Only.

(I have only tested with the -o flag, but looking at the code the
 problem seems general)

The problem is the "opt" variable in "losetup.c" that is reused in
the "set_loop()" call. Clear it before the call and everything is OK;

  opt = 0;         /* <-------- added line */
  if (delete)
    return del_loop (argv[optind]) ? EXIT_SUCCESS : EXIT_FAILURE;
  else
    return set_loop (argv[optind], argv[optind + 1], offset, &opt)
      ? EXIT_FAILURE : EXIT_SUCCESS;
}

Best Regards,
Lars Ekman

util-linux/losetup.c

index e2ea538d59662eeeb92bcd5216c6f39808619046..c94456522e8bf9d908a74f0fa7133b6c3d56356b 100644 (file)
@@ -50,6 +50,7 @@ losetup_main (int argc, char **argv)
       || (!delete && optind + 2 != argc))
     bb_show_usage();
 
+  opt = 0;
   if (delete)
     return del_loop (argv[optind]) ? EXIT_SUCCESS : EXIT_FAILURE;
   else