资源简介
ubuntu下的unyaffs工具,unyaffs.c 和unyaffs.h 两个文件打包zip。用gcc -o unyaffs unyaffs.c编译,产生可执行的unyaffs命令。

代码片段和文件信息
/*
* unyaffs: extract files from yaffs2 file system image to current directory
*
* Created by Kai Wei
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include
#include
#include
#include
#include
#include
#include
#include “unyaffs.h“
#define CHUNK_SIZE 2048
#define SPARE_SIZE 64
#define MAX_objectS 10000
#define YAFFS_objectID_ROOT 1
unsigned char data[CHUNK_SIZE + SPARE_SIZE];
unsigned char *chunk_data = data;
unsigned char *spare_data = data + CHUNK_SIZE;
int img_file;
char *obj_list[MAX_objectS];
int process_chunk()
{
int out_file remain s;
char *full_path_name;
yaffs_PackedTags2 *pt = (yaffs_PackedTags2 *)spare_data;
if (pt->t.byteCount == 0xffff) { //a new object
yaffs_objectHeader *oh = (yaffs_objectHeader *)malloc(sizeof(yaffs_objectHeader));
memcpy(oh chunk_data sizeof(yaffs_objectHeader));
full_path_name = (char *)malloc(strlen(oh->name) + strlen(obj_list[oh->parentobjectId]) + 2);
if (full_path_name == NULL) {
perror(“malloc full path name\n“);
}
strcpy(full_path_name obj_list[oh->parentobjectId]);
strcat(full_path_name “/“);
strcat(full_path_name oh->name);
obj_list[pt->t.objectId] = full_path_name;
switch(oh->type) {
case YAFFS_object_TYPE_FILE:
remain = oh->fileSize;
out_file = creat(full_path_name oh->yst_mode);
while(remain > 0) {
if (read_chunk())
return -1;
s = (remain < pt->t.byteCount) ? remain : pt->t.byteCount;
if (write(out_file chunk_data s) == -1)
return -1;
remain -= s;
}
close(out_file);
break;
case YAFFS_object_TYPE_SYMlink:
symlink(oh->alias full_path_name);
break;
case YAFFS_object_TYPE_DIRECTORY:
mkdir(full_path_name 0777);
break;
case YAFFS_object_TYPE_HARDlink:
link(obj_list[oh->equivalentobjectId] full_path_name);
break;
}
}
}
int read_chunk()
{
ssize_t s;
int ret = -1;
memset(chunk_data 0xff sizeof(chunk_data));
s = read(img_file data CHUNK_SIZE + SPARE_SIZE);
if (s == -1) {
perror(“read image file\n“);
} else if (s == 0) {
printf(“end of image\n“);
} else if ((s == (CHUNK_SIZE + SPARE_SIZE))) {
ret = 0;
} else {
fprintf(stderr “broken image file\n“);
}
return ret;
}
int main(int argc char **argv)
{
if (argc != 2) {
printf(“Usage: unyaffs image_file_name\n“);
exit(1);
}
img_file = open(argv[1] O_RDONLY);
if (img_file == -1) {
printf(“open image file failed\n“);
exit(1);
}
obj_list[YAFFS_objectID_ROOT] = “.“;
while(1) {
if (read_chunk() == -1)
break;
process_chunk();
}
close(img_file);
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2827 2013-03-10 11:32 unyaffs.c
文件 3729 2013-03-10 11:32 unyaffs.h
文件 10179 2013-03-10 11:32 unyaffs (1)
- 上一篇:CCSv5.5破解所需的License
- 下一篇:Bus Hound.zip
相关资源
- Img2Lcd(将图片转换为数组的工具)
- img写盘工具(roadkil‘s diskimage) v1.
- 添加MoCe的NiMgAl水滑石基催化剂对CH4
- img格式遥感图像读取代码
- .net MVC+Bootstrap下使用localResizeIMG上传图
- labelImg 1.7 for windows 标图软件
- labelImg-master.zip
- Img2Ozf(Ozi地图转换工具)v3.20官方安
- LenaLenna是一张被广泛使用的标准图片
- 气象数据.img格式文件的详解和读取方
- DSP imglib C64x+的CCS4工程文件
- 适用于Amlogic芯片方案的boot.img解包和
- Img2lcd 图片取模软件
- TI imgLib图像库源代码
- springboot图片代理,请求url传入img返回
- kpw3 内核文件 降级文件 img
- ti_imglib_
- img.rar
- 虚拟机镜像的制作
- 3750969ZXHNZXA10_F601V4.0.2P7T1_ZLD_UPGRADE.im
- IMG文件写入读取工具
- layui-springmvc-imgupload.zip
- 解包boot.img工具
- 内存测试工具+RST+PRO3+USB+IMG+u盘启动版
- 128k.S7img MMC卡镜像文件
- WIN 98启动盘 软盘镜像IMG
- BOOT.img和recovery.img解包打包工具
- DTiii版2018中国大数据产业地图(2233家
- labelImg.zip
- labelImg_qt5py3_mac_latest 2.zip
评论
共有 条评论