Android vendor.img中文件执行权问题

问题

Android 9、11往vendor.img增加文件,烧写到设备后发现增加的可执行文件没有执行权限。经过漫长查找,终于找到了问题的根源,谨以此篇献给哪些脚踏实地的人们。

根本原因

system/core/libcutils/fs_config.cpp文件,fs_config函数根据android_dirs、android_files中的配置修改文件的uid、gui、mode(权限)。除了/vendor/bin/、/vendor/xbin/目录下的文件的有执行权限,/vendor目录下的其他文件都没有执行权限。

vendor.img是如何生成的

build/core/Makefile

INSTALLED_VENDORIMAGE_TARGET 

3314 # We just build this directly to the install location.
3315 INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
3316 $(INSTALLED_VENDORIMAGE_TARGET): \
3317     $(INTERNAL_USERIMAGES_DEPS) \
3318     $(INTERNAL_VENDORIMAGE_FILES) \
3319     $(INSTALLED_FILES_FILE_VENDOR) \
3320     $(RECOVERY_FROM_BOOT_PATCH)
3321     $(build-vendorimage-target)

build-vendorimage-target

BUILT_VENDORIMAGE_TARGET

3294 vendorimage_intermediates := \
3295     $(call intermediates-dir-for,PACKAGING,vendor)
3296 BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
3297 define build-vendorimage-target
3298   # $(hide) /usr/bin/python build/tools/rcmerge.py $(subst full_,,$(TARGET_PRODUCT)) vnd
3299   $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
3300   @mkdir -p $(TARGET_OUT_VENDOR)
3301   @rm -rf $(TARGET_OUT_VENDOR)/avm
3302   @mkdir -p $(TARGET_OUT_VENDOR)/avm
3303   $(call create-vendor-odm-symlink)
3304   @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
3305   $(hide) cp -rf $(TOP)/vendor/autochips/proprietary/frameworks/base/avm/file/* $(TARGET_OUT_VENDOR)/avm
3306   $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
3307   PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3308       $(BUILD_IMAGE) \
3309           $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
3310           $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
3311   $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
3312 endef

build_image

build/core/config.mk

635 BUILD_IMAGE := $(HOST_OUT_EXECUTABLES)/build_image$(HOST_EXECUTABLE_SUFFIX)

out/host/linux-x86/bin/build_image

Builds output_image from the given input_directory, properties_file,
and writes the image to target_output_directory.

Usage:  build_image input_directory properties_file output_image \
            target_output_directory

build_image.py

build/tools/releasetools/build_image.py

BuildImageMkfs

231 def BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config):
232   """Builds a pure image for the files under in_dir and writes it to out_file.
233
234   Args:
235     in_dir: Path to input directory.
236     prop_dict: A property dict that contains info like partition size. Values
237         will be updated with computed values.
238     out_file: The output image file.
239     target_out: Path to the TARGET_OUT directory as in Makefile. It actually
240         points to the /system directory under PRODUCT_OUT. fs_config (the one
241         under system/core/libcutils) reads device specific FS config files from
242         there.
243     fs_config: The fs_config file that drives the prototype
244
245   Raises:
246     BuildImageError: On build image failures.
247   """

 build_command

mkuserimg_mke2fs -s out/target/product/ac8257_64bit/vendor out/target/product/ac8257_64bit/vendor.img ext4 vendor 825540608 -j 0 -D out/target/product/ac8257_64bit/system -L vendor -M 0 --inode_size 256 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值