Jeff Layton | 23db65f | 2012-05-15 12:20:51 -0400 | [diff] [blame] | 1 | /* |
| 2 | * SMB1 (CIFS) version specific operations |
| 3 | * |
| 4 | * Copyright (c) 2012, Jeff Layton <jlayton@redhat.com> |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License v2 as published |
| 8 | * by the Free Software Foundation. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 13 | * the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public License |
| 16 | * along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | |
| 20 | #include "cifsglob.h" |
Jeff Layton | 121b046 | 2012-05-15 12:21:10 -0400 | [diff] [blame] | 21 | #include "cifsproto.h" |
| 22 | #include "cifs_debug.h" |
Pavel Shilovsky | 106dc53 | 2012-02-28 14:23:34 +0300 | [diff] [blame] | 23 | #include "cifspdu.h" |
Jeff Layton | 121b046 | 2012-05-15 12:21:10 -0400 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * An NT cancel request header looks just like the original request except: |
| 27 | * |
| 28 | * The Command is SMB_COM_NT_CANCEL |
| 29 | * The WordCount is zeroed out |
| 30 | * The ByteCount is zeroed out |
| 31 | * |
| 32 | * This function mangles an existing request buffer into a |
| 33 | * SMB_COM_NT_CANCEL request and then sends it. |
| 34 | */ |
| 35 | static int |
| 36 | send_nt_cancel(struct TCP_Server_Info *server, void *buf, |
| 37 | struct mid_q_entry *mid) |
| 38 | { |
| 39 | int rc = 0; |
| 40 | struct smb_hdr *in_buf = (struct smb_hdr *)buf; |
| 41 | |
| 42 | /* -4 for RFC1001 length and +2 for BCC field */ |
| 43 | in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2); |
| 44 | in_buf->Command = SMB_COM_NT_CANCEL; |
| 45 | in_buf->WordCount = 0; |
| 46 | put_bcc(0, in_buf); |
| 47 | |
| 48 | mutex_lock(&server->srv_mutex); |
| 49 | rc = cifs_sign_smb(in_buf, server, &mid->sequence_number); |
| 50 | if (rc) { |
| 51 | mutex_unlock(&server->srv_mutex); |
| 52 | return rc; |
| 53 | } |
| 54 | rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); |
| 55 | mutex_unlock(&server->srv_mutex); |
| 56 | |
| 57 | cFYI(1, "issued NT_CANCEL for mid %u, rc = %d", |
| 58 | in_buf->Mid, rc); |
| 59 | |
| 60 | return rc; |
| 61 | } |
Jeff Layton | 23db65f | 2012-05-15 12:20:51 -0400 | [diff] [blame] | 62 | |
Pavel Shilovsky | 55157df | 2012-02-28 14:04:17 +0300 | [diff] [blame] | 63 | static bool |
| 64 | cifs_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2) |
| 65 | { |
| 66 | return ob1->netfid == ob2->netfid; |
| 67 | } |
| 68 | |
Jeff Layton | 23db65f | 2012-05-15 12:20:51 -0400 | [diff] [blame] | 69 | struct smb_version_operations smb1_operations = { |
Jeff Layton | 121b046 | 2012-05-15 12:21:10 -0400 | [diff] [blame] | 70 | .send_cancel = send_nt_cancel, |
Pavel Shilovsky | 55157df | 2012-02-28 14:04:17 +0300 | [diff] [blame] | 71 | .compare_fids = cifs_compare_fids, |
Pavel Shilovsky | 082d064 | 2012-05-17 12:18:21 +0400 | [diff] [blame^] | 72 | .setup_request = cifs_setup_request, |
| 73 | .check_receive = cifs_check_receive, |
Jeff Layton | 23db65f | 2012-05-15 12:20:51 -0400 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | struct smb_version_values smb1_values = { |
| 77 | .version_string = SMB1_VERSION_STRING, |
Pavel Shilovsky | 106dc53 | 2012-02-28 14:23:34 +0300 | [diff] [blame] | 78 | .large_lock_type = LOCKING_ANDX_LARGE_FILES, |
| 79 | .exclusive_lock_type = 0, |
| 80 | .shared_lock_type = LOCKING_ANDX_SHARED_LOCK, |
| 81 | .unlock_lock_type = 0, |
Jeff Layton | 23db65f | 2012-05-15 12:20:51 -0400 | [diff] [blame] | 82 | }; |