*** empty log message ***
[yaffs/.git] / utils / mkyaffsimage.c
index b71cf92bb63d79fa8299a209ec375f8d47dd7dec..814e2af779224bf73afc1017f05ab13cf1ae1342 100644 (file)
@@ -33,7 +33,7 @@
 
 #define MAX_OBJECTS 10000
 
-const char * mkyaffsimage_c_version = "$Id: mkyaffsimage.c,v 1.5 2002-11-28 07:24:32 charles Exp $";
+const char * mkyaffsimage_c_version = "$Id: mkyaffsimage.c,v 1.6 2002-12-13 00:13:06 charles Exp $";
 
 // External functions for ECC on data
 void nand_calculate_ecc (const u_char *dat, u_char *ecc_code);
@@ -59,7 +59,7 @@ static int outFile;
 static int error;
 
 
-int obj_compare(const void *a, const void * b)
+static int obj_compare(const void *a, const void * b)
 {
   objItem *oa, *ob;
   
@@ -75,7 +75,7 @@ int obj_compare(const void *a, const void * b)
 }
 
 
-void add_obj_to_list(dev_t dev, ino_t ino, int obj)
+static void add_obj_to_list(dev_t dev, ino_t ino, int obj)
 {
        if(n_obj < MAX_OBJECTS)
        {
@@ -95,11 +95,11 @@ void add_obj_to_list(dev_t dev, ino_t ino, int obj)
 }
 
 
-int find_obj_in_list(dev_t dev, ino_t ino)
+static int find_obj_in_list(dev_t dev, ino_t ino)
 {
        objItem *i = NULL;
        objItem test;
-       
+
        test.dev = dev;
        test.ino = ino;
        
@@ -133,13 +133,13 @@ static __u16 yaffs_CalcNameSum(const char *name)
 }
 
 
-void yaffs_CalcECC(const __u8 *data, yaffs_Spare *spare)
+static void yaffs_CalcECC(const __u8 *data, yaffs_Spare *spare)
 {
        nand_calculate_ecc (data , spare->ecc1);
        nand_calculate_ecc (&data[256] , spare->ecc2);
 }
 
-void yaffs_CalcTagsECC(yaffs_Tags *tags)
+static void yaffs_CalcTagsECC(yaffs_Tags *tags)
 {
        // Todo don't do anything yet. Need to calculate ecc
        unsigned char *b = ((yaffs_TagsUnion *)tags)->asBytes;
@@ -170,7 +170,7 @@ static void yaffs_LoadTagsIntoSpare(yaffs_Spare *sparePtr, yaffs_Tags *tagsPtr)
 {
        yaffs_TagsUnion *tu = (yaffs_TagsUnion *)tagsPtr;
        
-       yaffs_CalcTagsECC(tagsPtr);
+       //yaffs_CalcTagsECC(tagsPtr);
        
        sparePtr->tagByte0 = tu->asBytes[0];
        sparePtr->tagByte1 = tu->asBytes[1];
@@ -184,14 +184,14 @@ static void yaffs_LoadTagsIntoSpare(yaffs_Spare *sparePtr, yaffs_Tags *tagsPtr)
 
 
 
-int write_chunk(__u8 *data, __u32 objId, __u32 chunkId, __u32 nBytes)
+static int write_chunk(__u8 *data, __u32 objId, __u32 chunkId, __u32 nBytes)
 {
        yaffs_Tags t;
        yaffs_Spare s;
-       
+
        error = write(outFile,data,512);
        if(error < 0) return error;
-       
+
        memset(&t,0xff,sizeof (yaffs_Tags));
        memset(&s,0xff,sizeof (yaffs_Spare));
        
@@ -210,7 +210,7 @@ int write_chunk(__u8 *data, __u32 objId, __u32 chunkId, __u32 nBytes)
        
 }
 
-int write_object_header(int objId, yaffs_ObjectType t, struct stat *s, int parent, const char *name, int equivalentObj, const char * alias)
+static int write_object_header(int objId, yaffs_ObjectType t, struct stat *s, int parent, const char *name, int equivalentObj, const char * alias)
 {
        __u8 bytes[512];
        
@@ -258,13 +258,13 @@ int write_object_header(int objId, yaffs_ObjectType t, struct stat *s, int paren
 }
 
 
-int process_directory(int parent, const char *path)
+static int process_directory(int parent, const char *path)
 {
 
        DIR *dir;
        struct dirent *entry;
 
-       nDirectories++; 
+       nDirectories++;
        
        dir = opendir(path);
        
@@ -317,9 +317,9 @@ int process_directory(int parent, const char *path)
                                        
                                                        char symname[500];
                                                
-                                                       memset(symname,0,500);
+                                                       memset(symname,0, sizeof(symname));
                                        
-                                                       readlink(full_name,symname,499);
+                                                       readlink(full_name,symname,sizeof(symname) -1);
                                                
                                                        printf("symlink to \"%s\"\n",symname);
                                                        error =  write_object_header(newObj, YAFFS_OBJECT_TYPE_SYMLINK, &stats, parent, entry->d_name, -1, symname);
@@ -413,7 +413,7 @@ int main(int argc, char *argv[])
        {
                printf("usage: mkyaffsimage dir image_file\n");
                printf("           dir        the directory tree to be converted\n");
-               printf("           image_file the ouput file to hold the image\n");
+               printf("           image_file the output file to hold the image\n");
                exit(1);
        }