X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmkyaffsimage.c;fp=utils%2Fmkyaffsimage.c;h=bab5797501e20314b9c02d86206ca1944d4061a1;hb=4d9efb8e3f1bd240579632b4c1446d7384c3cc96;hp=797bc0f0f1192d32cb495afb83c36fdfe5e69ee1;hpb=f40b8435a109889e57bc37743ac7eb6badf1dd95;p=yaffs%2F.git diff --git a/utils/mkyaffsimage.c b/utils/mkyaffsimage.c index 797bc0f..bab5797 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.3 2002-09-27 20:50:50 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) @@ -206,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; @@ -364,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); } } }