fs/ubifs/super.c

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

File Facts

System
Linux kernel
Corpus path
fs/ubifs/super.c
Extension
.c
Size
66985 bytes
Lines
2516
Domain
Core OS
Bucket
VFS And Filesystem Core
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 ubifs_fs_context {
	struct ubifs_mount_opts mount_opts;
	char *auth_key_name;
	char *auth_hash_name;
	unsigned int no_chk_data_crc:1;
	unsigned int bulk_read:1;
	unsigned int default_compr:2;
	unsigned int assert_action:2;
};

/**
 * ubifs_parse_param - parse a parameter.
 * @fc: the filesystem context
 * @param: the parameter to parse
 *
 * This function parses UBIFS mount options and returns zero in case success
 * and a negative error code in case of failure.
 */
static int ubifs_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
	struct ubifs_fs_context *ctx = fc->fs_private;
	struct fs_parse_result result;
	bool is_remount = (fc->purpose & FS_CONTEXT_FOR_RECONFIGURE);
	int opt;

	opt = fs_parse(fc, ubifs_fs_param_spec, param, &result);
	if (opt < 0)
		return opt;

	switch (opt) {
		/*
		 * %Opt_fast_unmount and %Opt_norm_unmount options are ignored.
		 * We accept them in order to be backward-compatible. But this
		 * should be removed at some point.
		 */
	case Opt_fast_unmount:
		ctx->mount_opts.unmount_mode = 2;
		break;
	case Opt_norm_unmount:
		ctx->mount_opts.unmount_mode = 1;
		break;
	case Opt_bulk_read:
		ctx->mount_opts.bulk_read = 2;
		ctx->bulk_read = 1;
		break;
	case Opt_no_bulk_read:
		ctx->mount_opts.bulk_read = 1;
		ctx->bulk_read = 0;
		break;
	case Opt_chk_data_crc:
		ctx->mount_opts.chk_data_crc = 2;
		ctx->no_chk_data_crc = 0;
		break;
	case Opt_no_chk_data_crc:
		ctx->mount_opts.chk_data_crc = 1;
		ctx->no_chk_data_crc = 1;
		break;
	case Opt_override_compr:
		ctx->mount_opts.compr_type = result.uint_32;
		ctx->mount_opts.override_compr = 1;
		ctx->default_compr = ctx->mount_opts.compr_type;
		break;
	case Opt_assert:
		ctx->assert_action = result.uint_32;
		break;
	case Opt_auth_key:
		if (!is_remount) {
			kfree(ctx->auth_key_name);
			ctx->auth_key_name = param->string;
			param->string = NULL;
		}
		break;
	case Opt_auth_hash_name:
		if (!is_remount) {
			kfree(ctx->auth_hash_name);
			ctx->auth_hash_name = param->string;
			param->string = NULL;
		}
		break;
	case Opt_ignore:
		break;
	}

	return 0;
}

/*
 * ubifs_release_options - release mount parameters which have been dumped.
 * @c: UBIFS file-system description object
 */

Annotation

Implementation Notes