On Oct 12, 2020, at 9:57 AM, Arthur Krewat <krewat(a)kilonet.net> wrote:
On 10/11/2020 9:56 PM, Warner Losh wrote:
unaligned I/O on the block device
Sorry, I
have to laugh... isn't that an oxymoron? ;)
Actually there are no *block* devices in FreeBSD.
And while raw device files such as /dev/r<blkdev>
no longer exist, it is the block devices (with
their buffering etc.) that are gone. Only raw devices
exist now.
And FreeBSD raw disk device drivers don't allow
unaligned I/O access. Nor should they paper over
what is not allowed by the underlying device. Try
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
unsigned char buf[1024];
int main(int c, char**v) {
char* a = c > 1? v[1] : "1";
off_t off = (off_t)strtoull(a, 0, 0);
ssize_t r = pread(0, buf, sizeof buf, off);
if (r < 0) { perror("read"); return 1; }
for (int i = 0; i < 4; i++) printf(" %02x", buf[i]);
printf("\n");
return 0;
}