smb1ops.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #include "cifsglob.h"
  20. #include "cifsproto.h"
  21. #include "cifs_debug.h"
  22. #include "cifspdu.h"
  23. /*
  24. * An NT cancel request header looks just like the original request except:
  25. *
  26. * The Command is SMB_COM_NT_CANCEL
  27. * The WordCount is zeroed out
  28. * The ByteCount is zeroed out
  29. *
  30. * This function mangles an existing request buffer into a
  31. * SMB_COM_NT_CANCEL request and then sends it.
  32. */
  33. static int
  34. send_nt_cancel(struct TCP_Server_Info *server, void *buf,
  35. struct mid_q_entry *mid)
  36. {
  37. int rc = 0;
  38. struct smb_hdr *in_buf = (struct smb_hdr *)buf;
  39. /* -4 for RFC1001 length and +2 for BCC field */
  40. in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2);
  41. in_buf->Command = SMB_COM_NT_CANCEL;
  42. in_buf->WordCount = 0;
  43. put_bcc(0, in_buf);
  44. mutex_lock(&server->srv_mutex);
  45. rc = cifs_sign_smb(in_buf, server, &mid->sequence_number);
  46. if (rc) {
  47. mutex_unlock(&server->srv_mutex);
  48. return rc;
  49. }
  50. rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
  51. mutex_unlock(&server->srv_mutex);
  52. cFYI(1, "issued NT_CANCEL for mid %u, rc = %d",
  53. in_buf->Mid, rc);
  54. return rc;
  55. }
  56. static bool
  57. cifs_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)
  58. {
  59. return ob1->netfid == ob2->netfid;
  60. }
  61. struct smb_version_operations smb1_operations = {
  62. .send_cancel = send_nt_cancel,
  63. .compare_fids = cifs_compare_fids,
  64. .setup_request = cifs_setup_request,
  65. .check_receive = cifs_check_receive,
  66. };
  67. struct smb_version_values smb1_values = {
  68. .version_string = SMB1_VERSION_STRING,
  69. .large_lock_type = LOCKING_ANDX_LARGE_FILES,
  70. .exclusive_lock_type = 0,
  71. .shared_lock_type = LOCKING_ANDX_SHARED_LOCK,
  72. .unlock_lock_type = 0,
  73. };