ChangeSet 1.2192, 2005/03/21 22:32:17-06:00, [EMAIL PROTECTED](none)

        [CIFS] Fix NT4 attribute setting
        
        Signed-off-by: Steve French ([EMAIL PROTECTED])



 cifsglob.h |    3 +++
 connect.c  |   17 ++++++++++++-----
 inode.c    |   23 ++++++++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)


diff -Nru a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
--- a/fs/cifs/cifsglob.h        2005-03-30 12:08:48 -08:00
+++ b/fs/cifs/cifsglob.h        2005-03-30 12:08:48 -08:00
@@ -176,6 +176,7 @@
        enum statusEnum status;
        __u32 sequence_number;  /* needed for CIFS PDU signature */
        __u16 ipc_tid;          /* special tid for connection to IPC share */
+       __u16 flags;
        char mac_signing_key[CIFS_SESSION_KEY_SIZE + 16];       
        char *serverOS;         /* name of operating system underlying the 
server */
        char *serverNOS;        /* name of network operating system that the 
server is running */
@@ -188,6 +189,8 @@
        char domainName[MAX_USERNAME_SIZE + 1];
        char * password;
 };
+/* session flags */
+#define CIFS_SES_NT4 1
 
 /*
  * there is one of these for each connection to a resource on a particular
diff -Nru a/fs/cifs/connect.c b/fs/cifs/connect.c
--- a/fs/cifs/connect.c 2005-03-30 12:08:48 -08:00
+++ b/fs/cifs/connect.c 2005-03-30 12:08:48 -08:00
@@ -1580,7 +1580,8 @@
        if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | 
SECMODE_SIGN_ENABLED))
                smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
 
-       capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | 
CAP_LARGE_WRITE_X | CAP_LARGE_READ_X;
+       capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
+               CAP_LARGE_WRITE_X | CAP_LARGE_READ_X;
        if (ses->capabilities & CAP_UNICODE) {
                smb_buffer->Flags2 |= SMBFLG2_UNICODE;
                capabilities |= CAP_UNICODE;
@@ -1607,7 +1608,7 @@
        bcc_ptr += CIFS_SESSION_KEY_SIZE;
 
        if (ses->capabilities & CAP_UNICODE) {
-               if ((long) bcc_ptr % 2) {       /* must be word aligned for 
Unicode */
+               if ((long) bcc_ptr % 2) { /* must be word aligned for Unicode */
                        *bcc_ptr = 0;
                        bcc_ptr++;
                }
@@ -1617,7 +1618,8 @@
                        bytes_returned =
                                cifs_strtoUCS((wchar_t *) bcc_ptr, user, 100,
                                        nls_codepage);
-               bcc_ptr += 2 * bytes_returned;  /* convert num 16 bit words to 
bytes */
+               /* convert number of 16 bit words to bytes */
+               bcc_ptr += 2 * bytes_returned;
                bcc_ptr += 2;   /* trailing null */
                if (domain == NULL)
                        bytes_returned =
@@ -1634,8 +1636,8 @@
                                  32, nls_codepage);
                bcc_ptr += 2 * bytes_returned;
                bytes_returned =
-                   cifs_strtoUCS((wchar_t *) bcc_ptr, system_utsname.release, 
32,
-                                 nls_codepage);
+                   cifs_strtoUCS((wchar_t *) bcc_ptr, system_utsname.release,
+                                 32, nls_codepage);
                bcc_ptr += 2 * bytes_returned;
                bcc_ptr += 2;
                bytes_returned =
@@ -1721,6 +1723,11 @@
                                        bcc_ptr += 2 * (len + 1);
                                        ses->serverNOS[2 * len] = 0;
                                        ses->serverNOS[1 + (2 * len)] = 0;
+                                       if(strncmp(ses->serverNOS,
+                                               "NT LAN Manager 4",16) == 0) {
+                                               cFYI(1,("NT4 server"));
+                                               ses->flags |= CIFS_SES_NT4;
+                                       }
                                        remaining_words -= len + 1;
                                        if (remaining_words > 0) {
                                                len = UniStrnlen((wchar_t *) 
bcc_ptr, remaining_words); 
diff -Nru a/fs/cifs/inode.c b/fs/cifs/inode.c
--- a/fs/cifs/inode.c   2005-03-30 12:08:48 -08:00
+++ b/fs/cifs/inode.c   2005-03-30 12:08:48 -08:00
@@ -423,8 +423,12 @@
                        memset(pinfo_buf,0,sizeof(FILE_BASIC_INFO));        
                /* ATTRS set to normal clears r/o bit */
                        pinfo_buf->Attributes = cpu_to_le32(ATTR_NORMAL);
-                       rc = CIFSSMBSetTimes(xid, pTcon, full_path, pinfo_buf,
-                               cifs_sb->local_nls);
+                       if(!(pTcon->ses->flags & CIFS_SES_NT4))
+                               rc = CIFSSMBSetTimes(xid, pTcon, full_path,
+                                       pinfo_buf, cifs_sb->local_nls);
+                       else
+                               rc = -EOPNOTSUPP;
+
                        if(rc == -EOPNOTSUPP) {
                                int oplock = FALSE;
                                __u16 netfid;
@@ -438,9 +442,9 @@
                        /* BB could scan to see if we already have it open */
                        /* and pass in pid of opener to function */
                                rc = CIFSSMBOpen(xid, pTcon, full_path,
-                                               FILE_OPEN,
-                                               FILE_WRITE_ATTRIBUTES,
-                                               CREATE_NOT_DIR, &netfid,
+                                               FILE_OPEN, SYNCHRONIZE |
+                                                FILE_WRITE_ATTRIBUTES,
+                                               0, &netfid,
                                                &oplock, NULL,
                                                cifs_sb->local_nls);
                                if(rc==0) {
@@ -1011,8 +1015,12 @@
                time_buf.CreationTime = 0;      /* do not change */
                /* In the future we should experiment - try setting timestamps
                         via Handle (SetFileInfo) instead of by path */
-               rc = CIFSSMBSetTimes(xid, pTcon, full_path, &time_buf,
+               if(!(pTcon->ses->flags & CIFS_SES_NT4))
+                       rc = CIFSSMBSetTimes(xid, pTcon, full_path, &time_buf,
                                cifs_sb->local_nls);
+               else
+                       rc = -EOPNOTSUPP;
+
                if(rc == -EOPNOTSUPP) {
                        int oplock = FALSE;
                        __u16 netfid;
@@ -1020,7 +1028,8 @@
                        cFYI(1,("calling SetFileInfo since SetPathInfo for 
times not supported by this server"));
                    /* BB we could scan to see if we already have it open */
                    /* and pass in pid of opener to function */
-                       rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, 
FILE_WRITE_ATTRIBUTES,
+                       rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, 
+                               SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,
                                CREATE_NOT_DIR, &netfid, &oplock, NULL, 
cifs_sb->local_nls);
                        if(rc==0) {
                                rc = CIFSSMBSetFileTimes(xid, pTcon, 
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to