X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_vfs_single.c;h=d77c87dabfd85b3dafa9b9eb9fd9fc5975a5f344;hp=ba6f3d6eb8d9f54c6bc2e8788864eef4143c654f;hb=33308768bd24abe4e1f59c5025a3dd824119ae1d;hpb=07353dd87a46afc753441028af8f5e8629b13bdc diff --git a/yaffs_vfs_single.c b/yaffs_vfs_single.c index ba6f3d6..d77c87d 100644 --- a/yaffs_vfs_single.c +++ b/yaffs_vfs_single.c @@ -450,7 +450,7 @@ static int yaffs_sync_object(struct file *file, yaffs_trace(YAFFS_TRACE_OS | YAFFS_TRACE_SYNC, "yaffs_sync_object"); yaffs_gross_lock(dev); - yaffs_flush_file(obj, 1, datasync); + yaffs_flush_file(obj, 1, datasync, 0); yaffs_gross_unlock(dev); return 0; } @@ -890,7 +890,7 @@ static int yaffs_file_flush(struct file *file, fl_owner_t id) yaffs_gross_lock(dev); - yaffs_flush_file(obj, 1, 0); + yaffs_flush_file(obj, 1, 0, 0); yaffs_gross_unlock(dev); @@ -1496,7 +1496,7 @@ static void yaffs_flush_inodes(struct super_block *sb) if (obj) { yaffs_trace(YAFFS_TRACE_OS, "flushing obj %d", obj->obj_id); - yaffs_flush_file(obj, 1, 0); + yaffs_flush_file(obj, 1, 0, 0); } } } @@ -1510,7 +1510,7 @@ static void yaffs_flush_super(struct super_block *sb, int do_checkpoint) yaffs_flush_inodes(sb); yaffs_update_dirty_dirs(dev); - yaffs_flush_whole_cache(dev); + yaffs_flush_whole_cache(dev, 1); if (do_checkpoint) yaffs_checkpoint_save(dev); } @@ -1912,6 +1912,7 @@ static void yaffs_fill_inode_from_obj(struct inode *inode, static void yaffs_put_super(struct super_block *sb) { struct yaffs_dev *dev = yaffs_super_to_dev(sb); + struct mtd_info *mtd = yaffs_dev_to_mtd(dev); yaffs_trace(YAFFS_TRACE_OS, "yaffs_put_super"); @@ -1941,24 +1942,62 @@ static void yaffs_put_super(struct super_block *sb) } kfree(dev); + + if (mtd && mtd->sync) + mtd->sync(mtd); + + if (mtd) + put_mtd_device(mtd); } -static void yaffs_mtd_put_super(struct super_block *sb) +/* the function only is used to change dev->read_only when this file system + * is remounted. + */ +static int yaffs_remount_fs(struct super_block *sb, int *flags, char *data) { - struct mtd_info *mtd = yaffs_dev_to_mtd(yaffs_super_to_dev(sb)); + int read_only = 0; + struct mtd_info *mtd; + struct yaffs_dev *dev = 0; - if (mtd->sync) - mtd->sync(mtd); + /* Get the device */ + mtd = get_mtd_device(NULL, MINOR(sb->s_dev)); + if (!mtd) { + yaffs_trace(YAFFS_TRACE_ALWAYS, + "MTD device #%u doesn't appear to exist", + MINOR(sb->s_dev)); + return 1; + } - put_mtd_device(mtd); + /* Check it's NAND */ + if (mtd->type != MTD_NANDFLASH) { + yaffs_trace(YAFFS_TRACE_ALWAYS, + "MTD device is not NAND it's type %d", + mtd->type); + return 1; + } + + read_only = ((*flags & MS_RDONLY) != 0); + if (!read_only && !(mtd->flags & MTD_WRITEABLE)) { + read_only = 1; + printk(KERN_INFO + "yaffs: mtd is read only, setting superblock read only"); + *flags |= MS_RDONLY; + } + + dev = sb->s_fs_info; + dev->read_only = read_only; + + return 0; } + static const struct super_operations yaffs_super_ops = { .statfs = yaffs_statfs, .put_super = yaffs_put_super, .evict_inode = yaffs_evict_inode, .sync_fs = yaffs_sync_fs, .write_super = yaffs_write_super, + .remount_fs = yaffs_remount_fs, }; static struct super_block *yaffs_internal_read_super(int yaffs_version, @@ -2034,7 +2073,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, /* Get the device */ mtd = get_mtd_device(NULL, MINOR(sb->s_dev)); - if (!mtd) { + if (IS_ERR(mtd)) { yaffs_trace(YAFFS_TRACE_ALWAYS, "MTD device #%u doesn't appear to exist", MINOR(sb->s_dev)); @@ -2128,9 +2167,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, kfree(context); dev = NULL; context = NULL; - } - if (!dev) { /* Deep shit could not allocate device structure */ yaffs_trace(YAFFS_TRACE_ALWAYS, "yaffs_read_super failed trying to allocate yaffs_dev"); @@ -2213,7 +2250,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, yaffs_dev_to_lc(dev)->put_super_fn = yaffs_mtd_put_super; param->sb_dirty_fn = yaffs_touch_super; - param->gc_control = yaffs_gc_control_callback; + param->gc_control_fn = yaffs_gc_control_callback; yaffs_dev_to_lc(dev)->super = sb; @@ -2262,10 +2299,6 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, sb->s_maxbytes = yaffs_max_file_size(dev); - yaffs_trace(YAFFS_TRACE_OS, - "yaffs_readpage_nolock at %lld, size %08x", - (long long)pos, - (unsigned)PAGE_CACHE_SIZE); /* Release lock before yaffs_get_inode() */ yaffs_gross_unlock(dev);