]> git.hungrycats.org Git - bees/commit
hash: fix FLAGS_CREATE_FILE O_WRONLY preventing pread on new hash table
authorZygo Blaxell <bees@furryterror.org>
Fri, 13 Mar 2026 23:06:32 +0000 (19:06 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 2 May 2026 03:48:57 +0000 (23:48 -0400)
commit719046b53b4942e6c6e7ccfcb1a3f1b4bd565f1c
tree41a761618afa84cf5abd719f1aa248f792e694c6
parent94c13145e2ef85ddc8fcb02f8ec0b766dc2b039d
hash: fix FLAGS_CREATE_FILE O_WRONLY preventing pread on new hash table

FLAGS_CREATE_FILE used O_WRONLY|O_CREAT|O_EXCL.  On a fresh beeshome,
open_file() creates beeshash.dat through this flag and assigns the
write-only fd to m_fd.  The prefetch thread then calls pread_or_die(m_fd)
and gets EBADF because pread() requires O_RDONLY or O_RDWR.

In production, beesd and OpenRC pre-create beeshash.dat with truncate(1)
before exec'ing bees, so the creation branch in open_file() was never
exercised.  Integration tests exposed this by starting bees on a fresh
$BEESHOME.

Change FLAGS_CREATE_FILE from O_WRONLY to O_RDWR.  The name still
describes the intent (O_CREAT|O_EXCL ensure exclusive creation); O_RDWR
simply allows reading the file back after writing it.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees.h