Check read only flags in both the mount flags and mtd flags.
If the mount is read only then don't do some clean ups or start the
background gc thread.
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
int retval = 0;
struct yaffs_LinuxContext *context = yaffs_DeviceToLC(dev);
int retval = 0;
struct yaffs_LinuxContext *context = yaffs_DeviceToLC(dev);
+ if(dev->readOnly)
+ return -1;
+
context->bgRunning = 1;
context->bgThread = kthread_run(yaffs_BackgroundThread,
context->bgRunning = 1;
context->bgThread = kthread_run(yaffs_BackgroundThread,
struct yaffs_LinuxContext *context = NULL;
yaffs_DeviceParam *param;
struct yaffs_LinuxContext *context = NULL;
yaffs_DeviceParam *param;
yaffs_options options;
unsigned mount_id;
yaffs_options options;
unsigned mount_id;
sb->s_op = &yaffs_super_ops;
sb->s_flags |= MS_NOATIME;
sb->s_op = &yaffs_super_ops;
sb->s_flags |= MS_NOATIME;
+ readOnly =((sb->s_flags & MS_RDONLY) != 0);
+
+
#ifdef YAFFS_COMPILE_EXPORTFS
sb->s_export_op = &yaffs_export_ops;
#endif
#ifdef YAFFS_COMPILE_EXPORTFS
sb->s_export_op = &yaffs_export_ops;
#endif
else if (!yaffs_devname(sb, devname_buf))
printk(KERN_INFO "yaffs: devname is NULL\n");
else
else if (!yaffs_devname(sb, devname_buf))
printk(KERN_INFO "yaffs: devname is NULL\n");
else
- printk(KERN_INFO "yaffs: dev is %d name is \"%s\"\n",
+ printk(KERN_INFO "yaffs: dev is %d name is \"%s\" %s\n",
- yaffs_devname(sb, devname_buf));
+ yaffs_devname(sb, devname_buf),
+ readOnly ? "ro" : "rw");
if (!data_str)
data_str = "";
if (!data_str)
data_str = "";
* Set the yaffs_Device up for mtd
*/
* Set the yaffs_Device up for mtd
*/
+ if (!readOnly && !(mtd->flags & MTD_WRITEABLE)){
+ readOnly = 1;
+ printk(KERN_INFO "yaffs: mtd is read only, setting superblock read only");
+ sb->s_flags |= MS_RDONLY;
+ }
+
dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL);
context = kmalloc(sizeof(struct yaffs_LinuxContext),GFP_KERNEL);
dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL);
context = kmalloc(sizeof(struct yaffs_LinuxContext),GFP_KERNEL);
context->dev = dev;
context->superBlock = sb;
context->dev = dev;
context->superBlock = sb;
+ dev->readOnly = readOnly;
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
sb->s_fs_info = dev;
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
sb->s_fs_info = dev;
struct ylist_head *n;
yaffs_Object *l;
struct ylist_head *n;
yaffs_Object *l;
+ if (dev->readOnly)
+ return;
+
/* Soft delete all the unlinked files */
ylist_for_each_safe(i, n,
&dev->unlinkedDir->variant.directoryVariant.children) {
/* Soft delete all the unlinked files */
ylist_for_each_safe(i, n,
&dev->unlinkedDir->variant.directoryVariant.children) {
int depthLimit;
int hanging;
int depthLimit;
int hanging;
+ if (dev->readOnly)
+ return;
/* Iterate through the objects in each hash entry,
* looking at each object.
/* Iterate through the objects in each hash entry,
* looking at each object.