lkml.org 
[lkml]   [2008]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[RFC 5/7] cramfs: allow writing to existing files
    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
    --



    \
     
     \ /
      Last update: 2008-05-31 17:43    [W:3.827 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site