mm/memunmap: don't access uninitialized memmap in memunmap_pages()
[linux-2.6-block.git] / fs / cifs / smb1ops.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  *  SMB1 (CIFS) version specific operations
4  *
5  *  Copyright (c) 2012, Jeff Layton <jlayton@redhat.com>
6  */
7
8 #include <linux/pagemap.h>
9 #include <linux/vfs.h>
10 #include "cifsglob.h"
11 #include "cifsproto.h"
12 #include "cifs_debug.h"
13 #include "cifspdu.h"
14 #include "cifs_unicode.h"
15
16 /*
17  * An NT cancel request header looks just like the original request except:
18  *
19  * The Command is SMB_COM_NT_CANCEL
20  * The WordCount is zeroed out
21  * The ByteCount is zeroed out
22  *
23  * This function mangles an existing request buffer into a
24  * SMB_COM_NT_CANCEL request and then sends it.
25  */
26 static int
27 send_nt_cancel(struct TCP_Server_Info *server, struct smb_rqst *rqst,
28                struct mid_q_entry *mid)
29 {
30         int rc = 0;
31         struct smb_hdr *in_buf = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
32
33         /* -4 for RFC1001 length and +2 for BCC field */
34         in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4  + 2);
35         in_buf->Command = SMB_COM_NT_CANCEL;
36         in_buf->WordCount = 0;
37         put_bcc(0, in_buf);
38
39         mutex_lock(&server->srv_mutex);
40         rc = cifs_sign_smb(in_buf, server, &mid->sequence_number);
41         if (rc) {
42                 mutex_unlock(&server->srv_mutex);
43                 return rc;
44         }
45
46         /*
47          * The response to this call was already factored into the sequence
48          * number when the call went out, so we must adjust it back downward
49          * after signing here.
50          */
51         --server->sequence_number;
52         rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
53         if (rc < 0)
54                 server->sequence_number--;
55
56         mutex_unlock(&server->srv_mutex);
57
58         cifs_dbg(FYI, "issued NT_CANCEL for mid %u, rc = %d\n",
59                  get_mid(in_buf), rc);
60
61         return rc;
62 }
63
64 static bool
65 cifs_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)
66 {
67         return ob1->fid.netfid == ob2->fid.netfid;
68 }
69
70 static unsigned int
71 cifs_read_data_offset(char *buf)
72 {
73         READ_RSP *rsp = (READ_RSP *)buf;
74         return le16_to_cpu(rsp->DataOffset);
75 }
76
77 static unsigned int
78 cifs_read_data_length(char *buf, bool in_remaining)
79 {
80         READ_RSP *rsp = (READ_RSP *)buf;
81         /* It's a bug reading remaining data for SMB1 packets */
82         WARN_ON(in_remaining);
83         return (le16_to_cpu(rsp->DataLengthHigh) << 16) +
84                le16_to_cpu(rsp->DataLength);
85 }
86
87 static struct mid_q_entry *
88 cifs_find_mid(struct TCP_Server_Info *server, char *buffer)
89 {
90         struct smb_hdr *buf = (struct smb_hdr *)buffer;
91         struct mid_q_entry *mid;
92
93         spin_lock(&GlobalMid_Lock);
94         list_for_each_entry(mid, &server->pending_mid_q, qhead) {
95                 if (compare_mid(mid->mid, buf) &&
96                     mid->mid_state == MID_REQUEST_SUBMITTED &&
97                     le16_to_cpu(mid->command) == buf->Command) {
98                         kref_get(&mid->refcount);
99                         spin_unlock(&GlobalMid_Lock);
100                         return mid;
101                 }
102         }
103         spin_unlock(&GlobalMid_Lock);
104         return NULL;
105 }
106
107 static void
108 cifs_add_credits(struct TCP_Server_Info *server,
109                  const struct cifs_credits *credits, const int optype)
110 {
111         spin_lock(&server->req_lock);
112         server->credits += credits->value;
113         server->in_flight--;
114         spin_unlock(&server->req_lock);
115         wake_up(&server->request_q);
116 }
117
118 static void
119 cifs_set_credits(struct TCP_Server_Info *server, const int val)
120 {
121         spin_lock(&server->req_lock);
122         server->credits = val;
123         server->oplocks = val > 1 ? enable_oplocks : false;
124         spin_unlock(&server->req_lock);
125 }
126
127 static int *
128 cifs_get_credits_field(struct TCP_Server_Info *server, const int optype)
129 {
130         return &server->credits;
131 }
132
133 static unsigned int
134 cifs_get_credits(struct mid_q_entry *mid)
135 {
136         return 1;
137 }
138
139 /*
140  * Find a free multiplex id (SMB mid). Otherwise there could be
141  * mid collisions which might cause problems, demultiplexing the
142  * wrong response to this request. Multiplex ids could collide if
143  * one of a series requests takes much longer than the others, or
144  * if a very large number of long lived requests (byte range
145  * locks or FindNotify requests) are pending. No more than
146  * 64K-1 requests can be outstanding at one time. If no
147  * mids are available, return zero. A future optimization
148  * could make the combination of mids and uid the key we use
149  * to demultiplex on (rather than mid alone).
150  * In addition to the above check, the cifs demultiplex
151  * code already used the command code as a secondary
152  * check of the frame and if signing is negotiated the
153  * response would be discarded if the mid were the same
154  * but the signature was wrong. Since the mid is not put in the
155  * pending queue until later (when it is about to be dispatched)
156  * we do have to limit the number of outstanding requests
157  * to somewhat less than 64K-1 although it is hard to imagine
158  * so many threads being in the vfs at one time.
159  */
160 static __u64
161 cifs_get_next_mid(struct TCP_Server_Info *server)
162 {
163         __u64 mid = 0;
164         __u16 last_mid, cur_mid;
165         bool collision;
166
167         spin_lock(&GlobalMid_Lock);
168
169         /* mid is 16 bit only for CIFS/SMB */
170         cur_mid = (__u16)((server->CurrentMid) & 0xffff);
171         /* we do not want to loop forever */
172         last_mid = cur_mid;
173         cur_mid++;
174
175         /*
176          * This nested loop looks more expensive than it is.
177          * In practice the list of pending requests is short,
178          * fewer than 50, and the mids are likely to be unique
179          * on the first pass through the loop unless some request
180          * takes longer than the 64 thousand requests before it
181          * (and it would also have to have been a request that
182          * did not time out).
183          */
184         while (cur_mid != last_mid) {
185                 struct mid_q_entry *mid_entry;
186                 unsigned int num_mids;
187
188                 collision = false;
189                 if (cur_mid == 0)
190                         cur_mid++;
191
192                 num_mids = 0;
193                 list_for_each_entry(mid_entry, &server->pending_mid_q, qhead) {
194                         ++num_mids;
195                         if (mid_entry->mid == cur_mid &&
196                             mid_entry->mid_state == MID_REQUEST_SUBMITTED) {
197                                 /* This mid is in use, try a different one */
198                                 collision = true;
199                                 break;
200                         }
201                 }
202
203                 /*
204                  * if we have more than 32k mids in the list, then something
205                  * is very wrong. Possibly a local user is trying to DoS the
206                  * box by issuing long-running calls and SIGKILL'ing them. If
207                  * we get to 2^16 mids then we're in big trouble as this
208                  * function could loop forever.
209                  *
210                  * Go ahead and assign out the mid in this situation, but force
211                  * an eventual reconnect to clean out the pending_mid_q.
212                  */
213                 if (num_mids > 32768)
214                         server->tcpStatus = CifsNeedReconnect;
215
216                 if (!collision) {
217                         mid = (__u64)cur_mid;
218                         server->CurrentMid = mid;
219                         break;
220                 }
221                 cur_mid++;
222         }
223         spin_unlock(&GlobalMid_Lock);
224         return mid;
225 }
226
227 /*
228         return codes:
229                 0       not a transact2, or all data present
230                 >0      transact2 with that much data missing
231                 -EINVAL invalid transact2
232  */
233 static int
234 check2ndT2(char *buf)
235 {
236         struct smb_hdr *pSMB = (struct smb_hdr *)buf;
237         struct smb_t2_rsp *pSMBt;
238         int remaining;
239         __u16 total_data_size, data_in_this_rsp;
240
241         if (pSMB->Command != SMB_COM_TRANSACTION2)
242                 return 0;
243
244         /* check for plausible wct, bcc and t2 data and parm sizes */
245         /* check for parm and data offset going beyond end of smb */
246         if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */
247                 cifs_dbg(FYI, "invalid transact2 word count\n");
248                 return -EINVAL;
249         }
250
251         pSMBt = (struct smb_t2_rsp *)pSMB;
252
253         total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
254         data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
255
256         if (total_data_size == data_in_this_rsp)
257                 return 0;
258         else if (total_data_size < data_in_this_rsp) {
259                 cifs_dbg(FYI, "total data %d smaller than data in frame %d\n",
260                          total_data_size, data_in_this_rsp);
261                 return -EINVAL;
262         }
263
264         remaining = total_data_size - data_in_this_rsp;
265
266         cifs_dbg(FYI, "missing %d bytes from transact2, check next response\n",
267                  remaining);
268         if (total_data_size > CIFSMaxBufSize) {
269                 cifs_dbg(VFS, "TotalDataSize %d is over maximum buffer %d\n",
270                          total_data_size, CIFSMaxBufSize);
271                 return -EINVAL;
272         }
273         return remaining;
274 }
275
276 static int
277 coalesce_t2(char *second_buf, struct smb_hdr *target_hdr)
278 {
279         struct smb_t2_rsp *pSMBs = (struct smb_t2_rsp *)second_buf;
280         struct smb_t2_rsp *pSMBt  = (struct smb_t2_rsp *)target_hdr;
281         char *data_area_of_tgt;
282         char *data_area_of_src;
283         int remaining;
284         unsigned int byte_count, total_in_tgt;
285         __u16 tgt_total_cnt, src_total_cnt, total_in_src;
286
287         src_total_cnt = get_unaligned_le16(&pSMBs->t2_rsp.TotalDataCount);
288         tgt_total_cnt = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
289
290         if (tgt_total_cnt != src_total_cnt)
291                 cifs_dbg(FYI, "total data count of primary and secondary t2 differ source=%hu target=%hu\n",
292                          src_total_cnt, tgt_total_cnt);
293
294         total_in_tgt = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
295
296         remaining = tgt_total_cnt - total_in_tgt;
297
298         if (remaining < 0) {
299                 cifs_dbg(FYI, "Server sent too much data. tgt_total_cnt=%hu total_in_tgt=%u\n",
300                          tgt_total_cnt, total_in_tgt);
301                 return -EPROTO;
302         }
303
304         if (remaining == 0) {
305                 /* nothing to do, ignore */
306                 cifs_dbg(FYI, "no more data remains\n");
307                 return 0;
308         }
309
310         total_in_src = get_unaligned_le16(&pSMBs->t2_rsp.DataCount);
311         if (remaining < total_in_src)
312                 cifs_dbg(FYI, "transact2 2nd response contains too much data\n");
313
314         /* find end of first SMB data area */
315         data_area_of_tgt = (char *)&pSMBt->hdr.Protocol +
316                                 get_unaligned_le16(&pSMBt->t2_rsp.DataOffset);
317
318         /* validate target area */
319         data_area_of_src = (char *)&pSMBs->hdr.Protocol +
320                                 get_unaligned_le16(&pSMBs->t2_rsp.DataOffset);
321
322         data_area_of_tgt += total_in_tgt;
323
324         total_in_tgt += total_in_src;
325         /* is the result too big for the field? */
326         if (total_in_tgt > USHRT_MAX) {
327                 cifs_dbg(FYI, "coalesced DataCount too large (%u)\n",
328                          total_in_tgt);
329                 return -EPROTO;
330         }
331         put_unaligned_le16(total_in_tgt, &pSMBt->t2_rsp.DataCount);
332
333         /* fix up the BCC */
334         byte_count = get_bcc(target_hdr);
335         byte_count += total_in_src;
336         /* is the result too big for the field? */
337         if (byte_count > USHRT_MAX) {
338                 cifs_dbg(FYI, "coalesced BCC too large (%u)\n", byte_count);
339                 return -EPROTO;
340         }
341         put_bcc(byte_count, target_hdr);
342
343         byte_count = be32_to_cpu(target_hdr->smb_buf_length);
344         byte_count += total_in_src;
345         /* don't allow buffer to overflow */
346         if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
347                 cifs_dbg(FYI, "coalesced BCC exceeds buffer size (%u)\n",
348                          byte_count);
349                 return -ENOBUFS;
350         }
351         target_hdr->smb_buf_length = cpu_to_be32(byte_count);
352
353         /* copy second buffer into end of first buffer */
354         memcpy(data_area_of_tgt, data_area_of_src, total_in_src);
355
356         if (remaining != total_in_src) {
357                 /* more responses to go */
358                 cifs_dbg(FYI, "waiting for more secondary responses\n");
359                 return 1;
360         }
361
362         /* we are done */
363         cifs_dbg(FYI, "found the last secondary response\n");
364         return 0;
365 }
366
367 static void
368 cifs_downgrade_oplock(struct TCP_Server_Info *server,
369                         struct cifsInodeInfo *cinode, bool set_level2)
370 {
371         if (set_level2)
372                 cifs_set_oplock_level(cinode, OPLOCK_READ);
373         else
374                 cifs_set_oplock_level(cinode, 0);
375 }
376
377 static bool
378 cifs_check_trans2(struct mid_q_entry *mid, struct TCP_Server_Info *server,
379                   char *buf, int malformed)
380 {
381         if (malformed)
382                 return false;
383         if (check2ndT2(buf) <= 0)
384                 return false;
385         mid->multiRsp = true;
386         if (mid->resp_buf) {
387                 /* merge response - fix up 1st*/
388                 malformed = coalesce_t2(buf, mid->resp_buf);
389                 if (malformed > 0)
390                         return true;
391                 /* All parts received or packet is malformed. */
392                 mid->multiEnd = true;
393                 dequeue_mid(mid, malformed);
394                 return true;
395         }
396         if (!server->large_buf) {
397                 /*FIXME: switch to already allocated largebuf?*/
398                 cifs_dbg(VFS, "1st trans2 resp needs bigbuf\n");
399         } else {
400                 /* Have first buffer */
401                 mid->resp_buf = buf;
402                 mid->large_buf = true;
403                 server->bigbuf = NULL;
404         }
405         return true;
406 }
407
408 static bool
409 cifs_need_neg(struct TCP_Server_Info *server)
410 {
411         return server->maxBuf == 0;
412 }
413
414 static int
415 cifs_negotiate(const unsigned int xid, struct cifs_ses *ses)
416 {
417         int rc;
418         rc = CIFSSMBNegotiate(xid, ses);
419         if (rc == -EAGAIN) {
420                 /* retry only once on 1st time connection */
421                 set_credits(ses->server, 1);
422                 rc = CIFSSMBNegotiate(xid, ses);
423                 if (rc == -EAGAIN)
424                         rc = -EHOSTDOWN;
425         }
426         return rc;
427 }
428
429 static unsigned int
430 cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
431 {
432         __u64 unix_cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
433         struct TCP_Server_Info *server = tcon->ses->server;
434         unsigned int wsize;
435
436         /* start with specified wsize, or default */
437         if (volume_info->wsize)
438                 wsize = volume_info->wsize;
439         else if (tcon->unix_ext && (unix_cap & CIFS_UNIX_LARGE_WRITE_CAP))
440                 wsize = CIFS_DEFAULT_IOSIZE;
441         else
442                 wsize = CIFS_DEFAULT_NON_POSIX_WSIZE;
443
444         /* can server support 24-bit write sizes? (via UNIX extensions) */
445         if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP))
446                 wsize = min_t(unsigned int, wsize, CIFS_MAX_RFC1002_WSIZE);
447
448         /*
449          * no CAP_LARGE_WRITE_X or is signing enabled without CAP_UNIX set?
450          * Limit it to max buffer offered by the server, minus the size of the
451          * WRITEX header, not including the 4 byte RFC1001 length.
452          */
453         if (!(server->capabilities & CAP_LARGE_WRITE_X) ||
454             (!(server->capabilities & CAP_UNIX) && server->sign))
455                 wsize = min_t(unsigned int, wsize,
456                                 server->maxBuf - sizeof(WRITE_REQ) + 4);
457
458         /* hard limit of CIFS_MAX_WSIZE */
459         wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE);
460
461         return wsize;
462 }
463
464 static unsigned int
465 cifs_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
466 {
467         __u64 unix_cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
468         struct TCP_Server_Info *server = tcon->ses->server;
469         unsigned int rsize, defsize;
470
471         /*
472          * Set default value...
473          *
474          * HACK alert! Ancient servers have very small buffers. Even though
475          * MS-CIFS indicates that servers are only limited by the client's
476          * bufsize for reads, testing against win98se shows that it throws
477          * INVALID_PARAMETER errors if you try to request too large a read.
478          * OS/2 just sends back short reads.
479          *
480          * If the server doesn't advertise CAP_LARGE_READ_X, then assume that
481          * it can't handle a read request larger than its MaxBufferSize either.
482          */
483         if (tcon->unix_ext && (unix_cap & CIFS_UNIX_LARGE_READ_CAP))
484                 defsize = CIFS_DEFAULT_IOSIZE;
485         else if (server->capabilities & CAP_LARGE_READ_X)
486                 defsize = CIFS_DEFAULT_NON_POSIX_RSIZE;
487         else
488                 defsize = server->maxBuf - sizeof(READ_RSP);
489
490         rsize = volume_info->rsize ? volume_info->rsize : defsize;
491
492         /*
493          * no CAP_LARGE_READ_X? Then MS-CIFS states that we must limit this to
494          * the client's MaxBufferSize.
495          */
496         if (!(server->capabilities & CAP_LARGE_READ_X))
497                 rsize = min_t(unsigned int, CIFSMaxBufSize, rsize);
498
499         /* hard limit of CIFS_MAX_RSIZE */
500         rsize = min_t(unsigned int, rsize, CIFS_MAX_RSIZE);
501
502         return rsize;
503 }
504
505 static void
506 cifs_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
507 {
508         CIFSSMBQFSDeviceInfo(xid, tcon);
509         CIFSSMBQFSAttributeInfo(xid, tcon);
510 }
511
512 static int
513 cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
514                         struct cifs_sb_info *cifs_sb, const char *full_path)
515 {
516         int rc;
517         FILE_ALL_INFO *file_info;
518
519         file_info = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
520         if (file_info == NULL)
521                 return -ENOMEM;
522
523         rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
524                               0 /* not legacy */, cifs_sb->local_nls,
525                               cifs_remap(cifs_sb));
526
527         if (rc == -EOPNOTSUPP || rc == -EINVAL)
528                 rc = SMBQueryInformation(xid, tcon, full_path, file_info,
529                                 cifs_sb->local_nls, cifs_remap(cifs_sb));
530         kfree(file_info);
531         return rc;
532 }
533
534 static int
535 cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
536                      struct cifs_sb_info *cifs_sb, const char *full_path,
537                      FILE_ALL_INFO *data, bool *adjustTZ, bool *symlink)
538 {
539         int rc;
540
541         *symlink = false;
542
543         /* could do find first instead but this returns more info */
544         rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0 /* not legacy */,
545                               cifs_sb->local_nls, cifs_remap(cifs_sb));
546         /*
547          * BB optimize code so we do not make the above call when server claims
548          * no NT SMB support and the above call failed at least once - set flag
549          * in tcon or mount.
550          */
551         if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) {
552                 rc = SMBQueryInformation(xid, tcon, full_path, data,
553                                          cifs_sb->local_nls,
554                                          cifs_remap(cifs_sb));
555                 *adjustTZ = true;
556         }
557
558         if (!rc && (le32_to_cpu(data->Attributes) & ATTR_REPARSE)) {
559                 int tmprc;
560                 int oplock = 0;
561                 struct cifs_fid fid;
562                 struct cifs_open_parms oparms;
563
564                 oparms.tcon = tcon;
565                 oparms.cifs_sb = cifs_sb;
566                 oparms.desired_access = FILE_READ_ATTRIBUTES;
567                 oparms.create_options = 0;
568                 oparms.disposition = FILE_OPEN;
569                 oparms.path = full_path;
570                 oparms.fid = &fid;
571                 oparms.reconnect = false;
572
573                 /* Need to check if this is a symbolic link or not */
574                 tmprc = CIFS_open(xid, &oparms, &oplock, NULL);
575                 if (tmprc == -EOPNOTSUPP)
576                         *symlink = true;
577                 else if (tmprc == 0)
578                         CIFSSMBClose(xid, tcon, fid.netfid);
579         }
580
581         return rc;
582 }
583
584 static int
585 cifs_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
586                   struct cifs_sb_info *cifs_sb, const char *full_path,
587                   u64 *uniqueid, FILE_ALL_INFO *data)
588 {
589         /*
590          * We can not use the IndexNumber field by default from Windows or
591          * Samba (in ALL_INFO buf) but we can request it explicitly. The SNIA
592          * CIFS spec claims that this value is unique within the scope of a
593          * share, and the windows docs hint that it's actually unique
594          * per-machine.
595          *
596          * There may be higher info levels that work but are there Windows
597          * server or network appliances for which IndexNumber field is not
598          * guaranteed unique?
599          */
600         return CIFSGetSrvInodeNumber(xid, tcon, full_path, uniqueid,
601                                      cifs_sb->local_nls,
602                                      cifs_remap(cifs_sb));
603 }
604
605 static int
606 cifs_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
607                      struct cifs_fid *fid, FILE_ALL_INFO *data)
608 {
609         return CIFSSMBQFileInfo(xid, tcon, fid->netfid, data);
610 }
611
612 static void
613 cifs_clear_stats(struct cifs_tcon *tcon)
614 {
615         atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
616         atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
617         atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
618         atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
619         atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
620         atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
621         atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
622         atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
623         atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
624         atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
625         atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
626         atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
627         atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
628         atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
629         atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
630         atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
631         atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
632         atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
633         atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
634         atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
635         atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
636 }
637
638 static void
639 cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
640 {
641         seq_printf(m, " Oplocks breaks: %d",
642                    atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
643         seq_printf(m, "\nReads:  %d Bytes: %llu",
644                    atomic_read(&tcon->stats.cifs_stats.num_reads),
645                    (long long)(tcon->bytes_read));
646         seq_printf(m, "\nWrites: %d Bytes: %llu",
647                    atomic_read(&tcon->stats.cifs_stats.num_writes),
648                    (long long)(tcon->bytes_written));
649         seq_printf(m, "\nFlushes: %d",
650                    atomic_read(&tcon->stats.cifs_stats.num_flushes));
651         seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
652                    atomic_read(&tcon->stats.cifs_stats.num_locks),
653                    atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
654                    atomic_read(&tcon->stats.cifs_stats.num_symlinks));
655         seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
656                    atomic_read(&tcon->stats.cifs_stats.num_opens),
657                    atomic_read(&tcon->stats.cifs_stats.num_closes),
658                    atomic_read(&tcon->stats.cifs_stats.num_deletes));
659         seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
660                    atomic_read(&tcon->stats.cifs_stats.num_posixopens),
661                    atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
662         seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
663                    atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
664                    atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
665         seq_printf(m, "\nRenames: %d T2 Renames %d",
666                    atomic_read(&tcon->stats.cifs_stats.num_renames),
667                    atomic_read(&tcon->stats.cifs_stats.num_t2renames));
668         seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
669                    atomic_read(&tcon->stats.cifs_stats.num_ffirst),
670                    atomic_read(&tcon->stats.cifs_stats.num_fnext),
671                    atomic_read(&tcon->stats.cifs_stats.num_fclose));
672 }
673
674 static void
675 cifs_mkdir_setinfo(struct inode *inode, const char *full_path,
676                    struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
677                    const unsigned int xid)
678 {
679         FILE_BASIC_INFO info;
680         struct cifsInodeInfo *cifsInode;
681         u32 dosattrs;
682         int rc;
683
684         memset(&info, 0, sizeof(info));
685         cifsInode = CIFS_I(inode);
686         dosattrs = cifsInode->cifsAttrs|ATTR_READONLY;
687         info.Attributes = cpu_to_le32(dosattrs);
688         rc = CIFSSMBSetPathInfo(xid, tcon, full_path, &info, cifs_sb->local_nls,
689                                 cifs_remap(cifs_sb));
690         if (rc == 0)
691                 cifsInode->cifsAttrs = dosattrs;
692 }
693
694 static int
695 cifs_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
696                __u32 *oplock, FILE_ALL_INFO *buf)
697 {
698         if (!(oparms->tcon->ses->capabilities & CAP_NT_SMBS))
699                 return SMBLegacyOpen(xid, oparms->tcon, oparms->path,
700                                      oparms->disposition,
701                                      oparms->desired_access,
702                                      oparms->create_options,
703                                      &oparms->fid->netfid, oplock, buf,
704                                      oparms->cifs_sb->local_nls,
705                                      cifs_remap(oparms->cifs_sb));
706         return CIFS_open(xid, oparms, oplock, buf);
707 }
708
709 static void
710 cifs_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
711 {
712         struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
713         cfile->fid.netfid = fid->netfid;
714         cifs_set_oplock_level(cinode, oplock);
715         cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode);
716 }
717
718 static void
719 cifs_close_file(const unsigned int xid, struct cifs_tcon *tcon,
720                 struct cifs_fid *fid)
721 {
722         CIFSSMBClose(xid, tcon, fid->netfid);
723 }
724
725 static int
726 cifs_flush_file(const unsigned int xid, struct cifs_tcon *tcon,
727                 struct cifs_fid *fid)
728 {
729         return CIFSSMBFlush(xid, tcon, fid->netfid);
730 }
731
732 static int
733 cifs_sync_read(const unsigned int xid, struct cifs_fid *pfid,
734                struct cifs_io_parms *parms, unsigned int *bytes_read,
735                char **buf, int *buf_type)
736 {
737         parms->netfid = pfid->netfid;
738         return CIFSSMBRead(xid, parms, bytes_read, buf, buf_type);
739 }
740
741 static int
742 cifs_sync_write(const unsigned int xid, struct cifs_fid *pfid,
743                 struct cifs_io_parms *parms, unsigned int *written,
744                 struct kvec *iov, unsigned long nr_segs)
745 {
746
747         parms->netfid = pfid->netfid;
748         return CIFSSMBWrite2(xid, parms, written, iov, nr_segs);
749 }
750
751 static int
752 smb_set_file_info(struct inode *inode, const char *full_path,
753                   FILE_BASIC_INFO *buf, const unsigned int xid)
754 {
755         int oplock = 0;
756         int rc;
757         __u32 netpid;
758         struct cifs_fid fid;
759         struct cifs_open_parms oparms;
760         struct cifsFileInfo *open_file;
761         struct cifsInodeInfo *cinode = CIFS_I(inode);
762         struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
763         struct tcon_link *tlink = NULL;
764         struct cifs_tcon *tcon;
765
766         /* if the file is already open for write, just use that fileid */
767         open_file = find_writable_file(cinode, true);
768         if (open_file) {
769                 fid.netfid = open_file->fid.netfid;
770                 netpid = open_file->pid;
771                 tcon = tlink_tcon(open_file->tlink);
772                 goto set_via_filehandle;
773         }
774
775         tlink = cifs_sb_tlink(cifs_sb);
776         if (IS_ERR(tlink)) {
777                 rc = PTR_ERR(tlink);
778                 tlink = NULL;
779                 goto out;
780         }
781         tcon = tlink_tcon(tlink);
782
783         rc = CIFSSMBSetPathInfo(xid, tcon, full_path, buf, cifs_sb->local_nls,
784                                 cifs_remap(cifs_sb));
785         if (rc == 0) {
786                 cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
787                 goto out;
788         } else if (rc != -EOPNOTSUPP && rc != -EINVAL) {
789                 goto out;
790         }
791
792         oparms.tcon = tcon;
793         oparms.cifs_sb = cifs_sb;
794         oparms.desired_access = SYNCHRONIZE | FILE_WRITE_ATTRIBUTES;
795         oparms.create_options = CREATE_NOT_DIR;
796         oparms.disposition = FILE_OPEN;
797         oparms.path = full_path;
798         oparms.fid = &fid;
799         oparms.reconnect = false;
800
801         cifs_dbg(FYI, "calling SetFileInfo since SetPathInfo for times not supported by this server\n");
802         rc = CIFS_open(xid, &oparms, &oplock, NULL);
803         if (rc != 0) {
804                 if (rc == -EIO)
805                         rc = -EINVAL;
806                 goto out;
807         }
808
809         netpid = current->tgid;
810
811 set_via_filehandle:
812         rc = CIFSSMBSetFileInfo(xid, tcon, buf, fid.netfid, netpid);
813         if (!rc)
814                 cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
815
816         if (open_file == NULL)
817                 CIFSSMBClose(xid, tcon, fid.netfid);
818         else
819                 cifsFileInfo_put(open_file);
820 out:
821         if (tlink != NULL)
822                 cifs_put_tlink(tlink);
823         return rc;
824 }
825
826 static int
827 cifs_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
828                    struct cifsFileInfo *cfile)
829 {
830         return CIFSSMB_set_compression(xid, tcon, cfile->fid.netfid);
831 }
832
833 static int
834 cifs_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
835                      const char *path, struct cifs_sb_info *cifs_sb,
836                      struct cifs_fid *fid, __u16 search_flags,
837                      struct cifs_search_info *srch_inf)
838 {
839         int rc;
840
841         rc = CIFSFindFirst(xid, tcon, path, cifs_sb,
842                            &fid->netfid, search_flags, srch_inf, true);
843         if (rc)
844                 cifs_dbg(FYI, "find first failed=%d\n", rc);
845         return rc;
846 }
847
848 static int
849 cifs_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon,
850                     struct cifs_fid *fid, __u16 search_flags,
851                     struct cifs_search_info *srch_inf)
852 {
853         return CIFSFindNext(xid, tcon, fid->netfid, search_flags, srch_inf);
854 }
855
856 static int
857 cifs_close_dir(const unsigned int xid, struct cifs_tcon *tcon,
858                struct cifs_fid *fid)
859 {
860         return CIFSFindClose(xid, tcon, fid->netfid);
861 }
862
863 static int
864 cifs_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid,
865                      struct cifsInodeInfo *cinode)
866 {
867         return CIFSSMBLock(0, tcon, fid->netfid, current->tgid, 0, 0, 0, 0,
868                            LOCKING_ANDX_OPLOCK_RELEASE, false,
869                            CIFS_CACHE_READ(cinode) ? 1 : 0);
870 }
871
872 static int
873 cifs_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
874              struct kstatfs *buf)
875 {
876         int rc = -EOPNOTSUPP;
877
878         buf->f_type = CIFS_MAGIC_NUMBER;
879
880         /*
881          * We could add a second check for a QFS Unix capability bit
882          */
883         if ((tcon->ses->capabilities & CAP_UNIX) &&
884             (CIFS_POSIX_EXTENSIONS & le64_to_cpu(tcon->fsUnixInfo.Capability)))
885                 rc = CIFSSMBQFSPosixInfo(xid, tcon, buf);
886
887         /*
888          * Only need to call the old QFSInfo if failed on newer one,
889          * e.g. by OS/2.
890          **/
891         if (rc && (tcon->ses->capabilities & CAP_NT_SMBS))
892                 rc = CIFSSMBQFSInfo(xid, tcon, buf);
893
894         /*
895          * Some old Windows servers also do not support level 103, retry with
896          * older level one if old server failed the previous call or we
897          * bypassed it because we detected that this was an older LANMAN sess
898          */
899         if (rc)
900                 rc = SMBOldQFSInfo(xid, tcon, buf);
901         return rc;
902 }
903
904 static int
905 cifs_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
906                __u64 length, __u32 type, int lock, int unlock, bool wait)
907 {
908         return CIFSSMBLock(xid, tlink_tcon(cfile->tlink), cfile->fid.netfid,
909                            current->tgid, length, offset, unlock, lock,
910                            (__u8)type, wait, 0);
911 }
912
913 static int
914 cifs_unix_dfs_readlink(const unsigned int xid, struct cifs_tcon *tcon,
915                        const unsigned char *searchName, char **symlinkinfo,
916                        const struct nls_table *nls_codepage)
917 {
918 #ifdef CONFIG_CIFS_DFS_UPCALL
919         int rc;
920         struct dfs_info3_param referral = {0};
921
922         rc = get_dfs_path(xid, tcon->ses, searchName, nls_codepage, &referral,
923                           0);
924
925         if (!rc) {
926                 *symlinkinfo = kstrndup(referral.node_name,
927                                         strlen(referral.node_name),
928                                         GFP_KERNEL);
929                 free_dfs_info_param(&referral);
930                 if (!*symlinkinfo)
931                         rc = -ENOMEM;
932         }
933         return rc;
934 #else /* No DFS support */
935         return -EREMOTE;
936 #endif
937 }
938
939 static int
940 cifs_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
941                    struct cifs_sb_info *cifs_sb, const char *full_path,
942                    char **target_path, bool is_reparse_point)
943 {
944         int rc;
945         int oplock = 0;
946         struct cifs_fid fid;
947         struct cifs_open_parms oparms;
948
949         cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
950
951         if (is_reparse_point) {
952                 cifs_dbg(VFS, "reparse points not handled for SMB1 symlinks\n");
953                 return -EOPNOTSUPP;
954         }
955
956         /* Check for unix extensions */
957         if (cap_unix(tcon->ses)) {
958                 rc = CIFSSMBUnixQuerySymLink(xid, tcon, full_path, target_path,
959                                              cifs_sb->local_nls,
960                                              cifs_remap(cifs_sb));
961                 if (rc == -EREMOTE)
962                         rc = cifs_unix_dfs_readlink(xid, tcon, full_path,
963                                                     target_path,
964                                                     cifs_sb->local_nls);
965
966                 goto out;
967         }
968
969         oparms.tcon = tcon;
970         oparms.cifs_sb = cifs_sb;
971         oparms.desired_access = FILE_READ_ATTRIBUTES;
972         oparms.create_options = OPEN_REPARSE_POINT;
973         oparms.disposition = FILE_OPEN;
974         oparms.path = full_path;
975         oparms.fid = &fid;
976         oparms.reconnect = false;
977
978         rc = CIFS_open(xid, &oparms, &oplock, NULL);
979         if (rc)
980                 goto out;
981
982         rc = CIFSSMBQuerySymLink(xid, tcon, fid.netfid, target_path,
983                                  cifs_sb->local_nls);
984         if (rc)
985                 goto out_close;
986
987         convert_delimiter(*target_path, '/');
988 out_close:
989         CIFSSMBClose(xid, tcon, fid.netfid);
990 out:
991         if (!rc)
992                 cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
993         return rc;
994 }
995
996 static bool
997 cifs_is_read_op(__u32 oplock)
998 {
999         return oplock == OPLOCK_READ;
1000 }
1001
1002 static unsigned int
1003 cifs_wp_retry_size(struct inode *inode)
1004 {
1005         return CIFS_SB(inode->i_sb)->wsize;
1006 }
1007
1008 static bool
1009 cifs_dir_needs_close(struct cifsFileInfo *cfile)
1010 {
1011         return !cfile->srch_inf.endOfSearch && !cfile->invalidHandle;
1012 }
1013
1014 static bool
1015 cifs_can_echo(struct TCP_Server_Info *server)
1016 {
1017         if (server->tcpStatus == CifsGood)
1018                 return true;
1019
1020         return false;
1021 }
1022
1023 static int
1024 cifs_make_node(unsigned int xid, struct inode *inode,
1025                struct dentry *dentry, struct cifs_tcon *tcon,
1026                char *full_path, umode_t mode, dev_t dev)
1027 {
1028         struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1029         struct inode *newinode = NULL;
1030         int rc = -EPERM;
1031         int create_options = CREATE_NOT_DIR | CREATE_OPTION_SPECIAL;
1032         FILE_ALL_INFO *buf = NULL;
1033         struct cifs_io_parms io_parms;
1034         __u32 oplock = 0;
1035         struct cifs_fid fid;
1036         struct cifs_open_parms oparms;
1037         unsigned int bytes_written;
1038         struct win_dev *pdev;
1039         struct kvec iov[2];
1040
1041         if (tcon->unix_ext) {
1042                 /*
1043                  * SMB1 Unix Extensions: requires server support but
1044                  * works with all special files
1045                  */
1046                 struct cifs_unix_set_info_args args = {
1047                         .mode   = mode & ~current_umask(),
1048                         .ctime  = NO_CHANGE_64,
1049                         .atime  = NO_CHANGE_64,
1050                         .mtime  = NO_CHANGE_64,
1051                         .device = dev,
1052                 };
1053                 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
1054                         args.uid = current_fsuid();
1055                         args.gid = current_fsgid();
1056                 } else {
1057                         args.uid = INVALID_UID; /* no change */
1058                         args.gid = INVALID_GID; /* no change */
1059                 }
1060                 rc = CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args,
1061                                             cifs_sb->local_nls,
1062                                             cifs_remap(cifs_sb));
1063                 if (rc)
1064                         goto out;
1065
1066                 rc = cifs_get_inode_info_unix(&newinode, full_path,
1067                                               inode->i_sb, xid);
1068
1069                 if (rc == 0)
1070                         d_instantiate(dentry, newinode);
1071                 goto out;
1072         }
1073
1074         /*
1075          * SMB1 SFU emulation: should work with all servers, but only
1076          * support block and char device (no socket & fifo)
1077          */
1078         if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
1079                 goto out;
1080
1081         if (!S_ISCHR(mode) && !S_ISBLK(mode))
1082                 goto out;
1083
1084         cifs_dbg(FYI, "sfu compat create special file\n");
1085
1086         buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
1087         if (buf == NULL) {
1088                 rc = -ENOMEM;
1089                 goto out;
1090         }
1091
1092         if (backup_cred(cifs_sb))
1093                 create_options |= CREATE_OPEN_BACKUP_INTENT;
1094
1095         oparms.tcon = tcon;
1096         oparms.cifs_sb = cifs_sb;
1097         oparms.desired_access = GENERIC_WRITE;
1098         oparms.create_options = create_options;
1099         oparms.disposition = FILE_CREATE;
1100         oparms.path = full_path;
1101         oparms.fid = &fid;
1102         oparms.reconnect = false;
1103
1104         if (tcon->ses->server->oplocks)
1105                 oplock = REQ_OPLOCK;
1106         else
1107                 oplock = 0;
1108         rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, buf);
1109         if (rc)
1110                 goto out;
1111
1112         /*
1113          * BB Do not bother to decode buf since no local inode yet to put
1114          * timestamps in, but we can reuse it safely.
1115          */
1116
1117         pdev = (struct win_dev *)buf;
1118         io_parms.pid = current->tgid;
1119         io_parms.tcon = tcon;
1120         io_parms.offset = 0;
1121         io_parms.length = sizeof(struct win_dev);
1122         iov[1].iov_base = buf;
1123         iov[1].iov_len = sizeof(struct win_dev);
1124         if (S_ISCHR(mode)) {
1125                 memcpy(pdev->type, "IntxCHR", 8);
1126                 pdev->major = cpu_to_le64(MAJOR(dev));
1127                 pdev->minor = cpu_to_le64(MINOR(dev));
1128                 rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
1129                                                         &bytes_written, iov, 1);
1130         } else if (S_ISBLK(mode)) {
1131                 memcpy(pdev->type, "IntxBLK", 8);
1132                 pdev->major = cpu_to_le64(MAJOR(dev));
1133                 pdev->minor = cpu_to_le64(MINOR(dev));
1134                 rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
1135                                                         &bytes_written, iov, 1);
1136         }
1137         tcon->ses->server->ops->close(xid, tcon, &fid);
1138         d_drop(dentry);
1139
1140         /* FIXME: add code here to set EAs */
1141 out:
1142         kfree(buf);
1143         return rc;
1144 }
1145
1146
1147
1148 struct smb_version_operations smb1_operations = {
1149         .send_cancel = send_nt_cancel,
1150         .compare_fids = cifs_compare_fids,
1151         .setup_request = cifs_setup_request,
1152         .setup_async_request = cifs_setup_async_request,
1153         .check_receive = cifs_check_receive,
1154         .add_credits = cifs_add_credits,
1155         .set_credits = cifs_set_credits,
1156         .get_credits_field = cifs_get_credits_field,
1157         .get_credits = cifs_get_credits,
1158         .wait_mtu_credits = cifs_wait_mtu_credits,
1159         .get_next_mid = cifs_get_next_mid,
1160         .read_data_offset = cifs_read_data_offset,
1161         .read_data_length = cifs_read_data_length,
1162         .map_error = map_smb_to_linux_error,
1163         .find_mid = cifs_find_mid,
1164         .check_message = checkSMB,
1165         .dump_detail = cifs_dump_detail,
1166         .clear_stats = cifs_clear_stats,
1167         .print_stats = cifs_print_stats,
1168         .is_oplock_break = is_valid_oplock_break,
1169         .downgrade_oplock = cifs_downgrade_oplock,
1170         .check_trans2 = cifs_check_trans2,
1171         .need_neg = cifs_need_neg,
1172         .negotiate = cifs_negotiate,
1173         .negotiate_wsize = cifs_negotiate_wsize,
1174         .negotiate_rsize = cifs_negotiate_rsize,
1175         .sess_setup = CIFS_SessSetup,
1176         .logoff = CIFSSMBLogoff,
1177         .tree_connect = CIFSTCon,
1178         .tree_disconnect = CIFSSMBTDis,
1179         .get_dfs_refer = CIFSGetDFSRefer,
1180         .qfs_tcon = cifs_qfs_tcon,
1181         .is_path_accessible = cifs_is_path_accessible,
1182         .can_echo = cifs_can_echo,
1183         .query_path_info = cifs_query_path_info,
1184         .query_file_info = cifs_query_file_info,
1185         .get_srv_inum = cifs_get_srv_inum,
1186         .set_path_size = CIFSSMBSetEOF,
1187         .set_file_size = CIFSSMBSetFileSize,
1188         .set_file_info = smb_set_file_info,
1189         .set_compression = cifs_set_compression,
1190         .echo = CIFSSMBEcho,
1191         .mkdir = CIFSSMBMkDir,
1192         .mkdir_setinfo = cifs_mkdir_setinfo,
1193         .rmdir = CIFSSMBRmDir,
1194         .unlink = CIFSSMBDelFile,
1195         .rename_pending_delete = cifs_rename_pending_delete,
1196         .rename = CIFSSMBRename,
1197         .create_hardlink = CIFSCreateHardLink,
1198         .query_symlink = cifs_query_symlink,
1199         .open = cifs_open_file,
1200         .set_fid = cifs_set_fid,
1201         .close = cifs_close_file,
1202         .flush = cifs_flush_file,
1203         .async_readv = cifs_async_readv,
1204         .async_writev = cifs_async_writev,
1205         .sync_read = cifs_sync_read,
1206         .sync_write = cifs_sync_write,
1207         .query_dir_first = cifs_query_dir_first,
1208         .query_dir_next = cifs_query_dir_next,
1209         .close_dir = cifs_close_dir,
1210         .calc_smb_size = smbCalcSize,
1211         .oplock_response = cifs_oplock_response,
1212         .queryfs = cifs_queryfs,
1213         .mand_lock = cifs_mand_lock,
1214         .mand_unlock_range = cifs_unlock_range,
1215         .push_mand_locks = cifs_push_mandatory_locks,
1216         .query_mf_symlink = cifs_query_mf_symlink,
1217         .create_mf_symlink = cifs_create_mf_symlink,
1218         .is_read_op = cifs_is_read_op,
1219         .wp_retry_size = cifs_wp_retry_size,
1220         .dir_needs_close = cifs_dir_needs_close,
1221         .select_sectype = cifs_select_sectype,
1222 #ifdef CONFIG_CIFS_XATTR
1223         .query_all_EAs = CIFSSMBQAllEAs,
1224         .set_EA = CIFSSMBSetEA,
1225 #endif /* CIFS_XATTR */
1226         .get_acl = get_cifs_acl,
1227         .get_acl_by_fid = get_cifs_acl_by_fid,
1228         .set_acl = set_cifs_acl,
1229         .make_node = cifs_make_node,
1230 };
1231
1232 struct smb_version_values smb1_values = {
1233         .version_string = SMB1_VERSION_STRING,
1234         .protocol_id = SMB10_PROT_ID,
1235         .large_lock_type = LOCKING_ANDX_LARGE_FILES,
1236         .exclusive_lock_type = 0,
1237         .shared_lock_type = LOCKING_ANDX_SHARED_LOCK,
1238         .unlock_lock_type = 0,
1239         .header_preamble_size = 4,
1240         .header_size = sizeof(struct smb_hdr),
1241         .max_header_size = MAX_CIFS_HDR_SIZE,
1242         .read_rsp_size = sizeof(READ_RSP),
1243         .lock_cmd = cpu_to_le16(SMB_COM_LOCKING_ANDX),
1244         .cap_unix = CAP_UNIX,
1245         .cap_nt_find = CAP_NT_SMBS | CAP_NT_FIND,
1246         .cap_large_files = CAP_LARGE_FILES,
1247         .signing_enabled = SECMODE_SIGN_ENABLED,
1248         .signing_required = SECMODE_SIGN_REQUIRED,
1249 };