Storage class should be before const qualifier
[deliverable/linux.git] / fs / cifs / cifssmb.c
index 8d30a5c4f244db91dd8e578f4f927774fbed55b1..24364106b8f9d6883bc1dd6d29975bc22b50e5f8 100644 (file)
@@ -158,9 +158,15 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
                                                        nls_codepage);
                        if(!rc && (tcon->tidStatus == CifsNeedReconnect)) {
                                mark_open_files_invalid(tcon);
-                               rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon
-                                       , nls_codepage);
+                               rc = CIFSTCon(0, tcon->ses, tcon->treeName, 
+                                             tcon, nls_codepage);
                                up(&tcon->ses->sesSem);
+                               /* tell server which Unix caps we support */
+                               if (tcon->ses->capabilities & CAP_UNIX)
+                                       reset_cifs_unix_caps(0 /* no xid */,
+                                               tcon, 
+                                               NULL /* we do not know sb */,
+                                               NULL /* no vol info */);        
                                /* BB FIXME add code to check if wsize needs
                                   update due to negotiated smb buffer size
                                   shrinking */
@@ -298,6 +304,12 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
                                rc = CIFSTCon(0, tcon->ses, tcon->treeName,
                                              tcon, nls_codepage);
                                up(&tcon->ses->sesSem);
+                               /* tell server which Unix caps we support */
+                               if (tcon->ses->capabilities & CAP_UNIX)
+                                       reset_cifs_unix_caps(0 /* no xid */,
+                                               tcon, 
+                                               NULL /* do not know sb */,
+                                               NULL /* no vol info */);
                                /* BB FIXME add code to check if wsize needs
                                update due to negotiated smb buffer size
                                shrinking */
@@ -399,6 +411,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
        struct TCP_Server_Info * server;
        u16 count;
        unsigned int secFlags;
+       u16 dialect;
 
        if(ses->server)
                server = ses->server;
@@ -438,9 +451,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
        if (rc != 0) 
                goto neg_err_exit;
 
-       cFYI(1,("Dialect: %d", pSMBr->DialectIndex));
+       dialect = le16_to_cpu(pSMBr->DialectIndex);
+       cFYI(1,("Dialect: %d", dialect));
        /* Check wct = 1 error case */
-       if((pSMBr->hdr.WordCount < 13) || (pSMBr->DialectIndex == BAD_PROT)) {
+       if((pSMBr->hdr.WordCount < 13) || (dialect == BAD_PROT)) {
                /* core returns wct = 1, but we do not ask for core - otherwise
                small wct just comes when dialect index is -1 indicating we 
                could not negotiate a common dialect */
@@ -448,8 +462,8 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
                goto neg_err_exit;
 #ifdef CONFIG_CIFS_WEAK_PW_HASH 
        } else if((pSMBr->hdr.WordCount == 13)
-                       && ((pSMBr->DialectIndex == LANMAN_PROT)
-                               || (pSMBr->DialectIndex == LANMAN2_PROT))) {
+                       && ((dialect == LANMAN_PROT)
+                               || (dialect == LANMAN2_PROT))) {
                __s16 tmp;
                struct lanman_neg_rsp * rsp = (struct lanman_neg_rsp *)pSMBr;
 
@@ -477,7 +491,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
                        server->capabilities = CAP_MPX_MODE;
                }
                tmp = (__s16)le16_to_cpu(rsp->ServerTimeZone);
-               if (tmp == 0xffff) {
+               if (tmp == -1) {
                        /* OS/2 often does not set timezone therefore
                         * we must use server time to calc time zone.
                         * Could deviate slightly from the right zone.
@@ -495,7 +509,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
                                (int)(utc.tv_sec - ts.tv_sec)));
                        val = (int)(utc.tv_sec - ts.tv_sec);
                        seconds = val < 0 ? -val : val;
-                       result = (seconds / IN_TZ_ADJ) * MIN_TZ_ADJ;
+                       result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ;
                        remain = seconds % MIN_TZ_ADJ;
                        if(remain >= (MIN_TZ_ADJ / 2))
                                result += MIN_TZ_ADJ;
@@ -2810,10 +2824,10 @@ GetExtAttrOut:
 
 
 /* security id for everyone */
-const static struct cifs_sid sid_everyone = 
+static const struct cifs_sid sid_everyone =
                {1, 1, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0}};
 /* group users */
-const static struct cifs_sid sid_user = 
+static const struct cifs_sid sid_user =
                {1, 2 , {0, 0, 0, 0, 0, 5}, {32, 545, 0, 0}};
 
 /* Convert CIFS ACL to POSIX form */
@@ -2943,7 +2957,7 @@ QInfRetry:
                ts.tv_nsec = 0;
                ts.tv_sec = time;
                /* decode time fields */
-               pFinfo->ChangeTime = cifs_UnixTimeToNT(ts);
+               pFinfo->ChangeTime = cpu_to_le64(cifs_UnixTimeToNT(ts));
                pFinfo->LastWriteTime = pFinfo->ChangeTime;
                pFinfo->LastAccessTime = 0;
                pFinfo->AllocationSize =
@@ -2969,6 +2983,7 @@ int
 CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
                 const unsigned char *searchName,
                 FILE_ALL_INFO * pFindData,
+                int legacy /* old style infolevel */,
                 const struct nls_table *nls_codepage, int remap)
 {
 /* level 263 SMB_QUERY_FILE_ALL_INFO */
@@ -3017,7 +3032,10 @@ QPathInfoRetry:
        byte_count = params + 1 /* pad */ ;
        pSMB->TotalParameterCount = cpu_to_le16(params);
        pSMB->ParameterCount = pSMB->TotalParameterCount;
-       pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO);
+       if(legacy)
+               pSMB->InformationLevel = cpu_to_le16(SMB_INFO_STANDARD);
+       else
+               pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO);
        pSMB->Reserved4 = 0;
        pSMB->hdr.smb_buf_length += byte_count;
        pSMB->ByteCount = cpu_to_le16(byte_count);
@@ -3029,13 +3047,24 @@ QPathInfoRetry:
        } else {                /* decode response */
                rc = validate_t2((struct smb_t2_rsp *)pSMBr);
 
-               if (rc || (pSMBr->ByteCount < 40)) 
+               if (rc) /* BB add auto retry on EOPNOTSUPP? */
+                       rc = -EIO;
+               else if (!legacy && (pSMBr->ByteCount < 40)) 
                        rc = -EIO;      /* bad smb */
+               else if(legacy && (pSMBr->ByteCount < 24))
+                       rc = -EIO;  /* 24 or 26 expected but we do not read last field */
                else if (pFindData){
+                       int size;
                        __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
+                       if(legacy) /* we do not read the last field, EAsize, fortunately
+                                          since it varies by subdialect and on Set vs. Get, is  
+                                          two bytes or 4 bytes depending but we don't care here */
+                               size = sizeof(FILE_INFO_STANDARD);
+                       else
+                               size = sizeof(FILE_ALL_INFO);
                        memcpy((char *) pFindData,
                               (char *) &pSMBr->hdr.Protocol +
-                              data_offset, sizeof (FILE_ALL_INFO));
+                              data_offset, size);
                } else
                    rc = -ENOMEM;
        }
@@ -3660,6 +3689,14 @@ getDFSRetry:
                strncpy(pSMB->RequestFileName, searchName, name_len);
        }
 
+       if(ses->server) {
+               if(ses->server->secMode &
+                  (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
+                       pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
+       }
+
+        pSMB->hdr.Uid = ses->Suid;
+
        params = 2 /* level */  + name_len /*includes null */ ;
        pSMB->TotalDataCount = 0;
        pSMB->DataCount = 0;
@@ -4851,7 +4888,7 @@ int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
        } else {
                /* Add file to outstanding requests */
                /* BB change to kmem cache alloc */     
-               dnotify_req = (struct dir_notify_req *) kmalloc(
+               dnotify_req = kmalloc(
                                                sizeof(struct dir_notify_req),
                                                 GFP_KERNEL);
                if(dnotify_req) {
This page took 0.034134 seconds and 5 git commands to generate.