10 #include <arpa/inet.h>
19 static void usage(void)
21 printf("Usage: rromfs < device >\n");
24 static struct romfs_sb
*get_romfs_sb(const char *path
)
29 const size_t sb_length
= 16;
31 fd
= open(path
, O_RDONLY
);
37 sb
= malloc(sizeof(struct romfs_sb
));
42 memset(sb
, 0, sizeof(struct romfs_sb
));
44 p
= mmap(NULL
, sb_length
, PROT_READ
, MAP_PRIVATE
, fd
, (off_t
) 0);
50 /* File-system name */
51 memcpy(&sb
->name
, p
, (size_t) 8);
54 memcpy(&sb
->vname
, (char *) p
+16, (size_t) 16);
57 * FIXME: Is there a nicer way to read big
62 memcpy(&sb
->size
, (uint8_t *) p
+8, (size_t) 4);
63 sb
->size
= ntohl(sb
->size
);
66 memcpy(&sb
->checksum
, (uint8_t *) p
+12, (size_t) 4);
67 sb
->checksum
= ntohl(sb
->checksum
);
80 int main(int argc
, char *argv
[])
89 sb
= get_romfs_sb(argv
[1]);
93 /* Super-block information */
94 printf("sig: %s\n", sb
->name
);
95 printf("size: %d\n", sb
->size
);
96 printf("checksum: %d\n", sb
->checksum
);
97 printf("Volume name: %s\n", sb
->vname
);