ui_draw_extra(cf);
if (fdisk_is_readonly(cf->cxt))
- ui_warnx(_("Device is open in read-only mode."));
+ ui_warnx(_("Device is open in read-only mode. Changes will remain in memory only."));
else if (cf->wrong_order)
ui_info(_("Note that partition table entries are not in disk order now."));
fputs(_(" -z, --zero start with zeroed partition table\n"), out);
fprintf(out,
_(" --lock[=<mode>] use exclusive device lock (%s, %s or %s)\n"), "yes", "no", "nonblock");
+ fputs(_(" -r, --read-only forced open cfdisk in read-only mode\n"), out);
fputs(USAGE_SEPARATOR, out);
printf(USAGE_HELP_OPTIONS(26));
{
const char *diskpath = NULL, *lockmode = NULL;
int rc, c, colormode = UL_COLORMODE_UNDEF;
+ int read_only = 0;
struct cfdisk _cf = { .lines_idx = 0 },
*cf = &_cf;
enum {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "zero", no_argument, NULL, 'z' },
+ { "read-only", no_argument, NULL, 'r' },
{ NULL, 0, NULL, 0 },
};
textdomain(PACKAGE);
close_stdout_atexit();
- while((c = getopt_long(argc, argv, "L::hVz", longopts, NULL)) != -1) {
+ while((c = getopt_long(argc, argv, "L::hVzr", longopts, NULL)) != -1) {
switch(c) {
case 'h':
usage();
colormode = colormode_or_err(optarg,
_("unsupported color mode"));
break;
+ case 'r':
+ read_only = 1;
+ break;
case 'V':
print_version(EXIT_SUCCESS);
case 'z':
} else
diskpath = argv[optind];
- rc = fdisk_assign_device(cf->cxt, diskpath, 0);
- if (rc == -EACCES)
+ rc = fdisk_assign_device(cf->cxt, diskpath, read_only);
+ if (rc == -EACCES && read_only == 0)
rc = fdisk_assign_device(cf->cxt, diskpath, 1);
if (rc != 0)
err(EXIT_FAILURE, _("cannot open %s"), diskpath);