return;
break;
case 'z':
+#ifdef READ_ONLY
+ goto print_usage;
+#else
undo_file = optarg;
+#endif
break;
default:
goto print_usage;
print_usage:
fprintf(stderr, "%s: Usage: open [-s superblock] [-b blocksize] "
+#ifdef READ_ONLY
"[-d image_filename] [-z undo_file] [-c] [-i] [-f] [-e] [-D] "
-#ifndef READ_ONLY
- "[-w] "
+#else
+ "[-d image_filename] [-c] [-i] [-f] [-e] [-D] [-w] "
#endif
"<device>\n", argv[0]);
}
return;
}
}
-#endif /* READ_ONLY */
void do_symlink(int argc, char *argv[], int sci_idx EXT2FS_ATTR((unused)),
void *infop EXT2FS_ATTR((unused)))
com_err(argv[0], retval, 0);
}
+#endif /* READ_ONLY */
#if CONFIG_MMP
void do_dump_mmp(int argc EXT2FS_ATTR((unused)), char *argv[],
const char *opt_string = "nicR:f:b:s:Vd:D";
#else
const char *opt_string = "niwcR:f:b:s:Vd:Dz:";
- char *undo_file = NULL;
#endif
+ char *undo_file = NULL;
#ifdef CONFIG_JBD_DEBUG
char *jbd_debug;
#endif
fprintf(stderr, "\tUsing %s\n",
error_message(EXT2_ET_BASE));
exit(0);
+#ifndef READ_ONLY
case 'z':
undo_file = optarg;
break;
+#endif
default:
com_err(argv[0], 0, usage, debug_prog_name);
return 1;
/* util.c */
extern __s64 string_to_time(const char *arg);
-errcode_t read_list(char *str, blk64_t **list, size_t *len);
+extern errcode_t read_list(char *str, blk64_t **list, size_t *len);
+extern void do_byte_hexdump(FILE *fp, unsigned char *buf, size_t bufsize);
/* xattrs.c */
void dump_inode_attributes(FILE *out, ext2_ino_t ino);
/* zap.c */
extern void do_zap_block(int argc, char **argv, int sci_idx, void *infop);
extern void do_block_dump(int argc, char **argv, int sci_idx, void *infop);
-extern void do_byte_hexdump(FILE *fp, unsigned char *buf, size_t bufsize);
free(lst);
return retval;
}
+
+void do_byte_hexdump(FILE *fp, unsigned char *buf, size_t bufsize)
+{
+ size_t i, j, max;
+ int suppress = -1;
+
+ for (i = 0; i < bufsize; i += 16) {
+ max = (bufsize - i > 16) ? 16 : bufsize - i;
+ if (suppress < 0) {
+ if (i && memcmp(buf + i, buf + i - max, max) == 0) {
+ suppress = i;
+ fprintf(fp, "*\n");
+ continue;
+ }
+ } else {
+ if (memcmp(buf + i, buf + suppress, max) == 0)
+ continue;
+ suppress = -1;
+ }
+ fprintf(fp, "%04o ", (unsigned int)i);
+ for (j = 0; j < 16; j++) {
+ if (j < max)
+ fprintf(fp, "%02x", buf[i+j]);
+ else
+ fprintf(fp, " ");
+ if ((j % 2) == 1)
+ fprintf(fp, " ");
+ }
+ fprintf(fp, " ");
+ for (j = 0; j < max; j++)
+ fprintf(fp, "%c", isprint(buf[i+j]) ? buf[i+j] : '.');
+ fprintf(fp, "\n");
+ }
+ fprintf(fp, "\n");
+}
errout:
free(buf);
}
-
-void do_byte_hexdump(FILE *fp, unsigned char *buf, size_t bufsize)
-{
- size_t i, j, max;
- int suppress = -1;
-
- for (i = 0; i < bufsize; i += 16) {
- max = (bufsize - i > 16) ? 16 : bufsize - i;
- if (suppress < 0) {
- if (i && memcmp(buf + i, buf + i - max, max) == 0) {
- suppress = i;
- fprintf(fp, "*\n");
- continue;
- }
- } else {
- if (memcmp(buf + i, buf + suppress, max) == 0)
- continue;
- suppress = -1;
- }
- fprintf(fp, "%04o ", (unsigned int)i);
- for (j = 0; j < 16; j++) {
- if (j < max)
- fprintf(fp, "%02x", buf[i+j]);
- else
- fprintf(fp, " ");
- if ((j % 2) == 1)
- fprintf(fp, " ");
- }
- fprintf(fp, " ");
- for (j = 0; j < max; j++)
- fprintf(fp, "%c", isprint(buf[i+j]) ? buf[i+j] : '.');
- fprintf(fp, "\n");
- }
- fprintf(fp, "\n");
-}