fs/dlm/config.c

Source file repositories/reference/linux-study-clean/fs/dlm/config.c

File Facts

System
Linux kernel
Corpus path
fs/dlm/config.c
Extension
.c
Size
24544 bytes
Lines
1054
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 dlm_cluster {
	struct config_group group;
	struct dlm_spaces *sps;
	struct dlm_comms *cms;
};

static struct dlm_cluster *config_item_to_cluster(struct config_item *i)
{
	return i ? container_of(to_config_group(i), struct dlm_cluster, group) :
		   NULL;
}

enum {
	CLUSTER_ATTR_TCP_PORT = 0,
	CLUSTER_ATTR_BUFFER_SIZE,
	CLUSTER_ATTR_RSBTBL_SIZE,
	CLUSTER_ATTR_RECOVER_TIMER,
	CLUSTER_ATTR_TOSS_SECS,
	CLUSTER_ATTR_SCAN_SECS,
	CLUSTER_ATTR_LOG_DEBUG,
	CLUSTER_ATTR_LOG_INFO,
	CLUSTER_ATTR_PROTOCOL,
	CLUSTER_ATTR_MARK,
	CLUSTER_ATTR_NEW_RSB_COUNT,
	CLUSTER_ATTR_RECOVER_CALLBACKS,
	CLUSTER_ATTR_CLUSTER_NAME,
};

static ssize_t cluster_cluster_name_show(struct config_item *item, char *buf)
{
	return sprintf(buf, "%s\n", dlm_config.ci_cluster_name);
}

static ssize_t cluster_cluster_name_store(struct config_item *item,
					  const char *buf, size_t len)
{
	strscpy(dlm_config.ci_cluster_name, buf,
		sizeof(dlm_config.ci_cluster_name));
	return len;
}

CONFIGFS_ATTR(cluster_, cluster_name);

static ssize_t cluster_tcp_port_show(struct config_item *item, char *buf)
{
	return sprintf(buf, "%u\n", be16_to_cpu(dlm_config.ci_tcp_port));
}

static int dlm_check_zero_and_dlm_running(unsigned int x)
{
	if (!x)
		return -EINVAL;

	if (dlm_lowcomms_is_running())
		return -EBUSY;

	return 0;
}

static ssize_t cluster_tcp_port_store(struct config_item *item,
				      const char *buf, size_t len)
{
	int rc;
	u16 x;

	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;

	rc = kstrtou16(buf, 0, &x);
	if (rc)
		return rc;

	rc = dlm_check_zero_and_dlm_running(x);
	if (rc)
		return rc;

	dlm_config.ci_tcp_port = cpu_to_be16(x);
	return len;
}

CONFIGFS_ATTR(cluster_, tcp_port);

static ssize_t cluster_set(unsigned int *info_field,
			   int (*check_cb)(unsigned int x),
			   const char *buf, size_t len)
{
	unsigned int x;
	int rc;

	if (!capable(CAP_SYS_ADMIN))

Annotation

Implementation Notes