X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=cmd_fusemount.c;h=4470f83844a128b9f83f79d091c788b0d976c43c;hb=8642d4ae10f167a2eb850403f6d2b60757242b31;hp=de03ca182775885549133262cc4433354cea08b2;hpb=7bf4aa61a77b9ff6d0c066d370b03e67a2eaade4;p=bcachefs-tools-debian diff --git a/cmd_fusemount.c b/cmd_fusemount.c index de03ca1..4470f83 100644 --- a/cmd_fusemount.c +++ b/cmd_fusemount.c @@ -1,3 +1,5 @@ +#ifdef BCACHEFS_FUSE + #include #include #include @@ -15,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" @@ -169,7 +172,7 @@ static void bcachefs_fuse_setattr(fuse_req_t req, fuse_ino_t inum, 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; @@ -183,8 +186,7 @@ retry: 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; @@ -206,11 +208,11 @@ retry: 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; @@ -235,7 +237,7 @@ static int do_create(struct bch_fs *c, u64 dir, 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, @@ -287,7 +289,7 @@ static void bcachefs_fuse_unlink(fuse_req_t req, fuse_ino_t dir, 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)); @@ -324,7 +326,7 @@ static void bcachefs_fuse_rename(fuse_req_t req, 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, @@ -339,7 +341,7 @@ static void bcachefs_fuse_link(fuse_req_t req, fuse_ino_t inum, 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; @@ -348,9 +350,9 @@ static void bcachefs_fuse_link(fuse_req_t req, fuse_ino_t inum, 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); @@ -521,7 +523,7 @@ static void bcachefs_fuse_read(fuse_req_t req, fuse_ino_t inum, 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; @@ -531,22 +533,22 @@ retry: 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; @@ -1228,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 = @@ -1243,6 +1245,9 @@ int cmd_fusemount(int argc, char *argv[]) if (fuse_session_mount(se, fuse_opts.mountpoint)) die("fuse_mount err: %m"); + /* This print statement is a trigger for tests. */ + printf("Fuse mount initialized.\n"); + fuse_daemonize(fuse_opts.foreground); ret = fuse_session_loop(se); @@ -1259,3 +1264,5 @@ out: return ret ? 1 : 0; } + +#endif /* BCACHEFS_FUSE */