mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Robert Karszniewicz <r.karszniewicz@phytec.de>
To: barebox@lists.infradead.org
Subject: Re: [PATCH] sandbox: add_image: mmap block devices
Date: Fri, 25 Oct 2019 13:08:20 +0200	[thread overview]
Message-ID: <f7e34c2e-c3af-f606-1f3f-4298d9e4d252@phytec.de> (raw)
In-Reply-To: <9bc4633e-6f71-0c6c-988c-e8a1e11e713a@pengutronix.de>

On 10/24/19 6:07 PM, Ahmad Fatoum wrote:
> On 10/24/19 6:02 PM, Robert Karszniewicz wrote:
>> 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>
>> ---
>>   arch/sandbox/os/common.c | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
>> index 86118822a..805ac8eef 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 (-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.

> 
>> +			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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2019-10-25 11:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 16:02 Robert Karszniewicz
2019-10-24 16:07 ` Ahmad Fatoum
2019-10-25 11:08   ` Robert Karszniewicz [this message]
2019-10-25 11:19   ` [PATCH v2] " Robert Karszniewicz
2019-10-28 11:44     ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7e34c2e-c3af-f606-1f3f-4298d9e4d252@phytec.de \
    --to=r.karszniewicz@phytec.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox