aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2007-11-16 17:22:06 -0500
committerSteve French <sfrench@us.ibm.com>2007-11-16 17:22:06 -0500
commitc359cf3c61c6ea9f4f461a8bd22023a15d75d9b5 (patch)
tree24abf7b5a77af5007ee9bdf30592775df4e66035 /fs
parent70fe7dc05596a405ee6a83265f675a544e32f7d8 (diff)
[CIFS] add hostname field to TCP_Server_Info struct
...and populate it with the hostname portion of the UNC string. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifsglob.h1
-rw-r--r--fs/cifs/connect.c36
2 files changed, 37 insertions, 0 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 4ff8179df7ec..3525082f5e58 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -139,6 +139,7 @@ struct TCP_Server_Info {
139 /* 15 character server name + 0x20 16th byte indicating type = srv */ 139 /* 15 character server name + 0x20 16th byte indicating type = srv */
140 char server_RFC1001_name[SERVER_NAME_LEN_WITH_NULL]; 140 char server_RFC1001_name[SERVER_NAME_LEN_WITH_NULL];
141 char unicode_server_Name[SERVER_NAME_LEN_WITH_NULL * 2]; 141 char unicode_server_Name[SERVER_NAME_LEN_WITH_NULL * 2];
142 char *hostname; /* hostname portion of UNC string */
142 struct socket *ssocket; 143 struct socket *ssocket;
143 union { 144 union {
144 struct sockaddr_in sockAddr; 145 struct sockaddr_in sockAddr;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 58c509e6ac6a..98ec57ff4d98 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -752,6 +752,7 @@ multi_t2_fnd:
752 } 752 }
753 write_unlock(&GlobalSMBSeslock); 753 write_unlock(&GlobalSMBSeslock);
754 754
755 kfree(server->hostname);
755 kfree(server); 756 kfree(server);
756 if (length > 0) 757 if (length > 0)
757 mempool_resize(cifs_req_poolp, length + cifs_min_rcv, 758 mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
@@ -760,6 +761,34 @@ multi_t2_fnd:
760 return 0; 761 return 0;
761} 762}
762 763
764/* extract the host portion of the UNC string */
765static char *
766extract_hostname(const char *unc)
767{
768 const char *src;
769 char *dst, *delim;
770 unsigned int len;
771
772 /* skip double chars at beginning of string */
773 /* BB: check validity of these bytes? */
774 src = unc + 2;
775
776 /* delimiter between hostname and sharename is always '\\' now */
777 delim = strchr(src, '\\');
778 if (!delim)
779 return ERR_PTR(-EINVAL);
780
781 len = delim - src;
782 dst = kmalloc((len + 1), GFP_KERNEL);
783 if (dst == NULL)
784 return ERR_PTR(-ENOMEM);
785
786 memcpy(dst, src, len);
787 dst[len] = '\0';
788
789 return dst;
790}
791
763static int 792static int
764cifs_parse_mount_options(char *options, const char *devname, 793cifs_parse_mount_options(char *options, const char *devname,
765 struct smb_vol *vol) 794 struct smb_vol *vol)
@@ -1900,6 +1929,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1900 /* BB Add code for ipv6 case too */ 1929 /* BB Add code for ipv6 case too */
1901 srvTcp->ssocket = csocket; 1930 srvTcp->ssocket = csocket;
1902 srvTcp->protocolType = IPV4; 1931 srvTcp->protocolType = IPV4;
1932 srvTcp->hostname = extract_hostname(volume_info.UNC);
1933 if (IS_ERR(srvTcp->hostname)) {
1934 rc = PTR_ERR(srvTcp->hostname);
1935 sock_release(csocket);
1936 goto out;
1937 }
1903 init_waitqueue_head(&srvTcp->response_q); 1938 init_waitqueue_head(&srvTcp->response_q);
1904 init_waitqueue_head(&srvTcp->request_q); 1939 init_waitqueue_head(&srvTcp->request_q);
1905 INIT_LIST_HEAD(&srvTcp->pending_mid_q); 1940 INIT_LIST_HEAD(&srvTcp->pending_mid_q);
@@ -1914,6 +1949,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1914 cERROR(1, ("error %d create cifsd thread", rc)); 1949 cERROR(1, ("error %d create cifsd thread", rc));
1915 srvTcp->tsk = NULL; 1950 srvTcp->tsk = NULL;
1916 sock_release(csocket); 1951 sock_release(csocket);
1952 kfree(srvTcp->hostname);
1917 goto out; 1953 goto out;
1918 } 1954 }
1919 wait_for_completion(&cifsd_complete); 1955 wait_for_completion(&cifsd_complete);