wic/filemap: handle FIGETBSZ failing

Message ID 20190607110502.31175-1-ross.burton@intel.com
State Accepted
Commit 3757073726a00c5250556aae3d0daac76b88085e
Headers show
Series
  • wic/filemap: handle FIGETBSZ failing
Related show

Commit Message

Ross Burton June 7, 2019, 11:05 a.m.
Some file systems don't support fetching the block size (notably the file system
Docker uses for containers), so handle the iotctl() failing and raise the
expected error.

Signed-off-by: Ross Burton <ross.burton@intel.com>

---
 scripts/lib/wic/filemap.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

-- 
2.11.0

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Comments

Tom Rini June 7, 2019, 2:49 p.m. | #1
On Fri, Jun 07, 2019 at 12:05:02PM +0100, Ross Burton wrote:

> Some file systems don't support fetching the block size (notably the file system

> Docker uses for containers), so handle the iotctl() failing and raise the

> expected error.

> 

> Signed-off-by: Ross Burton <ross.burton@intel.com>


Reviewed-by: Tom Rini <trini@konsulko.com>


-- 
Tom
-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Tim Orling June 8, 2019, 12:48 a.m. | #2
On Fri, Jun 7, 2019 at 7:49 AM Tom Rini <trini@konsulko.com> wrote:

> On Fri, Jun 07, 2019 at 12:05:02PM +0100, Ross Burton wrote:

>

> > Some file systems don't support fetching the block size (notably the

> file system

> > Docker uses for containers), so handle the iotctl() failing and raise the

> > expected error.

> >

> > Signed-off-by: Ross Burton <ross.burton@intel.com>

>

> Reviewed-by: Tom Rini <trini@konsulko.com>

>


Thank you for finding the fix!

Reviewed-by: Tim Orling <timothy.t.orling@linux.intel.com>


—Tim

>

> --

> Tom

> --

> _______________________________________________

> Openembedded-core mailing list

> Openembedded-core@lists.openembedded.org

> http://lists.openembedded.org/mailman/listinfo/openembedded-core

>
<div><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 7, 2019 at 7:49 AM Tom Rini &lt;<a href="mailto:trini@konsulko.com">trini@konsulko.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, Jun 07, 2019 at 12:05:02PM +0100, Ross Burton wrote:<br>
<br>
&gt; Some file systems don&#39;t support fetching the block size (notably the file system<br>
&gt; Docker uses for containers), so handle the iotctl() failing and raise the<br>
&gt; expected error.<br>
&gt; <br>
&gt; Signed-off-by: Ross Burton &lt;<a href="mailto:ross.burton@intel.com" target="_blank">ross.burton@intel.com</a>&gt;<br>
<br>
Reviewed-by: Tom Rini &lt;<a href="mailto:trini@konsulko.com" target="_blank">trini@konsulko.com</a>&gt;<br>

</blockquote><div dir="auto"><br></div><div dir="auto">Thank you for finding the fix!</div><div dir="auto"><br></div><div dir="auto">Reviewed-by: Tim Orling &lt;<a href="mailto:timothy.t.orling@linux.intel.com">timothy.t.orling@linux.intel.com</a>&gt;</div><div dir="auto"><br></div><div dir="auto">—Tim</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
-- <br>
Tom<br>
-- <br>
_______________________________________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org" target="_blank">Openembedded-core@lists.openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/mailman/listinfo/openembedded-core</a><br>
</blockquote></div></div>
-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Patch

diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py
index 244c07a71cf..a3919fbcad8 100644
--- a/scripts/lib/wic/filemap.py
+++ b/scripts/lib/wic/filemap.py
@@ -32,7 +32,10 @@  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))
+    try:
+        binary_data = fcntl.ioctl(file_obj, 2, struct.pack('I', 0))
+    except OSError:
+        raise IOError("Unable to determine block size")
     bsize = struct.unpack('I', binary_data)[0]
     if not bsize:
         import os