From 9545c19fb2de4e3578eb63329f99754dd5041b55 Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Tue, 1 Jun 2021 10:49:45 +1200 Subject: [PATCH] Added support for 64 bit time to yaffs direct. These changes still need to be applied to the kernel and rtems. --- direct/test-framework/basic-tests/dtest.c | 84 ++++++++++++++++++++--- direct/yaffsfs.h | 10 +-- direct/ydirectenv.h | 5 ++ yaffs_guts.h | 12 ++-- yaffs_vfs_multi.c | 6 +- yaffs_vfs_single.c | 6 +- 6 files changed, 99 insertions(+), 24 deletions(-) diff --git a/direct/test-framework/basic-tests/dtest.c b/direct/test-framework/basic-tests/dtest.c index c788dd2..dbd194f 100644 --- a/direct/test-framework/basic-tests/dtest.c +++ b/direct/test-framework/basic-tests/dtest.c @@ -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"); diff --git a/direct/yaffsfs.h b/direct/yaffsfs.h index b96011f..4b0f420 100644 --- a/direct/yaffsfs.h +++ b/direct/yaffsfs.h @@ -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 */ diff --git a/direct/ydirectenv.h b/direct/ydirectenv.h index b477343..08fc04d 100644 --- a/direct/ydirectenv.h +++ b/direct/ydirectenv.h @@ -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 diff --git a/yaffs_guts.h b/yaffs_guts.h index 96fd547..22381f9 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -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; diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c index 19c8919..a08e071 100644 --- a/yaffs_vfs_multi.c +++ b/yaffs_vfs_multi.c @@ -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; diff --git a/yaffs_vfs_single.c b/yaffs_vfs_single.c index 1abbfd8..0817ff0 100644 --- a/yaffs_vfs_single.c +++ b/yaffs_vfs_single.c @@ -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; -- 2.30.2