title: make_ext4fs corrupts system.img on Android 6.0.1
body: <p>I am using since Android 4.4 the tool make_ext4fs to repack Samsung system images.</p>
  
  <pre><code>make_ext4fs -s -l [size] -a [mount-point] -S [file_contexts] [out_file] [src_folder]
  </code></pre>
  
  <p>This works fine for sparsed file systems up to Android 5.1.1. I need to repack an Android 6.0.1 system.img of a Samsung device. There aren't any errors, flashing works too but the Wifi device is broken.</p>
  
  <p>This is the logcat output</p>
  
  <pre><code>...
  08-30 13:38:35.489 I/WifiHW  ( 2149): wifi_change_fw_path(): fwpath = /system/etc/wifi/bcmdhd_sta.bin
  08-30 13:38:35.489 E/WifiHW  ( 2149): Cannot open "/data/.cid.info": No such file or directory
  ...
  08-30 13:38:35.809 I/wpa_supplicant( 3181): nl80211: deinit ifname=wlan0 disabled_11b_rates=0
  08-30 13:38:35.809 E/wpa_supplicant( 3181): Could not read interface wlan0 flags: No such device
  08-30 13:38:35.809 E/wpa_supplicant( 3181): wlan0: Failed to initialize driver interface
  ...
  </code></pre>
  
  <p>This the kmsg output</p>
  
  <pre><code>[5.560176]  [2: sh: 2269] macloader: Not yet wlan interface loaded
  </code></pre>
  
  <p>I tried to compare the stock and the repacked images, but they are compressed and not comparable.
  Has anything changed with the img format from Android 5.1.1 to Android 6.0.1 or is this a Samsung specific problem? The file_contexts is exracted from the stock boot.img. I think the selinux permissions are fine but I am not sure if the regular permissions are set correrctly. Is there a way to get sure the mac permissions will be preserved?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I've rebuilt make_ext4fs with branch android-6.0.1 according to this link (<a href="https://gist.github.com/monyxie/3128671a1f9508b7b9cdcf803e55af1e" rel="nofollow noreferrer">https://gist.github.com/monyxie/3128671a1f9508b7b9cdcf803e55af1e</a>) which has new options added.</p>
  
  <pre><code>[ -l &lt;len&gt; ] [ -j &lt;journal size&gt; ] [ -b &lt;block_size&gt; ]
  [ -g &lt;blocks per group&gt; ] [ -i &lt;inodes&gt; ] [ -I &lt;inode size&gt; ]
  [ -L &lt;label&gt; ] [ -f ] [ -a &lt;android mountpoint&gt; ] [ -u ]
  [ -S file_contexts ] [ -C fs_config ] [ -T timestamp ]
  [ -z | -s ] [ -w ] [ -c ] [ -J ] [ -v ] [ -B &lt;block_list_file&gt; ]
  &lt;filename&gt; [[&lt;directory&gt;] &lt;target_out_directory&gt;]
  </code></pre>
  
  <p>The added option <code>[-C fs_config]</code> let you set the permission of every single file and expects a list of files with its uid / gid / mac-permissions / (optional SELinux context). make_ext4fs throws an error if theres is any file without a config defined.</p>
  
  <pre><code>...
  system/bin 0 0 755 u:object_r:system_file:s0
  system/bin/iptables 0 0 750 u:object_r:system_file:s0
  system/bin/ip6tables 0 0 750 u:object_r:system_file:s0
  ...
  </code></pre>