Added support for 64 bit time to yaffs direct.
authorTimothy Manning <codedraftsman@gmail.com>
Mon, 31 May 2021 22:49:45 +0000 (10:49 +1200)
committerTimothy Manning <codedraftsman@gmail.com>
Fri, 4 Jun 2021 00:59:40 +0000 (12:59 +1200)
These changes still need to be applied to the kernel and rtems.

direct/test-framework/basic-tests/dtest.c
direct/yaffsfs.h
direct/ydirectenv.h
yaffs_guts.h
yaffs_vfs_multi.c
yaffs_vfs_single.c

index c788dd2d936a9d52237a5a2be848589690bea13d..dbd194fba236872b47ce1b5571f87521f71d37e6 100644 (file)
@@ -2677,8 +2677,8 @@ void basic_utime_test(const char *mountpt)
        h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
 
        yaffs_fstat(h,&st);
-       printf(" times before %lu %lu %lu\n",
-                       st.yst_atime, st.yst_ctime, st.yst_mtime);
+       printf(" times before %llu %llu %llu\n",
+                       ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
 
        //here are the last access and modification times.
        utb.actime = 1000;
@@ -2690,8 +2690,8 @@ void basic_utime_test(const char *mountpt)
 
        //read the times from the file header
        yaffs_fstat(h,&st);
-       printf(" times %lu %lu %lu\n",
-                       st.yst_atime, st.yst_ctime, st.yst_mtime);
+       printf(" times %llu %llu %llu\n",
+                       ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
 
 
        utb.actime = 5000;
@@ -2699,18 +2699,85 @@ void basic_utime_test(const char *mountpt)
        result = yaffs_utime(name, &utb);
        printf("utime to a 5000 m 8000 result %d\n",result);
        yaffs_fstat(h,&st);
-       printf(" times %lu %lu %lu\n",
-                       st.yst_atime, st.yst_ctime, st.yst_mtime);
+       printf(" times %llu %llu %llu\n",
+                       ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
 
        result = yaffs_utime(name, NULL);
        printf("utime to NULL result %d\n",result);
        yaffs_fstat(h,&st);
-       printf(" times %lu %lu %lu\n",
-                       st.yst_atime, st.yst_ctime, st.yst_mtime);
+       printf(" times %llu %llu %llu\n",
+                       ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
 
 
 }
 
+void size_utime_test(const char *mountpt)
+{
+       char name[100];
+       int h;
+       int result;
+       struct yaffs_utimbuf utb;
+       struct yaffs_stat st;
+
+       //setup
+       yaffs_start_up();
+
+       yaffs_mount(mountpt);
+
+       strcpy(name,mountpt);
+       strcat(name,"/");
+       strcat(name,"xfile");
+
+       yaffs_unlink(name);
+
+       printf("created\n");
+       h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+
+       yaffs_fstat(h,&st);
+       printf(" times before %llu %llu %llu\n",
+                          ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
+
+       //first lets get the yaffs_object.
+
+       //then check that yaffs_stat also works.
+       //yaffs_stat already uses 64 bits for both wince and unix times.
+       //To see if we are using 32 or 64 bit time, save a large number into the time and
+       //see if it overflows.
+
+       printf("the times are %ld bits long\n", 8*sizeof(st.yst_ctime));
+
+       //here are the last access and modification times.
+       utb.actime = 1000;
+       utb.modtime = 2000;
+
+       //futime sets the last modification and access time of the file
+       result = yaffs_futime(h,&utb);
+       printf("setting times using the futime function to a 1000 m 2000 result  %d\n",result);
+
+       //read the times from the file header
+       yaffs_fstat(h,&st);
+       printf(" times %llu %llu %llu\n",
+                   ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
+
+
+       utb.actime = 5000;
+       utb.modtime = 8000;
+       result = yaffs_utime(name, &utb);
+       printf("utime to a 5000 m 8000 result %d\n",result);
+       yaffs_fstat(h,&st);
+       printf(" times %llu %llu %llu\n",
+                   ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
+
+       result = yaffs_utime(name, NULL);
+       printf("utime to NULL result %d\n",result);
+       yaffs_fstat(h,&st);
+       printf(" times %llu %llu %llu\n",
+                   ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
+
+
+}
+
+
 void basic_xattr_test(const char *mountpt)
 {
        char name[100];
@@ -3550,6 +3617,7 @@ int main(int argc, char *argv[])
         //readdir_test("/nand");
 
         basic_utime_test("/nand");
+        size_utime_test("/nand");
         //case_insensitive_test("/nand");
 
         //yy_test("/nand");
index b96011f4f45b01f7536c28303988d7b7bcceb996..4b0f420625d85f1a36253f4695c9343d0b856be9 100644 (file)
@@ -69,16 +69,16 @@ struct yaffs_stat {
        unsigned long   yst_wince_mtime[2];
        unsigned long   yst_wince_ctime[2];
 #else
-       unsigned long   yst_atime;      /* time of last access */
-       unsigned long   yst_mtime;      /* time of last modification */
-       unsigned long   yst_ctime;      /* time of last change */
+       YTIME_T yst_atime;      /* time of last access */
+       YTIME_T yst_mtime;      /* time of last modification */
+       YTIME_T yst_ctime;      /* time of last change */
 #endif
 };
 
 
 struct yaffs_utimbuf {
-       unsigned long actime;
-       unsigned long modtime;
+       YTIME_T actime;
+       YTIME_T modtime;
 };
 
 /* Normal POSIX-style API functions */
index b477343d683f52f8f2d710603321c7feaa4426ec..08fc04d3812a9cb1276479a046d943f32d3820a3 100644 (file)
@@ -29,6 +29,11 @@ void yaffs_bug_fn(const char *file_name, int line_no);
 
 #define BUG() do { yaffs_bug_fn(__FILE__, __LINE__); } while (0)
 
+#ifdef YAFFS_USE_32_BIT_TIME_T
+       #define YTIME_T u32
+#else
+       #define YTIME_T u64
+#endif
 
 #define YCHAR char
 #define YUCHAR unsigned char
index 96fd547c40d47b629d41679cf26bf1a2521b04fa..22381f9c9fc695fd5741e5c9104cdc8448b0a4cf 100644 (file)
@@ -482,15 +482,17 @@ struct yaffs_obj {
        YCHAR short_name[YAFFS_SHORT_NAME_LENGTH + 1];
 
 #ifdef CONFIG_YAFFS_WINCE
+       //these are always 64 bits
        u32 win_ctime[2];
        u32 win_mtime[2];
        u32 win_atime[2];
 #else
-       u32 yst_uid;
-       u32 yst_gid;
-       u32 yst_atime;
-       u32 yst_mtime;
-       u32 yst_ctime;
+       //these can be 32 or 64 bits
+       YTIME_T yst_uid;
+       YTIME_T yst_gid;
+       YTIME_T yst_atime;
+       YTIME_T yst_mtime;
+       YTIME_T yst_ctime;
 #endif
 
        u32 yst_rdev;
index 19c891907e14fd521de7a974950a2d4023e3004d..a08e0716124291602ea99316f51c78bea2a19adc 100644 (file)
@@ -2047,11 +2047,11 @@ static void yaffs_fill_inode_from_obj(struct inode *inode,
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 
                inode->i_rdev = old_decode_dev(obj->yst_rdev);
-               inode->i_atime.tv_sec = (time_t) (obj->yst_atime);
+               inode->i_atime.tv_sec = (YTIME_T) (obj->yst_atime);
                inode->i_atime.tv_nsec = 0;
-               inode->i_mtime.tv_sec = (time_t) obj->yst_mtime;
+               inode->i_mtime.tv_sec = (YTIME_T) obj->yst_mtime;
                inode->i_mtime.tv_nsec = 0;
-               inode->i_ctime.tv_sec = (time_t) obj->yst_ctime;
+               inode->i_ctime.tv_sec = (YTIME_T) obj->yst_ctime;
                inode->i_ctime.tv_nsec = 0;
 #else
                inode->i_rdev = obj->yst_rdev;
index 1abbfd859a4217767a90d6af13d9a9862a091e19..0817ff0c30399db41e0104f112226b9d2210175a 100644 (file)
@@ -1890,11 +1890,11 @@ static void yaffs_fill_inode_from_obj(struct inode *inode,
 
        inode->i_rdev = old_decode_dev(obj->yst_rdev);
 
-       inode->i_atime.tv_sec = (time_t) (obj->yst_atime);
+       inode->i_atime.tv_sec = (YTIME_T) (obj->yst_atime);
        inode->i_atime.tv_nsec = 0;
-       inode->i_mtime.tv_sec = (time_t) obj->yst_mtime;
+       inode->i_mtime.tv_sec = (YTIME_T) obj->yst_mtime;
        inode->i_mtime.tv_nsec = 0;
-       inode->i_ctime.tv_sec = (time_t) obj->yst_ctime;
+       inode->i_ctime.tv_sec = (YTIME_T) obj->yst_ctime;
        inode->i_ctime.tv_nsec = 0;
        inode->i_size = yaffs_get_obj_length(obj);
        inode->i_blocks = (inode->i_size + 511) >> 9;