#include <linux/pagemap.h>
#include <linux/mtd/mtd.h>
#include <linux/interrupt.h>
#include <linux/pagemap.h>
#include <linux/mtd/mtd.h>
#include <linux/interrupt.h>
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 28))
static uint32_t YCALCBLOCKS(uint64_t partition_size, uint32_t block_size)
{
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 28))
static uint32_t YCALCBLOCKS(uint64_t partition_size, uint32_t block_size)
{
unsigned int yaffs_trace_mask = YAFFS_TRACE_BAD_BLOCKS | YAFFS_TRACE_ALWAYS;
unsigned int yaffs_wr_attempts = YAFFS_WR_ATTEMPTS;
unsigned int yaffs_auto_checkpoint = 1;
unsigned int yaffs_gc_control = 1;
unsigned int yaffs_bg_enable = 1;
unsigned int yaffs_trace_mask = YAFFS_TRACE_BAD_BLOCKS | YAFFS_TRACE_ALWAYS;
unsigned int yaffs_wr_attempts = YAFFS_WR_ATTEMPTS;
unsigned int yaffs_auto_checkpoint = 1;
unsigned int yaffs_gc_control = 1;
unsigned int yaffs_bg_enable = 1;
/* Module Parameters */
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
module_param(yaffs_trace_mask, uint, 0644);
/* Module Parameters */
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
module_param(yaffs_trace_mask, uint, 0644);
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
+static int yaffs_sync_object(struct file *file, loff_t start, loff_t end, int datasync);
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
static int yaffs_sync_object(struct file *file, int datasync);
#else
static int yaffs_sync_object(struct file *file, struct dentry *dentry,
static int yaffs_sync_object(struct file *file, int datasync);
#else
static int yaffs_sync_object(struct file *file, struct dentry *dentry,
static int yaffs_setxattr(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags);
static ssize_t yaffs_getxattr(struct dentry *dentry, const char *name,
void *buff, size_t size);
static int yaffs_removexattr(struct dentry *dentry, const char *name);
static ssize_t yaffs_listxattr(struct dentry *dentry, char *buff, size_t size);
static int yaffs_setxattr(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags);
static ssize_t yaffs_getxattr(struct dentry *dentry, const char *name,
void *buff, size_t size);
static int yaffs_removexattr(struct dentry *dentry, const char *name);
static ssize_t yaffs_listxattr(struct dentry *dentry, char *buff, size_t size);
#if (YAFFS_USE_WRITE_BEGIN_END != 0)
static int yaffs_write_begin(struct file *filp, struct address_space *mapping,
#if (YAFFS_USE_WRITE_BEGIN_END != 0)
static int yaffs_write_begin(struct file *filp, struct address_space *mapping,
static const struct inode_operations yaffs_file_inode_operations = {
.setattr = yaffs_setattr,
static const struct inode_operations yaffs_file_inode_operations = {
.setattr = yaffs_setattr,
.setxattr = yaffs_setxattr,
.getxattr = yaffs_getxattr,
.listxattr = yaffs_listxattr,
.removexattr = yaffs_removexattr,
.setxattr = yaffs_setxattr,
.getxattr = yaffs_getxattr,
.listxattr = yaffs_listxattr,
.removexattr = yaffs_removexattr,
.put_link = yaffs_put_link,
#endif
.setattr = yaffs_setattr,
.put_link = yaffs_put_link,
#endif
.setattr = yaffs_setattr,
.setxattr = yaffs_setxattr,
.getxattr = yaffs_getxattr,
.listxattr = yaffs_listxattr,
.removexattr = yaffs_removexattr,
.setxattr = yaffs_setxattr,
.getxattr = yaffs_getxattr,
.listxattr = yaffs_listxattr,
.removexattr = yaffs_removexattr,
.setxattr = yaffs_setxattr,
.getxattr = yaffs_getxattr,
.listxattr = yaffs_listxattr,
.removexattr = yaffs_removexattr,
.setxattr = yaffs_setxattr,
.getxattr = yaffs_getxattr,
.listxattr = yaffs_listxattr,
.removexattr = yaffs_removexattr,
- "yaffs_readpage_nolock at %08x, size %08x",
- (unsigned)(pg->index << PAGE_CACHE_SHIFT),
- (unsigned)PAGE_CACHE_SIZE);
+ "yaffs_readpage_nolock at %lld, size %08x",
+ (long long)pos,
+ (unsigned)PAGE_CACHE_SIZE);
- ret = yaffs_file_rd(obj, pg_buf,
- pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE);
+ ret = yaffs_file_rd(obj, pg_buf, pos, PAGE_CACHE_SIZE);
if (page->index > end_index || !n_bytes) {
yaffs_trace(YAFFS_TRACE_OS,
if (page->index > end_index || !n_bytes) {
yaffs_trace(YAFFS_TRACE_OS,
- "yaffs_writepage at %08x, inode size = %08x!!",
- (unsigned)(page->index << PAGE_CACHE_SHIFT),
- (unsigned)inode->i_size);
+ "yaffs_writepage at %lld, inode size = %lld!!",
+ ((loff_t)page->index) << PAGE_CACHE_SHIFT,
+ inode->i_size);
- "yaffs_writepage at %08x, size %08x",
- (unsigned)(page->index << PAGE_CACHE_SHIFT), n_bytes);
+ "yaffs_writepage at %lld, size %08x",
+ ((loff_t)page->index) << PAGE_CACHE_SHIFT, n_bytes);
- "writepag0: obj = %05x, ino = %05x",
- (int)obj->variant.file_variant.file_size, (int)inode->i_size);
+ "writepag0: obj = %lld, ino = %lld",
+ obj->variant.file_variant.file_size, inode->i_size);
- "writepag1: obj = %05x, ino = %05x",
- (int)obj->variant.file_variant.file_size, (int)inode->i_size);
+ "writepag1: obj = %lld, ino = %lld",
+ obj->variant.file_variant.file_size, inode->i_size);
addr = kva + offset_into_page;
yaffs_trace(YAFFS_TRACE_OS,
addr = kva + offset_into_page;
yaffs_trace(YAFFS_TRACE_OS,
- "yaffs_write_end addr %p pos %x n_bytes %d",
- addr, (unsigned)pos, copied);
+ "yaffs_write_end addr %p pos %lld n_bytes %d",
+ addr, pos, copied);
ret = yaffs_file_write(filp, addr, copied, &pos);
ret = yaffs_file_write(filp, addr, copied, &pos);
n_written = yaffs_file_write(f, addr, n_bytes, &pos);
n_written = yaffs_file_write(f, addr, n_bytes, &pos);
inode->i_mode, inode->i_uid, inode->i_gid,
inode->i_mode, inode->i_uid, inode->i_gid,
switch (obj->yst_mode & S_IFMT) {
default: /* fifo, device or socket */
switch (obj->yst_mode & S_IFMT) {
default: /* fifo, device or socket */
- "yaffs_file_write about to write writing %u(%x) bytes to object %d at %d(%x)",
- (unsigned)n, (unsigned)n, obj->obj_id, ipos, ipos);
+ "yaffs_file_write about to write writing %u(%x) bytes to object %d at %lld",
+ (unsigned)n, (unsigned)n, obj->obj_id, ipos);
n_written = yaffs_wr_file(obj, buf, ipos, n, 0);
n_written = yaffs_wr_file(obj, buf, ipos, n, 0);
inode->i_blocks = (ipos + 511) >> 9;
yaffs_trace(YAFFS_TRACE_OS,
inode->i_blocks = (ipos + 511) >> 9;
yaffs_trace(YAFFS_TRACE_OS,
ret_val = yaffs_unlinker(obj, dentry->d_name.name);
if (ret_val == YAFFS_OK) {
ret_val = yaffs_unlinker(obj, dentry->d_name.name);
if (ret_val == YAFFS_OK) {
d_instantiate(dentry, old_dentry->d_inode);
atomic_inc(&old_dentry->d_inode->i_count);
yaffs_trace(YAFFS_TRACE_OS,
d_instantiate(dentry, old_dentry->d_inode);
atomic_inc(&old_dentry->d_inode->i_count);
yaffs_trace(YAFFS_TRACE_OS,
dev = yaffs_inode_to_obj(dir)->my_dev;
yaffs_gross_lock(dev);
obj = yaffs_create_symlink(yaffs_inode_to_obj(dir), dentry->d_name.name,
dev = yaffs_inode_to_obj(dir)->my_dev;
yaffs_gross_lock(dev);
obj = yaffs_create_symlink(yaffs_inode_to_obj(dir), dentry->d_name.name,
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
+static int yaffs_sync_object(struct file *file, loff_t start, loff_t end, int datasync)
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
static int yaffs_sync_object(struct file *file, int datasync)
#else
static int yaffs_sync_object(struct file *file, struct dentry *dentry,
static int yaffs_sync_object(struct file *file, int datasync)
#else
static int yaffs_sync_object(struct file *file, struct dentry *dentry,
yaffs_trace(YAFFS_TRACE_OS,
"yaffs_setattr of object %d",
yaffs_inode_to_obj(inode)->obj_id);
yaffs_trace(YAFFS_TRACE_OS,
"yaffs_setattr of object %d",
yaffs_inode_to_obj(inode)->obj_id);
static int yaffs_setxattr(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
static int yaffs_setxattr(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
static int yaffs_statfs(struct dentry *dentry, struct kstatfs *buf)
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
static int yaffs_statfs(struct dentry *dentry, struct kstatfs *buf)
yaffs_trace(YAFFS_TRACE_OS | YAFFS_TRACE_BACKGROUND,
"Shutting down yaffs background thread");
yaffs_trace(YAFFS_TRACE_OS | YAFFS_TRACE_BACKGROUND,
"Shutting down yaffs background thread");
static void yaffs_touch_super(struct yaffs_dev *dev)
{
struct super_block *sb = yaffs_dev_to_lc(dev)->super;
static void yaffs_touch_super(struct yaffs_dev *dev)
{
struct super_block *sb = yaffs_dev_to_lc(dev)->super;
param->n_reserved_blocks = 5;
param->n_caches = (options.no_cache) ? 0 : 10;
param->inband_tags = options.inband_tags;
param->n_reserved_blocks = 5;
param->n_caches = (options.no_cache) ? 0 : 10;
param->inband_tags = options.inband_tags;
- param->write_chunk_tags_fn = nandmtd2_write_chunk_tags;
- param->read_chunk_tags_fn = nandmtd2_read_chunk_tags;
- param->bad_block_fn = nandmtd2_mark_block_bad;
- param->query_block_fn = nandmtd2_query_block;
- yaffs_dev_to_lc(dev)->spare_buffer =
- kmalloc(mtd->oobsize, GFP_NOFS);
param->is_yaffs2 = 1;
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
param->total_bytes_per_chunk = mtd->writesize;
param->is_yaffs2 = 1;
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
param->total_bytes_per_chunk = mtd->writesize;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
- /* use the MTD interface in yaffs_mtdif1.c */
- param->write_chunk_tags_fn = nandmtd1_write_chunk_tags;
- param->read_chunk_tags_fn = nandmtd1_read_chunk_tags;
- param->bad_block_fn = nandmtd1_mark_block_bad;
- param->query_block_fn = nandmtd1_query_block;
-#else
- param->write_chunk_fn = nandmtd_write_chunk;
- param->read_chunk_fn = nandmtd_read_chunk;
-#endif
+ n_blocks = YCALCBLOCKS(mtd->size,
+ YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
+
+ param->chunks_per_block = YAFFS_CHUNKS_PER_BLOCK;
+ param->total_bytes_per_chunk = YAFFS_BYTES_PER_CHUNK;
param->skip_checkpt_rd = options.skip_checkpoint_read;
param->skip_checkpt_wr = options.skip_checkpoint_write;
param->skip_checkpt_rd = options.skip_checkpoint_read;
param->skip_checkpt_wr = options.skip_checkpoint_write;
return yaffs_internal_read_super(1, sb, data, silent) ? 0 : -EINVAL;
}
return yaffs_internal_read_super(1, sb, data, silent) ? 0 : -EINVAL;
}
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
+static struct dentry *yaffs_mount(struct file_system_type *fs_type, int flags,
+ const char *dev_name, void *data)
+{
+ return mount_bdev(fs_type, flags, dev_name, data, yaffs_internal_read_super_mtd);
+}
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
static int yaffs_read_super(struct file_system_type *fs,
int flags, const char *dev_name,
void *data, struct vfsmount *mnt)
static int yaffs_read_super(struct file_system_type *fs,
int flags, const char *dev_name,
void *data, struct vfsmount *mnt)
- .get_sb = yaffs_read_super,
- .kill_sb = kill_block_super,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
+ .mount = yaffs_mount,
+#else
+ .get_sb = yaffs_read_super,
+#endif
+ .kill_sb = kill_block_super,
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
static int yaffs2_internal_read_super_mtd(struct super_block *sb, void *data,
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
static int yaffs2_internal_read_super_mtd(struct super_block *sb, void *data,
return yaffs_internal_read_super(2, sb, data, silent) ? 0 : -EINVAL;
}
return yaffs_internal_read_super(2, sb, data, silent) ? 0 : -EINVAL;
}
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
+static struct dentry *yaffs2_mount(struct file_system_type *fs_type, int flags,
+ const char *dev_name, void *data)
+{
+ return mount_bdev(fs_type, flags, dev_name, data, yaffs2_internal_read_super_mtd);
+}
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
static int yaffs2_read_super(struct file_system_type *fs,
int flags, const char *dev_name, void *data,
struct vfsmount *mnt)
static int yaffs2_read_super(struct file_system_type *fs,
int flags, const char *dev_name, void *data,
struct vfsmount *mnt)
- .get_sb = yaffs2_read_super,
- .kill_sb = kill_block_super,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
+ .mount = yaffs2_mount,
+#else
+ .get_sb = yaffs2_read_super,
+#endif
+ .kill_sb = kill_block_super,
buf += sprintf(buf, "data_bytes_per_chunk. %d\n",
dev->data_bytes_per_chunk);
buf += sprintf(buf, "chunk_grp_bits....... %d\n", dev->chunk_grp_bits);
buf += sprintf(buf, "data_bytes_per_chunk. %d\n",
dev->data_bytes_per_chunk);
buf += sprintf(buf, "chunk_grp_bits....... %d\n", dev->chunk_grp_bits);
dev->oldest_dirty_gc_count);
buf += sprintf(buf, "n_gc_blocks.......... %u\n", dev->n_gc_blocks);
buf += sprintf(buf, "bg_gcs............... %u\n", dev->bg_gcs);
dev->oldest_dirty_gc_count);
buf += sprintf(buf, "n_gc_blocks.......... %u\n", dev->n_gc_blocks);
buf += sprintf(buf, "bg_gcs............... %u\n", dev->bg_gcs);
- buf += sprintf(buf, "n_retired_writes..... %u\n",
- dev->n_retired_writes);
+ buf += sprintf(buf, "n_retried_writes..... %u\n",
+ dev->n_retried_writes);
buf += sprintf(buf, "n_retired_blocks..... %u\n",
dev->n_retired_blocks);
buf += sprintf(buf, "n_ecc_fixed.......... %u\n", dev->n_ecc_fixed);
buf += sprintf(buf, "n_retired_blocks..... %u\n",
dev->n_retired_blocks);
buf += sprintf(buf, "n_ecc_fixed.......... %u\n", dev->n_ecc_fixed);
yaffs_trace(YAFFS_TRACE_ALWAYS,
"yaffs built " __DATE__ " " __TIME__ " Installing.");
yaffs_trace(YAFFS_TRACE_ALWAYS,
"yaffs built " __DATE__ " " __TIME__ " Installing.");