X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmkyaffsimage.c;h=b71cf92bb63d79fa8299a209ec375f8d47dd7dec;hb=076194d2d15ac508c99890e6034a014e09fbfdff;hp=797bc0f0f1192d32cb495afb83c36fdfe5e69ee1;hpb=00e8c64d27b7c27e3e9df40e62bb9d12550831d4;p=yaffs%2F.git diff --git a/utils/mkyaffsimage.c b/utils/mkyaffsimage.c index 797bc0f..b71cf92 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.5 2002-11-28 07:24:32 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,13 @@ int write_object_header(int objId, yaffs_ObjectType t, struct stat *s, int paren strncpy(oh->name,name,YAFFS_MAX_NAME_LENGTH); + 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 +385,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); } } } @@ -417,7 +439,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);