0

I'm using Network Block Device (NBD) and I couldn't find any documentation on what NBD_SET_SIZE refers to. I suspect that it's the size of the block device, and then NBD_SET_BLKSIZE is the hint for the underlying device's block size. So then what's NBD_SET_SIZE_BLOCKS?

Is there someplace where I can get a definition for all the ioctl flags defined in nbd.h? Doing a google search turns up nothing, and the nbd.h contains no comments about these flags.

András Fekete
  • 162
  • 1
  • 5

1 Answers1

1

You can read the code here.

Basically, there are two modes of setting a size: one is in bytes, the other is in blocks.

The former is NBD_SET_SIZE. The latter requires you to do two ioctls, one to set the blocksize (NBD_SET_BLKSIZE), another one to set the size in blocks (NBD_SET_SIZE_BLOCKS).

It's really not that difficult once you understand where the names come from :-)

I'm not sure how well NBD_SET_SIZE is still supported though, seen as most nbd implementations that I know of use NBD_SET_BLKSIZE.

Wouter Verhelst
  • 1,269
  • 1
  • 12
  • 27
  • IMO `NBD_SET_SIZE_BLOCKS` is a confusing name, it should have been named `NBD_SET_NUMBER_OF_BLOCKS` or perhaps `NBD_SET_BLOCK_COUNT` or something instead – hanshenrik Jan 17 '21 at 11:15