X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=utils%2Fmkyaffsimage.c;h=8a50da5f77d01ffc72e5e0376061b8828723b4ad;hb=70c6bf2ff57c8a2fb778accdd5b4227abf273674;hp=fa9479ad3b227e7e32469b5386121255fcd49be1;hpb=34425627ebb5c993c8e60097b117710a45ff108a;p=yaffs2.git diff --git a/utils/mkyaffsimage.c b/utils/mkyaffsimage.c index fa9479a..8a50da5 100644 --- a/utils/mkyaffsimage.c +++ b/utils/mkyaffsimage.c @@ -1,25 +1,22 @@ /* - * YAFFS: Yet another FFS. A NAND-flash specific file system. + * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. * - * makeyaffsimage.c - * - * Makes a YAFFS file system image that can be used to load up a file system. - * - * Copyright (C) 2002 Aleph One Ltd. + * Copyright (C) 2002-2007 Aleph One Ltd. * for Toby Churchill Ltd and Brightstar Engineering * * Created by Charles Manning + * Nick Bane modifications flagged NCB + * Endian handling patches by James Ng * * 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. + */ + +/* + * makeyaffsimage.c * - * - * Nick Bane modifications flagged NCB - * - * Endian handling patches by James Ng. - * - * + * Makes a YAFFS file system image that can be used to load up a file system. */ #include @@ -116,7 +113,7 @@ static int find_obj_in_list(dev_t dev, ino_t ino) } // NCB added 10/9/2002 -static __u16 yaffs_CalcNameSum(const char *name) +static __u16 yaffs_calc_name_sum(const char *name) { __u16 sum = 0; __u16 i = 1; @@ -133,16 +130,16 @@ static __u16 yaffs_CalcNameSum(const char *name) } -static void yaffs_CalcECC(const __u8 *data, yaffs_Spare *spare) +static void yaffs_calc_ecc(const __u8 *data, yaffs_Spare *spare) { - yaffs_ECCCalculate(data , spare->ecc1); - yaffs_ECCCalculate(&data[256] , spare->ecc2); + yaffs_ecc_cacl(data , spare->ecc1); + yaffs_ecc_cacl(&data[256] , spare->ecc2); } -static void yaffs_CalcTagsECC(yaffs_Tags *tags) +static void yaffs_calc_tags_ecc(yaffs_Tags *tags) { // Todo don't do anything yet. Need to calculate ecc - unsigned char *b = ((yaffs_TagsUnion *)tags)->asBytes; + unsigned char *b = ((yaffs_tags_union_t *)tags)->asBytes; unsigned i,j; unsigned ecc = 0; unsigned bit = 0; @@ -184,20 +181,20 @@ static void yaffs_CalcTagsECC(yaffs_Tags *tags) b[7] |= ((ecc & 0x3F) << 2); } } -static void yaffs_LoadTagsIntoSpare(yaffs_Spare *sparePtr, yaffs_Tags *tagsPtr) +static void yaffs_load_tags_to_spare(yaffs_Spare *sparePtr, yaffs_Tags *tagsPtr) { - yaffs_TagsUnion *tu = (yaffs_TagsUnion *)tagsPtr; - - //yaffs_CalcTagsECC(tagsPtr); - - sparePtr->tagByte0 = tu->asBytes[0]; - sparePtr->tagByte1 = tu->asBytes[1]; - sparePtr->tagByte2 = tu->asBytes[2]; - sparePtr->tagByte3 = tu->asBytes[3]; - sparePtr->tagByte4 = tu->asBytes[4]; - sparePtr->tagByte5 = tu->asBytes[5]; - sparePtr->tagByte6 = tu->asBytes[6]; - sparePtr->tagByte7 = tu->asBytes[7]; + yaffs_tags_union_t *tu = (yaffs_tags_union_t *)tagsPtr; + + //yaffs_calc_tags_ecc(tagsPtr); + + sparePtr->tb0 = tu->asBytes[0]; + sparePtr->tb1 = tu->asBytes[1]; + sparePtr->tb2 = tu->asBytes[2]; + sparePtr->tb3 = tu->asBytes[3]; + sparePtr->tb4 = tu->asBytes[4]; + sparePtr->tb5 = tu->asBytes[5]; + sparePtr->tb6 = tu->asBytes[6]; + sparePtr->tb7 = tu->asBytes[7]; } /* This little function converts a little endian tag to a big endian tag. @@ -206,8 +203,8 @@ static void yaffs_LoadTagsIntoSpare(yaffs_Spare *sparePtr, yaffs_Tags *tagsPtr) */ static void little_to_big_endian(yaffs_Tags *tagsPtr) { - yaffs_TagsUnion * tags = (yaffs_TagsUnion* )tagsPtr; // Work in bytes. - yaffs_TagsUnion temp; + yaffs_tags_union_t * tags = (yaffs_tags_union_t* )tagsPtr; // Work in bytes. + yaffs_tags_union_t temp; memset(&temp, 0, sizeof(temp)); // Ick, I hate magic numbers. @@ -244,7 +241,7 @@ static int write_chunk(__u8 *data, __u32 objId, __u32 chunkId, __u32 nBytes) t.chunkId = chunkId; t.serialNumber = 0; - t.byteCount = nBytes; + t.byteCountLSB = nBytes; t.objectId = objId; if (convert_endian) @@ -252,9 +249,9 @@ static int write_chunk(__u8 *data, __u32 objId, __u32 chunkId, __u32 nBytes) little_to_big_endian(&t); } - yaffs_CalcTagsECC(&t); - yaffs_LoadTagsIntoSpare(&s,&t); - yaffs_CalcECC(data,&s); + yaffs_calc_tags_ecc(&t); + yaffs_load_tags_to_spare(&s,&t); + yaffs_calc_ecc(data,&s); nPages++;