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()
44 * @wbc: Write-back control structure
46 * Returns zero on success; non-zero otherwise
48 * This is where we encrypt the data and pass the encrypted data to
49 * the lower filesystem. In OpenPGP-compatible mode, we operate on
59 "page (upper index [0x%.16lx])\n", page->index); in ecryptfs_writepage()
72 if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) { in strip_xattr_flag()
75 crypt_stat->flags &= ~ECRYPTFS_METADATA_IN_XATTR; in strip_xattr_flag()
78 crypt_stat->flags |= ECRYPTFS_METADATA_IN_XATTR; in strip_xattr_flag()
84 * Octets 0-7: Unencrypted file size (big-endian)
85 * Octets 8-15: eCryptfs special marker
86 * Octets 16-19: Flags
88 * Octets 17-18: Reserved
91 * Bits 3-8: Reserved
92 * Octets 20-23: Header extent size (big-endian)
93 * Octets 24-25: Number of header extents at front of file
94 * (big-endian)
114 / crypt_stat->extent_size); in ecryptfs_copy_up_encrypted_with_header()
118 loff_t view_extent_num = ((((loff_t)page->index) in ecryptfs_copy_up_encrypted_with_header()
122 (crypt_stat->metadata_size / crypt_stat->extent_size); in ecryptfs_copy_up_encrypted_with_header()
135 page_virt, page->mapping->host); in ecryptfs_copy_up_encrypted_with_header()
149 /* This is an encrypted data extent */ in ecryptfs_copy_up_encrypted_with_header()
151 ((view_extent_num * crypt_stat->extent_size) in ecryptfs_copy_up_encrypted_with_header()
152 - crypt_stat->metadata_size); in ecryptfs_copy_up_encrypted_with_header()
157 crypt_stat->extent_size, page->mapping->host); in ecryptfs_copy_up_encrypted_with_header()
175 * @folio: Folio from eCryptfs inode mapping into which to stick the read data
179 * Returns zero on success; non-zero on error.
183 struct page *page = &folio->page; in ecryptfs_read_folio()
185 &ecryptfs_inode_to_private(page->mapping->host)->crypt_stat; in ecryptfs_read_folio()
188 if (!crypt_stat || !(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { in ecryptfs_read_folio()
189 rc = ecryptfs_read_lower_page_segment(page, page->index, 0, in ecryptfs_read_folio()
191 page->mapping->host); in ecryptfs_read_folio()
192 } else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) { in ecryptfs_read_folio()
193 if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) { in ecryptfs_read_folio()
207 page, page->index, 0, PAGE_SIZE, in ecryptfs_read_folio()
208 page->mapping->host); in ecryptfs_read_folio()
229 page->index); in ecryptfs_read_folio()
239 struct inode *inode = folio->mapping->host; in fill_zeros_to_end_of_page()
242 if ((i_size_read(inode) / PAGE_SIZE) != folio->index) in fill_zeros_to_end_of_page()
255 * @mapping: The eCryptfs object
259 * @fsdata: Pointer to return fs data (unused)
263 * Returns zero on success; non-zero otherwise
266 struct address_space *mapping, in ecryptfs_write_begin() argument
275 folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, in ecryptfs_write_begin()
276 mapping_gfp_mask(mapping)); in ecryptfs_write_begin()
284 &ecryptfs_inode_to_private(mapping->host)->crypt_stat; in ecryptfs_write_begin()
286 if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { in ecryptfs_write_begin()
288 &folio->page, index, 0, PAGE_SIZE, mapping->host); in ecryptfs_write_begin()
297 } else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) { in ecryptfs_write_begin()
298 if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) { in ecryptfs_write_begin()
300 &folio->page, crypt_stat); in ecryptfs_write_begin()
314 &folio->page, index, 0, PAGE_SIZE, in ecryptfs_write_begin()
315 mapping->host); in ecryptfs_write_begin()
327 >= i_size_read(mapping->host)) { in ecryptfs_write_begin()
331 rc = ecryptfs_decrypt_page(&folio->page); in ecryptfs_write_begin()
336 __func__, folio->index, rc); in ecryptfs_write_begin()
347 if (prev_page_end_size > i_size_read(mapping->host)) { in ecryptfs_write_begin()
348 rc = ecryptfs_truncate(file->f_path.dentry, in ecryptfs_write_begin()
361 if ((i_size_read(mapping->host) == prev_page_end_size) in ecryptfs_write_begin()
377 * Returns zero on success; non-zero on error.
386 rc = -ENOMEM; in ecryptfs_write_inode_size_to_header()
409 ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_path.dentry; in ecryptfs_write_inode_size_to_xattr()
413 if (!(lower_inode->i_opflags & IOP_XATTR)) { in ecryptfs_write_inode_size_to_xattr()
416 rc = -ENOSYS; in ecryptfs_write_inode_size_to_xattr()
421 rc = -ENOMEM; in ecryptfs_write_inode_size_to_xattr()
445 crypt_stat = &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat; in ecryptfs_write_inode_size_to_metadata()
446 BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)); in ecryptfs_write_inode_size_to_metadata()
447 if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) in ecryptfs_write_inode_size_to_metadata()
456 * @mapping: The eCryptfs object
458 * @len: The length of the data (unused)
459 * @copied: The amount of data copied
464 struct address_space *mapping, in ecryptfs_write_end() argument
469 unsigned from = pos & (PAGE_SIZE - 1); in ecryptfs_write_end()
471 struct inode *ecryptfs_inode = mapping->host; in ecryptfs_write_end()
473 &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat; in ecryptfs_write_end()
478 if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { in ecryptfs_write_end()
480 &folio->page, 0, to); in ecryptfs_write_end()
502 rc = ecryptfs_encrypt_page(&folio->page); in ecryptfs_write_end()
526 static sector_t ecryptfs_bmap(struct address_space *mapping, sector_t block) in ecryptfs_bmap() argument
528 struct inode *lower_inode = ecryptfs_inode_to_lower(mapping->host); in ecryptfs_bmap()
543 * address_space_operations without the ->dirty_folio method was