static int __yaffs_fstat(mount_point_t *point, file_t *file, struct stat *buf) { struct yaffs_stat st; int ret; ret = yaffs_fstat((int)file->ctx, &st); if (ret == 0) { buf->st_dev = st.st_dev; buf->st_ino = st.st_ino; buf->st_mode = st.st_mode; buf->st_nlink = st.st_nlink; buf->st_uid = st.st_uid; buf->st_gid = st.st_gid; buf->st_rdev = st.st_rdev; buf->st_size = st.st_size; buf->st_atime = st.yst_atime; buf->st_spare1 = 0; buf->st_mtime = st.yst_mtime; buf->st_spare2 = 0; buf->st_ctime = st.yst_ctime; buf->st_spare3 = 0; buf->st_blksize = st.st_blksize; buf->st_blocks = st.st_blocks; buf->st_spare4[0] = 0; buf->st_spare4[1] = 0; } return ret;
int test_yaffs_fstat_EBADF(void) { int output = 0; struct yaffs_stat stat; int error_code = 0; output = yaffs_fstat(-1 , &stat); if (output < 0){ error_code = yaffs_get_error(); if (abs(error_code) == EBADF){ return 1; } else { print_message("different error than expected\n", 2); return -1; } } else { print_message("non existant file truncated.(which is a bad thing)\n", 2 ); return -1; } }