I am trying to get some information (specifically block size) of block device in linux, in C++. Is it possible to get block size of a device without mounting it and possibly
You want to use ioctl, in particular BLKSSZGET.
BLKSSZGET
Quoting linux/fs.h:
#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
Untested example:
#include #include int fd = open("/dev/sda"); size_t blockSize; int rc = ioctl(fd, BLKSSZGET, &blockSize);