X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmkyaffsimage.c;h=0b6d4094060982b51994b28b2e83de16468f6ac6;hb=5750ae310d9c31b6c1773e58fd36808dbe845cd0;hp=87fc7dab837c2e40d4976c4ed3457db1b339a857;hpb=aa39fbf7616e8b26833a09cb64c6a40859494599;p=yaffs%2F.git diff --git a/utils/mkyaffsimage.c b/utils/mkyaffsimage.c index 87fc7da..0b6d409 100644 --- a/utils/mkyaffsimage.c +++ b/utils/mkyaffsimage.c @@ -14,6 +14,9 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * + * + * Nick Bane modifications flagged NCB + * */ #include @@ -30,14 +33,13 @@ #define MAX_OBJECTS 10000 +const char * mkyaffsimage_c_version = "$Id: mkyaffsimage.c,v 1.4 2002-10-02 00:10:17 charles Exp $"; + // External functions for ECC on data void nand_calculate_ecc (const u_char *dat, u_char *ecc_code); int nand_correct_data (u_char *dat, u_char *read_ecc, u_char *calc_ecc); - - - typedef struct { dev_t dev; @@ -113,6 +115,22 @@ int find_obj_in_list(dev_t dev, ino_t ino) return -1; } +// NCB added 10/9/2002 +static __u16 yaffs_CalcNameSum(const char *name) +{ + __u16 sum = 0; + __u16 i = 1; + + __u8 *bname = (__u8 *)name; + + while (*bname) + { + sum += (*bname) * i; + i++; + bname++; + } + return sum; +} void yaffs_CalcECC(const __u8 *data, yaffs_Spare *spare) @@ -133,7 +151,8 @@ void yaffs_CalcTagsECC(yaffs_Tags *tags) for(i = 0; i < 8; i++) { - for(j = 1; j &0x7f; j<<=1) +// NCB modified 20-9-02 for(j = 1; j &0x7f; j<<=1) + for(j = 1; j &0xff; j<<=1) { bit++; if(b[i] & j) @@ -174,6 +193,7 @@ int write_chunk(__u8 *data, __u32 objId, __u32 chunkId, __u32 nBytes) if(error < 0) return error; memset(&t,0xff,sizeof (yaffs_Tags)); + memset(&s,0xff,sizeof (yaffs_Spare)); t.chunkId = chunkId; t.serialNumber = 0; @@ -205,11 +225,15 @@ int write_object_header(int objId, yaffs_ObjectType t, struct stat *s, int paren strncpy(oh->name,name,YAFFS_MAX_NAME_LENGTH); + // NCB added 10/9/2001 + oh->sum = yaffs_CalcNameSum(oh->name); + if(t != YAFFS_OBJECT_TYPE_HARDLINK) { oh->st_mode = s->st_mode; oh->st_uid = s->st_uid; - oh->st_gid = s->st_uid; +// NCB 12/9/02 oh->st_gid = s->st_uid; + oh->st_gid = s->st_gid; oh->st_atime = s->st_atime; oh->st_mtime = s->st_mtime; oh->st_ctime = s->st_ctime; @@ -363,7 +387,8 @@ int process_directory(int parent, const char *path) { printf("directory\n"); error = write_object_header(newObj, YAFFS_OBJECT_TYPE_DIRECTORY, &stats, parent, entry->d_name, -1, NULL); - process_directory(1,full_name); +// NCB modified 10/9/2001 process_directory(1,full_name); + process_directory(newObj,full_name); } } } @@ -416,7 +441,8 @@ int main(int argc, char *argv[]) } printf("Processing directory %s into image file %s\n",argv[1],argv[2]); - + error = write_object_header(1, YAFFS_OBJECT_TYPE_DIRECTORY, &stats, 1,"", -1, NULL); + if(error) error = process_directory(YAFFS_OBJECTID_ROOT,argv[1]); close(outFile);