fubarnetes/bhyve-multiboot

use file IO callbacks from userboot.h instead of FILE* operations

Closed this issue · 0 comments

Instead of using fopen(3), fseek(3), ftell(3), fclose(3) and fileno(3), use

callbacks->open(void *arg, const char *filename, void **h_return);
callbacks->close(void *arg, void *h);
callbacks->read(void *arg, void *h, void *dst, size_t size, size_t *resid_return);
callbacks->seek(void *arg, void *h, uint64_t offset, int whence);
callbacks->stat(void *arg, void *h, int *mode_return, int *uid_return, int *gid_return, uint64_t *size_return);

The following code to get the file size will have to be rewritten using stat(2) to get the file size.

bhyve-multiboot/multiboot.c

Lines 428 to 431 in f0d394f

/* Get the kernel file size */
fseek(kernfile, 0L, SEEK_END);
kernsz = ftell(kernfile);
rewind(kernfile);