mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-22 00:00:03 +03:00
Use bch2_err_str() instead of strerror()
This correctly prints out our private error codes. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
e2670a38d1
commit
1eae1d718c
11
cmd_device.c
11
cmd_device.c
@ -14,6 +14,7 @@
|
||||
|
||||
#include "libbcachefs/bcachefs.h"
|
||||
#include "libbcachefs/bcachefs_ioctl.h"
|
||||
#include "libbcachefs/errcode.h"
|
||||
#include "libbcachefs/journal.h"
|
||||
#include "libbcachefs/super-io.h"
|
||||
#include "cmds.h"
|
||||
@ -410,7 +411,7 @@ int cmd_device_set_state(int argc, char *argv[])
|
||||
|
||||
int ret = bch2_read_super(dev_str, &opts, &sb);
|
||||
if (ret)
|
||||
die("error opening %s: %s", dev_str, strerror(-ret));
|
||||
die("error opening %s: %s", dev_str, bch2_err_str(ret));
|
||||
|
||||
struct bch_member *m = bch2_sb_get_members(sb.sb)->members + sb.sb->dev_idx;
|
||||
|
||||
@ -527,7 +528,7 @@ int cmd_device_resize(int argc, char *argv[])
|
||||
|
||||
struct bch_fs *c = bch2_fs_open(&dev, 1, bch2_opts_empty());
|
||||
if (IS_ERR(c))
|
||||
die("error opening %s: %s", dev, strerror(-PTR_ERR(c)));
|
||||
die("error opening %s: %s", dev, bch2_err_str(PTR_ERR(c)));
|
||||
|
||||
struct bch_dev *ca, *resize = NULL;
|
||||
unsigned i;
|
||||
@ -547,7 +548,7 @@ int cmd_device_resize(int argc, char *argv[])
|
||||
printf("resizing %s to %llu buckets\n", dev, nbuckets);
|
||||
int ret = bch2_dev_resize(c, resize, nbuckets);
|
||||
if (ret)
|
||||
fprintf(stderr, "resize error: %s\n", strerror(-ret));
|
||||
fprintf(stderr, "resize error: %s\n", bch2_err_str(ret));
|
||||
|
||||
percpu_ref_put(&resize->io_ref);
|
||||
bch2_fs_stop(c);
|
||||
@ -630,7 +631,7 @@ int cmd_device_resize_journal(int argc, char *argv[])
|
||||
|
||||
struct bch_fs *c = bch2_fs_open(&dev, 1, bch2_opts_empty());
|
||||
if (IS_ERR(c))
|
||||
die("error opening %s: %s", dev, strerror(-PTR_ERR(c)));
|
||||
die("error opening %s: %s", dev, bch2_err_str(PTR_ERR(c)));
|
||||
|
||||
struct bch_dev *ca, *resize = NULL;
|
||||
unsigned i;
|
||||
@ -647,7 +648,7 @@ int cmd_device_resize_journal(int argc, char *argv[])
|
||||
printf("resizing journal on %s to %llu buckets\n", dev, nbuckets);
|
||||
int ret = bch2_set_nr_journal_buckets(c, resize, nbuckets);
|
||||
if (ret)
|
||||
fprintf(stderr, "resize error: %s\n", strerror(-ret));
|
||||
fprintf(stderr, "resize error: %s\n", bch2_err_str(ret));
|
||||
|
||||
percpu_ref_put(&resize->io_ref);
|
||||
bch2_fs_stop(c);
|
||||
|
@ -82,7 +82,7 @@ static void dump_one_device(struct bch_fs *c, struct bch_dev *ca, int fd,
|
||||
}
|
||||
|
||||
if (ret)
|
||||
die("error %s walking btree nodes", strerror(-ret));
|
||||
die("error %s walking btree nodes", bch2_err_str(ret));
|
||||
|
||||
b = c->btree_roots[i].b;
|
||||
if (!btree_node_fake(b)) {
|
||||
@ -147,7 +147,7 @@ int cmd_dump(int argc, char *argv[])
|
||||
|
||||
struct bch_fs *c = bch2_fs_open(argv, argc, opts);
|
||||
if (IS_ERR(c))
|
||||
die("error opening %s: %s", argv[0], strerror(-PTR_ERR(c)));
|
||||
die("error opening %s: %s", argv[0], bch2_err_str(PTR_ERR(c)));
|
||||
|
||||
down_read(&c->gc_lock);
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#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"
|
||||
@ -270,7 +271,7 @@ int cmd_format(int argc, char *argv[])
|
||||
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);
|
||||
}
|
||||
@ -336,7 +337,7 @@ int cmd_show_super(int argc, char *argv[])
|
||||
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;
|
||||
|
||||
|
@ -89,7 +89,7 @@ int cmd_fsck(int argc, char *argv[])
|
||||
|
||||
struct bch_fs *c = bch2_fs_open(argv, argc, opts);
|
||||
if (IS_ERR(c)) {
|
||||
fprintf(stderr, "error opening %s: %s\n", argv[0], strerror(-PTR_ERR(c)));
|
||||
fprintf(stderr, "error opening %s: %s\n", argv[0], bch2_err_str(PTR_ERR(c)));
|
||||
exit(8);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "libbcachefs/btree_iter.h"
|
||||
#include "libbcachefs/buckets.h"
|
||||
#include "libbcachefs/dirent.h"
|
||||
#include "libbcachefs/errcode.h"
|
||||
#include "libbcachefs/error.h"
|
||||
#include "libbcachefs/fs-common.h"
|
||||
#include "libbcachefs/inode.h"
|
||||
@ -1229,7 +1230,7 @@ int cmd_fusemount(int argc, char *argv[])
|
||||
c = bch2_fs_open(ctx.devices, ctx.nr_devices, bch_opts);
|
||||
if (IS_ERR(c))
|
||||
die("error opening %s: %s", ctx.devices_str,
|
||||
strerror(-PTR_ERR(c)));
|
||||
bch2_err_str(PTR_ERR(c)));
|
||||
|
||||
/* Fuse */
|
||||
struct fuse_session *se =
|
||||
|
@ -55,7 +55,7 @@ int cmd_unlock(int argc, char *argv[])
|
||||
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));
|
||||
|
||||
if (!bch2_sb_is_encrypted(sb.sb))
|
||||
die("%s is not encrypted", dev);
|
||||
@ -90,7 +90,7 @@ int cmd_set_passphrase(int argc, char *argv[])
|
||||
|
||||
c = bch2_fs_open(argv + 1, argc - 1, opts);
|
||||
if (IS_ERR(c))
|
||||
die("Error opening %s: %s", argv[1], strerror(-PTR_ERR(c)));
|
||||
die("Error opening %s: %s", argv[1], bch2_err_str(PTR_ERR(c)));
|
||||
|
||||
struct bch_sb_field_crypt *crypt = bch2_sb_get_crypt(c->disk_sb.sb);
|
||||
if (!crypt)
|
||||
@ -127,7 +127,7 @@ int cmd_remove_passphrase(int argc, char *argv[])
|
||||
opt_set(opts, nostart, true);
|
||||
c = bch2_fs_open(argv + 1, argc - 1, opts);
|
||||
if (IS_ERR(c))
|
||||
die("Error opening %s: %s", argv[1], strerror(-PTR_ERR(c)));
|
||||
die("Error opening %s: %s", argv[1], bch2_err_str(PTR_ERR(c)));
|
||||
|
||||
struct bch_sb_field_crypt *crypt = bch2_sb_get_crypt(c->disk_sb.sb);
|
||||
if (!crypt)
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "libbcachefs/bcachefs.h"
|
||||
#include "libbcachefs/btree_iter.h"
|
||||
#include "libbcachefs/errcode.h"
|
||||
#include "libbcachefs/error.h"
|
||||
#include "libbcachefs/super.h"
|
||||
|
||||
@ -60,7 +61,7 @@ int cmd_kill_btree_node(int argc, char *argv[])
|
||||
|
||||
struct bch_fs *c = bch2_fs_open(argv, argc, opts);
|
||||
if (IS_ERR(c))
|
||||
die("error opening %s: %s", argv[0], strerror(-PTR_ERR(c)));
|
||||
die("error opening %s: %s", argv[0], bch2_err_str(PTR_ERR(c)));
|
||||
|
||||
struct btree_trans trans;
|
||||
struct btree_iter iter;
|
||||
@ -70,7 +71,7 @@ int cmd_kill_btree_node(int argc, char *argv[])
|
||||
|
||||
ret = posix_memalign(&zeroes, c->opts.block_size, c->opts.block_size);
|
||||
if (ret)
|
||||
die("error %s from posix_memalign", strerror(ret));
|
||||
die("error %s from posix_memalign", bch2_err_str(ret));
|
||||
|
||||
bch2_trans_init(&trans, c, 0, 0);
|
||||
|
||||
|
10
cmd_list.c
10
cmd_list.c
@ -67,7 +67,7 @@ static void list_btree_formats(struct bch_fs *c, enum btree_id btree_id, unsigne
|
||||
bch2_trans_iter_exit(&trans, &iter);
|
||||
|
||||
if (ret)
|
||||
die("error %s walking btree nodes", strerror(-ret));
|
||||
die("error %s walking btree nodes", bch2_err_str(ret));
|
||||
|
||||
bch2_trans_exit(&trans);
|
||||
printbuf_exit(&buf);
|
||||
@ -96,7 +96,7 @@ static void list_nodes(struct bch_fs *c, enum btree_id btree_id, unsigned level,
|
||||
bch2_trans_iter_exit(&trans, &iter);
|
||||
|
||||
if (ret)
|
||||
die("error %s walking btree nodes", strerror(-ret));
|
||||
die("error %s walking btree nodes", bch2_err_str(ret));
|
||||
|
||||
bch2_trans_exit(&trans);
|
||||
printbuf_exit(&buf);
|
||||
@ -232,7 +232,7 @@ static void list_nodes_ondisk(struct bch_fs *c, enum btree_id btree_id, unsigned
|
||||
bch2_trans_iter_exit(&trans, &iter);
|
||||
|
||||
if (ret)
|
||||
die("error %s walking btree nodes", strerror(-ret));
|
||||
die("error %s walking btree nodes", bch2_err_str(ret));
|
||||
|
||||
bch2_trans_exit(&trans);
|
||||
printbuf_exit(&buf);
|
||||
@ -270,7 +270,7 @@ static void list_nodes_keys(struct bch_fs *c, enum btree_id btree_id, unsigned l
|
||||
bch2_trans_iter_exit(&trans, &iter);
|
||||
|
||||
if (ret)
|
||||
die("error %s walking btree nodes", strerror(-ret));
|
||||
die("error %s walking btree nodes", bch2_err_str(ret));
|
||||
|
||||
bch2_trans_exit(&trans);
|
||||
printbuf_exit(&buf);
|
||||
@ -376,7 +376,7 @@ int cmd_list(int argc, char *argv[])
|
||||
|
||||
struct bch_fs *c = bch2_fs_open(argv, argc, opts);
|
||||
if (IS_ERR(c))
|
||||
die("error opening %s: %s", argv[0], strerror(-PTR_ERR(c)));
|
||||
die("error opening %s: %s", argv[0], bch2_err_str(PTR_ERR(c)));
|
||||
|
||||
|
||||
for (btree_id = btree_id_start;
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "libbcachefs/bcachefs.h"
|
||||
#include "libbcachefs/btree_iter.h"
|
||||
#include "libbcachefs/errcode.h"
|
||||
#include "libbcachefs/error.h"
|
||||
#include "libbcachefs/journal_io.h"
|
||||
#include "libbcachefs/journal_seq_blacklist.h"
|
||||
@ -75,7 +76,7 @@ int cmd_list_journal(int argc, char *argv[])
|
||||
|
||||
struct bch_fs *c = bch2_fs_open(argv, argc, opts);
|
||||
if (IS_ERR(c))
|
||||
die("error opening %s: %s", argv[0], strerror(-PTR_ERR(c)));
|
||||
die("error opening %s: %s", argv[0], bch2_err_str(PTR_ERR(c)));
|
||||
|
||||
struct journal_replay *p, **_p;
|
||||
struct genradix_iter iter;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "libbcachefs/btree_update.h"
|
||||
#include "libbcachefs/buckets.h"
|
||||
#include "libbcachefs/dirent.h"
|
||||
#include "libbcachefs/errcode.h"
|
||||
#include "libbcachefs/fs-common.h"
|
||||
#include "libbcachefs/inode.h"
|
||||
#include "libbcachefs/io.h"
|
||||
@ -127,7 +128,7 @@ static void update_inode(struct bch_fs *c,
|
||||
ret = bch2_btree_insert(c, BTREE_ID_inodes, &packed.inode.k_i,
|
||||
NULL, NULL, 0);
|
||||
if (ret)
|
||||
die("error updating inode: %s", strerror(-ret));
|
||||
die("error updating inode: %s", bch2_err_str(ret));
|
||||
}
|
||||
|
||||
static void create_link(struct bch_fs *c,
|
||||
@ -143,7 +144,7 @@ static void create_link(struct bch_fs *c,
|
||||
(subvol_inum) { 1, parent->bi_inum }, &parent_u,
|
||||
(subvol_inum) { 1, inum }, &inode, &qstr));
|
||||
if (ret)
|
||||
die("error creating hardlink: %s", strerror(-ret));
|
||||
die("error creating hardlink: %s", bch2_err_str(ret));
|
||||
}
|
||||
|
||||
static struct bch_inode_unpacked create_file(struct bch_fs *c,
|
||||
@ -164,7 +165,7 @@ static struct bch_inode_unpacked create_file(struct bch_fs *c,
|
||||
uid, gid, mode, rdev, NULL, NULL,
|
||||
(subvol_inum) {}, 0));
|
||||
if (ret)
|
||||
die("error creating %s: %s", name, strerror(-ret));
|
||||
die("error creating %s: %s", name, bch2_err_str(ret));
|
||||
|
||||
return new_inode;
|
||||
}
|
||||
@ -235,7 +236,7 @@ static void copy_xattrs(struct bch_fs *c, struct bch_inode_unpacked *dst,
|
||||
&hash_info, attr,
|
||||
val, val_size, h->flags, 0));
|
||||
if (ret < 0)
|
||||
die("error creating xattr: %s", strerror(-ret));
|
||||
die("error creating xattr: %s", bch2_err_str(ret));
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,7 +271,7 @@ static void write_data(struct bch_fs *c,
|
||||
int ret = bch2_disk_reservation_get(c, &op.res, len >> 9,
|
||||
c->opts.data_replicas, 0);
|
||||
if (ret)
|
||||
die("error reserving space in new filesystem: %s", strerror(-ret));
|
||||
die("error reserving space in new filesystem: %s", bch2_err_str(ret));
|
||||
|
||||
closure_call(&op.cl, bch2_write, NULL, &cl);
|
||||
|
||||
@ -335,12 +336,12 @@ static void link_data(struct bch_fs *c, struct bch_inode_unpacked *dst,
|
||||
BCH_DISK_RESERVATION_NOFAIL);
|
||||
if (ret)
|
||||
die("error reserving space in new filesystem: %s",
|
||||
strerror(-ret));
|
||||
bch2_err_str(ret));
|
||||
|
||||
ret = bch2_btree_insert(c, BTREE_ID_extents, &e->k_i,
|
||||
&res, NULL, 0);
|
||||
if (ret)
|
||||
die("btree insert error %s", strerror(-ret));
|
||||
die("btree insert error %s", bch2_err_str(ret));
|
||||
|
||||
bch2_disk_reservation_put(c, &res);
|
||||
|
||||
@ -581,7 +582,7 @@ static void copy_fs(struct bch_fs *c, int src_fd, const char *src_path,
|
||||
int ret = bch2_inode_find_by_inum(c, (subvol_inum) { 1, BCACHEFS_ROOT_INO },
|
||||
&root_inode);
|
||||
if (ret)
|
||||
die("error looking up root directory: %s", strerror(-ret));
|
||||
die("error looking up root directory: %s", bch2_err_str(ret));
|
||||
|
||||
if (fchdir(src_fd))
|
||||
die("chdir error: %m");
|
||||
@ -706,13 +707,13 @@ static int migrate_fs(const char *fs_path,
|
||||
|
||||
c = bch2_fs_open(path, 1, opts);
|
||||
if (IS_ERR(c))
|
||||
die("Error opening new filesystem: %s", strerror(-PTR_ERR(c)));
|
||||
die("Error opening new filesystem: %s", bch2_err_str(PTR_ERR(c)));
|
||||
|
||||
mark_unreserved_space(c, extents);
|
||||
|
||||
int ret = bch2_fs_start(c);
|
||||
if (ret)
|
||||
die("Error starting new filesystem: %s", strerror(-ret));
|
||||
die("Error starting new filesystem: %s", bch2_err_str(ret));
|
||||
|
||||
copy_fs(c, fs_fd, fs_path, bcachefs_inum, &extents);
|
||||
|
||||
@ -724,7 +725,7 @@ static int migrate_fs(const char *fs_path,
|
||||
|
||||
c = bch2_fs_open(path, 1, opts);
|
||||
if (IS_ERR(c))
|
||||
die("Error opening new filesystem: %s", strerror(-PTR_ERR(c)));
|
||||
die("Error opening new filesystem: %s", bch2_err_str(PTR_ERR(c)));
|
||||
|
||||
bch2_fs_stop(c);
|
||||
printf("fsck complete\n");
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "cmds.h"
|
||||
#include "libbcachefs.h"
|
||||
#include "libbcachefs/errcode.h"
|
||||
#include "libbcachefs/opts.h"
|
||||
#include "libbcachefs/super-io.h"
|
||||
|
||||
@ -64,7 +65,7 @@ int cmd_set_option(int argc, char *argv[])
|
||||
|
||||
struct bch_fs *c = bch2_fs_open(argv, argc, open_opts);
|
||||
if (IS_ERR(c)) {
|
||||
fprintf(stderr, "error opening %s: %s\n", argv[0], strerror(-PTR_ERR(c)));
|
||||
fprintf(stderr, "error opening %s: %s\n", argv[0], bch2_err_str(PTR_ERR(c)));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user