5 void assert_exit_yaffs(char *fun_name, int fun_return_value){
6 if (fun_return_value < 0) {
7 printf("yaffs command: %s failed with error code %d \n", fun_name, fun_return_value);
8 int error_code = yaffsfs_GetLastError();
9 printf("error code is: %d, which is %s\n", error_code, yaffs_error_to_str(error_code));
10 printf("exiting program now\n");
18 assert_exit_yaffs("yaffs_mount", yaffs_mount(YAFFS_MOUNT_POINT));
23 int shared_create(int argc, char *argv[]){
24 printf("YTIME_T size is %lu bits\n", sizeof(YTIME_T) *8);
25 #ifdef CONFIG_YAFFS_USE_32_BIT_TIME_T
26 if (sizeof(YTIME_T)*8 != 32) {
27 printf("YTIME_T size is incorrect. it is %lu and should be 32\n", sizeof(YTIME_T));
31 printf("wrong number of arguments\n");
32 printf("requires $ create file_name time\n");
37 char *file_path = argv[1];
38 int handle = yaffs_open(file_path, O_CREAT | O_RDWR, S_IREAD |S_IWRITE);
39 assert_exit_yaffs ( "yaffs_open", handle);
41 assert_exit_yaffs ( "yaffs_close", yaffs_close(handle));
45 uint time = atoi(argv[2]);
47 struct yaffs_utimbuf new_times;
48 new_times.actime = time;
49 int ret = yaffs_utime(file_path, &new_times);
50 assert_exit_yaffs("yaffs_utime", ret);
52 assert_exit_yaffs("yaffs_unmount", yaffs_unmount(YAFFS_MOUNT_POINT));
56 int shared_validate_file(int argc, char *argv[]){
59 printf("wrong number of arguments\n");
60 printf("requires $ create file_name time\n");
65 char *file_path = argv[1];
66 int handle = yaffs_open(file_path, O_RDWR, S_IREAD |S_IWRITE);
67 assert_exit_yaffs ( "yaffs_open", handle);
69 //assert the file is the correct size and has the correct time.
70 uint expected_time = atoi(argv[2]);
71 struct yaffs_stat stat;
72 assert_exit_yaffs ( "yaffs_stat", yaffs_stat(file_path, &stat));
73 assert_exit_yaffs ( "yaffs_close", yaffs_close(handle));
74 if (stat.yst_atime != expected_time) {
75 printf("stat time is different from expected time\n");
78 assert_exit_yaffs("yaffs_unmount", yaffs_unmount(YAFFS_MOUNT_POINT));