[RFC 5/7] cramfs: allow writing to existing files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Existing files in cramfs basically become ramfs files,
and we use the ramfs_file_operations for them.

Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
 fs/cramfs/inode.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 8c3e8bb..0d3ac80 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -15,6 +15,7 @@
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/init.h>
+#include <linux/ramfs.h>
 #include <linux/string.h>
 #include <linux/blkdev.h>
 #include <linux/cramfs_fs.h>
@@ -50,7 +51,7 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
            contents.  1 yields the right result in GNU find, even
 	   without -noleaf option. */
 	if (S_ISREG(mode)) {
-		inode->i_fop = &generic_ro_fops;
+		inode->i_fop = &ramfs_file_operations;
 		inode->i_data.a_ops = &cramfs_aops;
 	} else if (S_ISDIR(mode)) {
 		inode->i_op = &cramfs_dir_inode_operations;
@@ -531,6 +532,11 @@ static int cramfs_readpage(struct file *file, struct page * page)
 	u32 maxblock, bytes_filled;
 	void *pgdata;
 
+	/* FIXME: not enough we also need to handle sparse files
+	 * that originally came from the disk */
+	if (!inode->i_private)
+		return simple_readpage(file, page);
+
 	maxblock = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 	bytes_filled = 0;
 	if (page->index < maxblock) {
@@ -568,7 +574,10 @@ static int cramfs_readpage(struct file *file, struct page * page)
 }
 
 static const struct address_space_operations cramfs_aops = {
-	.readpage = cramfs_readpage
+	.readpage	= cramfs_readpage,
+	.write_begin	= simple_write_begin,
+	.write_end	= simple_write_end,
+	.set_page_dirty = __set_page_dirty_no_writeback,
 };
 
 /*
-- 
1.5.4.3

-- 

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux