From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: Dogukan Ergun <dogukan.ergun@gmail.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH v2] wic: if we can't get from ioctl, try from os.stat()
Date: Wed, 10 Jan 2018 13:58:29 +0200 [thread overview]
Message-ID: <20180110115829.i3ff7rc2f4vyc5px@linux.intel.com> (raw)
In-Reply-To: <1515504924-28160-1-git-send-email-dogukan.ergun@gmail.com>
On Tue, Jan 09, 2018 at 04:35:24PM +0300, Dogukan Ergun wrote:
> Under some conditions, ioctl FIGETBSZ can't return real value.
> We can try to use fallback via os.stat() to get block size.
>
Thank you for the patch!
+1
> Source of patch:
> https://github.com/intel/bmap-tools/commit/17365f4fe9089df7ee9800a2a0ced177ec4798a4
>
> Signed-off-by: Dogukan Ergun <dogukan.ergun@gmail.com>
> ---
> scripts/lib/wic/filemap.py | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py
> index 77e32b9..a72fa09 100644
> --- a/scripts/lib/wic/filemap.py
> +++ b/scripts/lib/wic/filemap.py
> @@ -37,7 +37,15 @@ def get_block_size(file_obj):
> # Get the block size of the host file-system for the image file by calling
> # the FIGETBSZ ioctl (number 2).
> binary_data = fcntl.ioctl(file_obj, 2, struct.pack('I', 0))
> - return struct.unpack('I', binary_data)[0]
> + bsize = struct.unpack('I', binary_data)[0]
> + if not bsize:
> + import os
> + stat = os.fstat(file_obj.fileno())
> + if hasattr(stat, 'st_blksize'):
> + bsize = stat.st_blksize
> + else:
> + raise IOError("Unable to determine block size")
> + return bsize
>
> class ErrorNotSupp(Exception):
> """
> --
> 2.7.4
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
--
--
Regards,
Ed
prev parent reply other threads:[~2018-01-10 13:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-09 13:35 [PATCH v2] wic: if we can't get from ioctl, try from os.stat() Dogukan Ergun
2018-01-10 11:58 ` Ed Bartosh [this message]
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=20180110115829.i3ff7rc2f4vyc5px@linux.intel.com \
--to=ed.bartosh@linux.intel.com \
--cc=dogukan.ergun@gmail.com \
--cc=openembedded-core@lists.openembedded.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.