调试指引
本文只记录存储服务的日志查看命令和问题定位流程。密钥异常见 crypto-key-management.md,IPC 故障见 ipc-interface-guide.md。
日志查看
hilog -t StorageDaemon # Daemon 日志
hilog -t StorageManager # Manager 日志
hilog -r && hilog -T StorageDaemon -T StorageManager # 清空后实时跟踪
hilog -t StorageDaemon -L E # 只看错误
hilog -P storage_daemon # 按进程过滤
服务状态检查
hidumper -s 5003 -a "-h" # Manager SA 注册
hidumper -s 5004 -a "-h" # Daemon SA 注册
ps -ef | grep storage # 进程状态
问题定位流程
服务未启动
hidumper -s 5003 -a "-h"/hidumper -s 5004 -a "-h"检查 SA 注册ps -ef | grep storage检查进程hilog -t StorageDaemon | grep "OnStart"检查启动日志
IPC 调用失败
hilog -t StorageManager | grep "Connect"检查连接- 确认
StorageDaemonCommunication::Connect()返回值 ps -ef | grep storage_daemon确认进程存活
密钥操作失败
hidumper -s HUKS检查 HUKS 服务ls /data/service/el1/public/storage_daemon/sd/el1/检查密钥文件- 检查
RECOVER_KEY_TEE_ENVIRONMENT编译宏
挂载失败
ls -la /dev/block/检查设备节点权限blkid /dev/block/sdcard检查文件系统类型- 确认挂载路径不存在且可写
用户目录异常
- 确认 userId 在 [100, 10738]
ls -la /data/user/<userId>检查目录权限ls -Z /data/user/<userId>检查 SELinux context
空间统计异常
hilog -t StorageManager | grep "GetBundleStats"检查统计日志repquota -a检查配额设置- 确认 BundleManager 连接可用
常用诊断命令
mount | grep -E "sdcard|usb|hmdfs" # 外部存储挂载
cat /proc/keys | grep fscrypt # 内核密钥(需 root)
df -h # 文件系统空间
dmesg | grep -E "sd|mmc|usb" # 内核设备日志