Lines Matching +full:data +full:- +full:mapping

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * decryption of the file data as it passes between the lower
8 * Copyright (C) 1997-2003 Erez Zadok
9 * Copyright (C) 2001-2003 Stony Brook University
10 * Copyright (C) 2004-2007 International Business Machines Corp.
16 #include <linux/page-flags.h>
30 * Returns locked and up-to-date page (if ok), with increased
35 struct page *page = read_mapping_page(inode->i_mapping, index, NULL); in ecryptfs_get_locked_page()
45 * Returns zero on success; non-zero otherwise
47 * This is where we encrypt the data and pass the encrypted data to
48 * the lower filesystem. In OpenPGP-compatible mode, we operate on
58 "page (upper index [0x%.16lx])\n", page->index); in ecryptfs_writepage()
71 if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) { in strip_xattr_flag()
74 crypt_stat->flags &= ~ECRYPTFS_METADATA_IN_XATTR; in strip_xattr_flag()
77 crypt_stat->flags |= ECRYPTFS_METADATA_IN_XATTR; in strip_xattr_flag()
83 * Octets 0-7: Unencrypted file size (big-endian)
84 * Octets 8-15: eCryptfs special marker
85 * Octets 16-19: Flags
87 * Octets 17-18: Reserved
90 * Bits 3-8: Reserved
91 * Octets 20-23: Header extent size (big-endian)
92 * Octets 24-25: Number of header extents at front of file
93 * (big-endian)
113 / crypt_stat->extent_size); in ecryptfs_copy_up_encrypted_with_header()
117 loff_t view_extent_num = ((((loff_t)page->index) in ecryptfs_copy_up_encrypted_with_header()
121 (crypt_stat->metadata_size / crypt_stat->extent_size); in ecryptfs_copy_up_encrypted_with_header()
134 page_virt, page->mapping->host); in ecryptfs_copy_up_encrypted_with_header()
148 /* This is an encrypted data extent */ in ecryptfs_copy_up_encrypted_with_header()
150 ((view_extent_num * crypt_stat->extent_size) in ecryptfs_copy_up_encrypted_with_header()
151 - crypt_stat->metadata_size); in ecryptfs_copy_up_encrypted_with_header()
156 crypt_stat->extent_size, page->mapping->host); in ecryptfs_copy_up_encrypted_with_header()
174 * @page: Page from eCryptfs inode mapping into which to stick the read data
178 * Returns zero on success; non-zero on error.
183 &ecryptfs_inode_to_private(page->mapping->host)->crypt_stat; in ecryptfs_readpage()
186 if (!crypt_stat || !(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { in ecryptfs_readpage()
187 rc = ecryptfs_read_lower_page_segment(page, page->index, 0, in ecryptfs_readpage()
189 page->mapping->host); in ecryptfs_readpage()
190 } else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) { in ecryptfs_readpage()
191 if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) { in ecryptfs_readpage()
205 page, page->index, 0, PAGE_SIZE, in ecryptfs_readpage()
206 page->mapping->host); in ecryptfs_readpage()
227 page->index); in ecryptfs_readpage()
237 struct inode *inode = page->mapping->host; in fill_zeros_to_end_of_page()
240 if ((i_size_read(inode) / PAGE_SIZE) != page->index) in fill_zeros_to_end_of_page()
253 * @mapping: The eCryptfs object
258 * @fsdata: Pointer to return fs data (unused)
262 * Returns zero on success; non-zero otherwise
265 struct address_space *mapping, in ecryptfs_write_begin() argument
274 page = grab_cache_page_write_begin(mapping, index, flags); in ecryptfs_write_begin()
276 return -ENOMEM; in ecryptfs_write_begin()
282 &ecryptfs_inode_to_private(mapping->host)->crypt_stat; in ecryptfs_write_begin()
284 if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { in ecryptfs_write_begin()
286 page, index, 0, PAGE_SIZE, mapping->host); in ecryptfs_write_begin()
295 } else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) { in ecryptfs_write_begin()
296 if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) { in ecryptfs_write_begin()
313 mapping->host); in ecryptfs_write_begin()
325 >= i_size_read(page->mapping->host)) { in ecryptfs_write_begin()
334 __func__, page->index, rc); in ecryptfs_write_begin()
345 if (prev_page_end_size > i_size_read(page->mapping->host)) { in ecryptfs_write_begin()
346 rc = ecryptfs_truncate(file->f_path.dentry, in ecryptfs_write_begin()
359 if ((i_size_read(mapping->host) == prev_page_end_size) in ecryptfs_write_begin()
376 * Returns zero on success; non-zero on error.
385 rc = -ENOMEM; in ecryptfs_write_inode_size_to_header()
408 ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_path.dentry; in ecryptfs_write_inode_size_to_xattr()
412 if (!(lower_inode->i_opflags & IOP_XATTR)) { in ecryptfs_write_inode_size_to_xattr()
415 rc = -ENOSYS; in ecryptfs_write_inode_size_to_xattr()
420 rc = -ENOMEM; in ecryptfs_write_inode_size_to_xattr()
444 crypt_stat = &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat; in ecryptfs_write_inode_size_to_metadata()
445 BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)); in ecryptfs_write_inode_size_to_metadata()
446 if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) in ecryptfs_write_inode_size_to_metadata()
455 * @mapping: The eCryptfs object
457 * @len: The length of the data (unused)
458 * @copied: The amount of data copied
463 struct address_space *mapping, in ecryptfs_write_end() argument
468 unsigned from = pos & (PAGE_SIZE - 1); in ecryptfs_write_end()
470 struct inode *ecryptfs_inode = mapping->host; in ecryptfs_write_end()
472 &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat; in ecryptfs_write_end()
477 if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { in ecryptfs_write_end()
525 static sector_t ecryptfs_bmap(struct address_space *mapping, sector_t block) in ecryptfs_bmap() argument
527 struct inode *lower_inode = ecryptfs_inode_to_lower(mapping->host); in ecryptfs_bmap()