yaffs_stat(str,&s);
- printf("%s length %d mode %X ",de->d_name,s.st_size,s.st_mode);
- switch(s.st_mode & S_IFMT)
+ printf("%s length %d mode %X ",de->d_name,s.yst_size,s.yst_mode);
+ switch(s.yst_mode & S_IFMT)
{
case S_IFREG: printf("data file"); break;
case S_IFDIR: printf("directory"); break;
yaffs_lstat(str,&s);
- printf("%s length %d mode %X ",de->d_name,s.st_size,s.st_mode);
- switch(s.st_mode & S_IFMT)
+ printf("%s length %d mode %X ",de->d_name,s.yst_size,s.yst_mode);
+ switch(s.yst_mode & S_IFMT)
{
case S_IFREG: printf("data file"); break;
case S_IFDIR: printf("directory"); break;
// Check chmod
yaffs_stat("/boot/yyfile",&ystat);
- temp_mode = ystat.st_mode;
+ temp_mode = ystat.yst_mode;
yaffs_chmod("/boot/yyfile",0x55555);
printf("\nDirectory look-up of /boot\n");
}
+int BeatsTest(void)
+{
+ int h;
+ char b[2000];
+ int freeSpace;
+ int fsize;
+ yaffs_StartUp();
+ yaffs_mount("/ram");
+
+ h = yaffs_open("/ram/f1", O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+
+ freeSpace = yaffs_freespace("/ram");
+ printf("start free space %d\n",freeSpace);
+
+ while(yaffs_write(h,b,600) > 0) {
+ fsize = yaffs_lseek(h,0,SEEK_CUR);
+ freeSpace = yaffs_freespace("/ram");
+ printf(" %d = %d + %d\n",fsize + freeSpace,fsize,freeSpace);
+ }
+ yaffs_close(h);
+
+ freeSpace = yaffs_freespace("/ram");
+
+ return 1;
+
+}
+
int main(int argc, char *argv[])
{
//return long_test(argc,argv);
//return cache_bypass_bug_test();
- return free_space_check();
+ // return free_space_check();
+
+ return BeatsTest();
}
#endif
-const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.7 2004-11-21 23:33:30 charles Exp $";
+const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.8 2005-08-31 09:21:12 charles Exp $";
// configurationList is the list of devices that are supported
static yaffsfs_DeviceConfiguration *yaffsfs_configurationList;
// Check file permissions
if( (oflag & (O_RDWR | O_WRONLY)) == 0 && // ie O_RDONLY
- !(obj->st_mode & S_IREAD))
+ !(obj->yst_mode & S_IREAD))
{
openDenied = 1;
}
if( (oflag & O_RDWR) &&
- !(obj->st_mode & S_IREAD))
+ !(obj->yst_mode & S_IREAD))
{
openDenied = 1;
}
if( (oflag & (O_RDWR | O_WRONLY)) &&
- !(obj->st_mode & S_IWRITE))
+ !(obj->yst_mode & S_IWRITE))
{
openDenied = 1;
}
if(obj && buf)
{
- buf->st_dev = (int)obj->myDev->genericDevice;
- buf->st_ino = obj->objectId;
- buf->st_mode = obj->st_mode & ~S_IFMT; // clear out file type bits
+ buf->yst_dev = (int)obj->myDev->genericDevice;
+ buf->yst_ino = obj->objectId;
+ buf->yst_mode = obj->yst_mode & ~S_IFMT; // clear out file type bits
if(obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY)
{
- buf->st_mode |= S_IFDIR;
+ buf->yst_mode |= S_IFDIR;
}
else if(obj->variantType == YAFFS_OBJECT_TYPE_SYMLINK)
{
- buf->st_mode |= S_IFLNK;
+ buf->yst_mode |= S_IFLNK;
}
else if(obj->variantType == YAFFS_OBJECT_TYPE_FILE)
{
- buf->st_mode |= S_IFREG;
+ buf->yst_mode |= S_IFREG;
}
- buf->st_nlink = yaffs_GetObjectLinkCount(obj);
- buf->st_uid = 0;
- buf->st_gid = 0;;
- buf->st_rdev = obj->st_rdev;
- buf->st_size = yaffs_GetObjectFileLength(obj);
- buf->st_blksize = YAFFS_BYTES_PER_CHUNK;
- buf->st_blocks = (buf->st_size + YAFFS_BYTES_PER_CHUNK -1)/YAFFS_BYTES_PER_CHUNK;
- buf->st_atime = obj->st_atime;
- buf->st_ctime = obj->st_ctime;
- buf->st_mtime = obj->st_mtime;
+ buf->yst_nlink = yaffs_GetObjectLinkCount(obj);
+ buf->yst_uid = 0;
+ buf->yst_gid = 0;;
+ buf->yst_rdev = obj->yst_rdev;
+ buf->yst_size = yaffs_GetObjectFileLength(obj);
+ buf->yst_blksize = YAFFS_BYTES_PER_CHUNK;
+ buf->yst_blocks = (buf->yst_size + YAFFS_BYTES_PER_CHUNK -1)/YAFFS_BYTES_PER_CHUNK;
+ buf->yst_atime = obj->yst_atime;
+ buf->yst_ctime = obj->yst_ctime;
+ buf->yst_mtime = obj->yst_mtime;
retVal = 0;
}
return retVal;
if(obj)
{
- obj->st_mode = mode;
+ obj->yst_mode = mode;
obj->dirty = 1;
result = yaffs_FlushFile(obj,0);
}
struct yaffs_stat{
- int st_dev; /* device */
- int st_ino; /* inode */
- mode_t st_mode; /* protection */
- int st_nlink; /* number of hard links */
- int st_uid; /* user ID of owner */
- int st_gid; /* group ID of owner */
- unsigned st_rdev; /* device type (if inode device) */
- off_t st_size; /* total size, in bytes */
- unsigned long st_blksize; /* blocksize for filesystem I/O */
- unsigned long st_blocks; /* number of blocks allocated */
- unsigned long st_atime; /* time of last access */
- unsigned long st_mtime; /* time of last modification */
- unsigned long st_ctime; /* time of last change */
+ int yst_dev; /* device */
+ int yst_ino; /* inode */
+ mode_t yst_mode; /* protection */
+ int yst_nlink; /* number of hard links */
+ int yst_uid; /* user ID of owner */
+ int yst_gid; /* group ID of owner */
+ unsigned yst_rdev; /* device type (if inode device) */
+ off_t yst_size; /* total size, in bytes */
+ unsigned long yst_blksize; /* blocksize for filesystem I/O */
+ unsigned long yst_blocks; /* number of blocks allocated */
+ unsigned long yst_atime; /* time of last access */
+ unsigned long yst_mtime; /* time of last modification */
+ unsigned long yst_ctime; /* time of last change */
};
int yaffs_open(const char *path, int oflag, int mode) ;