summaryrefslogtreecommitdiffstats
path: root/arch/sandbox
diff options
context:
space:
mode:
authorRobert Karszniewicz <r.karszniewicz@phytec.de>2019-10-25 13:19:12 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-10-28 12:48:32 +0100
commit8d6da6462b12a5e7cc84253ada8f91cd4561dc5e (patch)
tree42943218bb4c184294d6e6ba5b8ea3515e9f7767 /arch/sandbox
parentea7fa7c272320344b653e0d90a8b3d666e561493 (diff)
downloadbarebox-8d6da6462b12a5e7cc84253ada8f91cd4561dc5e.tar.gz
barebox-8d6da6462b12a5e7cc84253ada8f91cd4561dc5e.tar.xz
sandbox: add_image: mmap block devices
This makes it possible to mount block devices from the host machine, which have been passed as arguments to --image Signed-off-by: Robert Karszniewicz <r.karszniewicz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox')
-rw-r--r--arch/sandbox/os/common.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 1b2daa3965..3ad12b4a30 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -39,6 +39,8 @@
#include <signal.h>
#include <sys/select.h>
#include <sys/wait.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
/*
* ...except the ones needed to connect with barebox
*/
@@ -260,6 +262,12 @@ static int add_image(char *str, char *devname_template, int *devname_number)
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);