recovery怎么保存log
2013-11-04 22:04
204 查看
首先,要说明的是,我想知道或得到recovery过长的所有详细log信息。
但是log 不能保存到/data 或者 /cache ,又不能保存到/tmp目录下,
因为下次开机的时候,/tmp目录的内容又会清空。
所以只能格式化之后,factory reset 彻底成功后,才把log 从/tmp 拷贝到 /cache下。
// 临时目录
static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log";
// 所有log
static const char *LOG_FILE = "/cache/recovery/log";
// 最后一部分log
static const char *LAST_LOG_FILE = "/cache/recovery/last_log";
// factory reset 彻底成功后,会执行
// 拷贝文件的实现
但是log 不能保存到/data 或者 /cache ,又不能保存到/tmp目录下,
因为下次开机的时候,/tmp目录的内容又会清空。
所以只能格式化之后,factory reset 彻底成功后,才把log 从/tmp 拷贝到 /cache下。
// 临时目录
static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log";
// 所有log
static const char *LOG_FILE = "/cache/recovery/log";
// 最后一部分log
static const char *LAST_LOG_FILE = "/cache/recovery/last_log";
// factory reset 彻底成功后,会执行
static void finish_recovery(const char *send_intent) { { // Copy logs to cache so the system can find out what happened. copy_log_file(TEMPORARY_LOG_FILE, LOG_FILE, true); //追加 copy_log_file(TEMPORARY_LOG_FILE, LAST_LOG_FILE, false); //直接覆盖 copy_log_file(TEMPORARY_INSTALL_FILE, LAST_INSTALL_FILE, false); ........................... }
// 拷贝文件的实现
static void copy_log_file(const char* source, const char* destination, int append) { FILE *log = fopen_path(destination, append ? "a" : "w"); if (log == NULL) { LOGE("Can't open %s\n", destination); } else { FILE *tmplog = fopen(source, "r"); if (tmplog != NULL) { if (append) { fseek(tmplog, tmplog_offset, SEEK_SET); // Since last write } char buf[4096]; while (fgets(buf, sizeof(buf), tmplog)) fputs(buf, log); if (append) { tmplog_offset = ftell(tmplog); } check_and_fclose(tmplog, source); } check_and_fclose(log, destination); } }
相关文章推荐
- PHP怎么实现网站保存快捷方式方便用户随时浏览
- 微博视频怎么下载?微博视频下载和保存工具
- Java程序猿修炼之道 之 Logging(3/3) - 怎么分析Log
- 思维导图文件怎么保存到Google Drive种
- (论坛答疑点滴)怎么在ViewState中保存和取出自己定义的类
- ORA-00265: instance recovery required, cannot set ARCHIVELOG mode
- 怎么查找XCode模拟器的保存路径?以及真机的沙盒文件?
- 怎么把堆栈错误信息打印到log中
- Unity死机未保存场景怎么办
- 用Python获取命令行输出 将屏幕输出的log保存文件中
- 【caffe】caffe保存训练生成的log & 绘制训练过程的loss和accuracy曲线
- Log保存文件-Android
- vs2008 怎么设置创建项目时不要自动保存解决方案
- 微信语音怎么保存 微信语音导出文件夹教程
- 怎么恢复iMindMap中未保存文件
- Android的log保存到文件上查看
- Android将应用log信息保存文件
- 尚未备份数据库 "***" 的日志尾部。如果该日志包含您不希望丢失的工作,请使用 BACKUP LOG WITH NORECOVERY 备份该日志。
- 2016年3月1号【Vim写了个小作业,不知道保存到哪了,怎么办?】
- Kernel panic时log的保存