+#ifdef BCACHEFS_FUSE
+
#include <errno.h>
#include <float.h>
#include <getopt.h>
#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"
struct bch_fs *c = fuse_req_userdata(req);
struct bch_inode_unpacked inode_u;
struct btree_trans trans;
- struct btree_iter *iter;
+ struct btree_iter iter;
u64 now;
int ret;
bch2_trans_begin(&trans);
now = bch2_current_time(c);
- iter = bch2_inode_peek(&trans, &inode_u, inum, BTREE_ITER_INTENT);
- ret = PTR_ERR_OR_ZERO(iter);
+ ret = bch2_inode_peek(&trans, &iter, &inode_u, inum, BTREE_ITER_INTENT);
if (ret)
goto err;
inode_u.bi_mtime = now;
/* TODO: CTIME? */
- ret = bch2_inode_write(&trans, iter, &inode_u) ?:
+ ret = bch2_inode_write(&trans, &iter, &inode_u) ?:
bch2_trans_commit(&trans, NULL, NULL,
- BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOFAIL);
err:
+ bch2_trans_iter_exit(&trans, &iter);
if (ret == -EINTR)
goto retry;
bch2_inode_init_early(c, new_inode);
- return bch2_trans_do(c, NULL, BTREE_INSERT_ATOMIC,
+ return bch2_trans_do(c, NULL, NULL, 0,
bch2_create_trans(&trans,
dir, &dir_u,
new_inode, &qstr,
dir = map_root_ino(dir);
- ret = bch2_trans_do(c, NULL, BTREE_INSERT_ATOMIC|BTREE_INSERT_NOFAIL,
+ ret = bch2_trans_do(c, NULL, NULL, BTREE_INSERT_NOFAIL,
bch2_unlink_trans(&trans, dir, &dir_u,
&inode_u, &qstr));
dst_dir = map_root_ino(dst_dir);
/* XXX handle overwrites */
- ret = bch2_trans_do(c, NULL, BTREE_INSERT_ATOMIC,
+ ret = bch2_trans_do(c, NULL, NULL, 0,
bch2_rename_trans(&trans,
src_dir, &src_dir_u,
dst_dir, &dst_dir_u,
fuse_ino_t newparent, const char *newname)
{
struct bch_fs *c = fuse_req_userdata(req);
- struct bch_inode_unpacked inode_u;
+ struct bch_inode_unpacked dir_u, inode_u;
struct qstr qstr = QSTR(newname);
int ret;
newparent = map_root_ino(newparent);
- ret = bch2_trans_do(c, NULL, BTREE_INSERT_ATOMIC,
+ ret = bch2_trans_do(c, NULL, NULL, 0,
bch2_link_trans(&trans, newparent,
- inum, &inode_u, &qstr));
+ inum, &dir_u, &inode_u, &qstr));
if (!ret) {
struct fuse_entry_param e = inode_to_entry(c, &inode_u);
static int inode_update_times(struct bch_fs *c, fuse_ino_t inum)
{
struct btree_trans trans;
- struct btree_iter *iter;
+ struct btree_iter iter;
struct bch_inode_unpacked inode_u;
int ret = 0;
u64 now;
bch2_trans_begin(&trans);
now = bch2_current_time(c);
- iter = bch2_inode_peek(&trans, &inode_u, inum, BTREE_ITER_INTENT);
- ret = PTR_ERR_OR_ZERO(iter);
+ ret = bch2_inode_peek(&trans, &iter, &inode_u, inum, BTREE_ITER_INTENT);
if (ret)
goto err;
inode_u.bi_mtime = now;
inode_u.bi_ctime = now;
- ret = bch2_inode_write(&trans, iter, &inode_u);
+ ret = bch2_inode_write(&trans, &iter, &inode_u);
if (ret)
goto err;
ret = bch2_trans_commit(&trans, NULL, NULL,
- BTREE_INSERT_ATOMIC|BTREE_INSERT_NOFAIL);
+ BTREE_INSERT_NOFAIL);
err:
+ bch2_trans_iter_exit(&trans, &iter);
if (ret == -EINTR)
goto retry;
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 =
return ret ? 1 : 0;
}
+
+#endif /* BCACHEFS_FUSE */