fs/ubifs/ubifs.h

Source file repositories/reference/linux-study-clean/fs/ubifs/ubifs.h

File Facts

System
Linux kernel
Corpus path
fs/ubifs/ubifs.h
Extension
.h
Size
73885 bytes
Lines
2160
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: operation-table or driver-model contract
Status
pattern 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

extern const struct file_operations ubifs_file_operations;
extern const struct inode_operations ubifs_file_inode_operations;
extern const struct file_operations ubifs_dir_operations;
extern const struct inode_operations ubifs_dir_inode_operations;
extern const struct inode_operations ubifs_symlink_inode_operations;
extern struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
extern int ubifs_default_version;

/* auth.c */
static inline int ubifs_authenticated(const struct ubifs_info *c)
{
	return (IS_ENABLED(CONFIG_UBIFS_FS_AUTHENTICATION)) && c->authenticated;
}

struct shash_desc *__ubifs_hash_get_desc(const struct ubifs_info *c);
static inline struct shash_desc *ubifs_hash_get_desc(const struct ubifs_info *c)
{
	return ubifs_authenticated(c) ? __ubifs_hash_get_desc(c) : NULL;
}

static inline int ubifs_shash_init(const struct ubifs_info *c,
				   struct shash_desc *desc)
{
	if (ubifs_authenticated(c))
		return crypto_shash_init(desc);
	else
		return 0;
}

static inline int ubifs_shash_update(const struct ubifs_info *c,
				      struct shash_desc *desc, const void *buf,
				      unsigned int len)
{
	int err = 0;

	if (ubifs_authenticated(c)) {
		err = crypto_shash_update(desc, buf, len);
		if (err < 0)
			return err;
	}

	return 0;
}

static inline int ubifs_shash_final(const struct ubifs_info *c,
				    struct shash_desc *desc, u8 *out)
{
	return ubifs_authenticated(c) ? crypto_shash_final(desc, out) : 0;
}

int __ubifs_node_calc_hash(const struct ubifs_info *c, const void *buf,
			  u8 *hash);
static inline int ubifs_node_calc_hash(const struct ubifs_info *c,
					const void *buf, u8 *hash)
{
	if (ubifs_authenticated(c))
		return __ubifs_node_calc_hash(c, buf, hash);
	else
		return 0;
}

int ubifs_prepare_auth_node(struct ubifs_info *c, void *node,
			     struct shash_desc *inhash);

/**
 * ubifs_check_hash - compare two hashes
 * @c: UBIFS file-system description object
 * @expected: first hash
 * @got: second hash
 *
 * Compare two hashes @expected and @got. Returns 0 when they are equal, a
 * negative error code otherwise.
 */
static inline int ubifs_check_hash(const struct ubifs_info *c,
				   const u8 *expected, const u8 *got)
{
	return crypto_memneq(expected, got, c->hash_len);
}

/**
 * ubifs_check_hmac - compare two HMACs
 * @c: UBIFS file-system description object
 * @expected: first HMAC
 * @got: second HMAC
 *
 * Compare two hashes @expected and @got. Returns 0 when they are equal, a
 * negative error code otherwise.
 */
static inline int ubifs_check_hmac(const struct ubifs_info *c,
				   const u8 *expected, const u8 *got)

Annotation

Implementation Notes