Merge branch '32-bit-loff_t'
authorCharles Manning <cdhmanning@gmail.com>
Thu, 14 Jun 2012 01:22:40 +0000 (13:22 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Thu, 14 Jun 2012 01:22:40 +0000 (13:22 +1200)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
direct/handle_common.sh
direct/yaffsfs.c
direct/yaffsfs.h
direct/ydirectenv.h
yaffs_guts.c
yaffs_guts.h

index 04dbcf9d2a0506e0758c75ec1da1de149ada1409..0e339f190ebd1c14003f33cea354da507e60f1bf 100755 (executable)
@@ -26,7 +26,9 @@ if [ "$1" = "copy" ] ; then
                -e "s/strncpy/yaffs_strncpy/g" \
                -e "s/strnlen/yaffs_strnlen/g" \
                -e "s/strcmp/yaffs_strcmp/g" \
-               -e "s/strncmp/yaffs_strncmp/g" >$i
+               -e "s/strncmp/yaffs_strncmp/g"\
+               -e "s/loff_t/Y_LOFF_T/g" \
+                >$i
        done
 elif [ "$1" = "clean" ] ; then 
        for i in $YAFFS_COMMON_SOURCES ; do
index 61aee74710a92146a35d3b9d911e1adbfafb1c3c..d208e25df0b4fdf002bae73547caddcbc7892107 100644 (file)
@@ -74,7 +74,7 @@ struct yaffsfs_FileDes {
        u8 shareWrite:1;
        int inodeId:12;         /* Index to corresponding yaffsfs_Inode */
        int handleCount:10;     /* Number of handles for this fd */
-       loff_t position;        /* current position in file */
+       Y_LOFF_T position;      /* current position in file */
 };
 
 struct yaffsfs_Handle {
@@ -1064,17 +1064,17 @@ int yaffs_close(int handle)
 }
 
 static int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte,
-                   int isPread, loff_t offset)
+                   int isPread, Y_LOFF_T offset)
 {
        struct yaffsfs_FileDes *fd = NULL;
        struct yaffs_obj *obj = NULL;
-       loff_t pos = 0;
-       loff_t startPos = 0;
-       loff_t endPos = 0;
+       Y_LOFF_T pos = 0;
+       Y_LOFF_T startPos = 0;
+       Y_LOFF_T endPos = 0;
        int nRead = 0;
        int nToRead = 0;
        int totalRead = 0;
-       loff_t maxRead;
+       Y_LOFF_T maxRead;
        u8 *buf = (u8 *) vbuf;
 
        if (!vbuf) {
@@ -1180,19 +1180,19 @@ int yaffs_read(int handle, void *buf, unsigned int nbyte)
        return yaffsfs_do_read(handle, buf, nbyte, 0, 0);
 }
 
-int yaffs_pread(int handle, void *buf, unsigned int nbyte, loff_t offset)
+int yaffs_pread(int handle, void *buf, unsigned int nbyte, Y_LOFF_T offset)
 {
        return yaffsfs_do_read(handle, buf, nbyte, 1, offset);
 }
 
 static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte,
-                    int isPwrite, loff_t offset)
+                    int isPwrite, Y_LOFF_T offset)
 {
        struct yaffsfs_FileDes *fd = NULL;
        struct yaffs_obj *obj = NULL;
-       loff_t pos = 0;
-       loff_t startPos = 0;
-       loff_t endPos;
+       Y_LOFF_T pos = 0;
+       Y_LOFF_T startPos = 0;
+       Y_LOFF_T endPos;
        int nWritten = 0;
        int totalWritten = 0;
        int write_trhrough = 0;
@@ -1297,12 +1297,12 @@ int yaffs_write(int fd, const void *buf, unsigned int nbyte)
        return yaffsfs_do_write(fd, buf, nbyte, 0, 0);
 }
 
-int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, loff_t offset)
+int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, Y_LOFF_T offset)
 {
        return yaffsfs_do_write(fd, buf, nbyte, 1, offset);
 }
 
-int yaffs_truncate(const YCHAR *path, loff_t new_size)
+int yaffs_truncate(const YCHAR *path, Y_LOFF_T new_size)
 {
        struct yaffs_obj *obj = NULL;
        struct yaffs_obj *dir = NULL;
@@ -1347,7 +1347,7 @@ int yaffs_truncate(const YCHAR *path, loff_t new_size)
        return (result) ? 0 : -1;
 }
 
-int yaffs_ftruncate(int handle, loff_t new_size)
+int yaffs_ftruncate(int handle, Y_LOFF_T new_size)
 {
        struct yaffsfs_FileDes *fd = NULL;
        struct yaffs_obj *obj = NULL;
@@ -1375,12 +1375,12 @@ int yaffs_ftruncate(int handle, loff_t new_size)
 
 }
 
-loff_t yaffs_lseek(int handle, loff_t offset, int whence)
+Y_LOFF_T yaffs_lseek(int handle, Y_LOFF_T offset, int whence)
 {
        struct yaffsfs_FileDes *fd = NULL;
        struct yaffs_obj *obj = NULL;
-       loff_t pos = -1;
-       loff_t fSize = -1;
+       Y_LOFF_T pos = -1;
+       Y_LOFF_T fSize = -1;
 
        yaffsfs_Lock();
        fd = yaffsfs_HandleToFileDes(handle);
@@ -2648,9 +2648,9 @@ int yaffs_unmount(const YCHAR *path)
        return yaffs_unmount2(path, 0);
 }
 
-loff_t yaffs_freespace(const YCHAR *path)
+Y_LOFF_T yaffs_freespace(const YCHAR *path)
 {
-       loff_t retVal = -1;
+       Y_LOFF_T retVal = -1;
        struct yaffs_dev *dev = NULL;
        YCHAR *dummy;
 
@@ -2677,9 +2677,9 @@ loff_t yaffs_freespace(const YCHAR *path)
        return retVal;
 }
 
-loff_t yaffs_totalspace(const YCHAR *path)
+Y_LOFF_T yaffs_totalspace(const YCHAR *path)
 {
-       loff_t retVal = -1;
+       Y_LOFF_T retVal = -1;
        struct yaffs_dev *dev = NULL;
        YCHAR *dummy;
 
@@ -2710,7 +2710,7 @@ loff_t yaffs_totalspace(const YCHAR *path)
 
 int yaffs_inodecount(const YCHAR *path)
 {
-       loff_t retVal = -1;
+       Y_LOFF_T retVal = -1;
        struct yaffs_dev *dev = NULL;
        YCHAR *dummy;
 
index f2c7666625cfbf91b2a7c3934967975a2094f52d..3196f0c6a691b3b17f2d652e075971329ac1d977 100644 (file)
@@ -30,7 +30,8 @@
 #define NAME_MAX       256
 #endif
 
-#define YAFFS_MAX_FILE_SIZE (0x800000000LL - 1)
+#define YAFFS_MAX_FILE_SIZE \
+       ( (sizeof(Y_LOFF_T) < 8) ? YAFFS_MAX_FILE_SIZE_32 : (0x800000000LL - 1) )
 
 
 struct yaffs_dirent {
@@ -54,7 +55,7 @@ struct yaffs_stat {
        int             st_uid;         /* user ID of owner */
        int             st_gid;         /* group ID of owner */
        unsigned        st_rdev;        /* device type (if inode device) */
-       loff_t          st_size;        /* total size, in bytes */
+       Y_LOFF_T                st_size;        /* total size, in bytes */
        unsigned long   st_blksize;     /* blocksize for filesystem I/O */
        unsigned long   st_blocks;      /* number of blocks allocated */
 #ifdef CONFIG_YAFFS_WINCE
@@ -90,13 +91,13 @@ int yaffs_dup(int fd);
 int yaffs_read(int fd, void *buf, unsigned int nbyte) ;
 int yaffs_write(int fd, const void *buf, unsigned int nbyte) ;
 
-int yaffs_pread(int fd, void *buf, unsigned int nbyte, loff_t offset);
-int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, loff_t offset);
+int yaffs_pread(int fd, void *buf, unsigned int nbyte, Y_LOFF_T offset);
+int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, Y_LOFF_T offset);
 
-loff_t yaffs_lseek(int fd, loff_t offset, int whence) ;
+Y_LOFF_T yaffs_lseek(int fd, Y_LOFF_T offset, int whence) ;
 
-int yaffs_truncate(const YCHAR *path, loff_t new_size);
-int yaffs_ftruncate(int fd, loff_t new_size);
+int yaffs_truncate(const YCHAR *path, Y_LOFF_T new_size);
+int yaffs_ftruncate(int fd, Y_LOFF_T new_size);
 
 int yaffs_unlink(const YCHAR *path) ;
 int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath) ;
@@ -173,8 +174,8 @@ int yaffs_readlink(const YCHAR *path, YCHAR *buf, int bufsiz);
 int yaffs_link(const YCHAR *oldpath, const YCHAR *newpath);
 int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev);
 
-loff_t yaffs_freespace(const YCHAR *path);
-loff_t yaffs_totalspace(const YCHAR *path);
+Y_LOFF_T yaffs_freespace(const YCHAR *path);
+Y_LOFF_T yaffs_totalspace(const YCHAR *path);
 
 int yaffs_inodecount(const YCHAR *path);
 
index eff8ff93f194e7f9b23cd79dd5c7f7e86c578abb..b2293a62fbdf4236092590d21e67ed5c451d93a7 100644 (file)
@@ -35,6 +35,10 @@ void yaffs_bug_fn(const char *file_name, int line_no);
 #define YUCHAR unsigned char
 #define _Y(x) x
 
+#ifndef Y_LOFF_T
+#define Y_LOFF_T loff_t
+#endif
+
 #define yaffs_strcat(a, b)     strcat(a, b)
 #define yaffs_strcpy(a, b)     strcpy(a, b)
 #define yaffs_strncpy(a, b, c) strncpy(a, b, c)
index dfa775fce072c96a2caa2658cc301962d0195e1a..1602c4bde572e538482953ee10bff65d1624b5d9 100644 (file)
@@ -675,7 +675,10 @@ void yaffs_set_obj_name_from_oh(struct yaffs_obj *obj,
 
 loff_t yaffs_max_file_size(struct yaffs_dev *dev)
 {
-       return ((loff_t) YAFFS_MAX_CHUNK_ID) * dev->data_bytes_per_chunk;
+       if(sizeof(loff_t) < 8)
+               return YAFFS_MAX_FILE_SIZE_32;
+       else
+               return ((loff_t) YAFFS_MAX_CHUNK_ID) * dev->data_bytes_per_chunk;
 }
 
 /*-------------------- TNODES -------------------
@@ -4983,8 +4986,8 @@ int yaffs_get_n_free_chunks(struct yaffs_dev *dev)
        return n_free;
 }
 
-/*\
- * Marshalling functions to get loff_t file sizes into aand out of
+/*
+ * Marshalling functions to get loff_t file sizes into and out of
  * object headers.
  */
 void yaffs_oh_size_load(struct yaffs_obj_hdr *oh, loff_t fsize)
@@ -4997,7 +5000,7 @@ loff_t yaffs_oh_to_size(struct yaffs_obj_hdr *oh)
 {
        loff_t retval;
 
-       if (~(oh->file_size_high))
+       if (sizeof(loff_t) >= 8 && ~(oh->file_size_high))
                retval = (((loff_t) oh->file_size_high) << 32) |
                        (((loff_t) oh->file_size_low) & 0xFFFFFFFF);
        else
index d3200706675073c56f600e1a3234bba58ed58824..1aefb8518c5116b9644ace7d341cc47b4f214714 100644 (file)
@@ -54,6 +54,8 @@
                                        YAFFS_TNODES_MAX_LEVEL)
 #define YAFFS_MAX_CHUNK_ID             ((1 << YAFFS_TNODES_MAX_BITS) - 1)
 
+#define YAFFS_MAX_FILE_SIZE_32         0x7fffffff
+
 /* Constants for YAFFS1 mode */
 #define YAFFS_BYTES_PER_SPARE          16
 #define YAFFS_BYTES_PER_CHUNK          512