aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifssmb.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/cifssmb.c')
-rw-r--r--fs/cifs/cifssmb.c85
1 files changed, 77 insertions, 8 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 3ab78b776977..b339f5f128da 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -789,6 +789,82 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses)
789} 789}
790 790
791int 791int
792CIFSPOSIXDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName,
793 __u16 type, const struct nls_table *nls_codepage, int remap)
794{
795 TRANSACTION2_SPI_REQ *pSMB = NULL;
796 TRANSACTION2_SPI_RSP *pSMBr = NULL;
797 struct unlink_psx_rq *pRqD;
798 int name_len;
799 int rc = 0;
800 int bytes_returned = 0;
801 __u16 params, param_offset, offset, byte_count;
802
803 cFYI(1, ("In POSIX delete"));
804PsxDelete:
805 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
806 (void **) &pSMBr);
807 if (rc)
808 return rc;
809
810 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
811 name_len =
812 cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
813 PATH_MAX, nls_codepage, remap);
814 name_len++; /* trailing null */
815 name_len *= 2;
816 } else { /* BB add path length overrun check */
817 name_len = strnlen(fileName, PATH_MAX);
818 name_len++; /* trailing null */
819 strncpy(pSMB->FileName, fileName, name_len);
820 }
821
822 params = 6 + name_len;
823 pSMB->MaxParameterCount = cpu_to_le16(2);
824 pSMB->MaxDataCount = 0; /* BB double check this with jra */
825 pSMB->MaxSetupCount = 0;
826 pSMB->Reserved = 0;
827 pSMB->Flags = 0;
828 pSMB->Timeout = 0;
829 pSMB->Reserved2 = 0;
830 param_offset = offsetof(struct smb_com_transaction2_spi_req,
831 InformationLevel) - 4;
832 offset = param_offset + params;
833
834 /* Setup pointer to Request Data (inode type) */
835 pRqD = (struct unlink_psx_rq *)(((char *)&pSMB->hdr.Protocol) + offset);
836 pRqD->type = cpu_to_le16(type);
837 pSMB->ParameterOffset = cpu_to_le16(param_offset);
838 pSMB->DataOffset = cpu_to_le16(offset);
839 pSMB->SetupCount = 1;
840 pSMB->Reserved3 = 0;
841 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_PATH_INFORMATION);
842 byte_count = 3 /* pad */ + params + sizeof(struct unlink_psx_rq);
843
844 pSMB->DataCount = cpu_to_le16(sizeof(struct unlink_psx_rq));
845 pSMB->TotalDataCount = cpu_to_le16(sizeof(struct unlink_psx_rq));
846 pSMB->ParameterCount = cpu_to_le16(params);
847 pSMB->TotalParameterCount = pSMB->ParameterCount;
848 pSMB->InformationLevel = cpu_to_le16(SMB_POSIX_UNLINK);
849 pSMB->Reserved4 = 0;
850 pSMB->hdr.smb_buf_length += byte_count;
851 pSMB->ByteCount = cpu_to_le16(byte_count);
852 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
853 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
854 if (rc) {
855 cFYI(1, ("Posix delete returned %d", rc));
856 }
857 cifs_buf_release(pSMB);
858
859 cifs_stats_inc(&tcon->num_deletes);
860
861 if (rc == -EAGAIN)
862 goto PsxDelete;
863
864 return rc;
865}
866
867int
792CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName, 868CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName,
793 const struct nls_table *nls_codepage, int remap) 869 const struct nls_table *nls_codepage, int remap)
794{ 870{
@@ -933,7 +1009,6 @@ CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
933 int name_len; 1009 int name_len;
934 int rc = 0; 1010 int rc = 0;
935 int bytes_returned = 0; 1011 int bytes_returned = 0;
936 char *data_offset;
937 __u16 params, param_offset, offset, byte_count, count; 1012 __u16 params, param_offset, offset, byte_count, count;
938 OPEN_PSX_REQ * pdata; 1013 OPEN_PSX_REQ * pdata;
939 OPEN_PSX_RSP * psx_rsp; 1014 OPEN_PSX_RSP * psx_rsp;
@@ -969,7 +1044,6 @@ PsxCreat:
969 param_offset = offsetof(struct smb_com_transaction2_spi_req, 1044 param_offset = offsetof(struct smb_com_transaction2_spi_req,
970 InformationLevel) - 4; 1045 InformationLevel) - 4;
971 offset = param_offset + params; 1046 offset = param_offset + params;
972 data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
973 pdata = (OPEN_PSX_REQ *)(((char *)&pSMB->hdr.Protocol) + offset); 1047 pdata = (OPEN_PSX_REQ *)(((char *)&pSMB->hdr.Protocol) + offset);
974 pdata->Level = SMB_QUERY_FILE_UNIX_BASIC; 1048 pdata->Level = SMB_QUERY_FILE_UNIX_BASIC;
975 pdata->Permissions = cpu_to_le64(mode); 1049 pdata->Permissions = cpu_to_le64(mode);
@@ -1671,7 +1745,6 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1671{ 1745{
1672 struct smb_com_transaction2_sfi_req *pSMB = NULL; 1746 struct smb_com_transaction2_sfi_req *pSMB = NULL;
1673 struct smb_com_transaction2_sfi_rsp *pSMBr = NULL; 1747 struct smb_com_transaction2_sfi_rsp *pSMBr = NULL;
1674 char *data_offset;
1675 struct cifs_posix_lock *parm_data; 1748 struct cifs_posix_lock *parm_data;
1676 int rc = 0; 1749 int rc = 0;
1677 int timeout = 0; 1750 int timeout = 0;
@@ -1698,8 +1771,6 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1698 param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4; 1771 param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
1699 offset = param_offset + params; 1772 offset = param_offset + params;
1700 1773
1701 data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
1702
1703 count = sizeof(struct cifs_posix_lock); 1774 count = sizeof(struct cifs_posix_lock);
1704 pSMB->MaxParameterCount = cpu_to_le16(2); 1775 pSMB->MaxParameterCount = cpu_to_le16(2);
1705 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ 1776 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */
@@ -2120,9 +2191,7 @@ createSymLinkRetry:
2120 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2191 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2121 cifs_stats_inc(&tcon->num_symlinks); 2192 cifs_stats_inc(&tcon->num_symlinks);
2122 if (rc) { 2193 if (rc) {
2123 cFYI(1, 2194 cFYI(1, ("Send error in SetPathInfo create symlink = %d", rc));
2124 ("Send error in SetPathInfo (create symlink) = %d",
2125 rc));
2126 } 2195 }
2127 2196
2128 if (pSMB) 2197 if (pSMB)