This correctly prints out our private error codes.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
#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"
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;
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;
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);
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;
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);
}
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)) {
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);
#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"
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);
}
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;
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);
}
#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"
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 =
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);
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)
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)
#include "libbcachefs/bcachefs.h"
#include "libbcachefs/btree_iter.h"
+#include "libbcachefs/errcode.h"
#include "libbcachefs/error.h"
#include "libbcachefs/super.h"
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;
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);
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);
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);
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);
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);
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;
#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"
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;
#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"
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,
(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,
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;
}
&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));
}
}
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);
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);
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");
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);
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");
#include "cmds.h"
#include "libbcachefs.h"
+#include "libbcachefs/errcode.h"
#include "libbcachefs/opts.h"
#include "libbcachefs/super-io.h"
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);
}