fs/autofs/inode.c

Source file repositories/reference/linux-study-clean/fs/autofs/inode.c

File Facts

System
Linux kernel
Corpus path
fs/autofs/inode.c
Extension
.c
Size
10290 bytes
Lines
456
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 autofs_fs_context {
	kuid_t	uid;
	kgid_t	gid;
	int	pgrp;
	bool	pgrp_set;
};

/*
 * Open the fd.  We do it here rather than in get_tree so that it's done in the
 * context of the system call that passed the data and not the one that
 * triggered the superblock creation, lest the fd gets reassigned.
 */
static int autofs_parse_fd(struct fs_context *fc, struct autofs_sb_info *sbi,
			   struct fs_parameter *param,
			   struct fs_parse_result *result)
{
	struct file *pipe;
	int ret;

	if (param->type == fs_value_is_file) {
		/* came through the new api */
		pipe = param->file;
		param->file = NULL;
	} else {
		pipe = fget(result->uint_32);
	}
	if (!pipe) {
		errorf(fc, "could not open pipe file descriptor");
		return -EBADF;
	}

	ret = autofs_check_pipe(pipe);
	if (ret < 0) {
		errorf(fc, "Invalid/unusable pipe");
		fput(pipe);
		return -EBADF;
	}

	autofs_set_packet_pipe_flags(pipe);

	if (sbi->pipe)
		fput(sbi->pipe);

	sbi->pipefd = result->uint_32;
	sbi->pipe = pipe;

	return 0;
}

static int autofs_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
	struct autofs_fs_context *ctx = fc->fs_private;
	struct autofs_sb_info *sbi = fc->s_fs_info;
	struct fs_parse_result result;
	int opt;

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

	switch (opt) {
	case Opt_fd:
		return autofs_parse_fd(fc, sbi, param, &result);
	case Opt_uid:
		ctx->uid = result.uid;
		break;
	case Opt_gid:
		ctx->gid = result.gid;
		break;
	case Opt_pgrp:
		ctx->pgrp = result.uint_32;
		ctx->pgrp_set = true;
		break;
	case Opt_minproto:
		sbi->min_proto = result.uint_32;
		break;
	case Opt_maxproto:
		sbi->max_proto = result.uint_32;
		break;
	case Opt_indirect:
		set_autofs_type_indirect(&sbi->type);
		break;
	case Opt_direct:
		set_autofs_type_direct(&sbi->type);
		break;
	case Opt_offset:
		set_autofs_type_offset(&sbi->type);
		break;
	case Opt_strictexpire:
		sbi->flags |= AUTOFS_SBI_STRICTEXPIRE;

Annotation

Implementation Notes