Advertisement
stnmrshx

Patch mmaped non-eCryptfs file

Apr 10th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.20 KB | None | 0 0
  1. diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
  2. index 10ec695..a4be0e9 100644
  3. --- a/fs/ecryptfs/mmap.c
  4. +++ b/fs/ecryptfs/mmap.c
  5. @@ -65,6 +65,32 @@ struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index)
  6.  static int ecryptfs_writepage(struct page *page, struct writeback_control *wbc)
  7.  {
  8.     int rc;
  9. +   struct inode *inode;
  10. +   struct ecryptfs_crypt_stat *crypt_stat;
  11. +
  12. +   inode = page->mapping->host;
  13. +   crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
  14. +   if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
  15. +       size_t size;
  16. +       loff_t file_size = i_size_read(inode);
  17. +       pgoff_t end_page_index = file_size >> PAGE_CACHE_SHIFT;
  18. +
  19. +       if (end_page_index < page->index)
  20. +           size = 0;
  21. +       else if (end_page_index == page->index)
  22. +           size = file_size & ~PAGE_CACHE_MASK;
  23. +       else
  24. +           size = PAGE_CACHE_SIZE;
  25. +
  26. +       rc = ecryptfs_write_lower_page_segment(inode, page, 0, size);
  27. +       if (unlikely(rc)) {
  28. +           ecryptfs_printk(KERN_WARNING, "Error write "
  29. +                   "page (upper index [0x%.16lx])\n", page->index);
  30. +           ClearPageUptodate(page);
  31. +       } else
  32. +           SetPageUptodate(page);
  33. +       goto out;
  34. +   }
  35.  
  36.     /*
  37.      * Refuse to write the page out if we are called from reclaim context
  38. --
  39. 1.7.6.5
  40.  
  41. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement