<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>12319</bug_id>
          
          <creation_ts>2017-11-08 00:58:28 +0000</creation_ts>
          <short_desc>WIC: ZeroDivisionError when writing to Docker container volume residing on AUFS filesystem</short_desc>
          <delta_ts>2019-04-09 08:12:18 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>Scripts and Tools</component>
          <version>2.2.2</version>
          <rep_platform>Other</rep_platform>
          <op_sys>arm</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>Backport 2.2.3, 2.3.3, and 2.4.1?</status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.99</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="James Kelly">jamespeterkelly+yocto</reporter>
          <assigned_to name="Armin Kuster">akuster</assigned_to>
          <cc>akuster</cc>
    
    <cc>anuj.mittal</cc>
    
    <cc>ross.burton</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>78043</commentid>
    <comment_count>0</comment_count>
    <who name="James Kelly">jamespeterkelly+yocto</who>
    <bug_when>2017-11-08 00:58:28 +0000</bug_when>
    <thetext>Preconditions/Environment
-------------------------
Yocto build environment obtained from https://github.com/Xilinx/poky which is
based on Yocto 2.2.2.
Running in a Docker container derived from Ubuntu 16.04 image.
Docker host is using AUFS filesystem for Docker volumes.
Docker host is running Boot2Docker version 17.10.0-ce.Boot2Docker version 17.10.0-ce, build HEAD : 34fe485 - Wed Oct 18 17:16:34 UTC 2017 in a VM.

WIC is enabled in build/conf/local.conf using IMAGE_FSTYPES, WKS_SEARCH_PATH and WKS_FILES

Triggering Action/Cause
-----------------------
bitbake core-image-minimal

Expectation
-----------
A disk image is created by WIC from the build 

Actual Result
-------------
Build stops in meta/recipes-core/images/core-image-minimal.bb:do_image_wic
recipe with error:

| Traceback (most recent call last):
|   File &quot;/home/user/sources/core/scripts/wic&quot;, line 319, in &lt;module&gt;
|     sys.exit(main(sys.argv[1:]))
|   File &quot;/home/user/sources/core/scripts/wic&quot;, line 314, in main
|     return hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands)
|   File &quot;/home/user/sources/core/scripts/lib/wic/help.py&quot;, line 95, in invoke_subcommand
|     subcommands.get(args[0], subcommand_error)[0](args[1:], usage)
|   File &quot;/home/user/sources/core/scripts/wic&quot;, line 247, in wic_create_subcommand
|     options.compressor, options.bmap, options.debug)
|   File &quot;/home/user/sources/core/scripts/lib/wic/engine.py&quot;, line 195, in wic_create
|     crobj.main(cmdline)
|   File &quot;/home/user/sources/core/scripts/lib/wic/creator.py&quot;, line 125, in main
|     return self._subcmds[pname](options, *args[1:])
|   File &quot;/home/user/sources/core/scripts/lib/wic/plugins/imager/direct_plugin.py&quot;, line 94, in do_create
|     creator.assemble()
|   File &quot;/home/user/sources/core/scripts/lib/wic/imager/direct.py&quot;, line 330, in assemble
|     self.__image.assemble(full_path)
|   File &quot;/home/user/sources/core/scripts/lib/wic/utils/partitionedfs.py&quot;, line 361, in assemble
|     sparse_copy(source, image_file, part[&apos;start&apos;] * self.sector_size)
|   File &quot;/home/user/sources/core/scripts/lib/wic/filemap.py&quot;, line 535, in sparse_copy
|     fmap = filemap(src_fname)
|   File &quot;/home/user/sources/core/scripts/lib/wic/filemap.py&quot;, line 529, in filemap
|     return FilemapFiemap(image, log)
|   File &quot;/home/user/sources/core/scripts/lib/wic/filemap.py&quot;, line 347, in __init__
|     _FilemapBase.__init__(self, image, log)
|   File &quot;/home/user/sources/core/scripts/lib/wic/filemap.py&quot;, line 98, in __init__
|     self.blocks_cnt //= self.block_size
| ZeroDivisionError: integer division or modulo by zero

Reproducibility
---------------
5/5

Root Cause
----------
In function get_block_size in scripts/lib/wic/filemap.py the FIGETBSZ IOCTL is used to get the block size of the file system where WIC is creating the image.

In a Docker container with volumes created in a AUFS file system this IOCTL returns zero resulting in a divide by zero when the block size is subsequently used.

Suggested Fix
-------------

The Intel/bmap-tools project on Github had the same issue (it seems to have VERY similar code) and it was fixed with this commit that uses fstat to get the
block size if the FIGETBSZ IOCTL returns zero.

https://github.com/intel/bmap-tools/commit/17365f4fe9089df7ee9800a2a0ced177ec4798a4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81119</commentid>
    <comment_count>1</comment_count>
    <who name="Anuj Mittal">anuj.mittal</who>
    <bug_when>2018-07-17 01:39:38 +0000</bug_when>
    <thetext>Fixed back in Jan 2018: https://git.yoctoproject.org/cgit/cgit.cgi/poky/commit?id=bab3b2e9390d632a190bb96fa161bd5554a72948

It&apos;s in sumo. Should this be backported to rocko/pyro as well?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81207</commentid>
    <comment_count>2</comment_count>
    <who name="Armin Kuster">akuster</who>
    <bug_when>2018-07-30 17:52:02 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Fixed back in Jan 2018:
&gt; https://git.yoctoproject.org/cgit/cgit.cgi/poky/
&gt; commit?id=bab3b2e9390d632a190bb96fa161bd5554a72948
&gt; 
&gt; It&apos;s in sumo. Should this be backported to rocko/pyro as well?

got it in rocko-nmut</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82481</commentid>
    <comment_count>3</comment_count>
    <who name="Armin Kuster">akuster</who>
    <bug_when>2018-12-12 15:59:33 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; (In reply to comment #1)
&gt; &gt; Fixed back in Jan 2018:
&gt; &gt; https://git.yoctoproject.org/cgit/cgit.cgi/poky/
&gt; &gt; commit?id=bab3b2e9390d632a190bb96fa161bd5554a72948
&gt; &gt; 
&gt; &gt; It&apos;s in sumo. Should this be backported to rocko/pyro as well?
&gt; 
&gt; got it in rocko-nmut

in rocko proper

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?h=rocko&amp;id=53d5f01d2dc34ac140f985aef0fbe0c407394a2c</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83498</commentid>
    <comment_count>4</comment_count>
    <who name="Armin Kuster">akuster</who>
    <bug_when>2019-04-09 08:11:34 +0000</bug_when>
    <thetext>not fixing anything past rocko.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83499</commentid>
    <comment_count>5</comment_count>
    <who name="Armin Kuster">akuster</who>
    <bug_when>2019-04-09 08:12:18 +0000</bug_when>
    <thetext>closing</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>