diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 1b2daa3..3ad12b4 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include /* * ...except the ones needed to connect with barebox */ @@ -260,6 +262,12 @@ hf->size = s.st_size; hf->devname = strdup(devname); + if (S_ISBLK(s.st_mode)) { + if (ioctl(fd, BLKGETSIZE64, &hf->size) == -1) { + perror("ioctl"); + goto err_out; + } + } hf->base = (unsigned long)mmap(NULL, hf->size, PROT_READ | (readonly ? 0 : PROT_WRITE), MAP_SHARED, fd, 0);