Author: sfrench
Date: 2006-10-02 06:05:44 +0000 (Mon, 02 Oct 2006)
New Revision: 92

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=linux-cifs-client&rev=92

Log:
Merge latest fix from GK

Modified:
   branches/linux-converged-for-old-kernels/fs/cifs/cifsfs.h
   branches/linux-converged-for-old-kernels/fs/cifs/cifspdu.h
   branches/linux-converged-for-old-kernels/fs/cifs/cifssmb.c


Changeset:
Modified: branches/linux-converged-for-old-kernels/fs/cifs/cifsfs.h
===================================================================
--- branches/linux-converged-for-old-kernels/fs/cifs/cifsfs.h   2006-10-02 
06:04:39 UTC (rev 91)
+++ branches/linux-converged-for-old-kernels/fs/cifs/cifsfs.h   2006-10-02 
06:05:44 UTC (rev 92)
@@ -97,10 +97,10 @@
 extern struct inode_operations cifs_symlink_inode_ops;
 
 /* Functions related to files and directories */
-extern struct file_operations cifs_file_ops;
-extern struct file_operations cifs_file_direct_ops; /* if directio mount */
-extern struct file_operations cifs_file_nobrl_ops;
-extern struct file_operations cifs_file_direct_nobrl_ops; /* if directio mount 
*/
+extern const struct file_operations cifs_file_ops;
+extern const struct file_operations cifs_file_direct_ops; /* if directio mount 
*/
+extern const struct file_operations cifs_file_nobrl_ops;
+extern const struct file_operations cifs_file_direct_nobrl_ops; /* if directio 
mount */
 extern int cifs_open(struct inode *inode, struct file *file);
 extern int cifs_close(struct inode *inode, struct file *file);
 extern int cifs_closedir(struct inode *inode, struct file *file);
@@ -112,7 +112,7 @@
 extern int cifs_fsync(struct file *, struct dentry *, int);
 extern int cifs_flush(struct file *);
 extern int cifs_file_mmap(struct file * , struct vm_area_struct *);
-extern struct file_operations cifs_dir_ops;
+extern const struct file_operations cifs_dir_ops;
 extern int cifs_dir_open(struct inode *inode, struct file *file);
 extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir);
 extern int cifs_dir_notify(struct file *, unsigned long arg);

Modified: branches/linux-converged-for-old-kernels/fs/cifs/cifspdu.h
===================================================================
--- branches/linux-converged-for-old-kernels/fs/cifs/cifspdu.h  2006-10-02 
06:04:39 UTC (rev 91)
+++ branches/linux-converged-for-old-kernels/fs/cifs/cifspdu.h  2006-10-02 
06:05:44 UTC (rev 92)
@@ -418,6 +418,8 @@
 
 /* Dialect index is 13 for LANMAN */
 
+#define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
+
 typedef struct lanman_neg_rsp {
        struct smb_hdr hdr;     /* wct = 13 */
        __le16 DialectIndex;
@@ -687,7 +689,7 @@
 typedef struct smb_com_close_req {
        struct smb_hdr hdr;     /* wct = 3 */
        __u16 FileID;
-       __u32 LastWriteTime;    /* should be zero */
+       __u32 LastWriteTime;    /* should be zero or -1 */
        __u16 ByteCount;        /* 0 */
 } __attribute__((packed)) CLOSE_REQ;
 

Modified: branches/linux-converged-for-old-kernels/fs/cifs/cifssmb.c
===================================================================
--- branches/linux-converged-for-old-kernels/fs/cifs/cifssmb.c  2006-10-02 
06:04:39 UTC (rev 91)
+++ branches/linux-converged-for-old-kernels/fs/cifs/cifssmb.c  2006-10-02 
06:05:44 UTC (rev 92)
@@ -477,7 +477,7 @@
        } else if((pSMBr->hdr.WordCount == 13)
                        && ((pSMBr->DialectIndex == LANMAN_PROT)
                                || (pSMBr->DialectIndex == LANMAN2_PROT))) {
-               int tmp, adjust;
+               __s16 tmp;
                struct lanman_neg_rsp * rsp = (struct lanman_neg_rsp *)pSMBr;
 
                if((secFlags & CIFSSEC_MAY_LANMAN) || 
@@ -503,14 +503,16 @@
                        server->maxRw = 0;/* we do not need to use raw anyway */
                        server->capabilities = CAP_MPX_MODE;
                }
-               tmp = le16_to_cpu(rsp->ServerTimeZone);
-               if (tmp == (int)0xffff) {
+               tmp = (__s16)le16_to_cpu(rsp->ServerTimeZone);
+               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. Not easy
-                        * to adjust, since timezones are not always a multiple
-                        * of 60 (sometimes 30 minutes - are there smaller?)
+                        * Could deviate slightly from the right zone.
+                        * Smallest defined timezone difference is 15 minutes
+                        * (i.e. Nepal).  Rounding up/down is done to match
+                        * this requirement.
                         */
+                       int val, seconds, remain, result;
                        struct timespec ts, utc;
                        utc = CURRENT_TIME;
                        ts = cnvrtDosUnixTm(le16_to_cpu(rsp->SrvTime.Date),
@@ -518,12 +520,18 @@
                        cFYI(1,("SrvTime: %d sec since 1970 (utc: %d) diff: %d",
                                (int)ts.tv_sec, (int)utc.tv_sec,
                                (int)(utc.tv_sec - ts.tv_sec)));
-                       tmp = (int)(utc.tv_sec - ts.tv_sec);
-                       adjust = tmp < 0 ? -29 : 29;
-                       tmp = ((tmp + adjust) / 60) * 60;
-                       server->timeAdj = tmp;
+                       val = (int)(utc.tv_sec - ts.tv_sec);
+                       seconds = val < 0 ? -val : val;
+                       result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ;
+                       remain = seconds % MIN_TZ_ADJ;
+                       if(remain >= (MIN_TZ_ADJ / 2))
+                               result += MIN_TZ_ADJ;
+                       if(val < 0)
+                               result = - result;
+                       server->timeAdj = result;
                } else {
-                       server->timeAdj = tmp * 60; /* also in seconds */
+                       server->timeAdj = (int)tmp;
+                       server->timeAdj *= 60; /* also in seconds */
                }
                cFYI(1,("server->timeAdj: %d seconds", server->timeAdj));
 
@@ -586,7 +594,8 @@
        cFYI(0, ("Max buf = %d", ses->server->maxBuf));
        GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
        server->capabilities = le32_to_cpu(pSMBr->Capabilities);
-       server->timeAdj = le16_to_cpu(pSMBr->ServerTimeZone) * 60;      
+       server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone);
+       server->timeAdj *= 60;
        if (pSMBr->EncryptionKeyLength == CIFS_CRYPTO_KEY_SIZE) {
                memcpy(server->cryptKey, pSMBr->u.EncryptionKey,
                       CIFS_CRYPTO_KEY_SIZE);
@@ -1672,7 +1681,7 @@
        pSMBr = (CLOSE_RSP *)pSMB; /* BB removeme BB */
 
        pSMB->FileID = (__u16) smb_file_id;
-       pSMB->LastWriteTime = 0;
+       pSMB->LastWriteTime = 0xFFFFFFFF;
        pSMB->ByteCount = 0;
        rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
                         (struct smb_hdr *) pSMBr, &bytes_returned, 0);

Reply via email to