随着android版本升级,升级包越来越大,当升级包无法存储在cache分区的时候,会把升级包下载到data分区,然后从data分区升级,最近从data分区加载升级包升级的时候,遇到了如下错误:

  1. [ 1.945982] Supported API: 3
  2. [ 1.957270] charge_status 1, charged 1, status -2, capacity -9223372036854775808
  3. [ 1.973917] E:Failed to find CPU thermal info in /sys/class/thermal/
  4. [ 1.990514] I:current maximum temperature: -1
  5. [ 2.007184] Finding update package...
  6. [ 2.057199] I:Update location: @/cache/recovery/block.map
  7. [ 2.057251] Opening update package...
  8. [ 2.092148] E:Failed to read /cache/recovery/block.map: No such file or directory
  9. [ 2.107257] E:Map of '@/cache/recovery/block.map' failed
  10. [ 2.140532] E:failed to map file
  11. [ 2.158867] I:current maximum temperature: -1
  12. [ 2.159049] I:@/cache/recovery/block.map
  13. [ 2.159060] I:0
  14. [ 2.159072] I:time_total: 0
  15. [ 2.159079] I:retry: 0
  16. [ 2.159085] I:uncrypt_time: 0
  17. [ 2.159092] I:uncrypt_error: 1
  18. [ 2.159099] I:
  19. [ 2.159108] Installation aborted.
  20. [ 2.223841] I:Saving locale "en-US"

最直接的错误信息就是:E:Failed to read /cache/recovery/block.map: No such file or directory

我们根据提示信息,去查询下cache分区,这个block.map文件是否存在。

busybox mount -t ext4 /dev/block/cache /cache (如果无法挂载,设置selinux权限为 permissive)

  1. # busybox ls -l /cache/recovery/
  2. total 104
  3. __bionic_open_tzdata: couldn't find any tzdata when looking for localtime!
  4. __bionic_open_tzdata: couldn't find any tzdata when looking for GMT!
  5. __bionic_open_tzdata: couldn't find any tzdata when looking for posixrules!
  6. -rw-r--r-- 1 root root 85 Jan 1 00:01 last_install
  7. -rw------- 1 system system 61634 Jan 1 00:01 last_kmsg
  8. -rw------- 1 root root 5 Jan 1 00:00 last_locale
  9. -rw-r----- 1 root root 12160 Jan 1 00:01 last_log
  10. -rw------- 1 system system 12160 Jan 1 00:01 log
  11. -rw------- 1 system system 24 Jan 1 1970 uncrypt_file
  12. -rw------- 1 root root 33 Jan 1 1970 uncrypt_status

我们发现,我们需要的/cache/recovery/block.map文件竟然没有,那么肯定是生成block.map的时候出了问题,我们追寻重启进入recovery之前的log信息:

  1. [ 1212.869820@3] type=1400 audit(1209.144:3355): avc: denied { setattr } for pid=4433 comm="Thread-3" name="uncrypt_file" dev="mmcblk0p3" ino=13 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_recovery_file:s0 tclass=file permissive=0
  2. [ 1212.885402@3] type=1400 audit(1212.820:3356): avc: denied { getattr } for pid=4501 comm="uncrypt" path="/data/cache" dev="mmcblk0p17" ino=19 scontext=u:r:uncrypt:s0 tcontext=u:object_r:cache_file:s0 tclass=dir permissive=0
  3. [ 1212.906032@2] watchdogd: watchdogd started (interval 10, margin 20)!
  4. [ 1212.906143@2] watchdogd: Failed to open /dev/watchdog: No such file or directory

好像是处理/data与/cache分区时候遇到了selinux权限问题。(mmcblk0p3mmcblk0p17对应的分别是cache与data分区)

我们可能需要为升级的应用赋予相应的selinux权限,但是上面遇到selinux权限就没有继续了,我们需要知道所有需要的selinux权限,那么我们把selinux设置为 permissive 状态,然后再升级一次,我们观察log状态:

  1. [ 98.295965@1] type=1400 audit(84.812:43): avc: denied { open } for pid=2890 comm="HwBinder:2890_1" path="/sys/module/tvin_hdmirx/parameters/en_4k_2_2k" dev="sysfs" ino=6874 scontext=u:r:system_control:s0 tcontext=u:object_r:sysfs_cec:s0 tclass=file permissive=1
  2. [ 98.313718@1] type=1400 audit(98.244:44): avc: denied { remove_name } for pid=4076 comm="Thread-4" name="update.zip" dev="mmcblk0p17" ino=316 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_file:s0 tclass=dir permissive=1
  3. [ 98.333696@1] type=1400 audit(98.244:44): avc: denied { remove_name } for pid=4076 comm="Thread-4" name="update.zip" dev="mmcblk0p17" ino=316 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_file:s0 tclass=dir permissive=1
  4. [ 98.353378@1] type=1400 audit(98.244:45): avc: denied { unlink } for pid=4076 comm="Thread-4" name="update.zip" dev="mmcblk0p17" ino=316 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_file:s0 tclass=file permissive=1
  5. [ 98.373096@1] type=1400 audit(98.244:45): avc: denied { unlink } for pid=4076 comm="Thread-4" name="update.zip" dev="mmcblk0p17" ino=316 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_file:s0 tclass=file permissive=1
  6. [ 98.392458@1] type=1400 audit(98.304:46): avc: denied { read } for pid=4076 comm="Thread-4" path="/data/cache/update.zip" dev="mmcblk0p17" ino=316 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_file:s0 tclass=file permissive=1
  7. [ 98.618368@2] success set parent gpu_p1_composite rate to 500000000
  8. [ 99.302385@1] success set parent gpu_p0_composite rate to 400000000
  9. [ 100.074360@1] success set parent gpu_p1_composite rate to 285714285
  10. [ 101.234329@3] success set parent gpu_p0_composite rate to 125000000
  11. [ 101.344037@0] aml_snd_card_tv aml_snd_tv: I2S playback disable
  12. [ 101.344244@0] aml_snd_card_tv aml_snd_tv: IEC958 playback disable
  13. [ 120.075238@1] type=1400 audit(98.304:46): avc: denied { read } for pid=4076 comm="Thread-4" path="/data/cache/update.zip" dev="mmcblk0p17" ino=316 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_file:s0 tclass=file permissive=1
  14. [ 120.090346@1] type=1400 audit(120.024:47): avc: denied { setattr } for pid=4076 comm="Thread-4" name="uncrypt_file" dev="mmcblk0p3" ino=13 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_recovery_file:s0 tclass=file permissive=1
  15. [ 121.326417@0] success set parent gpu_p1_composite rate to 666666666
  16. [ 121.734307@0] success set parent gpu_p0_composite rate to 500000000
  17. [ 121.897440@1] BT_RADIO going: off
  18. [ 121.897470@1] BCM_BT: going OFF
  19. [ 122.342361@2] success set parent gpu_p1_composite rate to 400000000
  20. [ 123.438484@0] success set parent gpu_p0_composite rate to 285714285
  21. [ 123.556904@1] type=1400 audit(120.024:47): avc: denied { setattr } for pid=4076 comm="Thread-4" name="uncrypt_file" dev="mmcblk0p3" ino=13 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_recovery_file:s0 tclass=file permissive=1
  22. [ 123.572107@1] type=1400 audit(123.508:48): avc: denied { getattr } for pid=4211 comm="uncrypt" path="/data/cache" dev="mmcblk0p17" ino=19 scontext=u:r:uncrypt:s0 tcontext=u:object_r:cache_file:s0 tclass=dir permissive=1
  23. [ 123.591568@1] type=1400 audit(123.508:48): avc: denied { getattr } for pid=4211 comm="uncrypt" path="/data/cache" dev="mmcblk0p17" ino=19 scontext=u:r:uncrypt:s0 tcontext=u:object_r:cache_file:s0 tclass=dir permissive=1
  24. [ 123.610598@1] type=1400 audit(123.508:49): avc: denied { getattr } for pid=4211 comm="uncrypt" path="/data/cache/update.zip" dev="mmcblk0p17" ino=316 scontext=u:r:uncrypt:s0 tcontext=u:object_r:cache_file:s0 tclass=file permissive=1
  25. [ 123.631453@1] type=1400 audit(123.508:49): avc: denied { getattr } for pid=4211 comm="uncrypt" path="/data/cache/update.zip" dev="mmcblk0p17" ino=316 scontext=u:r:uncrypt:s0 tcontext=u:object_r:cache_file:s0 tclass=file permissive=1
  26. [ 123.652217@1] type=1400 audit(123.512:50): avc: denied { read } for pid=4211 comm="uncrypt" name="update.zip" dev="mmcblk0p17" ino=316 scontext=u:r:uncrypt:s0 tcontext=u:object_r:cache_file:s0 tclass=file permissive=1
  27. [ 123.672583@1] type=1400 audit(123.512:50): avc: denied { read } for pid=4211 comm="uncrypt" name="update.zip" dev="mmcblk0p17" ino=316 scontext=u:r:uncrypt:s0 tcontext=u:object_r:cache_file:s0 tclass=file permissive=1
  28. [ 123.689809@1] type=1400 audit(123.512:51): avc: denied { open } for pid=4211 comm="uncrypt" path="/data/cache/update.zip" dev="mmcblk0p17" ino=316 scontext=u:r:uncrypt:s0 tcontext=u:object_r:cache_file:s0 tclass=file permissive=1
  29. [ 124.950389@3] success set parent gpu_p1_composite rate to 125000000

我们根据提示信息,增加相应的selinux权限:

  1. diff --git a/common/sepolicy/system_app.te b/common/sepolicy/system_app.te
  2. index 17e7f4e..3c77d47 100644
  3. --- a/common/sepolicy/system_app.te
  4. +++ b/common/sepolicy/system_app.te
  5. @@ -23,8 +23,8 @@
  6. #allow system_app unlabeled:file { lock open read write getattr };
  7. #
  8. ## /cache_file for dvb app creat update.zip file at /cache dir
  9. -allow system_app cache_file:dir { search add_name write };
  10. -allow system_app cache_file:file { create getattr open write };
  11. +allow system_app cache_file:dir { search add_name remove_name write };
  12. +allow system_app cache_file:file { create getattr open write unlink read };
  13. #
  14. #allow system_app log_file:dir { search read open getattr };
  15. #allow system_app log_file:file { read open getattr };
  16. diff --git a/common/sepolicy/uncrypt.te b/common/sepolicy/uncrypt.te
  17. new file mode 100644
  18. index 0000000..578a6d7
  19. --- /dev/null
  20. +++ b/common/sepolicy/uncrypt.te
  21. @@ -0,0 +1,2 @@
  22. +allow uncrypt cache_file:dir getattr;
  23. +allow uncrypt cache_file:file { open read getattr };

然后就可以正常升级了。至于如何通过提示的avc: denied信息增加selinux权限,可以自行学习。

recovery 升级'@/cache/recovery/block.map' failed错误问题的更多相关文章

  1. recovery 根据@/cache/recovery/block.map描述从data分区升级

    随着android版本的更新,系统固件的大小也越来越大,升级包也越来越大,cache分区已经不够存储update.zip了,所以应用把update.zip下载到data分区,默认情况下data分区是可 ...

  2. Android Recovery升级原理

    摘要 Recovery模式指的是一种可以对安卓机内部的数据或系统进行修改的模式(类似于windows PE或DOS).也可以称之为安卓的恢复模式,在这个所谓的恢复模式下,我们可以刷入新的安卓系统,或者 ...

  3. recovery 升级过程LED灯闪烁

    Android设备在进入recovery升级的过程,我们在屏幕上面可以看到升级的机器人动画,以及升级的进度显示.这仅限于有屏幕的设备,比如平板PAD,电视TV等,对与没有屏幕的盒子BOX,那么在不接入 ...

  4. android recovery 升级之USB设备挂载

    Recovery升级过程,通常会从两个地方获取升级包update.zip升级,一般在线升级,会把升级包下载到cache分区,本地升级会从usb或者tf卡中升级.本文讨论下,本地USB升级时,无法挂载U ...

  5. Android Partitions Explained: boot, system, recovery, data, cache & misc

    from: http://www.addictivetips.com/mobile/android-partitions-explained-boot-system-recovery-data-cac ...

  6. recovery 升级过程执行自定义shell命令

    有时候我们需要,在升级的过程中,执行一些shell命令,来完成我们的一些需求,利用升级过程,进行一些特殊化的操作,思路如下: 第一: 把我们需要执行的命令,写成一个test.sh脚本,然后在recov ...

  7. 华为 进入和退出Fastboot、eRecovery和Recovery升级模式

    手机关机状态下,可以进入Fastboot/eRecovery / Recovery/升级这几种模式: 需要连接电脑:Fastboot模式:长按音量下键+电源键.eRecovery 模式:长按音量上键+ ...

  8. Recovery启动流程--recovery.cpp分析

    这篇文章主要通过分析高通recovery目录下的recovery.cpp源码,对recovery启动流程有一个宏观的了解. 当开机以后,在lk阶段,如果是recovery,会设置boot_into_r ...

  9. Eclipse打开Android项目报Parsing Data for android-21 failed错误的解决办法(转载)

    转载:http://segmentfault.com/blog/hongliang/1190000000739285 今天手贱,用android命令打开SDK Manager下载了最新的Android ...

随机推荐

  1. mysql之select语法

    一:连接查询(外链接outer和内链接inner) 连接查询是另一种类型的多表查询.连接查询对多个表进行JOIN运算,简单地说,就是先确定一个主表作为结果集,然后,把其他表的行有选择性地“连接”在主表 ...

  2. VS发布 错误 未能将文件 复制到

    在VS内部编译及试运行的时候并为出现错误一切正常 当将项目发布时提示XXX文件无法复制到对应的obj文件夹下 未能将文件 upfile\team\2013\0328\20130328112637296 ...

  3. Spring Boot 2.0正式发布,新特性解读

    作者|翟永超 Spring Boot 2.0 来啦,有哪些新特性?升级吗? 写在前面 北京时间 3 月 1 日,经过漫长的等待之后,Spring Boot 2.0 正式发布.作为 Spring 生态中 ...

  4. Android应用内实现视频播放--腾讯浏览服务(TBS)

    TBS视频播放 TBS视频播放器可以支持市面上几乎所有的视频格式,包括mp4, flv, avi, 3gp, webm, ts, ogv, m3u8, asf, wmv, rm, rmvb, mov, ...

  5. thinkphp通用控制器

    <?php namespace 目录\Controller; class TypeController extends Controller { public function add() { ...

  6. MVC 5 Scaffolder + EntityFramework+UnitOfWork Pattern 代码生成工具集成Visual Studio 2013

    MVC 5 Scaffolder + EntityFramework+UnitOfWork Pattern 代码生成工具 经过一个多星期的努力总算完成了单表,多表关联(一对多,多对一)的增删改查的代码 ...

  7. PHP 九九乘法表的4种表达方式

    九九乘法表的四种不同表现形式 x轴对称: //第一种 for($i=1;$i<=9;$i++){ for($j=1;$j<=$i;$j++) { echo $i.'x'.$j.'='.$i ...

  8. [转]angular2封装material2对话框组件

    本文转自:https://www.jianshu.com/p/da9978e25566 1. 说明 angular-material2自身文档不详,控件不齐,使用上造成了很大的障碍.这里提供一个方案用 ...

  9. T-SQL:探究UNOIN,INTERSECT,EXCEPT集合运算符(十一)

    1.UNOIN运算符 unoin合并了两个输入查询结果 并消除重复项  简单点说   就是输出并集 SELECT country, region, city FROM HR.Employees UNI ...

  10. scala中的isInstanceOf和asInstanceOf

    如果实例化了子类的对象,但是将其赋予了父类类型的变量, 在后续的过程中,又需要将父类类型的变量转换为子类类型的变量,应该如何做? Ø  首先,需要使用isInstanceOf 判断对象是否为指定类的对 ...