5

I'm developing a utility that needs to do low-level random access of disks (read individual sectors). In Linux I accomplish this by accessing the corresponding block device (e.g. /dev/sda). However, I've just installed FreeBSD, and I noticed that it doesn't have block devices. Instead, disks appear as character devices, which don't allow random "seeking".

Is there a way to accomplish this in FreeBSD? (i.e. low-level random access)

4

Disk character devices are equally if no more low level than block devices and are hopefully randomly seekable. One major difference between block devices and raw ones is the former are buffered while the latter are synchronous. That's the reason why FreeBSD dropped disk block devices.

  • I see! I should have mentioned that I'm actually using Mono to read from the device using a FileStream object. Perhaps it's a Mono issue, then? I haven't yet tried using native fopen/fseek with it. (The FileStream throws an exception saying that "the stream does not support seeking") – Dmitry Brant Sep 9 '13 at 0:09
  • Yep, it looks like Mono incorrectly treats character devices as un-seekable when opened as a FileStream. Thanks for the info! – Dmitry Brant Sep 9 '13 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.