From 7e5a6610647f93ee6e982b528099fda4b42edb45 Mon Sep 17 00:00:00 2001 From: "Koushik K. Dutta" Date: Sun, 21 Feb 2010 01:09:52 -0800 Subject: [PATCH] move unyaffs into external/yaffs2 --- nandroid/Android.mk | 18 ------ nandroid/unyaffs.c | 118 ------------------------------------ nandroid/unyaffs.h | 144 -------------------------------------------- 3 files changed, 280 deletions(-) delete mode 100644 nandroid/unyaffs.c delete mode 100644 nandroid/unyaffs.h diff --git a/nandroid/Android.mk b/nandroid/Android.mk index 9423c09..993daba 100644 --- a/nandroid/Android.mk +++ b/nandroid/Android.mk @@ -10,21 +10,3 @@ ADDITIONAL_RECOVERY_EXECUTABLES += recovery_nandroid include $(BUILD_PREBUILT) include $(CLEAR_VARS) -LOCAL_MODULE := recovery_unyaffs -LOCAL_MODULE_STEM := unyaffs -LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_TAGS := eng -LOCAL_FORCE_STATIC_EXECUTABLE := true -LOCAL_SRC_FILES := unyaffs.c -LOCAL_STATIC_LIBRARIES := libc libcutils -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin -ADDITIONAL_RECOVERY_EXECUTABLES += recovery_unyaffs -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_MODULE := unyaffs -LOCAL_SRC_FILES := unyaffs.c -LOCAL_MODULE_TAGS := eng -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) diff --git a/nandroid/unyaffs.c b/nandroid/unyaffs.c deleted file mode 100644 index aa8a735..0000000 --- a/nandroid/unyaffs.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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]; -void 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; -} diff --git a/nandroid/unyaffs.h b/nandroid/unyaffs.h deleted file mode 100644 index fcd8046..0000000 --- a/nandroid/unyaffs.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * definition copied from yaffs project - */ - -#ifndef __UNYAFFS_H__ -#define __UNYAFFS_H__ - - -#define YAFFS_MAX_NAME_LENGTH 255 -#define YAFFS_MAX_ALIAS_LENGTH 159 - -#include - -/* Definition of types */ -#ifndef __ASM_ARM_TYPES_H -typedef unsigned char __u8; -typedef unsigned short __u16; -typedef unsigned __u32; -#endif -typedef struct { - unsigned sequenceNumber; - unsigned objectId; - unsigned chunkId; - unsigned byteCount; -} yaffs_PackedTags2TagsPart; - -typedef struct { - unsigned char colParity; - unsigned lineParity; - unsigned lineParityPrime; -} yaffs_ECCOther; - -typedef struct { - yaffs_PackedTags2TagsPart t; - yaffs_ECCOther ecc; -} yaffs_PackedTags2; - -typedef enum { - YAFFS_ECC_RESULT_UNKNOWN, - YAFFS_ECC_RESULT_NO_ERROR, - YAFFS_ECC_RESULT_FIXED, - YAFFS_ECC_RESULT_UNFIXED -} yaffs_ECCResult; - -typedef enum { - YAFFS_OBJECT_TYPE_UNKNOWN, - YAFFS_OBJECT_TYPE_FILE, - YAFFS_OBJECT_TYPE_SYMLINK, - YAFFS_OBJECT_TYPE_DIRECTORY, - YAFFS_OBJECT_TYPE_HARDLINK, - YAFFS_OBJECT_TYPE_SPECIAL -} yaffs_ObjectType; - - -typedef struct { - - unsigned validMarker0; - unsigned chunkUsed; /* Status of the chunk: used or unused */ - unsigned objectId; /* If 0 then this is not part of an object (unused) */ - unsigned chunkId; /* If 0 then this is a header, else a data chunk */ - unsigned byteCount; /* Only valid for data chunks */ - - /* The following stuff only has meaning when we read */ - yaffs_ECCResult eccResult; - unsigned blockBad; - - /* YAFFS 1 stuff */ - unsigned chunkDeleted; /* The chunk is marked deleted */ - unsigned serialNumber; /* Yaffs1 2-bit serial number */ - - /* YAFFS2 stuff */ - unsigned sequenceNumber; /* The sequence number of this block */ - - /* Extra info if this is an object header (YAFFS2 only) */ - - unsigned extraHeaderInfoAvailable; /* There is extra info available if this is not zero */ - unsigned extraParentObjectId; /* The parent object */ - unsigned extraIsShrinkHeader; /* Is it a shrink header? */ - unsigned extraShadows; /* Does this shadow another object? */ - - yaffs_ObjectType extraObjectType; /* What object type? */ - - unsigned extraFileLength; /* Length if it is a file */ - unsigned extraEquivalentObjectId; /* Equivalent object Id if it is a hard link */ - - unsigned validMarker1; - -} yaffs_ExtendedTags; - -/* -------------------------- Object structure -------------------------------*/ -/* This is the object structure as stored on NAND */ - -typedef struct { - yaffs_ObjectType type; - - /* Apply to everything */ - int parentObjectId; - __u16 sum__NoLongerUsed; /* checksum of name. No longer used */ - char name[YAFFS_MAX_NAME_LENGTH + 1]; - - /* The following apply to directories, files, symlinks - not hard links */ - __u32 yst_mode; /* protection */ - -#ifdef CONFIG_YAFFS_WINCE - __u32 notForWinCE[5]; -#else - __u32 yst_uid; - __u32 yst_gid; - __u32 yst_atime; - __u32 yst_mtime; - __u32 yst_ctime; -#endif - - /* File size applies to files only */ - int fileSize; - - /* Equivalent object id applies to hard links only. */ - int equivalentObjectId; - - /* Alias is for symlinks only. */ - char alias[YAFFS_MAX_ALIAS_LENGTH + 1]; - - __u32 yst_rdev; /* device stuff for block and char devices (major/min) */ - -#ifdef CONFIG_YAFFS_WINCE - __u32 win_ctime[2]; - __u32 win_atime[2]; - __u32 win_mtime[2]; -#else - __u32 roomToGrow[6]; - -#endif - __u32 inbandShadowsObject; - __u32 inbandIsShrink; - - __u32 reservedSpace[2]; - int shadowsObject; /* This object header shadows the specified object if > 0 */ - - /* isShrink applies to object headers written when we shrink the file (ie resize) */ - __u32 isShrink; - -} yaffs_ObjectHeader; - -#endif