sandbox: add_image: mmap block devices
PATCH 1/1 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
--- arch/sandbox/os/common.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/sandbox/os/common.c +8 -0
@@ -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 (-1 ==ioctl (fd,BLKGETSIZE64 , &hf->size)) { +perror ("ioctl" ); + goto err_out; + } + } hf->base = (unsigned long )mmap (NULL , hf->size,PROT_READ | (readonly ?0 :PROT_WRITE ),MAP_SHARED , fd,0 );
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 22 lines · Robert Karszniewicz
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 <[email protected]>--- arch/sandbox/os/common.c | 8 ++++++++ 1 file changed, 8 insertions(+)arch/sandbox/os/common.c +2
-0@@ -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 */
arch/sandbox/os/common.c static int add_image(char *str, char *devname_template, int *devname_number) · line 266
Quoted 5 lines
arch/sandbox/os/common.c +2
-0@@ -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 (-1 ==ioctl (fd,BLKGETSIZE64 , &hf->size)) {
This looks out of place for barebox, the -1 should be on the right side.
Quoted 8 lines
arch/sandbox/os/common.c +4
-0+perror ("ioctl" ); + goto err_out; + } + } hf->base = (unsigned long )mmap (NULL , hf->size,PROT_READ | (readonly ?0 :PROT_WRITE ),MAP_SHARED , fd,0 );
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 26 lines · Ahmad Fatoum
Quoted 25 lines · Robert Karszniewicz
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 <[email protected]>--- arch/sandbox/os/common.c | 8 ++++++++ 1 file changed, 8 insertions(+)arch/sandbox/os/common.c +2
-0@@ -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);
Quoted 4 lines
arch/sandbox/os/common.c static int add_image(char *str, char *devname_template, int *devname_number) · line 266
Quoted 2 lines
arch/sandbox/os/common.c +2
-0+if (S_ISBLK (s.st_mode)) { +if (-1 ==ioctl (fd,BLKGETSIZE64 , &hf->size)) {This looks out of place for barebox, the -1 should be on the right side.
Oh, right, sorry! I have a habit to put trivial- and constant-sized symbols to the left, to not hide them behind those long function calls, etc.
Quoted 11 lines
arch/sandbox/os/common.c static int add_image(char *str, char *devname_template, int *devname_number) · line 273
Quoted 9 lines
arch/sandbox/os/common.c +4
-0+perror ("ioctl" ); + goto err_out; + } + } hf->base = (unsigned long )mmap (NULL , hf->size,PROT_READ | (readonly ?0 :PROT_WRITE ),MAP_SHARED , fd,0 );
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/1 sandbox: add_image: mmap block devices
In reply to Ahmad FatoumThis makes it possible to mount block devices from the host machine, which have been passed as arguments to --image
---
Changes from v1:
- move -1 to the right side of the comparison
arch/sandbox/os/common.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/sandbox/os/common.c +8 -0
@@ -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 );
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 10 lines · Robert Karszniewicz
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 <[email protected]>---
Changes from v1:
- move -1 to the right side of the comparisonarch/sandbox/os/common.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Applied, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox