bk://cifs.bkbits.net/linux-2.5cifs stevef@steveft21.ltcsamba|ChangeSet|20040512042926|01336 stevef # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/05/11 16:37:09-07:00 akpm@bix.(none) # Merge bk://cifs.bkbits.net/linux-2.5cifs # into bix.(none):/usr/src/bk-cifs # # ChangeSet # 2004/05/11 23:29:26-05:00 stevef@steveft21.ltcsamba # Fix oops when smb buffer can not be allocated # # fs/cifs/cifssmb.c # 2004/05/11 16:37:06-07:00 akpm@bix.(none) +0 -0 # Auto merged # # fs/cifs/cifssmb.c # 2004/05/11 23:29:04-05:00 stevef@steveft21.ltcsamba +1 -1 # Fix oops when smb buffer can not be allocated # # fs/cifs/CHANGES # 2004/05/11 23:29:03-05:00 stevef@steveft21.ltcsamba +1 -1 # Fix oops when smb buffer can not be allocated # # ChangeSet # 2004/05/11 01:02:01-05:00 stevef@steveft21.ltcsamba # Update readme with new information on symlinks to Samba # # fs/cifs/README # 2004/05/11 01:01:39-05:00 stevef@steveft21.ltcsamba +14 -2 # Update readme with new information on symlinks to Samba # # ChangeSet # 2004/05/10 18:51:27-05:00 stevef@steveft21.ltcsamba # Merge bk://cifs.bkbits.net/linux-2.5cifs # into steveft21.ltcsamba:/usr/src/bk/linux-2.5cifs # # fs/cifs/cifsencrypt.c # 2004/05/10 18:51:05-05:00 stevef@steveft21.ltcsamba +0 -0 # Auto merged # # ChangeSet # 2004/05/08 00:44:14-05:00 stevef@steveft21.ltcsamba # Merge bk://cifs.bkbits.net/linux-2.5cifs # into steveft21.ltcsamba:/usr/src/bk/linux-2.5cifs # # fs/cifs/CHANGES # 2004/05/08 00:43:50-05:00 stevef@steveft21.ltcsamba +0 -0 # Auto merged # # ChangeSet # 2004/05/07 17:31:12-05:00 stevef@stevef95.austin.ibm.com # update readme for mode,uid,gid description # # fs/cifs/README # 2004/05/07 17:31:03-05:00 stevef@stevef95.austin.ibm.com +22 -2 # update readme for mode,uid,gid description # # ChangeSet # 2004/05/04 13:51:19-07:00 akpm@bix.(none) # Merge bk://cifs.bkbits.net/linux-2.5cifs # into bix.(none):/usr/src/bk-cifs # # fs/cifs/cifssmb.c # 2004/05/04 13:51:17-07:00 akpm@bix.(none) +0 -0 # Auto merged # # ChangeSet # 2004/05/03 22:47:07-05:00 stevef@smfhome.smfdom # fix truncated directory listings on large directories to Samba (when Unicode and Unix extensions enabled) # # fs/cifs/file.c # 2004/05/03 22:47:01-05:00 stevef@smfhome.smfdom +2 -2 # fix truncated directory listings on large directories to Samba (when Unicode and Unix extensions enabled) # # fs/cifs/CHANGES # 2004/05/03 22:47:01-05:00 stevef@smfhome.smfdom +5 -0 # Update version log # # fs/cifs/AUTHORS # 2004/05/03 22:47:01-05:00 stevef@smfhome.smfdom +1 -0 # update contributors # # ChangeSet # 2004/05/03 22:15:58-05:00 stevef@smfhome.smfdom # Add smb copy function # # fs/cifs/cifssmb.c # 2004/05/03 22:15:51-05:00 stevef@smfhome.smfdom +71 -1 # Add smb copy function # # fs/cifs/cifsproto.h # 2004/05/03 22:15:51-05:00 stevef@smfhome.smfdom +5 -4 # correct definition of smb copy # # ChangeSet # 2004/05/02 21:56:11-07:00 akpm@bix.(none) # Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-cifs # # fs/cifs/cifssmb.c # 2004/05/02 21:56:09-07:00 akpm@bix.(none) +0 -0 # Auto merged # # fs/cifs/cifsfs.c # 2004/05/02 21:56:08-07:00 akpm@bix.(none) +0 -0 # Auto merged # # ChangeSet # 2004/05/02 23:05:26-05:00 stevef@smfhome.smfdom # Add missing cifs protocol data unit definitions # # fs/cifs/cifspdu.h # 2004/05/02 23:05:20-05:00 stevef@smfhome.smfdom +47 -1 # Add missing cifs protocol data unit definitions # # ChangeSet # 2004/05/02 11:36:06-05:00 stevef@steveft21.ltcsamba # Update cifs change log # # fs/cifs/CHANGES # 2004/05/02 11:35:42-05:00 stevef@steveft21.ltcsamba +1 -1 # Update cifs change log # # fs/cifs/cifsencrypt.c # 2004/05/02 11:34:46-05:00 stevef@steveft21.ltcsamba +0 -0 # Change mode to -rw-r--r-- # # ChangeSet # 2004/05/01 15:05:17-07:00 akpm@bix.(none) # Merge bk://cifs.bkbits.net/linux-2.5cifs # into bix.(none):/usr/src/bk-cifs # # fs/cifs/cifssmb.c # 2004/05/01 15:05:14-07:00 akpm@bix.(none) +0 -0 # Auto merged # # ChangeSet # 2004/04/29 15:41:50-07:00 akpm@bix.(none) # Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-cifs # # fs/cifs/cifssmb.c # 2004/04/29 15:41:48-07:00 akpm@bix.(none) +0 -0 # Auto merged # # fs/cifs/cifsencrypt.c # 2004/04/28 10:55:51-05:00 stevef@stevef95.austin.ibm.com +0 -0 # Change mode to -rw-r--r-- # # ChangeSet # 2004/04/26 18:11:55-07:00 akpm@bix.(none) # Merge bk://cifs.bkbits.net/linux-2.5cifs # into bix.(none):/usr/src/bk-cifs # # fs/cifs/cifsfs.c # 2004/04/26 18:11:52-07:00 akpm@bix.(none) +0 -0 # Auto merged # # ChangeSet # 2004/04/23 12:36:52-07:00 akpm@bix.(none) # Merge bk://cifs.bkbits.net/linux-2.5cifs # into bix.(none):/usr/src/bk-cifs # # fs/cifs/cifsfs.c # 2004/04/23 12:36:49-07:00 akpm@bix.(none) +0 -0 # Auto merged # # ChangeSet # 2004/04/19 19:23:58-07:00 akpm@bix.(none) # Merge bk://cifs.bkbits.net/linux-2.5cifs # into bix.(none):/usr/src/bk-cifs # # fs/cifs/cifsfs.c # 2004/04/19 19:23:56-07:00 akpm@bix.(none) +0 -0 # Auto merged # # ChangeSet # 2004/04/16 20:19:53-07:00 akpm@bix.(none) # Merge bk://cifs.bkbits.net/linux-2.5cifs # into bix.(none):/usr/src/bk-cifs # # fs/cifs/cifsfs.c # 2004/04/16 20:19:51-07:00 akpm@bix.(none) +0 -0 # Auto merged # # ChangeSet # 2004/04/16 20:18:59-07:00 akpm@bix.(none) # Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-cifs # # fs/cifs/cifsfs.c # 2004/04/16 20:18:56-07:00 akpm@bix.(none) +0 -0 # Auto merged # diff -Nru a/fs/cifs/AUTHORS b/fs/cifs/AUTHORS --- a/fs/cifs/AUTHORS Wed May 12 20:27:01 2004 +++ b/fs/cifs/AUTHORS Wed May 12 20:27:01 2004 @@ -22,6 +22,7 @@ Amrut Joshi Shobhit Dayal Sergey Vlasov +Richard Hughes Test case and Bug Report contributors ------------------------------------- diff -Nru a/fs/cifs/CHANGES b/fs/cifs/CHANGES --- a/fs/cifs/CHANGES Wed May 12 20:27:01 2004 +++ b/fs/cifs/CHANGES Wed May 12 20:27:01 2004 @@ -1,9 +1,14 @@ +Version 1.14 +------------ +Fix incomplete listings of large directories on Samba servers when Unix +extensions enabled. Fix oops when smb_buffer can not be allocated + Version 1.13 ------------ Fix open of files in which O_CREATE can cause the mode to change in some cases. Fix case in which retry of write overlaps file close. Fix PPC64 build error. Reduce excessive stack usage in smb password -hashing. +hashing. Fix overwrite of Linux user's view of file mode to Windows servers. Version 1.12 ------------ diff -Nru a/fs/cifs/README b/fs/cifs/README --- a/fs/cifs/README Wed May 12 20:27:01 2004 +++ b/fs/cifs/README Wed May 12 20:27:01 2004 @@ -104,9 +104,21 @@ see the manual pages ("man smb.conf") on the Samba server system. Note that the cifs vfs, unlike the smbfs vfs, does not read the smb.conf on the client system (the few optional settings are passed in on mount via -o parameters instead). -Note that Samba 2.2.7 or later includes a fix that allows the CIFS VFS to delete +Note that Samba 2.2.7 or later includes a fix that allows the CIFS VFS to delete open files (required for strict POSIX compliance). Windows Servers already -supported this feature. +supported this feature. Samba server does not allow symlinks that refer to files +outside of the share, so in Samba versions prior to 3.0.5, most symlinks to +files with absolute paths (ie beginning with slash) such as: + ln -s /mnt/foo bar +would be forbidden. Samba 3.0.5 server or later includes the ability to create +such symlinks safely by converting unsafe symlinks (ie symlinks to server +files that are outside of the share) to a samba specific format on the server +that is ignored by local server applications and non-cifs clients and that will +not be traversed by the Samba server). This is opaque to the Linux client +application using the cifs vfs. Absolute symlinks will work to Samba 3.0.5 or +later, but only for remote clients using the CIFS Unix extensions, and will +be invisbile to Windows clients and typically will not affect local +applications running on the same server as Samba. Use instructions: ================ @@ -166,8 +178,28 @@ mount. domain Set the SMB/CIFS workgroup name prepended to the username during CIFS session establishment - uid If CIFS Unix extensions are not supported by the server - this overrides the default uid for inodes. + uid If CIFS Unix extensions are not supported by the server + this overrides the default uid for inodes. For mounts to + servers which do support the CIFS Unix extensions, such + as a properly configured Samba server, the server provides + the uid, gid and mode. For servers which do not support + the Unix extensions, the default uid (and gid) returned on + lookup of existing files is the uid (gid) of the person + who executed the mount (root, except when mount.cifs + is configured setuid for user mounts) unless the "uid=" + (gid) mount option is specified. For the uid (gid) of newly + created files and directories, ie files created since + the last mount of the server share, the expected uid + (gid) is cached as as long as the inode remains in + memory on the client. Also note that permission + checks (authorization checks) on accesses to a file occur + at the server, but there are cases in which an administrator + may want to restrict at the client as well. For those + servers which do not report a uid/gid owner + (such as Windows), permissions can also be checked at the + client, and a crude form of client side permission checking + can be enabled by specifying file_mode and dir_mode on + the client gid If CIFS Unix extensions are not supported by the server this overrides the default gid for inodes. file_mode If CIFS Unix extensions are not supported by the server diff -Nru a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h --- a/fs/cifs/cifspdu.h Wed May 12 20:27:01 2004 +++ b/fs/cifs/cifspdu.h Wed May 12 20:27:01 2004 @@ -34,9 +34,10 @@ #define SMB_COM_DELETE 0x06 #define SMB_COM_RENAME 0x07 #define SMB_COM_LOCKING_ANDX 0x24 +#define SMB_COM_COPY 0x29 #define SMB_COM_READ_ANDX 0x2E #define SMB_COM_WRITE_ANDX 0x2F -#define SMB_COM_TRANSACTION2 0x32 +#define SMB_COM_TRANSACTION2 0x32 #define SMB_COM_TRANSACTION2_SECONDARY 0x33 #define SMB_COM_FIND_CLOSE2 0x34 #define SMB_COM_TREE_DISCONNECT 0x71 @@ -775,6 +776,34 @@ /* followed by NewFileName */ } RENAME_REQ; + /* copy request flags */ +#define COPY_MUST_BE_FILE 0x0001 +#define COPY_MUST_BE_DIR 0x0002 +#define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */ +#define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */ +#define COPY_VERIFY_WRITES 0x0010 +#define COPY_TREE 0x0020 + +typedef struct smb_com_copy_req { + struct smb_hdr hdr; /* wct = 3 */ + __u16 Tid2; + __u16 OpenFunction; + __u16 Flags; + __u16 ByteCount; + __u8 BufferFormat; /* 4 = ASCII or Unicode */ + unsigned char OldFileName[1]; + /* followed by __u8 BufferFormat2 */ + /* followed by NewFileName string */ +} COPY_REQ; + +typedef struct smb_com_copy_rsp { + struct smb_hdr hdr; /* wct = 1 */ + __u16 CopyCount; /* number of files copied */ + __u16 ByteCount; /* may be zero */ + __u8 BufferFormat; /* 0x04 - only present if errored file follows */ + unsigned char ErrorFileName[1]; /* only present if error in copy */ +} COPY_RSP; + #define CREATE_HARD_LINK 0x103 #define MOVEFILE_COPY_ALLOWED 0x0002 #define MOVEFILE_REPLACE_EXISTING 0x0001 @@ -912,6 +941,15 @@ #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 +#define FILE_ACTION_ADDED 0x00000001 +#define FILE_ACTION_REMOVED 0x00000002 +#define FILE_ACTION_MODIFIED 0x00000003 +#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 +#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 +#define FILE_ACTION_ADDED_STREAM 0x00000006 +#define FILE_ACTION_REMOVED_STREAM 0x00000007 +#define FILE_ACTION_MODIFIED_STREAM 0x00000008 + /* response contains array of the following structures */ struct file_notify_information { __u32 NextEntryOffset; @@ -1010,8 +1048,13 @@ #define SMB_SET_FILE_UNIX_HLINK 0x203 #define SMB_SET_FILE_BASIC_INFO2 0x3ec #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 +#define SMB_FILE_ALL_INFO2 0x3fa #define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb #define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc +#define SMB_FILE_MOVE_CLUSTER_INFO 0x407 +#define SMB_FILE_QUOTA_INFO 0x408 +#define SMB_FILE_REPARSEPOINT_INFO 0x409 +#define SMB_FILE_MAXIMUM_INFO 0x40d /* Find File infolevels */ #define SMB_FIND_FILE_DIRECTORY_INFO 0x101 @@ -1273,6 +1316,7 @@ __u16 LastNameOffset; } T2_FNEXT_RSP_PARMS; +/* QFSInfo Levels */ #define SMB_INFO_ALLOCATION 1 #define SMB_INFO_VOLUME 2 #define SMB_QUERY_FS_VOLUME_INFO 0x102 @@ -1280,6 +1324,8 @@ #define SMB_QUERY_FS_DEVICE_INFO 0x104 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105 #define SMB_QUERY_CIFS_UNIX_INFO 0x200 +#define SMB_QUERY_LABEL_INFO 0x3ea +#define SMB_QUERY_FS_QUOTA_INFO 0x3ee typedef struct smb_com_transaction2_qfsi_req { struct smb_hdr hdr; /* wct = 14+ */ diff -Nru a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h --- a/fs/cifs/cifsproto.h Wed May 12 20:27:01 2004 +++ b/fs/cifs/cifsproto.h Wed May 12 20:27:01 2004 @@ -239,8 +239,9 @@ int whence, unsigned long offset, long long *newoffset); extern int CIFSSMBCopy(int xid, - struct cifsTconInfo *ftcon, - char *fromName, - struct cifsTconInfo *ttcon, - char *toName, int ofun, int flags); + struct cifsTconInfo *source_tcon, + const char *fromName, + const __u16 target_tid, + const char *toName, const int flags, + const struct nls_table *nls_codepage); #endif /* _CIFSPROTO_H */ diff -Nru a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c --- a/fs/cifs/cifssmb.c Wed May 12 20:27:01 2004 +++ b/fs/cifs/cifssmb.c Wed May 12 20:27:01 2004 @@ -143,7 +143,7 @@ return rc; *request_buf = cifs_buf_get(); - if (request_buf == 0) { + if (*request_buf == 0) { return -ENOMEM; } /* Although the original thought was we needed the response buf for */ @@ -892,7 +892,6 @@ } pSMB->ByteCount = 1 /* 1st signature byte */ + name_len + name_len2; - /* we could also set search attributes but not needed */ pSMB->hdr.smb_buf_length += pSMB->ByteCount; pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); @@ -986,6 +985,77 @@ return rc; } +int +CIFSSMBCopy(const int xid, struct cifsTconInfo *tcon, const char * fromName, + const __u16 target_tid, const char *toName, const int flags, + const struct nls_table *nls_codepage) +{ + int rc = 0; + COPY_REQ *pSMB = NULL; + COPY_RSP *pSMBr = NULL; + int bytes_returned; + int name_len, name_len2; + + cFYI(1, ("In CIFSSMBCopy")); +copyRetry: + rc = smb_init(SMB_COM_COPY, 1, tcon, (void **) &pSMB, + (void **) &pSMBr); + if (rc) + return rc; + + pSMB->BufferFormat = 0x04; + pSMB->Tid2 = target_tid; + + if(flags & COPY_TREE) + pSMB->Flags |= COPY_TREE; + pSMB->Flags = cpu_to_le16(pSMB->Flags); + + if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { + name_len = + cifs_strtoUCS((wchar_t *) pSMB->OldFileName, fromName, 530 + /* find define for this maxpathcomponent */ + , nls_codepage); + name_len++; /* trailing null */ + name_len *= 2; + pSMB->OldFileName[name_len] = 0x04; /* pad */ + /* protocol requires ASCII signature byte on Unicode string */ + pSMB->OldFileName[name_len + 1] = 0x00; + name_len2 = + cifs_strtoUCS((wchar_t *) & pSMB-> + OldFileName[name_len + 2], toName, 530, + nls_codepage); + name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; + name_len2 *= 2; /* convert to bytes */ + } else { /* BB improve the check for buffer overruns BB */ + name_len = strnlen(fromName, 530); + name_len++; /* trailing null */ + strncpy(pSMB->OldFileName, fromName, name_len); + name_len2 = strnlen(toName, 530); + name_len2++; /* trailing null */ + pSMB->OldFileName[name_len] = 0x04; /* 2nd buffer format */ + strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2); + name_len2++; /* trailing null */ + name_len2++; /* signature byte */ + } + + pSMB->ByteCount = 1 /* 1st signature byte */ + name_len + name_len2; + pSMB->hdr.smb_buf_length += pSMB->ByteCount; + pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); + + rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, + (struct smb_hdr *) pSMBr, &bytes_returned, 0); + if (rc) { + cFYI(1, ("Send error in copy = %d with %d files copied", + rc, pSMBr->CopyCount)); + } + if (pSMB) + cifs_buf_release(pSMB); + + if (rc == -EAGAIN) + goto copyRetry; + + return rc; +} int CIFSUnixCreateSymLink(const int xid, struct cifsTconInfo *tcon, diff -Nru a/fs/cifs/file.c b/fs/cifs/file.c --- a/fs/cifs/file.c Wed May 12 20:27:01 2004 +++ b/fs/cifs/file.c Wed May 12 20:27:01 2004 @@ -1793,10 +1793,10 @@ cifsFile->search_resume_name = kmalloc(cifsFile->resume_name_length, GFP_KERNEL); cFYI(1,("fnext last file: %s with name %d bytes long", - lastFindData->FileName, + pfindDataUnix->FileName, cifsFile->resume_name_length)); memcpy(cifsFile->search_resume_name, - lastFindData->FileName, + pfindDataUnix->FileName, cifsFile->resume_name_length); }