metablock->mb_blocklog = BBSHIFT;
metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC);
+ /* Set flags about state of metadump */
+ metablock->mb_info = XFS_METADUMP_INFO_FLAGS;
+ if (obfuscate)
+ metablock->mb_info |= XFS_METADUMP_OBFUSCATED;
+ if (!zero_stale_data)
+ metablock->mb_info |= XFS_METADUMP_FULLBLOCKS;
+
+ /* If we'll copy the log, see if the log is dirty */
+ if (mp->m_sb.sb_logstart) {
+ push_cur();
+ set_cur(&typtab[TYP_LOG],
+ XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
+ mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL);
+ if (iocur_top->data) { /* best effort */
+ struct xlog log;
+
+ if (xlog_is_dirty(mp, &log, &x, 0))
+ metablock->mb_info |= XFS_METADUMP_DIRTYLOG;
+ }
+ pop_cur();
+ }
+
block_index = (__be64 *)((char *)metablock + sizeof(xfs_metablock_t));
block_buffer = (char *)metablock + BBSIZE;
num_indices = (BBSIZE - sizeof(xfs_metablock_t)) / sizeof(__be64);
__be32 mb_magic;
__be16 mb_count;
__uint8_t mb_blocklog;
- __uint8_t mb_reserved;
+ __uint8_t mb_info;
/* followed by an array of xfs_daddr_t */
} xfs_metablock_t;
+/* These flags are informational only, not backwards compatible */
+#define XFS_METADUMP_INFO_FLAGS (1 << 0) /* This image has informative flags */
+#define XFS_METADUMP_OBFUSCATED (1 << 1)
+#define XFS_METADUMP_FULLBLOCKS (1 << 2)
+#define XFS_METADUMP_DIRTYLOG (1 << 3)
+
#endif /* _XFS_METADUMP_H_ */
.SH SYNOPSIS
.B xfs_mdrestore
[
-.B \-g
+.B \-gi
]
.I source
.I target
.br
+.B xfs_mdrestore
+.B \-i
+.I source
+.br
.B xfs_mdrestore \-V
.SH DESCRIPTION
.B xfs_mdrestore
.B \-g
Shows restore progress on stdout.
.TP
+.B \-i
+Shows metadump information on stdout. If no
+.I target
+is specified, exits after displaying information. Older metadumps man not
+include any descriptive information.
+.TP
.B \-V
Prints the version number and exits.
.SH DIAGNOSTICS
char *progname;
int show_progress = 0;
+int show_info = 0;
int progress_since_warning = 0;
static void
progname = basename(argv[0]);
- while ((c = getopt(argc, argv, "gV")) != EOF) {
+ while ((c = getopt(argc, argv, "giV")) != EOF) {
switch (c) {
case 'g':
show_progress = 1;
break;
+ case 'i':
+ show_info = 1;
+ break;
case 'V':
printf("%s version %s\n", progname, VERSION);
exit(0);
}
}
- if (argc - optind != 2)
+ if (argc - optind < 1 || argc - optind > 2)
+ usage();
+
+ /* show_info without a target is ok */
+ if (!show_info && argc - optind != 2)
usage();
/* open source */
if (src_f == NULL)
fatal("cannot open source dump file\n");
}
+
+ if (show_info) {
+ xfs_metablock_t mb;
+
+ if (fread(&mb, sizeof(mb), 1, src_f) != 1)
+ fatal("error reading from file: %s\n", strerror(errno));
+
+ if (be32_to_cpu(mb.mb_magic) != XFS_MD_MAGIC)
+ fatal("specified file is not a metadata dump\n");
+
+ if (mb.mb_info & XFS_METADUMP_INFO_FLAGS) {
+ printf("%s: %sobfuscated, %s log, %s metadata blocks\n",
+ argv[optind],
+ mb.mb_info & XFS_METADUMP_OBFUSCATED ? "":"not ",
+ mb.mb_info & XFS_METADUMP_DIRTYLOG ? "dirty":"clean",
+ mb.mb_info & XFS_METADUMP_FULLBLOCKS ? "full":"zeroed");
+ } else {
+ printf("%s: no informational flags present\n",
+ argv[optind]);
+ }
+
+ if (argc - optind == 1)
+ exit(0);
+
+ /* Go back to the beginning for the restore function */
+ fseek(src_f, 0L, SEEK_SET);
+ }
+
optind++;
/* check and open target */