add ability to set block size
This commit is contained in:
parent
5192bb933b
commit
220843fb6a
15
buse.c
15
buse.c
|
@ -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
3
buse.h
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue