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