* 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 <stdlib.h>
#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;
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)
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)
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;
{
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);
}
}
}
}
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);