VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
1a59d1b8e05ea (Thomas Gleixner    2019-05-27 08:55:05 +0200   1) // SPDX-License-Identifier: GPL-2.0-or-later
a62187eb1f483 (Lee Jones          2021-03-30 17:44:50 +0100   2) /*
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700   3)  * eCryptfs: Linux filesystem encryption layer
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700   4)  *
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700   5)  * Copyright (C) 1997-2004 Erez Zadok
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700   6)  * Copyright (C) 2001-2004 Stony Brook University
dd2a3b7ad98f8 (Michael Halcrow    2007-02-12 00:53:46 -0800   7)  * Copyright (C) 2004-2007 International Business Machines Corp.
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700   8)  *   Author(s): Michael A. Halcrow <mhalcrow@us.ibm.com>
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700   9)  *   		Michael C. Thompson <mcthomps@us.ibm.com>
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  10)  */
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  11) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  12) #include <linux/file.h>
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  13) #include <linux/poll.h>
5a0e3ad6af866 (Tejun Heo          2010-03-24 17:04:11 +0900  14) #include <linux/slab.h>
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  15) #include <linux/mount.h>
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  16) #include <linux/pagemap.h>
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  17) #include <linux/security.h>
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  18) #include <linux/compat.h>
0cc72dc7f0501 (Josef "Jeff" Sipek 2006-12-08 02:36:31 -0800  19) #include <linux/fs_stack.h>
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  20) #include "ecryptfs_kernel.h"
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  21) 
a62187eb1f483 (Lee Jones          2021-03-30 17:44:50 +0100  22) /*
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  23)  * ecryptfs_read_update_atime
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  24)  *
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  25)  * generic_file_read updates the atime of upper layer inode.  But, it
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  26)  * doesn't give us a chance to update the atime of the lower layer
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  27)  * inode.  This function is a wrapper to generic_file_read.  It
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  28)  * updates the atime of the lower level inode if generic_file_read
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  29)  * returns without any errors. This is to be used only for file reads.
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  30)  * The function to be used for directory reads is ecryptfs_read.
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  31)  */
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  32) static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb,
027978295d455 (Al Viro            2014-04-02 14:40:38 -0400  33) 				struct iov_iter *to)
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  34) {
38a708d775947 (Edward Shishkin    2010-10-30 00:11:50 +0200  35) 	ssize_t rc;
cc18ec3c8f5dd (Matthew Wilcox     2013-06-15 07:55:59 -0400  36) 	struct path *path;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  37) 	struct file *file = iocb->ki_filp;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  38) 
027978295d455 (Al Viro            2014-04-02 14:40:38 -0400  39) 	rc = generic_file_read_iter(iocb, to);
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  40) 	if (rc >= 0) {
cc18ec3c8f5dd (Matthew Wilcox     2013-06-15 07:55:59 -0400  41) 		path = ecryptfs_dentry_to_lower_path(file->f_path.dentry);
cc18ec3c8f5dd (Matthew Wilcox     2013-06-15 07:55:59 -0400  42) 		touch_atime(path);
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  43) 	}
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  44) 	return rc;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  45) }
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  46) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  47) struct ecryptfs_getdents_callback {
5c0ba4e0762e6 (Al Viro            2013-05-15 13:52:59 -0400  48) 	struct dir_context ctx;
2de5f059c4422 (Al Viro            2013-05-22 21:23:40 -0400  49) 	struct dir_context *caller;
0747fdb2bd59d (Al Viro            2013-06-16 20:05:38 +0400  50) 	struct super_block *sb;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  51) 	int filldir_called;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  52) 	int entries_written;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  53) };
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  54) 
7d6c7045581d3 (Michael Halcrow    2008-10-15 22:02:49 -0700  55) /* Inspired by generic filldir in fs/readdir.c */
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  56) static int
ac7576f4b1da8 (Miklos Szeredi     2014-10-30 17:37:34 +0100  57) ecryptfs_filldir(struct dir_context *ctx, const char *lower_name,
ac7576f4b1da8 (Miklos Szeredi     2014-10-30 17:37:34 +0100  58) 		 int lower_namelen, loff_t offset, u64 ino, unsigned int d_type)
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  59) {
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  60) 	struct ecryptfs_getdents_callback *buf =
ac7576f4b1da8 (Miklos Szeredi     2014-10-30 17:37:34 +0100  61) 		container_of(ctx, struct ecryptfs_getdents_callback, ctx);
a8f12864c52f8 (Michael Halcrow    2009-01-06 14:42:03 -0800  62) 	size_t name_size;
addd65ad8d19a (Michael Halcrow    2009-01-06 14:42:00 -0800  63) 	char *name;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  64) 	int rc;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  65) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  66) 	buf->filldir_called++;
addd65ad8d19a (Michael Halcrow    2009-01-06 14:42:00 -0800  67) 	rc = ecryptfs_decode_and_decrypt_filename(&name, &name_size,
0747fdb2bd59d (Al Viro            2013-06-16 20:05:38 +0400  68) 						  buf->sb, lower_name,
addd65ad8d19a (Michael Halcrow    2009-01-06 14:42:00 -0800  69) 						  lower_namelen);
addd65ad8d19a (Michael Halcrow    2009-01-06 14:42:00 -0800  70) 	if (rc) {
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  71) 		if (rc != -EINVAL) {
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  72) 			ecryptfs_printk(KERN_DEBUG,
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  73) 					"%s: Error attempting to decode and decrypt filename [%s]; rc = [%d]\n",
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  74) 					__func__, lower_name, rc);
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  75) 			return rc;
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  76) 		}
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  77) 
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  78) 		/* Mask -EINVAL errors as these are most likely due a plaintext
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  79) 		 * filename present in the lower filesystem despite filename
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  80) 		 * encryption being enabled. One unavoidable example would be
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  81) 		 * the "lost+found" dentry in the root directory of an Ext4
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  82) 		 * filesystem.
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  83) 		 */
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  84) 		return 0;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  85) 	}
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  86) 
2de5f059c4422 (Al Viro            2013-05-22 21:23:40 -0400  87) 	buf->caller->pos = buf->ctx.pos;
2de5f059c4422 (Al Viro            2013-05-22 21:23:40 -0400  88) 	rc = !dir_emit(buf->caller, name, name_size, ino, d_type);
addd65ad8d19a (Michael Halcrow    2009-01-06 14:42:00 -0800  89) 	kfree(name);
2de5f059c4422 (Al Viro            2013-05-22 21:23:40 -0400  90) 	if (!rc)
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  91) 		buf->entries_written++;
e86281e700cca (Tyler Hicks        2018-03-28 23:41:52 +0000  92) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  93) 	return rc;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  94) }
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  95) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  96) /**
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700  97)  * ecryptfs_readdir
addd65ad8d19a (Michael Halcrow    2009-01-06 14:42:00 -0800  98)  * @file: The eCryptfs directory file
2de5f059c4422 (Al Viro            2013-05-22 21:23:40 -0400  99)  * @ctx: The actor to feed the entries to
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 100)  */
2de5f059c4422 (Al Viro            2013-05-22 21:23:40 -0400 101) static int ecryptfs_readdir(struct file *file, struct dir_context *ctx)
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 102) {
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 103) 	int rc;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 104) 	struct file *lower_file;
0747fdb2bd59d (Al Viro            2013-06-16 20:05:38 +0400 105) 	struct inode *inode = file_inode(file);
2de5f059c4422 (Al Viro            2013-05-22 21:23:40 -0400 106) 	struct ecryptfs_getdents_callback buf = {
2de5f059c4422 (Al Viro            2013-05-22 21:23:40 -0400 107) 		.ctx.actor = ecryptfs_filldir,
2de5f059c4422 (Al Viro            2013-05-22 21:23:40 -0400 108) 		.caller = ctx,
0747fdb2bd59d (Al Viro            2013-06-16 20:05:38 +0400 109) 		.sb = inode->i_sb,
2de5f059c4422 (Al Viro            2013-05-22 21:23:40 -0400 110) 	};
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 111) 	lower_file = ecryptfs_file_to_lower(file);
5c0ba4e0762e6 (Al Viro            2013-05-15 13:52:59 -0400 112) 	rc = iterate_dir(lower_file, &buf.ctx);
2de5f059c4422 (Al Viro            2013-05-22 21:23:40 -0400 113) 	ctx->pos = buf.ctx.pos;
7d6c7045581d3 (Michael Halcrow    2008-10-15 22:02:49 -0700 114) 	if (rc < 0)
7d6c7045581d3 (Michael Halcrow    2008-10-15 22:02:49 -0700 115) 		goto out;
7d6c7045581d3 (Michael Halcrow    2008-10-15 22:02:49 -0700 116) 	if (buf.filldir_called && !buf.entries_written)
7d6c7045581d3 (Michael Halcrow    2008-10-15 22:02:49 -0700 117) 		goto out;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 118) 	if (rc >= 0)
7d6c7045581d3 (Michael Halcrow    2008-10-15 22:02:49 -0700 119) 		fsstack_copy_attr_atime(inode,
496ad9aa8ef44 (Al Viro            2013-01-23 17:07:38 -0500 120) 					file_inode(lower_file));
7d6c7045581d3 (Michael Halcrow    2008-10-15 22:02:49 -0700 121) out:
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 122) 	return rc;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 123) }
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 124) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 125) struct kmem_cache *ecryptfs_file_info_cache;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 126) 
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 127) static int read_or_initialize_metadata(struct dentry *dentry)
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 128) {
2b0143b5c986b (David Howells      2015-03-17 22:25:59 +0000 129) 	struct inode *inode = d_inode(dentry);
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 130) 	struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 131) 	struct ecryptfs_crypt_stat *crypt_stat;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 132) 	int rc;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 133) 
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 134) 	crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 135) 	mount_crypt_stat = &ecryptfs_superblock_to_private(
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 136) 						inode->i_sb)->mount_crypt_stat;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 137) 	mutex_lock(&crypt_stat->cs_mutex);
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 138) 
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 139) 	if (crypt_stat->flags & ECRYPTFS_POLICY_APPLIED &&
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 140) 	    crypt_stat->flags & ECRYPTFS_KEY_VALID) {
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 141) 		rc = 0;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 142) 		goto out;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 143) 	}
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 144) 
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 145) 	rc = ecryptfs_read_metadata(dentry);
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 146) 	if (!rc)
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 147) 		goto out;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 148) 
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 149) 	if (mount_crypt_stat->flags & ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED) {
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 150) 		crypt_stat->flags &= ~(ECRYPTFS_I_SIZE_INITIALIZED
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 151) 				       | ECRYPTFS_ENCRYPTED);
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 152) 		rc = 0;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 153) 		goto out;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 154) 	}
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 155) 
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 156) 	if (!(mount_crypt_stat->flags & ECRYPTFS_XATTR_METADATA_ENABLED) &&
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 157) 	    !i_size_read(ecryptfs_inode_to_lower(inode))) {
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 158) 		rc = ecryptfs_initialize_file(dentry, inode);
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 159) 		if (!rc)
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 160) 			goto out;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 161) 	}
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 162) 
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 163) 	rc = -EIO;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 164) out:
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 165) 	mutex_unlock(&crypt_stat->cs_mutex);
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 166) 	return rc;
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 167) }
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 168) 
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 169) static int ecryptfs_mmap(struct file *file, struct vm_area_struct *vma)
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 170) {
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 171) 	struct file *lower_file = ecryptfs_file_to_lower(file);
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 172) 	/*
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 173) 	 * Don't allow mmap on top of file systems that don't support it
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 174) 	 * natively.  If FILESYSTEM_MAX_STACK_DEPTH > 2 or ecryptfs
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 175) 	 * allows recursive mounting, this will need to be extended.
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 176) 	 */
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 177) 	if (!lower_file->f_op->mmap)
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 178) 		return -ENODEV;
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 179) 	return generic_file_mmap(file, vma);
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 180) }
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 181) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 182) /**
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 183)  * ecryptfs_open
40f0fd372a623 (Chris J Arges      2016-06-09 15:31:29 -0500 184)  * @inode: inode specifying file to open
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 185)  * @file: Structure to return filled in
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 186)  *
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 187)  * Opens the file specified by inode.
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 188)  *
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 189)  * Returns zero on success; non-zero otherwise
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 190)  */
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 191) static int ecryptfs_open(struct inode *inode, struct file *file)
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 192) {
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 193) 	int rc = 0;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 194) 	struct ecryptfs_crypt_stat *crypt_stat = NULL;
bd243a4b4b028 (Josef "Jeff" Sipek 2006-12-08 02:36:48 -0800 195) 	struct dentry *ecryptfs_dentry = file->f_path.dentry;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 196) 	/* Private value of ecryptfs_dentry allocated in
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 197) 	 * ecryptfs_lookup() */
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 198) 	struct ecryptfs_file_info *file_info;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 199) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 200) 	/* Released in ecryptfs_release or end of function if failure */
c376222960ae9 (Robert P. J. Day   2007-02-10 01:45:03 -0800 201) 	file_info = kmem_cache_zalloc(ecryptfs_file_info_cache, GFP_KERNEL);
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 202) 	ecryptfs_set_file_private(file, file_info);
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 203) 	if (!file_info) {
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 204) 		ecryptfs_printk(KERN_ERR,
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 205) 				"Error attempting to allocate memory\n");
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 206) 		rc = -ENOMEM;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 207) 		goto out;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 208) 	}
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 209) 	crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 210) 	mutex_lock(&crypt_stat->cs_mutex);
e2bd99ec5c0e2 (Michael Halcrow    2007-02-12 00:53:49 -0800 211) 	if (!(crypt_stat->flags & ECRYPTFS_POLICY_APPLIED)) {
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 212) 		ecryptfs_printk(KERN_DEBUG, "Setting flags for stat...\n");
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 213) 		/* Policy code enabled in future release */
2ed92554abc5c (Michael Halcrow    2007-10-16 01:28:10 -0700 214) 		crypt_stat->flags |= (ECRYPTFS_POLICY_APPLIED
2ed92554abc5c (Michael Halcrow    2007-10-16 01:28:10 -0700 215) 				      | ECRYPTFS_ENCRYPTED);
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 216) 	}
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 217) 	mutex_unlock(&crypt_stat->cs_mutex);
3b06b3ebf4417 (Tyler Hicks        2011-05-24 03:49:02 -0500 218) 	rc = ecryptfs_get_lower_file(ecryptfs_dentry, inode);
27992890b02d3 (Roberto Sassu      2010-11-03 11:11:28 +0100 219) 	if (rc) {
27992890b02d3 (Roberto Sassu      2010-11-03 11:11:28 +0100 220) 		printk(KERN_ERR "%s: Error attempting to initialize "
332ab16f830f5 (Tyler Hicks        2011-04-14 15:35:11 -0500 221) 			"the lower file for the dentry with name "
9e78d14a9f641 (David Howells      2013-12-10 15:26:48 +0000 222) 			"[%pd]; rc = [%d]\n", __func__,
9e78d14a9f641 (David Howells      2013-12-10 15:26:48 +0000 223) 			ecryptfs_dentry, rc);
27992890b02d3 (Roberto Sassu      2010-11-03 11:11:28 +0100 224) 		goto out_free;
72b55fffd631a (Michael Halcrow    2008-07-23 21:30:07 -0700 225) 	}
0abe116947057 (Roberto Sassu      2010-11-03 11:11:34 +0100 226) 	if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_ACCMODE)
0abe116947057 (Roberto Sassu      2010-11-03 11:11:34 +0100 227) 	    == O_RDONLY && (file->f_flags & O_ACCMODE) != O_RDONLY) {
e27759d7a333d (Erez Zadok         2009-12-03 13:35:27 -0500 228) 		rc = -EPERM;
332ab16f830f5 (Tyler Hicks        2011-04-14 15:35:11 -0500 229) 		printk(KERN_WARNING "%s: Lower file is RO; eCryptfs "
e27759d7a333d (Erez Zadok         2009-12-03 13:35:27 -0500 230) 		       "file must hence be opened RO\n", __func__);
332ab16f830f5 (Tyler Hicks        2011-04-14 15:35:11 -0500 231) 		goto out_put;
e27759d7a333d (Erez Zadok         2009-12-03 13:35:27 -0500 232) 	}
2ed92554abc5c (Michael Halcrow    2007-10-16 01:28:10 -0700 233) 	ecryptfs_set_file_lower(
2ed92554abc5c (Michael Halcrow    2007-10-16 01:28:10 -0700 234) 		file, ecryptfs_inode_to_private(inode)->lower_file);
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 235) 	rc = read_or_initialize_metadata(ecryptfs_dentry);
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 236) 	if (rc)
e3ccaa9761200 (Tyler Hicks        2012-06-20 23:50:59 -0700 237) 		goto out_put;
888d57bbc91eb (Joe Perches        2010-11-10 15:46:16 -0800 238) 	ecryptfs_printk(KERN_DEBUG, "inode w/ addr = [0x%p], i_ino = "
888d57bbc91eb (Joe Perches        2010-11-10 15:46:16 -0800 239) 			"[0x%.16lx] size: [0x%.16llx]\n", inode, inode->i_ino,
888d57bbc91eb (Joe Perches        2010-11-10 15:46:16 -0800 240) 			(unsigned long long)i_size_read(inode));
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 241) 	goto out;
332ab16f830f5 (Tyler Hicks        2011-04-14 15:35:11 -0500 242) out_put:
332ab16f830f5 (Tyler Hicks        2011-04-14 15:35:11 -0500 243) 	ecryptfs_put_lower_file(inode);
2ed92554abc5c (Michael Halcrow    2007-10-16 01:28:10 -0700 244) out_free:
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 245) 	kmem_cache_free(ecryptfs_file_info_cache,
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 246) 			ecryptfs_file_to_private(file));
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 247) out:
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 248) 	return rc;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 249) }
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 250) 
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 251) /**
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 252)  * ecryptfs_dir_open
40f0fd372a623 (Chris J Arges      2016-06-09 15:31:29 -0500 253)  * @inode: inode specifying file to open
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 254)  * @file: Structure to return filled in
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 255)  *
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 256)  * Opens the file specified by inode.
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 257)  *
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 258)  * Returns zero on success; non-zero otherwise
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 259)  */
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 260) static int ecryptfs_dir_open(struct inode *inode, struct file *file)
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 261) {
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 262) 	struct dentry *ecryptfs_dentry = file->f_path.dentry;
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 263) 	/* Private value of ecryptfs_dentry allocated in
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 264) 	 * ecryptfs_lookup() */
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 265) 	struct ecryptfs_file_info *file_info;
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 266) 	struct file *lower_file;
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 267) 
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 268) 	/* Released in ecryptfs_release or end of function if failure */
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 269) 	file_info = kmem_cache_zalloc(ecryptfs_file_info_cache, GFP_KERNEL);
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 270) 	ecryptfs_set_file_private(file, file_info);
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 271) 	if (unlikely(!file_info)) {
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 272) 		ecryptfs_printk(KERN_ERR,
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 273) 				"Error attempting to allocate memory\n");
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 274) 		return -ENOMEM;
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 275) 	}
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 276) 	lower_file = dentry_open(ecryptfs_dentry_to_lower_path(ecryptfs_dentry),
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 277) 				 file->f_flags, current_cred());
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 278) 	if (IS_ERR(lower_file)) {
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 279) 		printk(KERN_ERR "%s: Error attempting to initialize "
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 280) 			"the lower file for the dentry with name "
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 281) 			"[%pd]; rc = [%ld]\n", __func__,
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 282) 			ecryptfs_dentry, PTR_ERR(lower_file));
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 283) 		kmem_cache_free(ecryptfs_file_info_cache, file_info);
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 284) 		return PTR_ERR(lower_file);
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 285) 	}
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 286) 	ecryptfs_set_file_lower(file, lower_file);
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 287) 	return 0;
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 288) }
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 289) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 290) static int ecryptfs_flush(struct file *file, fl_owner_t td)
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 291) {
64e6651dcc10e (Tyler Hicks        2012-09-12 18:38:00 -0700 292) 	struct file *lower_file = ecryptfs_file_to_lower(file);
64e6651dcc10e (Tyler Hicks        2012-09-12 18:38:00 -0700 293) 
72c2d53192004 (Al Viro            2013-09-22 16:27:52 -0400 294) 	if (lower_file->f_op->flush) {
64e6651dcc10e (Tyler Hicks        2012-09-12 18:38:00 -0700 295) 		filemap_write_and_wait(file->f_mapping);
64e6651dcc10e (Tyler Hicks        2012-09-12 18:38:00 -0700 296) 		return lower_file->f_op->flush(lower_file, td);
64e6651dcc10e (Tyler Hicks        2012-09-12 18:38:00 -0700 297) 	}
64e6651dcc10e (Tyler Hicks        2012-09-12 18:38:00 -0700 298) 
64e6651dcc10e (Tyler Hicks        2012-09-12 18:38:00 -0700 299) 	return 0;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 300) }
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 301) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 302) static int ecryptfs_release(struct inode *inode, struct file *file)
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 303) {
332ab16f830f5 (Tyler Hicks        2011-04-14 15:35:11 -0500 304) 	ecryptfs_put_lower_file(inode);
2ed92554abc5c (Michael Halcrow    2007-10-16 01:28:10 -0700 305) 	kmem_cache_free(ecryptfs_file_info_cache,
2ed92554abc5c (Michael Halcrow    2007-10-16 01:28:10 -0700 306) 			ecryptfs_file_to_private(file));
2ed92554abc5c (Michael Halcrow    2007-10-16 01:28:10 -0700 307) 	return 0;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 308) }
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 309) 
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 310) static int ecryptfs_dir_release(struct inode *inode, struct file *file)
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 311) {
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 312) 	fput(ecryptfs_file_to_lower(file));
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 313) 	kmem_cache_free(ecryptfs_file_info_cache,
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 314) 			ecryptfs_file_to_private(file));
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 315) 	return 0;
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 316) }
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 317) 
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 318) static loff_t ecryptfs_dir_llseek(struct file *file, loff_t offset, int whence)
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 319) {
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 320) 	return vfs_llseek(ecryptfs_file_to_lower(file), offset, whence);
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 321) }
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 322) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 323) static int
02c24a82187d5 (Josef Bacik        2011-07-16 20:44:56 -0400 324) ecryptfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 325) {
bc5abcf7e411b (Tyler Hicks        2013-06-04 10:24:56 -0700 326) 	int rc;
bc5abcf7e411b (Tyler Hicks        2013-06-04 10:24:56 -0700 327) 
6d4b512413946 (Jeff Layton        2017-08-02 10:14:21 -0400 328) 	rc = file_write_and_wait(file);
bc5abcf7e411b (Tyler Hicks        2013-06-04 10:24:56 -0700 329) 	if (rc)
bc5abcf7e411b (Tyler Hicks        2013-06-04 10:24:56 -0700 330) 		return rc;
bc5abcf7e411b (Tyler Hicks        2013-06-04 10:24:56 -0700 331) 
821f7494a7762 (Tyler Hicks        2012-07-03 16:50:57 -0700 332) 	return vfs_fsync(ecryptfs_file_to_lower(file), datasync);
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 333) }
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 334) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 335) static int ecryptfs_fasync(int fd, struct file *file, int flag)
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 336) {
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 337) 	int rc = 0;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 338) 	struct file *lower_file = NULL;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 339) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 340) 	lower_file = ecryptfs_file_to_lower(file);
72c2d53192004 (Al Viro            2013-09-22 16:27:52 -0400 341) 	if (lower_file->f_op->fasync)
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 342) 		rc = lower_file->f_op->fasync(fd, lower_file, flag);
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 343) 	return rc;
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 344) }
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 345) 
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 346) static long
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 347) ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 348) {
2000f5beabc9c (Tyler Hicks        2013-11-13 10:09:42 -0800 349) 	struct file *lower_file = ecryptfs_file_to_lower(file);
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 350) 	long rc = -ENOTTY;
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 351) 
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 352) 	if (!lower_file->f_op->unlocked_ioctl)
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 353) 		return rc;
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 354) 
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 355) 	switch (cmd) {
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 356) 	case FITRIM:
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 357) 	case FS_IOC_GETFLAGS:
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 358) 	case FS_IOC_SETFLAGS:
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 359) 	case FS_IOC_GETVERSION:
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 360) 	case FS_IOC_SETVERSION:
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 361) 		rc = lower_file->f_op->unlocked_ioctl(lower_file, cmd, arg);
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 362) 		fsstack_copy_attr_all(file_inode(file), file_inode(lower_file));
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 363) 
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 364) 		return rc;
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 365) 	default:
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 366) 		return rc;
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 367) 	}
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 368) }
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 369) 
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 370) #ifdef CONFIG_COMPAT
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 371) static long
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 372) ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 373) {
2000f5beabc9c (Tyler Hicks        2013-11-13 10:09:42 -0800 374) 	struct file *lower_file = ecryptfs_file_to_lower(file);
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 375) 	long rc = -ENOIOCTLCMD;
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 376) 
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 377) 	if (!lower_file->f_op->compat_ioctl)
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 378) 		return rc;
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 379) 
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 380) 	switch (cmd) {
314999dcbca75 (Arnd Bergmann      2019-06-03 13:51:58 +0200 381) 	case FITRIM:
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 382) 	case FS_IOC32_GETFLAGS:
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 383) 	case FS_IOC32_SETFLAGS:
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 384) 	case FS_IOC32_GETVERSION:
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 385) 	case FS_IOC32_SETVERSION:
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 386) 		rc = lower_file->f_op->compat_ioctl(lower_file, cmd, arg);
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 387) 		fsstack_copy_attr_all(file_inode(file), file_inode(lower_file));
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 388) 
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 389) 		return rc;
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 390) 	default:
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 391) 		return rc;
6d65261a09ada (Tyler Hicks        2015-02-24 19:28:10 -0600 392) 	}
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 393) }
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 394) #endif
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 395) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 396) const struct file_operations ecryptfs_dir_fops = {
51a16a9cd5387 (Al Viro            2016-05-04 16:21:20 -0400 397) 	.iterate_shared = ecryptfs_readdir,
323ef68faf1bb (Andy Whitcroft     2011-02-16 04:49:59 +0000 398) 	.read = generic_read_dir,
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 399) 	.unlocked_ioctl = ecryptfs_unlocked_ioctl,
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 400) #ifdef CONFIG_COMPAT
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 401) 	.compat_ioctl = ecryptfs_compat_ioctl,
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 402) #endif
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 403) 	.open = ecryptfs_dir_open,
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 404) 	.release = ecryptfs_dir_release,
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 405) 	.fsync = ecryptfs_fsync,
6a480a7842545 (Al Viro            2016-05-04 14:04:13 -0400 406) 	.llseek = ecryptfs_dir_llseek,
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 407) };
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 408) 
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 409) const struct file_operations ecryptfs_main_fops = {
53a2731f9310a (Michael Halcrow    2007-05-23 13:58:15 -0700 410) 	.llseek = generic_file_llseek,
027978295d455 (Al Viro            2014-04-02 14:40:38 -0400 411) 	.read_iter = ecryptfs_read_update_atime,
8174202b34c30 (Al Viro            2014-04-03 03:17:43 -0400 412) 	.write_iter = generic_file_write_iter,
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 413) 	.unlocked_ioctl = ecryptfs_unlocked_ioctl,
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 414) #ifdef CONFIG_COMPAT
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 415) 	.compat_ioctl = ecryptfs_compat_ioctl,
c43f7b8fb03be (Tyler Hicks        2009-11-03 11:45:11 -0600 416) #endif
f0fe970df3838 (Jeff Mahoney       2016-07-05 17:32:30 -0400 417) 	.mmap = ecryptfs_mmap,
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 418) 	.open = ecryptfs_open,
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 419) 	.flush = ecryptfs_flush,
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 420) 	.release = ecryptfs_release,
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 421) 	.fsync = ecryptfs_fsync,
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 422) 	.fasync = ecryptfs_fasync,
e9f6a99cb844a (Michael Halcrow    2007-10-16 01:28:04 -0700 423) 	.splice_read = generic_file_splice_read,
237fead619984 (Michael Halcrow    2006-10-04 02:16:22 -0700 424) };