23 static uint32_t get_unaligned(
const uint8_t * d) {
24 return ((uint32_t) d[0]) | ((uint32_t) (d[1] << 8)) | ((uint32_t) (d[2] << 16)) | ((uint32_t) (d[3] << 24));
27 static ssize_t romfs_read(
void * opaque,
void * buf,
size_t count) {
29 const uint8_t * size_p = f->
file - 4;
30 uint32_t size = get_unaligned(size_p);
32 if ((f->
cursor + count) > size)
41 static off_t romfs_seek(
void * opaque,
off_t offset,
int whence) {
43 const uint8_t * size_p = f->
file - 4;
44 uint32_t size = get_unaligned(size_p);
61 offset = origin + offset;
76 for (meta = romfs; get_unaligned(meta) && get_unaligned(meta + 4); meta += get_unaligned(meta + 4) + 8) {
77 if (get_unaligned(meta) == h) {
79 *len = get_unaligned(meta + 4);
88 static int romfs_open(
void * opaque,
const char * path,
int flags,
int mode) {
89 uint32_t h =
hash_djb2((
const uint8_t *) path, -1);
90 const uint8_t * romfs = (
const uint8_t *) opaque;
109 register_fs(mountpoint, romfs_open, (
void *) romfs);