#include <fcntl.h>
+#include <getopt.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "libbcachefs/btree_iter.h"
#include "libbcachefs/error.h"
#include "libbcachefs/extents.h"
+#include "libbcachefs/sb-members.h"
#include "libbcachefs/super.h"
static void dump_usage(void)
"\n"
"Options:\n"
" -o output Output qcow2 image(s)\n"
- " -f Force; overwrite when needed\n"
- " -j Dump entire journal, not just dirty entries\n"
- " -h Display this help and exit\n"
+ " -f, --force Force; overwrite when needed\n"
+ " --nojournal Don't dump entire journal, just dirty entries\n"
+ " -h, --help Display this help and exit\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}
for (i = 0; i < BTREE_ID_NR; i++) {
const struct bch_extent_ptr *ptr;
struct bkey_ptrs_c ptrs;
- struct btree_trans trans;
+ struct btree_trans *trans = bch2_trans_get(c);
struct btree_iter iter;
struct btree *b;
- bch2_trans_init(&trans, c, 0, 0);
-
- __for_each_btree_node(&trans, iter, i, POS_MIN, 0, 1, 0, b, ret) {
+ __for_each_btree_node(trans, iter, i, POS_MIN, 0, 1, 0, b, ret) {
struct btree_node_iter iter;
struct bkey u;
struct bkey_s_c k;
btree_bytes(c));
}
- bch2_trans_iter_exit(&trans, &iter);
- bch2_trans_exit(&trans);
+ bch2_trans_iter_exit(trans, &iter);
+ bch2_trans_put(trans);
}
qcow2_write_image(ca->disk_sb.bdev->bd_buffered_fd, fd, &data,
int cmd_dump(int argc, char *argv[])
{
+ static const struct option longopts[] = {
+ { "force", no_argument, NULL, 'f' },
+ { "nojournal", no_argument, NULL, 'j' },
+ { "verbose", no_argument, NULL, 'v' },
+ { "help", no_argument, NULL, 'h' },
+ { NULL }
+ };
struct bch_opts opts = bch2_opts_empty();
struct bch_dev *ca;
char *out = NULL;
unsigned i, nr_devices = 0;
- bool force = false, entire_journal = false;
+ bool force = false, entire_journal = true;
int fd, opt;
+ opt_set(opts, read_only, true);
opt_set(opts, nochanges, true);
opt_set(opts, norecovery, true);
opt_set(opts, degraded, true);
opt_set(opts, errors, BCH_ON_ERROR_continue);
- opt_set(opts, fix_errors, FSCK_OPT_NO);
+ opt_set(opts, fix_errors, FSCK_FIX_no);
- while ((opt = getopt(argc, argv, "o:fjvh")) != -1)
+ while ((opt = getopt_long(argc, argv, "o:fvh",
+ longopts, NULL)) != -1)
switch (opt) {
case 'o':
out = optarg;
force = true;
break;
case 'j':
- entire_journal = true;
+ entire_journal = false;
break;
case 'v':
opt_set(opts, verbose, true);