*/
const char *yaffs_fs_c_version =
- "$Id: yaffs_fs.c,v 1.45 2006-04-25 00:41:43 wookey Exp $";
+ "$Id: yaffs_fs.c,v 1.51 2006-07-25 21:03:22 charles Exp $";
extern const char *yaffs_guts_c_version;
#include <linux/config.h>
#define BDEVNAME_SIZE 0
#define yaffs_devname(sb, buf) kdevname(sb->s_dev)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+/* added NCB 26/5/2006 for 2.4.25-vrs2-tcl1 kernel */
+#define __user
+#endif
+
#endif
#include <asm/uaccess.h>
#include "yportenv.h"
#include "yaffs_guts.h"
-unsigned yaffs_traceMask = YAFFS_TRACE_ALWAYS | YAFFS_TRACE_BAD_BLOCKS /* | 0xFFFFFFFF */;
+unsigned yaffs_traceMask = YAFFS_TRACE_ALWAYS |
+ YAFFS_TRACE_BAD_BLOCKS |
+ YAFFS_TRACE_CHECKPOINT
+ /* | 0xFFFFFFFF */;
#include <linux/mtd/mtd.h>
#include "yaffs_mtdif.h"
struct inode *new_dir, struct dentry *new_dentry);
static int yaffs_setattr(struct dentry *dentry, struct iattr *attr);
+static int yaffs_sync_fs(struct super_block *sb);
+static int yaffs_write_super(struct super_block *sb);
+
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf);
#else
.put_super = yaffs_put_super,
.delete_inode = yaffs_delete_inode,
.clear_inode = yaffs_clear_inode,
+ .sync_fs = yaffs_sync_fs,
+ .write_super = yaffs_write_super,
};
static void yaffs_GrossLock(yaffs_Device * dev)
static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj)
{
if (inode && obj) {
+
+
+ /* Check mode against the variant type and attempt to repair if broken. */
+ __u32 mode = obj->yst_mode;
+ switch( obj->variantType ){
+ case YAFFS_OBJECT_TYPE_FILE :
+ if( ! S_ISREG(mode) ){
+ obj->yst_mode &= ~S_IFMT;
+ obj->yst_mode |= S_IFREG;
+ }
+
+ break;
+ case YAFFS_OBJECT_TYPE_SYMLINK :
+ if( ! S_ISLNK(mode) ){
+ obj->yst_mode &= ~S_IFMT;
+ obj->yst_mode |= S_IFLNK;
+ }
+
+ break;
+ case YAFFS_OBJECT_TYPE_DIRECTORY :
+ if( ! S_ISDIR(mode) ){
+ obj->yst_mode &= ~S_IFMT;
+ obj->yst_mode |= S_IFDIR;
+ }
+
+ break;
+ case YAFFS_OBJECT_TYPE_UNKNOWN :
+ case YAFFS_OBJECT_TYPE_HARDLINK :
+ case YAFFS_OBJECT_TYPE_SPECIAL :
+ default:
+ /* TODO? */
+ break;
+ }
+
inode->i_ino = obj->objectId;
inode->i_mode = obj->yst_mode;
inode->i_uid = obj->yst_uid;
int error = -ENOSPC;
uid_t uid = current->fsuid;
gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
+
+ if((dir->i_mode & S_ISGID) && S_ISDIR(mode))
+ mode |= S_ISGID;
if (parent) {
T(YAFFS_TRACE_OS,
return 0;
}
+
+
+static int yaffs_do_sync_fs(struct super_block *sb)
+{
+
+ yaffs_Device *dev = yaffs_SuperToDevice(sb);
+ T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_do_sync_fs\n"));
+
+ if(sb->s_dirt) {
+ yaffs_GrossLock(dev);
+
+ if(dev)
+ yaffs_CheckpointSave(dev);
+
+ yaffs_GrossUnlock(dev);
+
+ sb->s_dirt = 0;
+ }
+ return 0;
+}
+
+
+static int yaffs_write_super(struct super_block *sb)
+{
+
+ T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_write_super\n"));
+ return 0; /* yaffs_do_sync_fs(sb);*/
+
+}
+
+
+static int yaffs_sync_fs(struct super_block *sb)
+{
+
+ T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_sync_fs\n"));
+
+ return 0; /* yaffs_do_sync_fs(sb);*/
+
+}
+
+
static void yaffs_read_inode(struct inode *inode)
{
/* NB This is called as a side effect of other functions, but
{
yaffs_Device *dev = yaffs_SuperToDevice(sb);
+ T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_put_super\n"));
+
yaffs_GrossLock(dev);
yaffs_FlushEntireDeviceCache(dev);
if (dev->putSuperFunc) {
dev->putSuperFunc(sb);
}
+
+ yaffs_CheckpointSave(dev);
yaffs_Deinitialise(dev);
+
yaffs_GrossUnlock(dev);
/* we assume this is protected by lock_kernel() in mount/umount */
}
+static void yaffs_MarkSuperBlockDirty(void *vsb)
+{
+ struct super_block *sb = (struct super_block *)vsb;
+
+ T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_MarkSuperBlockDirty() sb = %p\n",sb));
+// if(sb)
+// sb->s_dirt = 1;
+}
+
static struct super_block *yaffs_internal_read_super(int yaffsVersion,
struct super_block *sb,
void *data, int silent)
T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs2\n"));
yaffsVersion = 2;
}
+
+ /* Added NCB 26/5/2006 for completeness */
+ if (yaffsVersion == 2 &&
+ mtd->oobblock == 512) {
+ T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs1\n"));
+ yaffsVersion = 1;
+ }
+
#endif
if (yaffsVersion == 2) {
dev->nBytesPerChunk = mtd->oobblock;
dev->nChunksPerBlock = mtd->erasesize / mtd->oobblock;
nBlocks = mtd->size / mtd->erasesize;
+
+ dev->nCheckpointReservedBlocks = 10;
dev->startBlock = 0;
dev->endBlock = nBlocks - 1;
} else {
dev->initialiseNAND = nandmtd_InitialiseNAND;
dev->putSuperFunc = yaffs_MTDPutSuper;
+
+ dev->superBlock = (void *)sb;
+ dev->markSuperBlockDirty = yaffs_MarkSuperBlockDirty;
+
#ifndef CONFIG_YAFFS_DOES_ECC
dev->useNANDECC = 1;