Prerequisites: tape written with 128k block size, mt blocksize 131072 bsdtar -tf /dev/sa0 -b 256 gives sa0: request ptr 0x2888ed80 is not on a page boundary; cannot split request bsdtar: Error opening archive: Error reading '/dev/sa0' This seems to be an alignment problem. The problem goes away after aligning the buffer in archive_read_open_filename.c: --- archive_read_open_filename.c.ORI 2020-03-13 08:22:53.000000000 +0100 +++ archive_read_open_filename.c 2021-01-06 10:37:34.176333000 +0100 @@ -359,12 +359,17 @@ new_block_size *= 2; mine->block_size = new_block_size; } +#if 0 buffer = malloc(mine->block_size); +#else + buffer = malloc(mine->block_size + 4096); +#endif if (buffer == NULL) { archive_set_error(a, ENOMEM, "No memory"); goto fail; } mine->buffer = buffer; + mine->buffer = (void*)(((u_int32_t)buffer + 4096) & ~4095); mine->fd = fd; /* Remember mode so close can decide whether to flush. */ mine->st_mode = st.st_mode; This is NO patch to fix the issue -- it's just to show the origin of the problem . A proper patch will probably use PAGESIZE and distinguish between malloc start and aligned buffer (so it can bee free()ed).
See aligned_alloc(3). But it is bizarre that a device driver does not support reads into unaligned user addresses.
Thanks for aligned_alloc(), didn't know that. Maybe sa(4) would allow this with kern.cam.sa.allow_io_split but if I read the comments correctly, this will go away (or should have been gone already).