public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: arnd@arndb.de
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hch@lst.de
Subject: [RFC 5/7] cramfs: allow writing to existing files
Date: Sat, 31 May 2008 17:20:18 +0200	[thread overview]
Message-ID: <20080531153511.075653384@arndb.de> (raw)
In-Reply-To: 20080531152013.031903990@arndb.de

[-- Attachment #1: 0005-cramfs-allow-writing-to-existing-files.patch --]
[-- Type: text/plain, Size: 1764 bytes --]

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

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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

-- 


  parent reply	other threads:[~2008-05-31 15:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080531152013.031903990@arndb.de>
2008-05-31 15:20 ` [RFC 1/7] cramfs: allow remount rw arnd
2008-05-31 15:20 ` [RFC 2/7] cramfs: create unique inode numbers arnd
2008-06-01 16:50   ` Jörn Engel
2008-06-01 21:24     ` Arnd Bergmann
2008-06-02  5:42       ` Jörn Engel
2008-05-31 15:20 ` [RFC 3/7] cramfs: allow unlinking of files arnd
2008-06-01 16:54   ` Jörn Engel
2008-06-01 21:28     ` Arnd Bergmann
2008-05-31 15:20 ` [RFC 4/7] cramfs: allow rmdir arnd
2008-05-31 15:20 ` arnd [this message]
2008-05-31 15:20 ` [RFC 6/7] cramfs: read directory entries from dcache arnd
2008-05-31 15:20 ` [RFC 7/7] cramfs: add missing inode operations arnd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080531153511.075653384@arndb.de \
    --to=arnd@arndb.de \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox