include/linux/fscrypt.h

Source file repositories/reference/linux-study-clean/include/linux/fscrypt.h

File Facts

System
Linux kernel
Corpus path
include/linux/fscrypt.h
Extension
.h
Size
36051 bytes
Lines
1136
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct fscrypt_str {
	unsigned char *name;
	u32 len;
};

struct fscrypt_name {
	const struct qstr *usr_fname;
	struct fscrypt_str disk_name;
	u32 hash;
	u32 minor_hash;
	struct fscrypt_str crypto_buf;
	bool is_nokey_name;
};

#define FSTR_INIT(n, l)		{ .name = n, .len = l }
#define FSTR_TO_QSTR(f)		QSTR_INIT((f)->name, (f)->len)
#define fname_name(p)		((p)->disk_name.name)
#define fname_len(p)		((p)->disk_name.len)

/* Maximum value for the third parameter of fscrypt_operations.set_context(). */
#define FSCRYPT_SET_CONTEXT_MAX_SIZE	40

#ifdef CONFIG_FS_ENCRYPTION

/* Crypto operations for filesystems */
struct fscrypt_operations {
	/*
	 * The offset of the pointer to struct fscrypt_inode_info in the
	 * filesystem-specific part of the inode, relative to the beginning of
	 * the common part of the inode (the 'struct inode').
	 */
	ptrdiff_t inode_info_offs;

	/*
	 * If set, then fs/crypto/ will allocate a global bounce page pool the
	 * first time an encryption key is set up for a file.  The bounce page
	 * pool is required by the following functions:
	 *
	 * - fscrypt_encrypt_pagecache_blocks()
	 * - fscrypt_zeroout_range() for files not using inline crypto
	 *
	 * If the filesystem doesn't use those, it doesn't need to set this.
	 */
	unsigned int needs_bounce_pages : 1;

	/*
	 * If set, then fs/crypto/ will allow the use of encryption settings
	 * that assume inode numbers fit in 32 bits (i.e.
	 * FSCRYPT_POLICY_FLAG_IV_INO_LBLK_{32,64}), provided that the other
	 * prerequisites for these settings are also met.  This is only useful
	 * if the filesystem wants to support inline encryption hardware that is
	 * limited to 32-bit or 64-bit data unit numbers and where programming
	 * keyslots is very slow.
	 */
	unsigned int has_32bit_inodes : 1;

	/*
	 * If set, then fs/crypto/ will allow users to select a crypto data unit
	 * size that is less than the filesystem block size.  This is done via
	 * the log2_data_unit_size field of the fscrypt policy.  This flag is
	 * not compatible with filesystems that encrypt variable-length blocks
	 * (i.e. blocks that aren't all equal to filesystem's block size), for
	 * example as a result of compression.  It's also not compatible with
	 * the fscrypt_encrypt_block_inplace() and
	 * fscrypt_decrypt_block_inplace() functions.
	 */
	unsigned int supports_subblock_data_units : 1;

	/*
	 * This field exists only for backwards compatibility reasons and should
	 * only be set by the filesystems that are setting it already.  It
	 * contains the filesystem-specific key description prefix that is
	 * accepted for "logon" keys for v1 fscrypt policies.  This
	 * functionality is deprecated in favor of the generic prefix
	 * "fscrypt:", which itself is deprecated in favor of the filesystem
	 * keyring ioctls such as FS_IOC_ADD_ENCRYPTION_KEY.  Filesystems that
	 * are newly adding fscrypt support should not set this field.
	 */
	const char *legacy_key_prefix;

	/*
	 * Get the fscrypt context of the given inode.
	 *
	 * @inode: the inode whose context to get
	 * @ctx: the buffer into which to get the context
	 * @len: length of the @ctx buffer in bytes
	 *
	 * Return: On success, returns the length of the context in bytes; this
	 *	   may be less than @len.  On failure, returns -ENODATA if the
	 *	   inode doesn't have a context, -ERANGE if the context is

Annotation

Implementation Notes