#include "libbcachefs.h"
#include "crypto.h"
#include "libbcachefs/darray.h"
+#include "libbcachefs/errcode.h"
#include "libbcachefs/opts.h"
#include "libbcachefs/super-io.h"
#include "libbcachefs/util.h"
"Device specific options must come before corresponding devices, e.g.\n"
" bcachefs format --label cache /dev/sdb /dev/sdc\n"
"\n"
- "Report bugs to <linux-bcache@vger.kernel.org>");
+ "Report bugs to <linux-bcachefs@vger.kernel.org>");
}
enum {
initialize = false;
break;
case O_no_opt:
- darray_push(device_paths, optarg);
+ darray_push(&device_paths, optarg);
dev_opts.path = optarg;
- darray_push(devices, dev_opts);
+ darray_push(&devices, dev_opts);
dev_opts.size = 0;
break;
case O_quiet:
break;
}
+ if (opts.version != bcachefs_metadata_version_current)
+ initialize = false;
+
if (!devices.nr)
die("Please supply a device");
if (!quiet) {
struct printbuf buf = PRINTBUF;
- buf.units = PRINTBUF_UNITS_HUMAN_READABLE;
+ buf.human_readable_units = true;
bch2_sb_to_text(&buf, sb, false, 1 << BCH_SB_FIELD_members);
printf("%s", buf.buf);
free(opts.passphrase);
}
- darray_exit(devices);
+ darray_exit(&devices);
if (initialize) {
struct bch_opts mount_opts = bch2_opts_empty();
mount_opts);
if (IS_ERR(c))
die("error opening %s: %s", device_paths.data[0],
- strerror(-PTR_ERR(c)));
+ bch2_err_str(PTR_ERR(c)));
bch2_fs_stop(c);
}
- darray_exit(device_paths);
+ darray_exit(&device_paths);
return 0;
}
" -f, --fields=(fields) list of sections to print\n"
" -l, --layout print superblock layout\n"
" -h, --help display this help and exit\n"
- "Report bugs to <linux-bcache@vger.kernel.org>");
+ "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}
struct bch_sb_handle sb;
int ret = bch2_read_super(dev, &opts, &sb);
if (ret)
- die("Error opening %s: %s", dev, strerror(-ret));
+ die("Error opening %s: %s", dev, bch2_err_str(ret));
struct printbuf buf = PRINTBUF;
- buf.units = PRINTBUF_UNITS_HUMAN_READABLE;
+ buf.human_readable_units = true;
bch2_sb_to_text(&buf, sb.sb, print_layout, fields);
printf("%s", buf.buf);