static void write_help(void);
static const cmdinfo_t write_cmd =
- { "write", NULL, write_f, 0, -1, 0, N_("[field or value]..."),
+ { "write", NULL, write_f, 0, -1, 0, N_("[-c] [field or value]..."),
N_("write value to disk"), write_help };
void
" String mode: 'write \"This_is_a_filename\" - write null terminated string.\n"
"\n"
" In data mode type 'write' by itself for a list of specific commands.\n\n"
+" Specifying the -c option will allow writes of invalid (corrupt) data.\n\n"
));
}
{
pfunc_t pf;
extern char *progname;
+ int c;
+ int corrupt = 0; /* Allow write of corrupt data; skip verification */
+ struct xfs_buf_ops nowrite_ops;
+ const struct xfs_buf_ops *stashed_ops = NULL;
if (x.isreadonly & LIBXFS_ISREADONLY) {
dbprintf(_("%s started in read only mode, writing disabled\n"),
return 0;
}
- /* move past the "write" command */
- argc--;
- argv++;
+ while ((c = getopt(argc, argv, "c")) != EOF) {
+ switch (c) {
+ case 'c':
+ corrupt = 1;
+ break;
+ default:
+ dbprintf(_("bad option for write command\n"));
+ return 0;
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ if (iocur_top->bp->b_ops && corrupt) {
+ /* Temporarily remove write verifier to write bad data */
+ stashed_ops = iocur_top->bp->b_ops;
+ nowrite_ops.verify_read = stashed_ops->verify_read;
+ nowrite_ops.verify_write = xfs_dummy_verify;
+ iocur_top->bp->b_ops = &nowrite_ops;
+ dbprintf(_("Allowing write of corrupted data\n"));
+ }
(*pf)(DB_WRITE, cur_typ->fields, argc, argv);
+ if (stashed_ops)
+ iocur_top->bp->b_ops = stashed_ops;
+
return 0;
}
bits respectively, and their string equivalent reported
(but no modifications are made).
.TP
-.BI "write [" "field value" "] ..."
+.BI "write [\-c] [" "field value" "] ..."
Write a value to disk.
Specific fields can be set in structures (struct mode),
or a block can be set to data values (data mode),
with a sequence, a constant value, or a random value. In this mode
.B write
with no arguments gives more information on the allowed commands.
+.RS 1.0i
+.TP 0.4i
+.B \-c
+Skip write verifiers and CRC recalculation; allows invalid data to be written
+to disk.
+.RE
.SH TYPES
This section gives the fields in each structure type and their meanings.
Note that some types of block cover multiple actual structures,