add file position info to proc
[powerpc.git] / fs / 9p / vfs_file.c
index 9f17b0c..c7b6772 100644 (file)
@@ -42,6 +42,8 @@
 #include "v9fs_vfs.h"
 #include "fid.h"
 
+static const struct file_operations v9fs_cached_file_operations;
+
 /**
  * v9fs_file_open - open a file (or directory)
  * @inode: inode to be opened
@@ -79,6 +81,13 @@ int v9fs_file_open(struct inode *inode, struct file *file)
        vfid->filp = file;
        kfree(fcall);
 
+       if((vfid->qid.version) && (v9ses->cache)) {
+               dprintk(DEBUG_VFS, "cached");
+               /* enable cached file options */
+               if(file->f_op == &v9fs_file_operations)
+                       file->f_op = &v9fs_cached_file_operations;
+       }
+
        return 0;
 
 Clunk_Fid:
@@ -110,7 +119,7 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
 
        if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
                filemap_write_and_wait(inode->i_mapping);
-               invalidate_inode_pages(&inode->i_data);
+               invalidate_mapping_pages(&inode->i_data, 0, -1);
        }
 
        return res;
@@ -234,10 +243,21 @@ v9fs_file_write(struct file *filp, const char __user * data,
                total += result;
        } while (count);
 
-               invalidate_inode_pages2(inode->i_mapping);
+       invalidate_inode_pages2(inode->i_mapping);
        return total;
 }
 
+static const struct file_operations v9fs_cached_file_operations = {
+       .llseek = generic_file_llseek,
+       .read = do_sync_read,
+       .aio_read = generic_file_aio_read,
+       .write = v9fs_file_write,
+       .open = v9fs_file_open,
+       .release = v9fs_dir_release,
+       .lock = v9fs_file_lock,
+       .mmap = generic_file_mmap,
+};
+
 const struct file_operations v9fs_file_operations = {
        .llseek = generic_file_llseek,
        .read = v9fs_file_read,