linux/fs/ecryptfs/inode.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * eCryptfs: Linux filesystem encryption layer
 *
 * Copyright (C) 1997-2004 Erez Zadok
 * Copyright (C) 2001-2004 Stony Brook University
 * Copyright (C) 2004-2007 International Business Machines Corp.
 *   Author(s): Michael A. Halcrow <[email protected]>
 *              Michael C. Thompsion <[email protected]>
 */

#include <linux/file.h>
#include <linux/vmalloc.h>
#include <linux/pagemap.h>
#include <linux/dcache.h>
#include <linux/namei.h>
#include <linux/mount.h>
#include <linux/fs_stack.h>
#include <linux/slab.h>
#include <linux/xattr.h>
#include <linux/posix_acl.h>
#include <linux/posix_acl_xattr.h>
#include <linux/fileattr.h>
#include <asm/unaligned.h>
#include "ecryptfs_kernel.h"

static int lock_parent(struct dentry *dentry,
		       struct dentry **lower_dentry,
		       struct inode **lower_dir)
{}

static int ecryptfs_inode_test(struct inode *inode, void *lower_inode)
{}

static int ecryptfs_inode_set(struct inode *inode, void *opaque)
{}

static struct inode *__ecryptfs_get_inode(struct inode *lower_inode,
					  struct super_block *sb)
{}

struct inode *ecryptfs_get_inode(struct inode *lower_inode,
				 struct super_block *sb)
{}

/**
 * ecryptfs_interpose
 * @lower_dentry: Existing dentry in the lower filesystem
 * @dentry: ecryptfs' dentry
 * @sb: ecryptfs's super_block
 *
 * Interposes upper and lower dentries.
 *
 * Returns zero on success; non-zero otherwise
 */
static int ecryptfs_interpose(struct dentry *lower_dentry,
			      struct dentry *dentry, struct super_block *sb)
{}

static int ecryptfs_do_unlink(struct inode *dir, struct dentry *dentry,
			      struct inode *inode)
{}

/**
 * ecryptfs_do_create
 * @directory_inode: inode of the new file's dentry's parent in ecryptfs
 * @ecryptfs_dentry: New file's dentry in ecryptfs
 * @mode: The mode of the new file
 *
 * Creates the underlying file and the eCryptfs inode which will link to
 * it. It will also update the eCryptfs directory inode to mimic the
 * stat of the lower directory inode.
 *
 * Returns the new eCryptfs inode on success; an ERR_PTR on error condition
 */
static struct inode *
ecryptfs_do_create(struct inode *directory_inode,
		   struct dentry *ecryptfs_dentry, umode_t mode)
{}

/*
 * ecryptfs_initialize_file
 *
 * Cause the file to be changed from a basic empty file to an ecryptfs
 * file with a header and first data page.
 *
 * Returns zero on success
 */
int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry,
			     struct inode *ecryptfs_inode)
{}

/*
 * ecryptfs_create
 * @mode: The mode of the new file.
 *
 * Creates a new file.
 *
 * Returns zero on success; non-zero on error condition
 */
static int
ecryptfs_create(struct mnt_idmap *idmap,
		struct inode *directory_inode, struct dentry *ecryptfs_dentry,
		umode_t mode, bool excl)
{}

static int ecryptfs_i_size_read(struct dentry *dentry, struct inode *inode)
{}

/*
 * ecryptfs_lookup_interpose - Dentry interposition for a lookup
 */
static struct dentry *ecryptfs_lookup_interpose(struct dentry *dentry,
				     struct dentry *lower_dentry)
{}

/**
 * ecryptfs_lookup
 * @ecryptfs_dir_inode: The eCryptfs directory inode
 * @ecryptfs_dentry: The eCryptfs dentry that we are looking up
 * @flags: lookup flags
 *
 * Find a file on disk. If the file does not exist, then we'll add it to the
 * dentry cache and continue on to read it from the disk.
 */
static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
				      struct dentry *ecryptfs_dentry,
				      unsigned int flags)
{}

static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
			 struct dentry *new_dentry)
{}

static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
{}

static int ecryptfs_symlink(struct mnt_idmap *idmap,
			    struct inode *dir, struct dentry *dentry,
			    const char *symname)
{}

static int ecryptfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
			  struct dentry *dentry, umode_t mode)
{}

static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
{}

static int
ecryptfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
	       struct dentry *dentry, umode_t mode, dev_t dev)
{}

static int
ecryptfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
		struct dentry *old_dentry, struct inode *new_dir,
		struct dentry *new_dentry, unsigned int flags)
{}

static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
{}

static const char *ecryptfs_get_link(struct dentry *dentry,
				     struct inode *inode,
				     struct delayed_call *done)
{}

/**
 * upper_size_to_lower_size
 * @crypt_stat: Crypt_stat associated with file
 * @upper_size: Size of the upper file
 *
 * Calculate the required size of the lower file based on the
 * specified size of the upper file. This calculation is based on the
 * number of headers in the underlying file and the extent size.
 *
 * Returns Calculated size of the lower file.
 */
static loff_t
upper_size_to_lower_size(struct ecryptfs_crypt_stat *crypt_stat,
			 loff_t upper_size)
{}

/**
 * truncate_upper
 * @dentry: The ecryptfs layer dentry
 * @ia: Address of the ecryptfs inode's attributes
 * @lower_ia: Address of the lower inode's attributes
 *
 * Function to handle truncations modifying the size of the file. Note
 * that the file sizes are interpolated. When expanding, we are simply
 * writing strings of 0's out. When truncating, we truncate the upper
 * inode and update the lower_ia according to the page index
 * interpolations. If ATTR_SIZE is set in lower_ia->ia_valid upon return,
 * the caller must use lower_ia in a call to notify_change() to perform
 * the truncation of the lower inode.
 *
 * Returns zero on success; non-zero otherwise
 */
static int truncate_upper(struct dentry *dentry, struct iattr *ia,
			  struct iattr *lower_ia)
{}

static int ecryptfs_inode_newsize_ok(struct inode *inode, loff_t offset)
{}

/**
 * ecryptfs_truncate
 * @dentry: The ecryptfs layer dentry
 * @new_length: The length to expand the file to
 *
 * Simple function that handles the truncation of an eCryptfs inode and
 * its corresponding lower inode.
 *
 * Returns zero on success; non-zero otherwise
 */
int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
{}

static int
ecryptfs_permission(struct mnt_idmap *idmap, struct inode *inode,
		    int mask)
{}

/**
 * ecryptfs_setattr
 * @idmap: idmap of the target mount
 * @dentry: dentry handle to the inode to modify
 * @ia: Structure with flags of what to change and values
 *
 * Updates the metadata of an inode. If the update is to the size
 * i.e. truncation, then ecryptfs_truncate will handle the size modification
 * of both the ecryptfs inode and the lower inode.
 *
 * All other metadata changes will be passed right to the lower filesystem,
 * and we will just update our inode to look like the lower.
 */
static int ecryptfs_setattr(struct mnt_idmap *idmap,
			    struct dentry *dentry, struct iattr *ia)
{}

static int ecryptfs_getattr_link(struct mnt_idmap *idmap,
				 const struct path *path, struct kstat *stat,
				 u32 request_mask, unsigned int flags)
{}

static int ecryptfs_do_getattr(const struct path *path, struct kstat *stat,
			       u32 request_mask, unsigned int flags)
{}

static int ecryptfs_getattr(struct mnt_idmap *idmap,
			    const struct path *path, struct kstat *stat,
			    u32 request_mask, unsigned int flags)
{}

int
ecryptfs_setxattr(struct dentry *dentry, struct inode *inode,
		  const char *name, const void *value,
		  size_t size, int flags)
{}

ssize_t
ecryptfs_getxattr_lower(struct dentry *lower_dentry, struct inode *lower_inode,
			const char *name, void *value, size_t size)
{}

static ssize_t
ecryptfs_getxattr(struct dentry *dentry, struct inode *inode,
		  const char *name, void *value, size_t size)
{}

static ssize_t
ecryptfs_listxattr(struct dentry *dentry, char *list, size_t size)
{}

static int ecryptfs_removexattr(struct dentry *dentry, struct inode *inode,
				const char *name)
{}

static int ecryptfs_fileattr_get(struct dentry *dentry, struct fileattr *fa)
{}

static int ecryptfs_fileattr_set(struct mnt_idmap *idmap,
				 struct dentry *dentry, struct fileattr *fa)
{}

static struct posix_acl *ecryptfs_get_acl(struct mnt_idmap *idmap,
					  struct dentry *dentry, int type)
{}

static int ecryptfs_set_acl(struct mnt_idmap *idmap,
			    struct dentry *dentry, struct posix_acl *acl,
			    int type)
{}

const struct inode_operations ecryptfs_symlink_iops =;

const struct inode_operations ecryptfs_dir_iops =;

const struct inode_operations ecryptfs_main_iops =;

static int ecryptfs_xattr_get(const struct xattr_handler *handler,
			      struct dentry *dentry, struct inode *inode,
			      const char *name, void *buffer, size_t size)
{}

static int ecryptfs_xattr_set(const struct xattr_handler *handler,
			      struct mnt_idmap *idmap,
			      struct dentry *dentry, struct inode *inode,
			      const char *name, const void *value, size_t size,
			      int flags)
{}

static const struct xattr_handler ecryptfs_xattr_handler =;

const struct xattr_handler * const ecryptfs_xattr_handlers[] =;