* Acknowledgements:
* * Luc van OostenRyck for numerous patches.
* * Nick Bane for numerous patches.
+ * * Andras Toth for mknod rdev issue.
* * Some code bodily lifted from JFFS2.
*/
+const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.17 2002-10-02 02:11:25 charles Exp $";
+extern const char *yaffs_guts_c_version;
+
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
yaffs_Device *dev;
T((KERN_DEBUG"yaffs_readpage at %08x, size %08x\n",
- pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE));
+ (unsigned)(pg->index << PAGE_CACHE_SHIFT), (unsigned)PAGE_CACHE_SIZE));
obj = yaffs_DentryToObject(f->f_dentry);
int nWritten;
unsigned spos = pos;
- unsigned saddr = addr;
+ unsigned saddr = (unsigned)addr;
T((KERN_DEBUG"yaffs_commit_write addr %x pos %x nBytes %d\n",saddr,spos,nBytes));
inode->i_size = ipos;
inode->i_blocks = (ipos + inode->i_blksize - 1)/ inode->i_blksize;
- T((KERN_DEBUG"yaffs_file_write size updated to %d bytes, %d blocks\n",ipos,inode->i_blocks));
+ T((KERN_DEBUG"yaffs_file_write size updated to %d bytes, %d blocks\n",ipos,(int)(inode->i_blocks)));
}
}
/*
* File creation. Allocate an inode, and we're done..
*/
-static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev)
+static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev)
{
struct inode *inode;
}
T(("yaffs_mknod: making oject for %s, mode %x dev %x\n",
- dentry->d_name.name, mode,dev));
+ dentry->d_name.name, mode,rdev));
dev = parent->myDev;
default:
// Special (socket, fifo, device...)
T((KERN_DEBUG"yaffs_mknod: making special\n"));
- obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,dev);
+ obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,rdev);
break;
case S_IFREG: // file
T((KERN_DEBUG"yaffs_mknod: making file\n"));
if(obj)
{
- inode = yaffs_get_inode(dir->i_sb, mode, dev, obj);
+ inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
d_instantiate(dentry, inode);
T((KERN_DEBUG"yaffs_mknod created object %d count = %d\n",obj->objectId,atomic_read(&inode->i_count)));
error = 0;
yaffs_Device *dev;
- T((KERN_DEBUG"yaffs_unlink %d:%s\n",dir->i_ino,dentry->d_name.name));
+ T((KERN_DEBUG"yaffs_unlink %d:%s\n",(int)(dir->i_ino),dentry->d_name.name));
dev = yaffs_InodeToObject(dir)->myDev;
yaffs_GrossLock(dev);
- nlinks =
retVal = yaffs_Unlink(yaffs_InodeToObject(dir),dentry->d_name.name);
yaffs_GrossLock(dev);
+ // Unlink the target if it exists
+ yaffs_Unlink(yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
+
+
retVal = yaffs_RenameObject(yaffs_InodeToObject(old_dir),old_dentry->d_name.name,
yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
yaffs_GrossUnlock(dev);
}
+
+static yaffs_Device *yaffs_dev;
+static yaffs_Device *yaffsram_dev;
+
+
+
static void yaffs_put_super(struct super_block *sb)
{
yaffs_Device *dev = yaffs_SuperToDevice(sb);
}
yaffs_Deinitialise(dev);
yaffs_GrossUnlock(dev);
-
+
+ if(dev == yaffs_dev) yaffs_dev = NULL;
+ if(dev == yaffsram_dev) yaffsram_dev = NULL;
+
kfree(dev);
}
#endif
+
static struct super_block *yaffs_internal_read_super(int useRam, struct super_block * sb, void * data, int silent)
{
int nBlocks;
sb->s_blocksize = PAGE_CACHE_SIZE;
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
#endif
- T(("yaffs_read_super: %s block size %d\n", useRam ? "RAM" : "MTD",sb->s_blocksize));
+ T(("yaffs_read_super: %s block size %d\n", useRam ? "RAM" : "MTD",(int)(sb->s_blocksize)));
#ifdef CONFIG_YAFFS_DISABLE_WRITE_VERIFY
T(("yaffs: Write verification disabled. All guarantees null and void\n");
dev->readChunkFromNAND = nandemul_ReadChunkFromNAND;
dev->eraseBlockInNAND = nandemul_EraseBlockInNAND;
dev->initialiseNAND = nandemul_InitialiseNAND;
+
+ yaffsram_dev = dev;
#endif
return NULL;
}
- printk(KERN_DEBUG" erase %x\n",mtd->erase);
- printk(KERN_DEBUG" read %x\n",mtd->read);
- printk(KERN_DEBUG" write %x\n",mtd->write);
- printk(KERN_DEBUG" readoob %x\n",mtd->read_oob);
- printk(KERN_DEBUG" writeoob %x\n",mtd->write_oob);
- printk(KERN_DEBUG" oobblock %x\n",mtd->oobblock);
- printk(KERN_DEBUG" oobsize %x\n",mtd->oobsize);
+ //printk(KERN_DEBUG" erase %x\n",mtd->erase);
+ //printk(KERN_DEBUG" read %x\n",mtd->read);
+ //printk(KERN_DEBUG" write %x\n",mtd->write);
+ //printk(KERN_DEBUG" readoob %x\n",mtd->read_oob);
+ //printk(KERN_DEBUG" writeoob %x\n",mtd->write_oob);
+ //printk(KERN_DEBUG" oobblock %x\n",mtd->oobblock);
+ //printk(KERN_DEBUG" oobsize %x\n",mtd->oobsize);
if(!mtd->erase ||
dev->readChunkFromNAND = nandmtd_ReadChunkFromNAND;
dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND;
dev->initialiseNAND = nandmtd_InitialiseNAND;
-
+
dev->putSuperFunc = yaffs_MTDPutSuper;
+
+ yaffs_dev = dev;
+
#endif
}
static struct proc_dir_entry *my_proc_entry;
static struct proc_dir_entry *my_proc_ram_write_entry;
+static char * yaffs_dump_dev(char *buf,yaffs_Device *dev,char *name)
+{
+ buf +=sprintf(buf,"\nDevice %s\n",name);
+ buf +=sprintf(buf,"startBlock......... %d\n",dev->startBlock);
+ buf +=sprintf(buf,"endBlock........... %d\n",dev->endBlock);
+ buf +=sprintf(buf,"chunkGroupBits..... %d\n",dev->chunkGroupBits);
+ buf +=sprintf(buf,"chunkGroupSize..... %d\n",dev->chunkGroupSize);
+ buf +=sprintf(buf,"nErasedBlocks...... %d\n",dev->nErasedBlocks);
+ buf +=sprintf(buf,"nTnodesCreated..... %d\n",dev->nTnodesCreated);
+ buf +=sprintf(buf,"nFreeTnodes........ %d\n",dev->nFreeTnodes);
+ buf +=sprintf(buf,"nObjectsCreated.... %d\n",dev->nObjectsCreated);
+ buf +=sprintf(buf,"nFreeObjects....... %d\n",dev->nFreeObjects);
+ buf +=sprintf(buf,"nFreeChunks........ %d\n",dev->nFreeChunks);
+ buf +=sprintf(buf,"nPageWrites........ %d\n",dev->nPageWrites);
+ buf +=sprintf(buf,"nPageReads......... %d\n",dev->nPageReads);
+ buf +=sprintf(buf,"nBlockErasures..... %d\n",dev->nBlockErasures);
+ buf +=sprintf(buf,"nGCCopies.......... %d\n",dev->nGCCopies);
+ buf +=sprintf(buf,"garbageCollections. %d\n",dev->garbageCollections);
+ buf +=sprintf(buf,"nRetriedWrites..... %d\n",dev->nRetriedWrites);
+ buf +=sprintf(buf,"nRetireBlocks...... %d\n",dev->nRetiredBlocks);
+ buf +=sprintf(buf,"eccFixed........... %d\n",dev->eccFixed);
+ buf +=sprintf(buf,"eccUnfixed......... %d\n",dev->eccUnfixed);
+ buf +=sprintf(buf,"tagsEccFixed....... %d\n",dev->tagsEccFixed);
+ buf +=sprintf(buf,"tagsEccUnfixed..... %d\n",dev->tagsEccUnfixed);
+ buf +=sprintf(buf,"cacheHits.......... %d\n",dev->cacheHits);
+ buf +=sprintf(buf,"nDeletedFiles...... %d\n",dev->nDeletedFiles);
+ buf +=sprintf(buf,"nUnlinkedFiles..... %d\n",dev->nUnlinkedFiles);
+ buf +=sprintf(buf,"nBackgroudDeletions %d\n",dev->nBackgroundDeletions);
+
+ return buf;
+}
static int yaffs_proc_read(
char *page,
)
{
- static char my_buffer[1000];
+ char my_buffer[3000];
+ char *buf;
+ buf = my_buffer;
if (offset > 0) return 0;
/* Fill the buffer and get its length */
- sprintf( my_buffer,
- "YAFFS built:"__DATE__ " "__TIME__"\n"
-
- );
+ buf +=sprintf(buf,"YAFFS built:"__DATE__ " "__TIME__"\n%s\n%s\n", yaffs_fs_c_version,yaffs_guts_c_version);
+
+ if(yaffs_dev) buf = yaffs_dump_dev(buf,yaffs_dev,"yaffs");
+ if(yaffsram_dev) buf = yaffs_dump_dev(buf,yaffsram_dev,"yaffsram");
+
strcpy(page,my_buffer);
return strlen(my_buffer);
{
int error = 0;
+ yaffs_dev = yaffsram_dev = NULL;
+
printk(KERN_DEBUG "yaffs " __DATE__ " " __TIME__ " Initialisation\n");
#ifdef CONFIG_YAFFS_USE_GENERIC_RW
printk(KERN_DEBUG "yaffs is using generic read/write (caching)\n");
}
#ifdef CONFIG_YAFFS_RAM_ENABLED
-
+#if 0
my_proc_ram_write_entry = create_proc_entry("yaffs_ram",
S_IRUGO | S_IFREG,
&proc_root);
{
my_proc_ram_write_entry->write_proc = yaffs_proc_ram_write;
}
+#endif
+
error = register_filesystem(&yaffs_ram_fs_type);
if(error)
{