add ability to set block size

This commit is contained in:
detworam 2017-05-24 13:09:37 -04:00
parent 5192bb933b
commit 220843fb6a
2 changed files with 16 additions and 2 deletions

15
buse.c
View File

@ -103,8 +103,19 @@ int buse_main(const char* dev_file, const struct buse_operations *aop, void *use
return 1;
}
err = ioctl(nbd, NBD_SET_SIZE, aop->size);
assert(err != -1);
if (aop->blksize) {
err = ioctl(nbd, NBD_SET_BLKSIZE, aop->blksize);
assert(err != -1);
}
if (aop->size) {
err = ioctl(nbd, NBD_SET_SIZE, aop->size);
assert(err != -1);
}
if (aop->size_blocks) {
err = ioctl(nbd, NBD_SET_SIZE_BLOCKS, aop->size_blocks);
assert(err != -1);
}
err = ioctl(nbd, NBD_CLEAR_SOCK);
assert(err != -1);

3
buse.h
View File

@ -17,7 +17,10 @@ extern "C" {
int (*flush)(void *userdata);
int (*trim)(u_int64_t from, u_int32_t len, void *userdata);
// either set size, OR set both blksize and size_blocks
u_int64_t size;
u_int32_t blksize;
u_int64_t size_blocks;
};
int buse_main(const char* dev_file, const struct buse_operations *bop, void *userdata);