mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-11 00:00:12 +03:00
fix fuse build
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
c2f3e4c99c
commit
36a3634c5e
@ -946,7 +946,9 @@ static void bcachefs_fuse_readdir(fuse_req_t req, fuse_ino_t dir_ino,
|
|||||||
if (!handle_dots(&ctx, dir.inum))
|
if (!handle_dots(&ctx, dir.inum))
|
||||||
goto reply;
|
goto reply;
|
||||||
|
|
||||||
ret = bch2_readdir(c, dir, &ctx.ctx);
|
struct bch_hash_info dir_hash = bch2_hash_info_init(c, &bi);
|
||||||
|
|
||||||
|
ret = bch2_readdir(c, dir, &dir_hash, &ctx.ctx);
|
||||||
reply:
|
reply:
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
fuse_log(FUSE_LOG_DEBUG, "bcachefs_fuse_readdir reply %zd\n",
|
fuse_log(FUSE_LOG_DEBUG, "bcachefs_fuse_readdir reply %zd\n",
|
||||||
@ -1113,19 +1115,16 @@ static const struct fuse_lowlevel_ops bcachefs_fuse_ops = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct bf_context {
|
struct bf_context {
|
||||||
char *devices_str;
|
char *devices_str;
|
||||||
char **devices;
|
darray_const_str devices;
|
||||||
int nr_devices;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void bf_context_free(struct bf_context *ctx)
|
static void bf_context_free(struct bf_context *ctx)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
free(ctx->devices_str);
|
free(ctx->devices_str);
|
||||||
for (i = 0; i < ctx->nr_devices; ++i)
|
darray_for_each(ctx->devices, i)
|
||||||
free(ctx->devices[i]);
|
free((void *) *i);
|
||||||
free(ctx->devices);
|
darray_exit(&ctx->devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct fuse_opt bf_opts[] = {
|
static struct fuse_opt bf_opts[] = {
|
||||||
@ -1162,26 +1161,11 @@ static void tokenize_devices(struct bf_context *ctx)
|
|||||||
{
|
{
|
||||||
char *devices_str = strdup(ctx->devices_str);
|
char *devices_str = strdup(ctx->devices_str);
|
||||||
char *devices_tmp = devices_str;
|
char *devices_tmp = devices_str;
|
||||||
char **devices = NULL;
|
|
||||||
int nr = 0;
|
|
||||||
char *dev = NULL;
|
char *dev = NULL;
|
||||||
|
|
||||||
while ((dev = strsep(&devices_tmp, ":"))) {
|
while ((dev = strsep(&devices_tmp, ":")))
|
||||||
if (strlen(dev) > 0) {
|
if (strlen(dev) > 0)
|
||||||
devices = realloc(devices, (nr + 1) * sizeof *devices);
|
darray_push(&ctx->devices, strdup(dev));
|
||||||
devices[nr] = strdup(dev);
|
|
||||||
nr++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!devices) {
|
|
||||||
devices = malloc(sizeof *devices);
|
|
||||||
devices[0] = strdup(ctx->devices_str);
|
|
||||||
nr = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->devices = devices;
|
|
||||||
ctx->nr_devices = nr;
|
|
||||||
|
|
||||||
free(devices_str);
|
free(devices_str);
|
||||||
}
|
}
|
||||||
@ -1200,7 +1184,7 @@ int cmd_fusemount(int argc, char *argv[])
|
|||||||
struct bf_context ctx = { 0 };
|
struct bf_context ctx = { 0 };
|
||||||
struct bch_fs *c = NULL;
|
struct bch_fs *c = NULL;
|
||||||
struct fuse_session *se = NULL;
|
struct fuse_session *se = NULL;
|
||||||
int ret = 0, i;
|
int ret = 0;
|
||||||
|
|
||||||
/* Parse arguments. */
|
/* Parse arguments. */
|
||||||
if (fuse_opt_parse(&args, &ctx, bf_opts, bf_opt_proc) < 0)
|
if (fuse_opt_parse(&args, &ctx, bf_opts, bf_opt_proc) < 0)
|
||||||
@ -1240,21 +1224,19 @@ int cmd_fusemount(int argc, char *argv[])
|
|||||||
|
|
||||||
struct printbuf fsname = PRINTBUF;
|
struct printbuf fsname = PRINTBUF;
|
||||||
prt_printf(&fsname, "fsname=");
|
prt_printf(&fsname, "fsname=");
|
||||||
for (i = 0; i < ctx.nr_devices; ++i) {
|
darray_for_each(ctx.devices, i) {
|
||||||
if (i)
|
if (i != ctx.devices.data)
|
||||||
prt_str(&fsname, ":");
|
prt_str(&fsname, ":");
|
||||||
prt_str(&fsname, ctx.devices[i]);
|
prt_str(&fsname, *i);
|
||||||
}
|
}
|
||||||
|
|
||||||
fuse_opt_add_arg(&args, "-o");
|
fuse_opt_add_arg(&args, "-o");
|
||||||
fuse_opt_add_arg(&args, fsname.buf);
|
fuse_opt_add_arg(&args, fsname.buf);
|
||||||
|
|
||||||
/* Open bch */
|
/* Open bch */
|
||||||
printf("Opening bcachefs filesystem on:\n");
|
printf("Opening bcachefs filesystem on %s\n", ctx.devices_str);
|
||||||
for (i = 0; i < ctx.nr_devices; ++i)
|
|
||||||
printf("\t%s\n", ctx.devices[i]);
|
|
||||||
|
|
||||||
c = bch2_fs_open(ctx.devices, ctx.nr_devices, bch_opts);
|
c = bch2_fs_open(&ctx.devices, &bch_opts);
|
||||||
if (IS_ERR(c))
|
if (IS_ERR(c))
|
||||||
die("error opening %s: %s", ctx.devices_str,
|
die("error opening %s: %s", ctx.devices_str,
|
||||||
bch2_err_str(PTR_ERR(c)));
|
bch2_err_str(PTR_ERR(c)));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user