fs/smb/client/cifs_swn.c

Source file repositories/reference/linux-study-clean/fs/smb/client/cifs_swn.c

File Facts

System
Linux kernel
Corpus path
fs/smb/client/cifs_swn.c
Extension
.c
Size
22808 bytes
Lines
877
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 cifs_swn_reg {
	int id;
	struct kref ref_count;

	const char *net_name;
	const char *share_name;
	bool net_name_notify;
	bool share_name_notify;
	bool ip_notify;
};

struct cifs_swn_reg_info {
	int id;
	unsigned int ref_count;
	const char *net_name;
	const char *share_name;
	bool net_name_notify;
	bool share_name_notify;
	bool ip_notify;
};

static void cifs_swn_snapshot_reg(struct cifs_swn_reg *swnreg,
				  struct cifs_swn_reg_info *info)
{
	info->id = swnreg->id;
	info->ref_count = kref_read(&swnreg->ref_count);
	info->net_name = swnreg->net_name;
	info->share_name = swnreg->share_name;
	info->net_name_notify = swnreg->net_name_notify;
	info->share_name_notify = swnreg->share_name_notify;
	info->ip_notify = swnreg->ip_notify;
}

static int cifs_swn_dup_reg(struct cifs_swn_reg *swnreg,
			    struct cifs_swn_reg_info *info)
{
	cifs_swn_snapshot_reg(swnreg, info);

	info->net_name = kstrdup(swnreg->net_name, GFP_KERNEL);
	if (!info->net_name)
		return -ENOMEM;

	info->share_name = kstrdup(swnreg->share_name, GFP_KERNEL);
	if (!info->share_name) {
		kfree(info->net_name);
		return -ENOMEM;
	}

	return 0;
}

static void cifs_swn_free_reg_info(struct cifs_swn_reg_info *info)
{
	kfree(info->net_name);
	kfree(info->share_name);
}

static int cifs_swn_auth_info_krb(struct cifs_tcon *tcon, struct sk_buff *skb)
{
	int ret;

	ret = nla_put_flag(skb, CIFS_GENL_ATTR_SWN_KRB_AUTH);
	if (ret < 0)
		return ret;

	return 0;
}

static int cifs_swn_auth_info_ntlm(struct cifs_tcon *tcon, struct sk_buff *skb)
{
	int ret;

	if (tcon->ses->user_name != NULL) {
		ret = nla_put_string(skb, CIFS_GENL_ATTR_SWN_USER_NAME, tcon->ses->user_name);
		if (ret < 0)
			return ret;
	}

	if (tcon->ses->password != NULL) {
		ret = nla_put_string(skb, CIFS_GENL_ATTR_SWN_PASSWORD, tcon->ses->password);
		if (ret < 0)
			return ret;
	}

	if (tcon->ses->domainName != NULL) {
		ret = nla_put_string(skb, CIFS_GENL_ATTR_SWN_DOMAIN_NAME, tcon->ses->domainName);
		if (ret < 0)
			return ret;
	}

Annotation

Implementation Notes