[Yaffs] Build CVS yaffs under linux

Top Page
Attachments:
Message as email
+ (text/plain)
+ cvs_yaffs1.patch (text/x-patch)
Delete this message
Reply to this message
Author: Claudio Lanconelli
Date:  
To: yaffs
Subject: [Yaffs] Build CVS yaffs under linux
Hi,
I'm new to this mailing-list.
I make some changes to current CVS version of yaffs1 to make it build
and run
under my desktop linux: Suse Linux 9.1 (yaffs direct) and
my embedded board using uClinux 2.4.31 with Samsung K9F5608 nand chip.
Most of the changes regards the known problem of time fields.
Other changes add some include file to avoid warning and/or errors.

If you think this patch is correct apply to your CVS, please. Otherwise
explain me what I'm doing wrong, why I can't build cleanly without these
changes.

Is yaffs1 + linux 2.4.x still supported?

Regards,
Claudio Lanconelli
*** devextras.h    27 Sep 2002 20:50:50 -0000    1.5
--- devextras.h    26 Sep 2005 11:31:17 -0000
@@ -204,6 +204,7 @@
 /*
  * File types
  */
+#ifndef DT_UNKNOWN
 #define DT_UNKNOWN    0
 #define DT_FIFO        1
 #define DT_CHR        2
@@ -213,6 +214,7 @@
 #define DT_LNK        10
 #define DT_SOCK        12
 #define DT_WHT        14
+#endif


#ifndef WIN32
#include <sys/stat.h>


*** yaffs_fs.c    25 Jun 2005 03:22:23 -0000    1.40
--- yaffs_fs.c    26 Sep 2005 11:31:18 -0000
@@ -625,9 +625,9 @@
         inode->i_ctime.tv_nsec = 0;
 #else
         inode->i_rdev = obj->st_rdev;
-        inode->i_atime = obj->st_atime;
-        inode->i_mtime = obj->st_mtime;
-        inode->i_ctime = obj->st_ctime;
+        inode->i_atime = obj->st_atim;
+        inode->i_mtime = obj->st_mtim;
+        inode->i_ctime = obj->st_ctim;
 #endif
         inode->i_size = yaffs_GetObjectFileLength(obj);
         inode->i_blocks = (inode->i_size + 511) >> 9;



*** yaffs_guts.c    25 Jun 2005 03:22:23 -0000    1.42
--- yaffs_guts.c    26 Sep 2005 11:31:18 -0000
@@ -1116,12 +1116,12 @@
 static int yaffs_SoftDeleteWorker(yaffs_Object *in, yaffs_Tnode *tn, __u32 level, int chunkOffset)
 {
     int i;
-    int chunkInInode;
+//    int chunkInInode;
     int theChunk;
     yaffs_BlockInfo *theBlock;
-    yaffs_Tags tags;
-    int found;
-    int chunkDeleted;
+//    yaffs_Tags tags;
+//    int found;
+//    int chunkDeleted;
     int allDone = 1;

    
    
@@ -1665,7 +1665,7 @@

#else

-        theObject->st_atime = theObject->st_mtime =    theObject->st_ctime = Y_CURRENT_TIME;
+        theObject->st_atim = theObject->st_mtim =    theObject->st_ctim = Y_CURRENT_TIME;


 #endif
         switch(type)
@@ -1771,7 +1771,7 @@

        
#else

-        in->st_atime = in->st_mtime = in->st_ctime = Y_CURRENT_TIME;
+        in->st_atim = in->st_mtim = in->st_ctim = Y_CURRENT_TIME;
         in->st_rdev  = rdev;
         in->st_uid   = uid;
         in->st_gid   = gid;
@@ -3036,9 +3036,9 @@
 #else
         oh->st_uid = in->st_uid;
         oh->st_gid = in->st_gid;
-        oh->st_atime = in->st_atime;
-        oh->st_mtime = in->st_mtime;
-        oh->st_ctime = in->st_ctime;
+        oh->st_atim = in->st_atim;
+        oh->st_mtim = in->st_mtim;
+        oh->st_ctim = in->st_ctim;
         oh->st_rdev = in->st_rdev;
 #endif    
         if(in->parent)
@@ -3142,7 +3142,7 @@
     int i;
     yaffs_ChunkCache *cache;
     int chunkWritten = 0;
-    int nBytes;
+//    int nBytes;
     int nCaches = obj->myDev->nShortOpCaches;

    
     if  (nCaches > 0)
@@ -3746,7 +3746,7 @@
 #ifdef CONFIG_YAFFS_WINCE
             yfsd_WinFileTimeNow(in->win_mtime);
 #else
-            in->st_mtime = Y_CURRENT_TIME;
+            in->st_mtim = Y_CURRENT_TIME;
 #endif
         }


@@ -4203,9 +4203,9 @@
 #else
                     in->st_uid   = oh->st_uid;
                     in->st_gid   = oh->st_gid;
-                    in->st_atime = oh->st_atime;
-                    in->st_mtime = oh->st_mtime;
-                    in->st_ctime = oh->st_ctime;
+                    in->st_atim = oh->st_atim;
+                    in->st_mtim = oh->st_mtim;
+                    in->st_ctim = oh->st_ctim;
                     in->st_rdev = oh->st_rdev;
 #endif
                     in->chunkId  = chunk;
@@ -4229,9 +4229,9 @@
 #else
                     in->st_uid   = oh->st_uid;
                     in->st_gid   = oh->st_gid;
-                    in->st_atime = oh->st_atime;
-                    in->st_mtime = oh->st_mtime;
-                    in->st_ctime = oh->st_ctime;
+                    in->st_atim = oh->st_atim;
+                    in->st_mtim = oh->st_mtim;
+                    in->st_ctim = oh->st_ctim;
                     in->st_rdev = oh->st_rdev;
 #endif
                     in->chunkId  = chunk;
@@ -4608,9 +4608,12 @@
     if(valid & ATTR_UID) obj->st_uid = attr->ia_uid;
     if(valid & ATTR_GID) obj->st_gid = attr->ia_gid;

    
-    if(valid & ATTR_ATIME) obj->st_atime = Y_TIME_CONVERT(attr->ia_atime);
-    if(valid & ATTR_CTIME) obj->st_ctime = Y_TIME_CONVERT(attr->ia_ctime);
-    if(valid & ATTR_MTIME) obj->st_mtime = Y_TIME_CONVERT(attr->ia_mtime);
+    if(valid & ATTR_ATIME)
+        obj->st_atim = Y_TIME_CONVERT(attr->ia_atime);
+    if(valid & ATTR_CTIME)
+        obj->st_ctim = Y_TIME_CONVERT(attr->ia_ctime);
+    if(valid & ATTR_MTIME)
+        obj->st_mtim = Y_TIME_CONVERT(attr->ia_mtime);


    
     if(valid & ATTR_SIZE) yaffs_ResizeFile(obj,attr->ia_size);
@@ -4630,9 +4633,9 @@
     attr->ia_gid = obj->st_gid;        valid |= ATTR_GID;

    
    
-    Y_TIME_CONVERT(attr->ia_atime) = obj->st_atime;    valid |= ATTR_ATIME;
-    Y_TIME_CONVERT(attr->ia_ctime) = obj->st_ctime;    valid |= ATTR_CTIME;
-    Y_TIME_CONVERT(attr->ia_mtime) = obj->st_mtime;    valid |= ATTR_MTIME;
+    Y_TIME_CONVERT(attr->ia_atime) = obj->st_atim;    valid |= ATTR_ATIME;
+    Y_TIME_CONVERT(attr->ia_ctime) = obj->st_ctim;    valid |= ATTR_CTIME;
+    Y_TIME_CONVERT(attr->ia_mtime) = obj->st_mtim;    valid |= ATTR_MTIME;


     attr->ia_size = yaffs_GetFileSize(obj); valid |= ATTR_SIZE;

    
@@ -5032,10 +5035,3 @@
     yaffs_ObjectTest(dev);    
 }
 #endif
-
-
-
-
-
-
-



*** yaffs_guts.h    25 Jun 2005 03:22:24 -0000    1.20
--- yaffs_guts.h    26 Sep 2005 11:31:19 -0000
@@ -200,9 +200,9 @@
 #else
     __u32 st_uid;   // user ID of owner
     __u32 st_gid;    // group ID of owner 
-    __u32 st_atime; // time of last access
-    __u32 st_mtime; // time of last modification
-    __u32 st_ctime; // time of last change
+    __u32 st_atim; // time of last access
+    __u32 st_mtim; // time of last modification
+    __u32 st_ctim; // time of last change
 #endif


     // File size  applies to files only
@@ -349,9 +349,9 @@
 #else
     __u32 st_uid;       // user ID of owner
     __u32 st_gid;        // group ID of owner 
-    __u32 st_atime;     // time of last access
-    __u32 st_mtime;     // time of last modification
-    __u32 st_ctime;     // time of last change
+    __u32 st_atim;     // time of last access
+    __u32 st_mtim;     // time of last modification
+    __u32 st_ctim;     // time of last change
 #endif


     __u32 st_rdev;         // device stuff for block and char devices
@@ -594,5 +594,3 @@



#endif
-
-


*** yaffs_mtdif.c    19 Sep 2004 08:14:50 -0000    1.10
--- yaffs_mtdif.c    26 Sep 2005 11:31:20 -0000
@@ -13,6 +13,8 @@
  *
  */


+#include <linux/config.h>
+
const char *yaffs_mtdif_c_version = "$Id: yaffs_mtdif.c,v 1.10 2004/09/19 08:14:50 charles Exp $";

#ifdef CONFIG_YAFFS_MTD_ENABLED
@@ -27,7 +29,6 @@

 #ifndef    CONFIG_YAFFS_USE_OLD_MTD
 #include "linux/mtd/nand.h"
-#endif


 struct nand_oobinfo yaffs_oobinfo = {
     useecc: 1,
@@ -41,6 +42,7 @@
 struct nand_oobinfo yaffs_noeccinfo = {
     useecc: 0,
 };
+#endif



int nandmtd_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_Spare *spare)


*** yaffs_ramem.c    26 Nov 2002 01:15:37 -0000    1.6
--- yaffs_ramem.c    26 Sep 2005 11:31:21 -0000
@@ -19,6 +19,8 @@


#ifndef __KERNEL__
#define CONFIG_YAFFS_RAM_ENABLED
+#else
+#include <linux/config.h>
#endif

#ifdef CONFIG_YAFFS_RAM_ENABLED


*** direct/dtest.c    31 Aug 2005 09:21:12 -0000    1.7
--- direct/dtest.c    26 Sep 2005 11:31:22 -0000
@@ -2,9 +2,10 @@
 * Test code for the "direct" interface. 
 */


-
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>

#include "yaffsfs.h"

@@ -292,6 +293,8 @@
    
}

+extern int yaffs_DumpDevStruct(const char *path);
+
int long_test(int argc, char *argv[])
{

@@ -618,7 +621,7 @@
     // This test reporoduces a bug whereby YAFFS caching is buypassed
     // resulting in erroneous reads after writes.
     int a;
-    int i;
+//    int i;
     char buffer1[1000];
     char buffer2[1000];

    


*** direct/yaffsfs.c    31 Aug 2005 09:21:12 -0000    1.8
--- direct/yaffsfs.c    26 Sep 2005 11:31:22 -0000
@@ -410,19 +410,19 @@

            
             // Check file permissions
             if( (oflag & (O_RDWR | O_WRONLY)) == 0 &&     // ie O_RDONLY
-               !(obj->yst_mode & S_IREAD))
+               !(obj->st_mode & S_IREAD))
             {
                 openDenied = 1;
             }


             if( (oflag & O_RDWR) && 
-               !(obj->yst_mode & S_IREAD))
+               !(obj->st_mode & S_IREAD))
             {
                 openDenied = 1;
             }


             if( (oflag & (O_RDWR | O_WRONLY)) && 
-               !(obj->yst_mode & S_IWRITE))
+               !(obj->st_mode & S_IWRITE))
             {
                 openDenied = 1;
             }
@@ -807,7 +807,7 @@
     {
         buf->yst_dev = (int)obj->myDev->genericDevice;
         buf->yst_ino = obj->objectId;
-        buf->yst_mode = obj->yst_mode & ~S_IFMT; // clear out file type bits
+        buf->yst_mode = obj->st_mode & ~S_IFMT; // clear out file type bits

    
         if(obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY) 
         {
@@ -825,13 +825,13 @@
         buf->yst_nlink = yaffs_GetObjectLinkCount(obj);
         buf->yst_uid = 0;    
         buf->yst_gid = 0;;     
-        buf->yst_rdev = obj->yst_rdev;
+        buf->yst_rdev = obj->st_rdev;
         buf->yst_size = yaffs_GetObjectFileLength(obj);
         buf->yst_blksize = YAFFS_BYTES_PER_CHUNK;
         buf->yst_blocks = (buf->yst_size + YAFFS_BYTES_PER_CHUNK -1)/YAFFS_BYTES_PER_CHUNK;
-        buf->yst_atime = obj->yst_atime; 
-        buf->yst_ctime = obj->yst_ctime; 
-        buf->yst_mtime = obj->yst_mtime; 
+        buf->yst_atime = obj->st_atim;
+        buf->yst_ctime = obj->st_ctim;
+        buf->yst_mtime = obj->st_mtim;
         retVal = 0;
     }
     return retVal;
@@ -912,7 +912,7 @@

    
     if(obj)
     {
-        obj->yst_mode = mode;
+        obj->st_mode = mode;
         obj->dirty = 1;
         result = yaffs_FlushFile(obj,0);
     }



*** utils/Makefile    11 Mar 2003 05:16:53 -0000    1.5
--- utils/Makefile    26 Sep 2005 11:31:23 -0000
@@ -14,7 +14,8 @@


## Change or override KERNELDIR to your kernel

-KERNELDIR = /usr/src/kernel-headers-2.4.18
+#KERNELDIR = /usr/src/kernel-headers-2.4.18
+KERNELDIR = /usr/src/linux

CFLAGS = -I$(KERNELDIR)/include -I.. -O2 -Wall -DCONFIG_YAFFS_UTIL
CFLAGS+= -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations
@@ -27,7 +28,7 @@

MKYAFFSOBJS = mkyaffs.o

-MKYAFFSIMAGEOBJS = mkyaffsimage.o nand_ecc.o
+MKYAFFSIMAGEOBJS = mkyaffsimage.o yaffs_ecc.o


 all: mkyaffs mkyaffsimage
@@ -44,8 +45,8 @@
 mkyaffs: $(MKYAFFSOBJS)
     $(CC) -o $@ $(MKYAFFSOBJS)


-nand_ecc.c:
-    ln -s ../nand_ecc.c nand_ecc.c
+yaffs_ecc.c:
+    ln -s ../yaffs_ecc.c yaffs_ecc.c



clean:


*** utils/mkyaffs.c    12 Mar 2003 19:54:07 -0000    1.8
--- utils/mkyaffs.c    26 Sep 2005 11:31:23 -0000
@@ -25,6 +25,7 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <time.h>
 #include <unistd.h>
 #include <sys/stat.h>



*** utils/mkyaffsimage.c    16 Jul 2003 03:00:48 -0000    1.7
--- utils/mkyaffsimage.c    26 Sep 2005 11:31:24 -0000
@@ -32,15 +32,17 @@
 #include <unistd.h>


#include "yaffs_guts.h"
-
+#include "yaffs_ecc.h"

#define MAX_OBJECTS 10000

const char * mkyaffsimage_c_version = "$Id: mkyaffsimage.c,v 1.7 2003/07/16 03:00:48 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);
+//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);
+#define nand_calculate_ecc    yaffs_ECCCalculate
+#define nand_correct_data    yaffs_ECCCorrect



 typedef struct
@@ -293,9 +295,9 @@
     // Regular POSIX.
     oh->st_uid = SWAP32(oh->st_uid);
     oh->st_gid = SWAP32(oh->st_gid);
-    oh->st_atime = SWAP32(oh->st_atime);
-    oh->st_mtime = SWAP32(oh->st_mtime);
-    oh->st_ctime = SWAP32(oh->st_ctime);
+    oh->st_atim = SWAP32(oh->st_atim);
+    oh->st_mtim = SWAP32(oh->st_mtim);
+    oh->st_ctim = SWAP32(oh->st_ctim);
 #endif


     oh->fileSize = SWAP32(oh->fileSize); // Aiee. An int... signed, at that!
@@ -354,9 +356,9 @@
         oh->st_uid = 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;
+        oh->st_atim = s->st_atime;
+        oh->st_mtim = s->st_mtime;
+        oh->st_ctim = s->st_ctime;
         oh->st_rdev  = s->st_rdev;
     }

    
@@ -536,7 +538,7 @@
    
     printf("mkyaffsimage: image building tool for YAFFS built "__DATE__"\n");

    
-    if(argc <= 3)
+    if(argc < 3)
     {
         printf("usage: mkyaffsimage dir image_file [convert]\n");
         printf("           dir        the directory tree to be converted\n");
@@ -589,9 +591,9 @@
                "%d objects in %d directories\n"
                "%d NAND pages\n",nObjects, nDirectories, nPages);
     }
-    
+
     close(outFile);
-    
+
     exit(0);
 }