]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
CIFS: Move protocol specific session setup/logoff code to ops struct
authorPavel Shilovsky <pshilovsky@samba.org>
Fri, 25 May 2012 06:54:49 +0000 (10:54 +0400)
committerSteve French <smfrench@gmail.com>
Tue, 24 Jul 2012 15:25:03 +0000 (10:25 -0500)
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/cifsglob.h
fs/cifs/cifsproto.h
fs/cifs/cifssmb.c
fs/cifs/connect.c
fs/cifs/sess.c
fs/cifs/smb1ops.c

index 8a4150573cf819bd2c4e153d25d3a11f04cb030a..a6eb9befdb2daa16ba372469b6aa087c2ef563a6 100644 (file)
@@ -196,6 +196,11 @@ struct smb_version_operations {
        bool (*need_neg)(struct TCP_Server_Info *);
        /* negotiate to the server */
        int (*negotiate)(const unsigned int, struct cifs_ses *);
+       /* setup smb sessionn */
+       int (*sess_setup)(const unsigned int, struct cifs_ses *,
+                         const struct nls_table *);
+       /* close smb session */
+       int (*logoff)(const unsigned int, struct cifs_ses *);
 };
 
 struct smb_version_values {
index 723a3273c6bb92875fbe04e421eaf8c539046b87..a17be2618473c697d7e2d82e84fd41ca271963e4 100644 (file)
@@ -112,8 +112,8 @@ extern void header_assemble(struct smb_hdr *, char /* command */ ,
 extern int small_smb_init_no_tc(const int smb_cmd, const int wct,
                                struct cifs_ses *ses,
                                void **request_buf);
-extern int CIFS_SessSetup(unsigned int xid, struct cifs_ses *ses,
-                            const struct nls_table *nls_cp);
+extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
+                         const struct nls_table *nls_cp);
 extern struct timespec cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
 extern u64 cifs_UnixTimeToNT(struct timespec);
 extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
@@ -180,8 +180,8 @@ void cifs_proc_clean(void);
 
 extern int cifs_negotiate_protocol(const unsigned int xid,
                                   struct cifs_ses *ses);
-extern int cifs_setup_session(unsigned int xid, struct cifs_ses *ses,
-                       struct nls_table *nls_info);
+extern int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
+                             struct nls_table *nls_info);
 extern int CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses);
 
 extern int CIFSTCon(unsigned int xid, struct cifs_ses *ses,
@@ -391,7 +391,7 @@ extern int CIFSSMBPosixLock(const int xid, struct cifs_tcon *tcon,
                        const bool waitFlag);
 extern int CIFSSMBTDis(const int xid, struct cifs_tcon *tcon);
 extern int CIFSSMBEcho(struct TCP_Server_Info *server);
-extern int CIFSSMBLogoff(const int xid, struct cifs_ses *ses);
+extern int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses);
 
 extern struct cifs_ses *sesInfoAlloc(void);
 extern void sesInfoFree(struct cifs_ses *);
index ae59d6e4e4f5cb417d2b2f29a887f4962615aa8b..915b8fc212e9af788d7ce28fb04b8c7647336056 100644 (file)
@@ -781,7 +781,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server)
 }
 
 int
-CIFSSMBLogoff(const int xid, struct cifs_ses *ses)
+CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses)
 {
        LOGOFF_ANDX_REQ *pSMB;
        int rc = 0;
index 03389f59390fbd815ece51bb3c399ae26d1f8829..444243d9232b475f52c8d4fa5d6d33416370d8b6 100644 (file)
@@ -2253,7 +2253,7 @@ cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb_vol *vol)
 static void
 cifs_put_smb_ses(struct cifs_ses *ses)
 {
-       int xid;
+       unsigned int xid;
        struct TCP_Server_Info *server = ses->server;
 
        cFYI(1, "%s: ses_count=%d", __func__, ses->ses_count);
@@ -2266,9 +2266,9 @@ cifs_put_smb_ses(struct cifs_ses *ses)
        list_del_init(&ses->smb_ses_list);
        spin_unlock(&cifs_tcp_ses_lock);
 
-       if (ses->status == CifsGood) {
+       if (ses->status == CifsGood && server->ops->logoff) {
                xid = GetXid();
-               CIFSSMBLogoff(xid, ses);
+               server->ops->logoff(xid, ses);
                _FreeXid(xid);
        }
        sesInfoFree(ses);
@@ -3989,11 +3989,11 @@ cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses)
        return rc;
 }
 
-
-int cifs_setup_session(unsigned int xid, struct cifs_ses *ses,
-                       struct nls_table *nls_info)
+int
+cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
+                  struct nls_table *nls_info)
 {
-       int rc = 0;
+       int rc = -ENOSYS;
        struct TCP_Server_Info *server = ses->server;
 
        ses->flags = 0;
@@ -4004,7 +4004,9 @@ int cifs_setup_session(unsigned int xid, struct cifs_ses *ses,
        cFYI(1, "Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d",
                 server->sec_mode, server->capabilities, server->timeAdj);
 
-       rc = CIFS_SessSetup(xid, ses, nls_info);
+       if (server->ops->sess_setup)
+               rc = server->ops->sess_setup(xid, ses, nls_info);
+
        if (rc) {
                cERROR(1, "Send error in SessSetup = %d", rc);
        } else {
index 3ba3f3cd2397f260c04459c88e1a507c3311121b..08efc3c8efef423487f1ebe26a8ef5fc1695d062 100644 (file)
@@ -556,7 +556,7 @@ setup_ntlmv2_ret:
 }
 
 int
-CIFS_SessSetup(unsigned int xid, struct cifs_ses *ses,
+CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
               const struct nls_table *nls_cp)
 {
        int rc = 0;
index ea4fb8aaaafb2d7da71746f49efd506fb5b65ae6..6b0a5d61633801c9ee713f93c17702863ea8360a 100644 (file)
@@ -430,6 +430,8 @@ struct smb_version_operations smb1_operations = {
        .check_trans2 = cifs_check_trans2,
        .need_neg = cifs_need_neg,
        .negotiate = cifs_negotiate,
+       .sess_setup = CIFS_SessSetup,
+       .logoff = CIFSSMBLogoff,
 };
 
 struct smb_version_values smb1_values = {