I am using since Android 4.4 the tool make_ext4fs to repack Samsung system images.
make_ext4fs -s -l [size] -a [mount-point] -S [file_contexts] [out_file] [src_folder]
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.
This is the logcat output
...
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
...
This the kmsg output
[5.560176] [2: sh: 2269] macloader: Not yet wlan interface loaded
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?
Update
I've rebuilt make_ext4fs with branch android-6.0.1 according to this link (https://gist.github.com/monyxie/3128671a1f9508b7b9cdcf803e55af1e) which has new options added.
[ -l <len> ] [ -j <journal size> ] [ -b <block_size> ]
[ -g <blocks per group> ] [ -i <inodes> ] [ -I <inode size> ]
[ -L <label> ] [ -f ] [ -a <android mountpoint> ] [ -u ]
[ -S file_contexts ] [ -C fs_config ] [ -T timestamp ]
[ -z | -s ] [ -w ] [ -c ] [ -J ] [ -v ] [ -B <block_list_file> ]
<filename> [[<directory>] <target_out_directory>]
The added option [-C fs_config]
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.
...
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
...