cifs: Make extract_hostname function public
Move the function to misc.c and give it a public header. Signed-off-by: Samuel Cabrero <scabrero@suse.de> Reviewed-by: Aurelien Aptel <aaptel@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
parent
a2a52a8a36
commit
a87e67254b
|
@ -617,6 +617,7 @@ int smb2_parse_query_directory(struct cifs_tcon *tcon, struct kvec *rsp_iov,
|
||||||
struct super_block *cifs_get_tcp_super(struct TCP_Server_Info *server);
|
struct super_block *cifs_get_tcp_super(struct TCP_Server_Info *server);
|
||||||
void cifs_put_tcp_super(struct super_block *sb);
|
void cifs_put_tcp_super(struct super_block *sb);
|
||||||
int update_super_prepath(struct cifs_tcon *tcon, char *prefix);
|
int update_super_prepath(struct cifs_tcon *tcon, char *prefix);
|
||||||
|
char *extract_hostname(const char *unc);
|
||||||
|
|
||||||
#ifdef CONFIG_CIFS_DFS_UPCALL
|
#ifdef CONFIG_CIFS_DFS_UPCALL
|
||||||
static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,
|
static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,
|
||||||
|
|
|
@ -77,7 +77,6 @@ static int ip_connect(struct TCP_Server_Info *server);
|
||||||
static int generic_ip_connect(struct TCP_Server_Info *server);
|
static int generic_ip_connect(struct TCP_Server_Info *server);
|
||||||
static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink);
|
static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink);
|
||||||
static void cifs_prune_tlinks(struct work_struct *work);
|
static void cifs_prune_tlinks(struct work_struct *work);
|
||||||
static char *extract_hostname(const char *unc);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Resolve hostname and set ip addr in tcp ses. Useful for hostnames that may
|
* Resolve hostname and set ip addr in tcp ses. Useful for hostnames that may
|
||||||
|
@ -1025,39 +1024,6 @@ next_pdu:
|
||||||
module_put_and_exit(0);
|
module_put_and_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extract the host portion of the UNC string */
|
|
||||||
static char *
|
|
||||||
extract_hostname(const char *unc)
|
|
||||||
{
|
|
||||||
const char *src;
|
|
||||||
char *dst, *delim;
|
|
||||||
unsigned int len;
|
|
||||||
|
|
||||||
/* skip double chars at beginning of string */
|
|
||||||
/* BB: check validity of these bytes? */
|
|
||||||
if (strlen(unc) < 3)
|
|
||||||
return ERR_PTR(-EINVAL);
|
|
||||||
for (src = unc; *src && *src == '\\'; src++)
|
|
||||||
;
|
|
||||||
if (!*src)
|
|
||||||
return ERR_PTR(-EINVAL);
|
|
||||||
|
|
||||||
/* delimiter between hostname and sharename is always '\\' now */
|
|
||||||
delim = strchr(src, '\\');
|
|
||||||
if (!delim)
|
|
||||||
return ERR_PTR(-EINVAL);
|
|
||||||
|
|
||||||
len = delim - src;
|
|
||||||
dst = kmalloc((len + 1), GFP_KERNEL);
|
|
||||||
if (dst == NULL)
|
|
||||||
return ERR_PTR(-ENOMEM);
|
|
||||||
|
|
||||||
memcpy(dst, src, len);
|
|
||||||
dst[len] = '\0';
|
|
||||||
|
|
||||||
return dst;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns true if srcaddr isn't specified and rhs isn't
|
/** Returns true if srcaddr isn't specified and rhs isn't
|
||||||
* specified, or if srcaddr is specified and
|
* specified, or if srcaddr is specified and
|
||||||
* matches the IP address of the rhs argument.
|
* matches the IP address of the rhs argument.
|
||||||
|
|
|
@ -1195,3 +1195,35 @@ out:
|
||||||
cifs_put_tcon_super(sb);
|
cifs_put_tcon_super(sb);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* extract the host portion of the UNC string */
|
||||||
|
char *extract_hostname(const char *unc)
|
||||||
|
{
|
||||||
|
const char *src;
|
||||||
|
char *dst, *delim;
|
||||||
|
unsigned int len;
|
||||||
|
|
||||||
|
/* skip double chars at beginning of string */
|
||||||
|
/* BB: check validity of these bytes? */
|
||||||
|
if (strlen(unc) < 3)
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
for (src = unc; *src && *src == '\\'; src++)
|
||||||
|
;
|
||||||
|
if (!*src)
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
|
/* delimiter between hostname and sharename is always '\\' now */
|
||||||
|
delim = strchr(src, '\\');
|
||||||
|
if (!delim)
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
|
len = delim - src;
|
||||||
|
dst = kmalloc((len + 1), GFP_KERNEL);
|
||||||
|
if (dst == NULL)
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
|
memcpy(dst, src, len);
|
||||||
|
dst[len] = '\0';
|
||||||
|
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue