You can also use the BLKSSZGET ioctl which works on any block device. It returns the hardware sector size. Available in kernel 2.4 and 2.6 (linux/fs.h).
Note that writing single sectors does not really guarantee atomicity. The disk driver is still free to reorder writes. You will have to write synchronously either by passing the O_SYNC flag to open() or by using fsync().
If you are writing to a file system (instead of directly to disk) then logical file blocks may not correspond to physical disk blocks.
Main Topics
Browse All Topics





by: jleviePosted on 2004-09-01 at 10:44:57ID: 11955777
You can work out what it is from what's returned by an HDIO_GET_IDENTITY ioctl(). See /usr/include/linux/hdreg.h .
Are you going to be writing directly to the disk (no file system)? It seems to me that's the only time that the sector size would be meaningful.