Skip to content

Commit b86169e

Browse files
committed
init: support -o size flags
Fixes #21
1 parent d471fac commit b86169e

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ tu=(not set) temporary zdb unix socket path (optional)
7272
tn=zdbfs-temp temporary namespace name
7373
ts=hello temporary namespace password (mandatory)
7474
75+
size=(10G) runtime filesystem reported size (for debug purpose)
76+
size needs to be in bytes, default is 10737418240 (10G)
77+
7578
nocache disable runtime cache (for debug purpose)
7679
autons try to create required namespace on runtime
7780
background run in background when filesystem is ready

src/init.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ static struct fuse_opt zdbfs_opts[] = {
4141
{"tn=%s", zdb_opt_field(temp_ns), 0},
4242
{"ts=%s", zdb_opt_field(temp_pass), 0},
4343

44+
{"size=%llu", zdb_opt_field(size), 0},
45+
4446
{"nocache", zdb_opt_field(nocache), 0},
4547
{"autons", zdb_opt_field(autons), 0},
4648
{"background", zdb_opt_field(background), 0},
@@ -83,6 +85,7 @@ int zdbfs_init_args(zdbfs_t *fs, struct fuse_args *args, struct fuse_cmdline_opt
8385
fs->opts->background = -1;
8486
fs->opts->autons = -1;
8587
fs->opts->cachesize = ZDBFS_BLOCKS_CACHE_LIMIT;
88+
fs->opts->size = 10ull * 1024 * 1024 * 1024;
8689

8790
// parsing fuse options
8891
if(fuse_parse_cmdline(args, fopts) != 0)
@@ -139,8 +142,10 @@ int zdbfs_init_runtime(zdbfs_t *fs) {
139142
fs->autons = (fs->opts->autons == 0) ? 1 : 0;
140143
fs->logfile = fs->opts->logfile;
141144
fs->cachesize = fs->opts->cachesize;
145+
fs->fssize = fs->opts->size;
142146

143147
zdbfs_verbose("[+] blocks cache size: %lu KB\n", (fs->cachesize * ZDBFS_BLOCK_SIZE) / 1024);
148+
zdbfs_verbose("[+] virtual filesystem size: %.1f GB\n", GB(fs->fssize));
144149

145150
// initialize cache
146151
if(!(fs->tmpblock = malloc(ZDBFS_BLOCK_SIZE)))

src/zdbfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ static void zdbfs_fuse_statfs(fuse_req_t req, fuse_ino_t ino) {
10821082
return zdbfs_fuse_error(req, EIO, ino);
10831083

10841084
// hardcode 10G for debug
1085-
uint64_t sizefs = 10ull * 1024 * 1024 * 1024;
1085+
uint64_t sizefs = fs->fssize;
10861086
size_t fragment = 1024; // optional, could be 1 and no division
10871087

10881088
// maximum inodes is uint64_t maximun value

src/zdbfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@
247247
char *logfile; // logfile where logging actions
248248
int cachesize; // amount of blocks to keep in cache
249249

250+
size_t size; // filesystem size (for debug purpose)
251+
250252
} zdbfs_options;
251253

252254
typedef struct zdb_t {

0 commit comments

Comments
 (0)