Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2)  *   fs/cifs/cifsglob.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *   Copyright (C) International Business Machines  Corp., 2002,2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *   Author(s): Steve French (sfrench@us.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  *              Jeremy Allison (jra@samba.org)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  *   This library is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  *   it under the terms of the GNU Lesser General Public License as published
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  *   by the Free Software Foundation; either version 2.1 of the License, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  *   (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)  *   This library is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14)  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15)  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16)  *   the GNU Lesser General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #ifndef _CIFS_GLOB_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #define _CIFS_GLOB_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include <linux/in6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #include <linux/mempool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #include "cifs_fs_sb.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #include "cifsacl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #include <crypto/internal/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #include <linux/scatterlist.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) #include <uapi/linux/cifs/cifs_mount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) #include "smb2pdu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) #define CIFS_MAGIC_NUMBER 0xFF534D42      /* the first four bytes of SMB PDUs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) #define SMB_PATH_MAX 260
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) #define CIFS_PORT 445
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) #define RFC1001_PORT 139
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41)  * The sizes of various internal tables and strings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) #define MAX_UID_INFO 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) #define MAX_SES_INFO 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) #define MAX_TCON_INFO 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) #define MAX_TREE_SIZE (2 + CIFS_NI_MAXHOST + 1 + CIFS_MAX_SHARE_LEN + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) #define CIFS_MIN_RCV_POOL 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) #define MAX_REOPEN_ATT	5 /* these many maximum attempts to reopen a file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53)  * default attribute cache timeout (jiffies)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) #define CIFS_DEF_ACTIMEO (1 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58)  * max attribute cache timeout (jiffies) - 2^30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) #define CIFS_MAX_ACTIMEO (1 << 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63)  * Max persistent and resilient handle timeout (milliseconds).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64)  * Windows durable max was 960000 (16 minutes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) #define SMB3_MAX_HANDLE_TIMEOUT 960000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69)  * MAX_REQ is the maximum number of requests that WE will send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70)  * on one socket concurrently.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) #define CIFS_MAX_REQ 32767
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) #define RFC1001_NAME_LEN 15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) #define RFC1001_NAME_LEN_WITH_NULL (RFC1001_NAME_LEN + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) /* maximum length of ip addr as a string (including ipv6 and sctp) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) #define SERVER_NAME_LENGTH 80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) #define SERVER_NAME_LEN_WITH_NULL     (SERVER_NAME_LENGTH + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) /* echo interval in seconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) #define SMB_ECHO_INTERVAL_MIN 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) #define SMB_ECHO_INTERVAL_MAX 600
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) #define SMB_ECHO_INTERVAL_DEFAULT 60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) /* maximum number of PDUs in one compound */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) #define MAX_COMPOUND 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90)  * Default number of credits to keep available for SMB3.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91)  * This value is chosen somewhat arbitrarily. The Windows client
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92)  * defaults to 128 credits, the Windows server allows clients up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93)  * 512 credits (or 8K for later versions), and the NetApp server
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94)  * does not limit clients at all.  Choose a high enough default value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95)  * such that the client shouldn't limit performance, but allow mount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96)  * to override (until you approach 64K, where we limit credits to 65000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97)  * to reduce possibility of seeing more server credit overflow bugs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) #define SMB2_MAX_CREDITS_AVAILABLE 32000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) #include "cifspdu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) #ifndef XATTR_DOS_ATTRIB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) #define XATTR_DOS_ATTRIB "user.DOSATTRIB"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108)  * CIFS vfs client Status information (based on what we know.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) /* associated with each tcp and smb session */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) enum statusEnum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 	CifsNew = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	CifsGood,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	CifsExiting,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	CifsNeedReconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 	CifsNeedNegotiate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) enum securityEnum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	Unspecified = 0,	/* not specified */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	LANMAN,			/* Legacy LANMAN auth */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	NTLM,			/* Legacy NTLM012 auth with NTLM hash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 	NTLMv2,			/* Legacy NTLM auth with NTLMv2 hash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	RawNTLMSSP,		/* NTLMSSP without SPNEGO, NTLMv2 hash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 	Kerberos,		/* Kerberos via SPNEGO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) struct session_key {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 	unsigned int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 	char *response;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) /* crypto security descriptor definition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) struct sdesc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	struct shash_desc shash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	char ctx[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) /* crypto hashing related structure/fields, not specific to a sec mech */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) struct cifs_secmech {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 	struct crypto_shash *hmacmd5; /* hmac-md5 hash function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	struct crypto_shash *md5; /* md5 hash function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 	struct crypto_shash *hmacsha256; /* hmac-sha256 hash function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 	struct crypto_shash *cmacaes; /* block-cipher based MAC function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 	struct crypto_shash *sha512; /* sha512 hash function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 	struct sdesc *sdeschmacmd5;  /* ctxt to generate ntlmv2 hash, CR1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 	struct sdesc *sdescmd5; /* ctxt to generate cifs/smb signature */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 	struct sdesc *sdeschmacsha256;  /* ctxt to generate smb2 signature */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 	struct sdesc *sdesccmacaes;  /* ctxt to generate smb3 signature */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	struct sdesc *sdescsha512; /* ctxt to generate smb3.11 signing key */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	struct crypto_aead *ccmaesencrypt; /* smb3 encryption aead */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	struct crypto_aead *ccmaesdecrypt; /* smb3 decryption aead */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) /* per smb session structure/fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) struct ntlmssp_auth {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	bool sesskey_per_smbsess; /* whether session key is per smb session */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 	__u32 client_flags; /* sent by client in type 1 ntlmsssp exchange */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	__u32 server_flags; /* sent by server in type 2 ntlmssp exchange */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	unsigned char ciphertext[CIFS_CPHTXT_SIZE]; /* sent to server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlmssp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) struct cifs_cred {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	int uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 	int gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	int mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	int cecount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 	struct cifs_sid osid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 	struct cifs_sid gsid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	struct cifs_ntace *ntaces;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	struct cifs_ace *aces;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177)  *****************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178)  * Except the CIFS PDUs themselves all the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179)  * globally interesting structs should go here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180)  *****************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184)  * A smb_rqst represents a complete request to be issued to a server. It's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185)  * formed by a kvec array, followed by an array of pages. Page data is assumed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186)  * to start at the beginning of the first page.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) struct smb_rqst {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	struct kvec	*rq_iov;	/* array of kvecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	unsigned int	rq_nvec;	/* number of kvecs in array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	struct page	**rq_pages;	/* pointer to array of page ptrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	unsigned int	rq_offset;	/* the offset to the 1st page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	unsigned int	rq_npages;	/* number pages in array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	unsigned int	rq_pagesz;	/* page size to use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 	unsigned int	rq_tailsz;	/* length of last page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) struct mid_q_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) struct TCP_Server_Info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) struct cifsFileInfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) struct cifs_ses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) struct cifs_tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) struct dfs_info3_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) struct cifs_fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) struct smb_vol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) struct cifs_fid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) struct cifs_readdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) struct cifs_writedata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) struct cifs_io_parms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) struct cifs_search_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) struct cifsInodeInfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) struct cifs_open_parms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) struct cifs_credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) struct smb_version_operations {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	int (*send_cancel)(struct TCP_Server_Info *, struct smb_rqst *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 			   struct mid_q_entry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 	bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	/* setup request: allocate mid, sign message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 	struct mid_q_entry *(*setup_request)(struct cifs_ses *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 					     struct TCP_Server_Info *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 					     struct smb_rqst *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	/* setup async request: allocate mid, sign message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	struct mid_q_entry *(*setup_async_request)(struct TCP_Server_Info *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 						struct smb_rqst *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	/* check response: verify signature, map error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 			     bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 	void (*add_credits)(struct TCP_Server_Info *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 			    const struct cifs_credits *credits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 			    const int optype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	void (*set_credits)(struct TCP_Server_Info *, const int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 	int * (*get_credits_field)(struct TCP_Server_Info *, const int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	unsigned int (*get_credits)(struct mid_q_entry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 	__u64 (*get_next_mid)(struct TCP_Server_Info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 	void (*revert_current_mid)(struct TCP_Server_Info *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 				   const unsigned int val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 	/* data offset from read response message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 	unsigned int (*read_data_offset)(char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 	 * Data length from read response message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 	 * When in_remaining is true, the returned data length is in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	 * message field DataRemaining for out-of-band data read (e.g through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 	 * Memory Registration RDMA write in SMBD).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	 * Otherwise, the returned data length is in message field DataLength.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	unsigned int (*read_data_length)(char *, bool in_remaining);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 	/* map smb to linux error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	int (*map_error)(char *, bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	/* find mid corresponding to the response message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	struct mid_q_entry * (*find_mid)(struct TCP_Server_Info *, char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	void (*dump_detail)(void *buf, struct TCP_Server_Info *ptcp_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	void (*clear_stats)(struct cifs_tcon *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	void (*print_stats)(struct seq_file *m, struct cifs_tcon *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	void (*dump_share_caps)(struct seq_file *, struct cifs_tcon *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 	/* verify the message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	int (*check_message)(char *, unsigned int, struct TCP_Server_Info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	bool (*is_oplock_break)(char *, struct TCP_Server_Info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	int (*handle_cancelled_mid)(struct mid_q_entry *, struct TCP_Server_Info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 	void (*downgrade_oplock)(struct TCP_Server_Info *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 				 struct cifsInodeInfo *cinode, __u32 oplock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 				 unsigned int epoch, bool *purge_cache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	/* process transaction2 response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	bool (*check_trans2)(struct mid_q_entry *, struct TCP_Server_Info *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 			     char *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	/* check if we need to negotiate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	bool (*need_neg)(struct TCP_Server_Info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	/* negotiate to the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 	int (*negotiate)(const unsigned int, struct cifs_ses *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	/* set negotiated write size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	unsigned int (*negotiate_wsize)(struct cifs_tcon *, struct smb_vol *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	/* set negotiated read size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 	unsigned int (*negotiate_rsize)(struct cifs_tcon *, struct smb_vol *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 	/* setup smb sessionn */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 	int (*sess_setup)(const unsigned int, struct cifs_ses *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 			  const struct nls_table *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 	/* close smb session */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 	int (*logoff)(const unsigned int, struct cifs_ses *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 	/* connect to a server share */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 	int (*tree_connect)(const unsigned int, struct cifs_ses *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 			    struct cifs_tcon *, const struct nls_table *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 	/* close tree connecion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 	int (*tree_disconnect)(const unsigned int, struct cifs_tcon *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 	/* get DFS referrals */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 	int (*get_dfs_refer)(const unsigned int, struct cifs_ses *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 			     const char *, struct dfs_info3_param **,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 			     unsigned int *, const struct nls_table *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 	/* informational QFS call */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 	void (*qfs_tcon)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 			 struct cifs_sb_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 	/* check if a path is accessible or not */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 	int (*is_path_accessible)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 				  struct cifs_sb_info *, const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	/* query path data from the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	int (*query_path_info)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 			       struct cifs_sb_info *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 			       FILE_ALL_INFO *, bool *, bool *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	/* query file data from the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	int (*query_file_info)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 			       struct cifs_fid *, FILE_ALL_INFO *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	/* query reparse tag from srv to determine which type of special file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	int (*query_reparse_tag)(const unsigned int xid, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 				struct cifs_sb_info *cifs_sb, const char *path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 				__u32 *reparse_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 	/* get server index number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	int (*get_srv_inum)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 			    struct cifs_sb_info *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 			    u64 *uniqueid, FILE_ALL_INFO *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	/* set size by path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	int (*set_path_size)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 			     const char *, __u64, struct cifs_sb_info *, bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 	/* set size by file handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	int (*set_file_size)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 			     struct cifsFileInfo *, __u64, bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	/* set attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	int (*set_file_info)(struct inode *, const char *, FILE_BASIC_INFO *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 			     const unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	int (*set_compression)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 			       struct cifsFileInfo *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	/* check if we can send an echo or nor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 	bool (*can_echo)(struct TCP_Server_Info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	/* send echo request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	int (*echo)(struct TCP_Server_Info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 	/* create directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 	int (*posix_mkdir)(const unsigned int xid, struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 			umode_t mode, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 			const char *full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 			struct cifs_sb_info *cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 	int (*mkdir)(const unsigned int xid, struct inode *inode, umode_t mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 		     struct cifs_tcon *tcon, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 		     struct cifs_sb_info *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	/* set info on created directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	void (*mkdir_setinfo)(struct inode *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 			      struct cifs_sb_info *, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 			      const unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	/* remove directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 	int (*rmdir)(const unsigned int, struct cifs_tcon *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 		     struct cifs_sb_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	/* unlink file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	int (*unlink)(const unsigned int, struct cifs_tcon *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 		      struct cifs_sb_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	/* open, rename and delete file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	int (*rename_pending_delete)(const char *, struct dentry *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 				     const unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 	/* send rename request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	int (*rename)(const unsigned int, struct cifs_tcon *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 		      const char *, struct cifs_sb_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	/* send create hardlink request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	int (*create_hardlink)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 			       const char *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 			       struct cifs_sb_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 	/* query symlink target */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	int (*query_symlink)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 			     struct cifs_sb_info *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 			     char **, bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	/* open a file for non-posix mounts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 	int (*open)(const unsigned int, struct cifs_open_parms *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 		    __u32 *, FILE_ALL_INFO *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	/* set fid protocol-specific info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	void (*set_fid)(struct cifsFileInfo *, struct cifs_fid *, __u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 	/* close a file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 	void (*close)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 		      struct cifs_fid *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 	/* close a file, returning file attributes and timestamps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 	void (*close_getattr)(const unsigned int xid, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 		      struct cifsFileInfo *pfile_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 	/* send a flush request to the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	int (*flush)(const unsigned int, struct cifs_tcon *, struct cifs_fid *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 	/* async read from the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	int (*async_readv)(struct cifs_readdata *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 	/* async write to the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 	int (*async_writev)(struct cifs_writedata *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 			    void (*release)(struct kref *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	/* sync read from the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	int (*sync_read)(const unsigned int, struct cifs_fid *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 			 struct cifs_io_parms *, unsigned int *, char **,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 			 int *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	/* sync write to the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 	int (*sync_write)(const unsigned int, struct cifs_fid *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 			  struct cifs_io_parms *, unsigned int *, struct kvec *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 			  unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 	/* open dir, start readdir */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	int (*query_dir_first)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 			       const char *, struct cifs_sb_info *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 			       struct cifs_fid *, __u16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 			       struct cifs_search_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 	/* continue readdir */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 	int (*query_dir_next)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 			      struct cifs_fid *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 			      __u16, struct cifs_search_info *srch_inf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 	/* close dir */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 	int (*close_dir)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 			 struct cifs_fid *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 	/* calculate a size of SMB message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 	unsigned int (*calc_smb_size)(void *buf, struct TCP_Server_Info *ptcpi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	/* check for STATUS_PENDING and process the response if yes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 	bool (*is_status_pending)(char *buf, struct TCP_Server_Info *server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	/* check for STATUS_NETWORK_SESSION_EXPIRED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 	bool (*is_session_expired)(char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 	/* send oplock break response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 	int (*oplock_response)(struct cifs_tcon *, struct cifs_fid *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 			       struct cifsInodeInfo *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 	/* query remote filesystem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	int (*queryfs)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 		       struct cifs_sb_info *, struct kstatfs *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	/* send mandatory brlock to the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 	int (*mand_lock)(const unsigned int, struct cifsFileInfo *, __u64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 			 __u64, __u32, int, int, bool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 	/* unlock range of mandatory locks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 	int (*mand_unlock_range)(struct cifsFileInfo *, struct file_lock *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 				 const unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 	/* push brlocks from the cache to the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 	int (*push_mand_locks)(struct cifsFileInfo *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	/* get lease key of the inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	void (*get_lease_key)(struct inode *, struct cifs_fid *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 	/* set lease key of the inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 	void (*set_lease_key)(struct inode *, struct cifs_fid *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 	/* generate new lease key */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 	void (*new_lease_key)(struct cifs_fid *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 	int (*generate_signingkey)(struct cifs_ses *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 	int (*calc_signature)(struct smb_rqst *, struct TCP_Server_Info *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 				bool allocate_crypto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 	int (*set_integrity)(const unsigned int, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 			     struct cifsFileInfo *src_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 	int (*enum_snapshots)(const unsigned int xid, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 			     struct cifsFileInfo *src_file, void __user *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	int (*notify)(const unsigned int xid, struct file *pfile,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 			     void __user *pbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	int (*query_mf_symlink)(unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 				struct cifs_sb_info *, const unsigned char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 				char *, unsigned int *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 	int (*create_mf_symlink)(unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 				 struct cifs_sb_info *, const unsigned char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 				 char *, unsigned int *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 	/* if we can do cache read operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	bool (*is_read_op)(__u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 	/* set oplock level for the inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 	void (*set_oplock_level)(struct cifsInodeInfo *, __u32, unsigned int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 				 bool *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 	/* create lease context buffer for CREATE request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	char * (*create_lease_buf)(u8 *lease_key, u8 oplock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	/* parse lease context buffer and return oplock/epoch info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	__u8 (*parse_lease_buf)(void *buf, unsigned int *epoch, char *lkey);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 	ssize_t (*copychunk_range)(const unsigned int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 			struct cifsFileInfo *src_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 			struct cifsFileInfo *target_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 			u64 src_off, u64 len, u64 dest_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 	int (*duplicate_extents)(const unsigned int, struct cifsFileInfo *src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 			struct cifsFileInfo *target_file, u64 src_off, u64 len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 			u64 dest_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 	int (*validate_negotiate)(const unsigned int, struct cifs_tcon *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 	ssize_t (*query_all_EAs)(const unsigned int, struct cifs_tcon *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 			const unsigned char *, const unsigned char *, char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 			size_t, struct cifs_sb_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 	int (*set_EA)(const unsigned int, struct cifs_tcon *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 			const char *, const void *, const __u16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 			const struct nls_table *, struct cifs_sb_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	struct cifs_ntsd * (*get_acl)(struct cifs_sb_info *, struct inode *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 			const char *, u32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	struct cifs_ntsd * (*get_acl_by_fid)(struct cifs_sb_info *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 			const struct cifs_fid *, u32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	int (*set_acl)(struct cifs_ntsd *, __u32, struct inode *, const char *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 			int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	/* writepages retry size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	unsigned int (*wp_retry_size)(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 	/* get mtu credits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	int (*wait_mtu_credits)(struct TCP_Server_Info *, unsigned int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 				unsigned int *, struct cifs_credits *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	/* adjust previously taken mtu credits to request size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	int (*adjust_credits)(struct TCP_Server_Info *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 			      struct cifs_credits *credits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 			      const unsigned int payload_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	/* check if we need to issue closedir */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 	bool (*dir_needs_close)(struct cifsFileInfo *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 	long (*fallocate)(struct file *, struct cifs_tcon *, int, loff_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 			  loff_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	/* init transform request - used for encryption for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 	int (*init_transform_rq)(struct TCP_Server_Info *, int num_rqst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 				 struct smb_rqst *, struct smb_rqst *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	int (*is_transform_hdr)(void *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	int (*receive_transform)(struct TCP_Server_Info *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 				 struct mid_q_entry **, char **, int *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	enum securityEnum (*select_sectype)(struct TCP_Server_Info *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 			    enum securityEnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	int (*next_header)(char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	/* ioctl passthrough for query_info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	int (*ioctl_query_info)(const unsigned int xid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 				struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 				struct cifs_sb_info *cifs_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 				__le16 *path, int is_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 				unsigned long p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	/* make unix special files (block, char, fifo, socket) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	int (*make_node)(unsigned int xid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 			 struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 			 struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 			 struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 			 char *full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 			 umode_t mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 			 dev_t device_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	/* version specific fiemap implementation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 	int (*fiemap)(struct cifs_tcon *tcon, struct cifsFileInfo *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 		      struct fiemap_extent_info *, u64, u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	/* version specific llseek implementation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 	loff_t (*llseek)(struct file *, struct cifs_tcon *, loff_t, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 	/* Check for STATUS_IO_TIMEOUT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 	bool (*is_status_io_timeout)(char *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) struct smb_version_values {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	char		*version_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	__u16		protocol_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 	__u32		req_capabilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	__u32		large_lock_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	__u32		exclusive_lock_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	__u32		shared_lock_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	__u32		unlock_lock_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	size_t		header_preamble_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 	size_t		header_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 	size_t		max_header_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 	size_t		read_rsp_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 	__le16		lock_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 	unsigned int	cap_unix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 	unsigned int	cap_nt_find;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 	unsigned int	cap_large_files;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	__u16		signing_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 	__u16		signing_required;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 	size_t		create_lease_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) #define HEADER_SIZE(server) (server->vals->header_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) #define MAX_HEADER_SIZE(server) (server->vals->max_header_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) struct smb_vol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 	char *username;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 	char *password;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 	char *domainname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 	char *UNC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 	char *iocharset;  /* local code page for mapping to and from Unicode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 	char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	kuid_t cred_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	kuid_t linux_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 	kgid_t linux_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 	kuid_t backupuid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 	kgid_t backupgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	umode_t file_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 	umode_t dir_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 	enum securityEnum sectype; /* sectype requested via mnt opts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 	bool sign; /* was signing requested via mnt opts? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 	bool ignore_signature:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	bool retry:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 	bool intr:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	bool setuids:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 	bool setuidfromacl:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 	bool override_uid:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 	bool override_gid:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 	bool dynperm:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 	bool noperm:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	bool nodelete:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 	bool mode_ace:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 	bool no_psx_acl:1; /* set if posix acl support should be disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 	bool cifs_acl:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	bool backupuid_specified; /* mount option  backupuid  is specified */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	bool backupgid_specified; /* mount option  backupgid  is specified */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	bool no_xattr:1;   /* set if xattr (EA) support should be disabled*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	bool server_ino:1; /* use inode numbers from server ie UniqueId */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	bool direct_io:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	bool strict_io:1; /* strict cache behavior */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	bool cache_ro:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	bool cache_rw:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 	bool remap:1;      /* set to remap seven reserved chars in filenames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 	bool sfu_remap:1;  /* remap seven reserved chars ala SFU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	bool posix_paths:1; /* unset to not ask for posix pathnames. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	bool no_linux_ext:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	bool linux_ext:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 	bool sfu_emul:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	bool nullauth:1;   /* attempt to authenticate with null user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 	bool nocase:1;     /* request case insensitive filenames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	bool nobrl:1;      /* disable sending byte range locks to srv */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 	bool nohandlecache:1; /* disable caching dir handles if srvr probs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	bool mand_lock:1;  /* send mandatory not posix byte range lock reqs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 	bool seal:1;       /* request transport encryption on share */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	bool nodfs:1;      /* Do not request DFS, even if available */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 	bool local_lease:1; /* check leases only on local system, not remote */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 	bool noblocksnd:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	bool noautotune:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 	bool no_lease:1;     /* disable requesting leases */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	bool fsc:1;	/* enable fscache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	bool mfsymlinks:1; /* use Minshall+French Symlinks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 	bool multiuser:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 	bool rwpidforward:1; /* pid forward for read/write operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 	bool nosharesock:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 	bool persistent:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	bool nopersistent:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	bool resilient:1; /* noresilient not required since not fored for CA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	bool domainauto:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	bool rdma:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	bool multichannel:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 	bool use_client_guid:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 	/* reuse existing guid for multichannel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 	u8 client_guid[SMB2_CLIENT_GUID_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 	unsigned int bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 	unsigned int rsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 	unsigned int wsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 	unsigned int min_offload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 	bool sockopt_tcp_nodelay:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 	unsigned long actimeo; /* attribute cache timeout (jiffies) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	struct smb_version_operations *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	struct smb_version_values *vals;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 	char *prepath;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	struct sockaddr_storage dstaddr; /* destination address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 	struct sockaddr_storage srcaddr; /* allow binding to a local IP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 	struct nls_table *local_nls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 	unsigned int echo_interval; /* echo interval in secs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 	__u64 snapshot_time; /* needed for timewarp tokens */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 	__u32 handle_timeout; /* persistent and durable handle timeout in ms */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 	unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 	unsigned int max_channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 	__u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	bool rootfs:1; /* if it's a SMB root file system */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625)  * CIFS superblock mount flags (mnt_cifs_flags) to consider when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626)  * trying to reuse existing superblock for a new mount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) #define CIFS_MOUNT_MASK (CIFS_MOUNT_NO_PERM | CIFS_MOUNT_SET_UID | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 			 CIFS_MOUNT_SERVER_INUM | CIFS_MOUNT_DIRECT_IO | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 			 CIFS_MOUNT_NO_XATTR | CIFS_MOUNT_MAP_SPECIAL_CHR | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 			 CIFS_MOUNT_MAP_SFM_CHR | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 			 CIFS_MOUNT_UNX_EMUL | CIFS_MOUNT_NO_BRL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 			 CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_OVERR_UID | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 			 CIFS_MOUNT_OVERR_GID | CIFS_MOUNT_DYNPERM | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 			 CIFS_MOUNT_NOPOSIXBRL | CIFS_MOUNT_NOSSYNC | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 			 CIFS_MOUNT_FSCACHE | CIFS_MOUNT_MF_SYMLINKS | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 			 CIFS_MOUNT_MULTIUSER | CIFS_MOUNT_STRICT_IO | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 			 CIFS_MOUNT_CIFS_BACKUPUID | CIFS_MOUNT_CIFS_BACKUPGID | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 			 CIFS_MOUNT_UID_FROM_ACL | CIFS_MOUNT_NO_HANDLE_CACHE | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 			 CIFS_MOUNT_NO_DFS | CIFS_MOUNT_MODE_FROM_SID | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 			 CIFS_MOUNT_RO_CACHE | CIFS_MOUNT_RW_CACHE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644)  * Generic VFS superblock mount flags (s_flags) to consider when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645)  * trying to reuse existing superblock for a new mount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) #define CIFS_MS_MASK (SB_RDONLY | SB_MANDLOCK | SB_NOEXEC | SB_NOSUID | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 		      SB_NODEV | SB_SYNCHRONOUS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) struct cifs_mnt_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	struct cifs_sb_info *cifs_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 	struct smb_vol *vol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) static inline unsigned int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) get_rfc1002_length(void *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) inc_rfc1001_len(void *buf, int count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	be32_add_cpu((__be32 *)buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) struct TCP_Server_Info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 	struct list_head tcp_ses_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 	struct list_head smb_ses_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 	int srv_count; /* reference counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	/* 15 character server name + 0x20 16th byte indicating type = srv */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 	struct smb_version_operations	*ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	struct smb_version_values	*vals;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 	enum statusEnum tcpStatus; /* what we think the status is */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	char *hostname; /* hostname portion of UNC string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 	struct socket *ssocket;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 	struct sockaddr_storage dstaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 	struct sockaddr_storage srcaddr; /* locally bind to this IP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) #ifdef CONFIG_NET_NS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 	struct net *net;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 	wait_queue_head_t response_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 	wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 	struct list_head pending_mid_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 	bool noblocksnd;		/* use blocking sendmsg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	bool noautotune;		/* do not autotune send buf sizes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	bool tcp_nodelay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 	unsigned int credits;  /* send no more requests at once */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 	unsigned int max_credits; /* can override large 32000 default at mnt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 	unsigned int in_flight;  /* number of requests on the wire to server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	unsigned int max_in_flight; /* max number of requests that were on wire */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	spinlock_t req_lock;  /* protect the two values above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	struct mutex srv_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	struct task_struct *tsk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 	char server_GUID[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 	__u16 sec_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 	bool sign; /* is signing enabled on this connection? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	bool ignore_signature:1; /* skip validation of signatures in SMB2/3 rsp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 	bool session_estab; /* mark when very first sess is established */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 	int echo_credits;  /* echo reserved slots */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 	int oplock_credits;  /* oplock break reserved slots */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	bool echoes:1; /* enable echoes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 	__u8 client_guid[SMB2_CLIENT_GUID_SIZE]; /* Client GUID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 	u16 dialect; /* dialect index that server chose */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 	bool oplocks:1; /* enable oplocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	unsigned int maxReq;	/* Clients should submit no more */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	/* than maxReq distinct unanswered SMBs to the server when using  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	/* multiplexed reads or writes (for SMB1/CIFS only, not SMB2/SMB3) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	unsigned int maxBuf;	/* maxBuf specifies the maximum */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 	/* message size the server can send or receive for non-raw SMBs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 	/* maxBuf is returned by SMB NegotiateProtocol so maxBuf is only 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 	/* when socket is setup (and during reconnect) before NegProt sent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 	unsigned int max_rw;	/* maxRw specifies the maximum */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 	/* message size the server can send or receive for */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 	/* SMB_COM_WRITE_RAW or SMB_COM_READ_RAW. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 	unsigned int capabilities; /* selective disabling of caps by smb sess */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	int timeAdj;  /* Adjust for difference in server time zone in sec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 	__u64 CurrentMid;         /* multiplex id - rotating counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 	char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlm, ntlmv2 etc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 	/* 16th byte of RFC1001 workstation name is always null */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 	char workstation_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	__u32 sequence_number; /* for signing, protected by srv_mutex */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 	__u32 reconnect_instance; /* incremented on each reconnect */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	struct session_key session_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	unsigned long lstrp; /* when we got last response from this server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	struct cifs_secmech secmech; /* crypto sec mech functs, descriptors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) #define	CIFS_NEGFLAVOR_LANMAN	0	/* wct == 13, LANMAN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) #define	CIFS_NEGFLAVOR_UNENCAP	1	/* wct == 17, but no ext_sec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) #define	CIFS_NEGFLAVOR_EXTENDED	2	/* wct == 17, ext_sec bit set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 	char	negflavor;	/* NEGOTIATE response flavor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	/* extended security flavors that server supports */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 	bool	sec_ntlmssp;		/* supports NTLMSSP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	bool	sec_kerberosu2u;	/* supports U2U Kerberos */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	bool	sec_kerberos;		/* supports plain Kerberos */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	bool	sec_mskerberos;		/* supports legacy MS Kerberos */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	bool	large_buf;		/* is current buffer large? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	/* use SMBD connection instead of socket */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	bool	rdma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	/* point to the SMBD connection if RDMA is used instead of socket */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	struct smbd_connection *smbd_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	struct delayed_work	echo; /* echo ping workqueue job */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	char	*smallbuf;	/* pointer to current "small" buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	char	*bigbuf;	/* pointer to current "big" buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	/* Total size of this PDU. Only valid from cifs_demultiplex_thread */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	unsigned int pdu_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	unsigned int total_read; /* total amount of data read in this pass */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	atomic_t in_send; /* requests trying to send */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	atomic_t num_waiters;   /* blocked waiting to get in sendrecv */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) #ifdef CONFIG_CIFS_FSCACHE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	struct fscache_cookie   *fscache; /* client index cache cookie */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	atomic_t num_cmds[NUMBER_OF_SMB2_COMMANDS]; /* total requests by cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 	atomic_t smb2slowcmd[NUMBER_OF_SMB2_COMMANDS]; /* count resps > 1 sec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 	__u64 time_per_cmd[NUMBER_OF_SMB2_COMMANDS]; /* total time per cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	__u32 slowest_cmd[NUMBER_OF_SMB2_COMMANDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 	__u32 fastest_cmd[NUMBER_OF_SMB2_COMMANDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) #endif /* STATS2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 	unsigned int	max_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	unsigned int	max_write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 	unsigned int	min_offload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	__le16	compress_algorithm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	__le16	cipher_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	 /* save initital negprot hash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 	__u8	preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	bool	posix_ext_supported;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 	struct delayed_work reconnect; /* reconnect workqueue job */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	struct mutex reconnect_mutex; /* prevent simultaneous reconnects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 	unsigned long echo_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 	 * Number of targets available for reconnect. The more targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	 * the more tasks have to wait to let the demultiplex thread
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	 * reconnect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	int nr_targets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 	bool noblockcnt; /* use non-blocking connect() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	bool is_channel; /* if a session channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) struct cifs_credits {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	unsigned int value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	unsigned int instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) static inline unsigned int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) in_flight(struct TCP_Server_Info *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 	unsigned int num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 	spin_lock(&server->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	num = server->in_flight;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 	spin_unlock(&server->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 	return num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) static inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) has_credits(struct TCP_Server_Info *server, int *credits, int num_credits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	int num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 	spin_lock(&server->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	num = *credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	spin_unlock(&server->req_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	return num >= num_credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) add_credits(struct TCP_Server_Info *server, const struct cifs_credits *credits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 	    const int optype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	server->ops->add_credits(server, credits, optype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) add_credits_and_wake_if(struct TCP_Server_Info *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 			const struct cifs_credits *credits, const int optype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	if (credits->value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 		server->ops->add_credits(server, credits, optype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 		wake_up(&server->request_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) set_credits(struct TCP_Server_Info *server, const int val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	server->ops->set_credits(server, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) adjust_credits(struct TCP_Server_Info *server, struct cifs_credits *credits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 	       const unsigned int payload_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 	return server->ops->adjust_credits ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 		server->ops->adjust_credits(server, credits, payload_size) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) static inline __le64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) get_next_mid64(struct TCP_Server_Info *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 	return cpu_to_le64(server->ops->get_next_mid(server));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) static inline __le16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) get_next_mid(struct TCP_Server_Info *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	__u16 mid = server->ops->get_next_mid(server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	 * The value in the SMB header should be little endian for easy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 	 * on-the-wire decoding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 	return cpu_to_le16(mid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) revert_current_mid(struct TCP_Server_Info *server, const unsigned int val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 	if (server->ops->revert_current_mid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 		server->ops->revert_current_mid(server, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) revert_current_mid_from_hdr(struct TCP_Server_Info *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 			    const struct smb2_sync_hdr *shdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	unsigned int num = le16_to_cpu(shdr->CreditCharge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	return revert_current_mid(server, num > 0 ? num : 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) static inline __u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) get_mid(const struct smb_hdr *smb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 	return le16_to_cpu(smb->Mid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) static inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) compare_mid(__u16 mid, const struct smb_hdr *smb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 	return mid == le16_to_cpu(smb->Mid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885)  * When the server supports very large reads and writes via POSIX extensions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886)  * we can allow up to 2^24-1, minus the size of a READ/WRITE_AND_X header, not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887)  * including the RFC1001 length.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889)  * Note that this might make for "interesting" allocation problems during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890)  * writeback however as we have to allocate an array of pointers for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891)  * pages. A 16M write means ~32kb page array with PAGE_SIZE == 4096.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893)  * For reads, there is a similar problem as we need to allocate an array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894)  * of kvecs to handle the receive, though that should only need to be done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895)  * once.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) #define CIFS_MAX_WSIZE ((1<<24) - 1 - sizeof(WRITE_REQ) + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) #define CIFS_MAX_RSIZE ((1<<24) - sizeof(READ_RSP) + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901)  * When the server doesn't allow large posix writes, only allow a rsize/wsize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902)  * of 2^17-1 minus the size of the call header. That allows for a read or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903)  * write up to the maximum size described by RFC1002.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) #define CIFS_MAX_RFC1002_WSIZE ((1<<17) - 1 - sizeof(WRITE_REQ) + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) #define CIFS_MAX_RFC1002_RSIZE ((1<<17) - 1 - sizeof(READ_RSP) + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909)  * The default wsize is 1M. find_get_pages seems to return a maximum of 256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910)  * pages in a single call. With PAGE_SIZE == 4k, this means we can fill
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911)  * a single wsize request with a single call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) #define CIFS_DEFAULT_IOSIZE (1024 * 1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) #define SMB3_DEFAULT_IOSIZE (4 * 1024 * 1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917)  * Windows only supports a max of 60kb reads and 65535 byte writes. Default to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918)  * those values when posix extensions aren't in force. In actuality here, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919)  * use 65536 to allow for a write that is a multiple of 4k. Most servers seem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920)  * to be ok with the extra byte even though Windows doesn't send writes that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921)  * are that large.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923)  * Citation:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925)  * https://blogs.msdn.com/b/openspecification/archive/2009/04/10/smb-maximum-transmit-buffer-size-and-performance-tuning.aspx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) #define CIFS_DEFAULT_NON_POSIX_RSIZE (60 * 1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) #define CIFS_DEFAULT_NON_POSIX_WSIZE (65536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931)  * Macros to allow the TCP_Server_Info->net field and related code to drop out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932)  * when CONFIG_NET_NS isn't set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) #ifdef CONFIG_NET_NS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	return srv->net;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 	srv->net = net;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 	return &init_net;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) struct cifs_server_iface {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 	size_t speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 	unsigned int rdma_capable : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 	unsigned int rss_capable : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 	struct sockaddr_storage sockaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) struct cifs_chan {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	struct TCP_Server_Info *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	__u8 signkey[SMB3_SIGN_KEY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973)  * Session structure.  One of these for each uid session with a particular host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) struct cifs_ses {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	struct list_head smb_ses_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 	struct list_head tcon_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	struct cifs_tcon *tcon_ipc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 	struct mutex session_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 	struct TCP_Server_Info *server;	/* pointer to server info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 	int ses_count;		/* reference counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	enum statusEnum status;  /* updates protected by GlobalMid_Lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 	unsigned overrideSecFlg;  /* if non-zero override global sec flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	char *serverOS;		/* name of operating system underlying server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 	char *serverNOS;	/* name of network operating system of server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	char *serverDomain;	/* security realm of server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	__u64 Suid;		/* remote smb uid  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	kuid_t linux_uid;	/* overriding owner of files on the mount */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 	kuid_t cred_uid;	/* owner of credentials */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	unsigned int capabilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	char serverName[SERVER_NAME_LEN_WITH_NULL];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 	char *user_name;	/* must not be null except during init of sess
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 				   and after mount option parsing we fill it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	char *domainName;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 	char *password;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 	struct session_key auth_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 	struct ntlmssp_auth *ntlmssp; /* ciphertext, flags, server challenge */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 	enum securityEnum sectype; /* what security flavor was specified? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 	bool sign;		/* is signing required? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 	bool need_reconnect:1; /* connection reset, uid now invalid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	bool domainAuto:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 	bool binding:1; /* are we binding the session? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 	__u16 session_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	__u8 smb3signingkey[SMB3_SIGN_KEY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 	__u8 smb3encryptionkey[SMB3_ENC_DEC_KEY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 	__u8 smb3decryptionkey[SMB3_ENC_DEC_KEY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	__u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	__u8 binding_preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	 * Network interfaces available on the server this session is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	 * connected to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	 * Other channels can be opened by connecting and binding this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 	 * session to interfaces from this list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 	 * iface_lock should be taken when accessing any of these fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 	spinlock_t iface_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	struct cifs_server_iface *iface_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 	size_t iface_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	unsigned long iface_last_update; /* jiffies */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) #define CIFS_MAX_CHANNELS 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 	struct cifs_chan chans[CIFS_MAX_CHANNELS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	struct cifs_chan *binding_chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	size_t chan_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	size_t chan_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	atomic_t chan_seq; /* round robin state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034)  * When binding a new channel, we need to access the channel which isn't fully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035)  * established yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) struct cifs_chan *cifs_ses_binding_channel(struct cifs_ses *ses)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	if (ses->binding)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 		return ses->binding_chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048)  * Returns the server pointer of the session. When binding a new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049)  * channel this returns the last channel which isn't fully established
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050)  * yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052)  * This function should be use for negprot/sess.setup codepaths. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053)  * the other requests see cifs_pick_channel().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) struct TCP_Server_Info *cifs_ses_server(struct cifs_ses *ses)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 	if (ses->binding)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 		return ses->binding_chan->server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 		return ses->server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) static inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) cap_unix(struct cifs_ses *ses)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 	return ses->server->vals->cap_unix & ses->capabilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) struct cached_fid {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 	bool is_valid:1;	/* Do we have a useable root fid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	bool file_all_info_is_valid:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	bool has_lease:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 	struct kref refcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	struct cifs_fid *fid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 	struct mutex fid_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	struct cifs_tcon *tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 	struct work_struct lease_break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 	struct smb2_file_all_info file_all_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083)  * there is one of these for each connection to a resource on a particular
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084)  * session
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) struct cifs_tcon {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 	struct list_head tcon_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 	int tc_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 	struct list_head rlist; /* reconnect list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 	atomic_t num_local_opens;  /* num of all opens including disconnected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 	atomic_t num_remote_opens; /* num of all network opens on server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 	struct list_head openFileList;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 	spinlock_t open_file_lock; /* protects list above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 	struct cifs_ses *ses;	/* pointer to session associated with */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 	char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 	char *nativeFileSystem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 	char *password;		/* for share-level security */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 	__u32 tid;		/* The 4 byte tree id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 	__u16 Flags;		/* optional support bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 	enum statusEnum tidStatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 	atomic_t num_smbs_sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 			atomic_t num_writes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 			atomic_t num_reads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 			atomic_t num_flushes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 			atomic_t num_oplock_brks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 			atomic_t num_opens;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 			atomic_t num_closes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 			atomic_t num_deletes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 			atomic_t num_mkdirs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 			atomic_t num_posixopens;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 			atomic_t num_posixmkdirs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 			atomic_t num_rmdirs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 			atomic_t num_renames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 			atomic_t num_t2renames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 			atomic_t num_ffirst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 			atomic_t num_fnext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 			atomic_t num_fclose;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 			atomic_t num_hardlinks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 			atomic_t num_symlinks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 			atomic_t num_locks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 			atomic_t num_acl_get;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 			atomic_t num_acl_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 		} cifs_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 			atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 			atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 		} smb2_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 	} stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 	__u64    bytes_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 	__u64    bytes_written;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 	spinlock_t stat_lock;  /* protects the two fields above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 	FILE_SYSTEM_DEVICE_INFO fsDevInfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 	FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 	FILE_SYSTEM_UNIX_INFO fsUnixInfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 	bool ipc:1;   /* set if connection to IPC$ share (always also pipe) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 	bool pipe:1;  /* set if connection to pipe share */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 	bool print:1; /* set if connection to printer share */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 	bool retry:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 	bool nocase:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 	bool nohandlecache:1; /* if strange server resource prob can turn off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 	bool nodelete:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 	bool seal:1;      /* transport encryption for this mounted share */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 	bool unix_ext:1;  /* if false disable Linux extensions to CIFS protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 				for this mount even if server would support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 	bool posix_extensions; /* if true SMB3.11 posix extensions enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 	bool local_lease:1; /* check leases (only) on local system not remote */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 	bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 	bool broken_sparse_sup; /* if server or share does not support sparse */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 	bool need_reconnect:1; /* connection reset, tid now invalid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	bool need_reopen_files:1; /* need to reopen tcon file handles */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 	bool use_resilient:1; /* use resilient instead of durable handles */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 	bool use_persistent:1; /* use persistent instead of durable handles */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 	bool no_lease:1;    /* Do not request leases on files or directories */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 	__le32 capabilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 	__u32 share_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	__u32 maximal_access;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 	__u32 vol_serial_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 	__le64 vol_create_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	__u64 snapshot_time; /* for timewarp tokens - timestamp of snapshot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 	__u32 handle_timeout; /* persistent and durable handle timeout in ms */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 	__u32 ss_flags;		/* sector size flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 	__u32 perf_sector_size; /* best sector size for perf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 	__u32 max_chunks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 	__u32 max_bytes_chunk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 	__u32 max_bytes_copy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) #ifdef CONFIG_CIFS_FSCACHE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 	u64 resource_id;		/* server resource id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 	struct fscache_cookie *fscache;	/* cookie for share */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 	struct list_head pending_opens;	/* list of incomplete opens */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 	struct cached_fid crfid; /* Cached root fid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	/* BB add field for back pointer to sb struct(s)? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) #ifdef CONFIG_CIFS_DFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 	char *dfs_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 	int remap:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 	struct list_head ulist; /* cache update list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183)  * This is a refcounted and timestamped container for a tcon pointer. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184)  * container holds a tcon reference. It is considered safe to free one of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185)  * these when the tl_count goes to 0. The tl_time is the time of the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186)  * "get" on the container.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) struct tcon_link {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 	struct rb_node		tl_rbnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 	kuid_t			tl_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 	unsigned long		tl_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) #define TCON_LINK_MASTER	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) #define TCON_LINK_PENDING	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) #define TCON_LINK_IN_TREE	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 	unsigned long		tl_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	atomic_t		tl_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 	struct cifs_tcon	*tl_tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) extern struct tcon_link *cifs_sb_tlink(struct cifs_sb_info *cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) extern void smb3_free_compound_rqst(int num_rqst, struct smb_rqst *rqst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) static inline struct cifs_tcon *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) tlink_tcon(struct tcon_link *tlink)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 	return tlink->tl_tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) static inline struct tcon_link *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) cifs_sb_master_tlink(struct cifs_sb_info *cifs_sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 	return cifs_sb->master_tlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) extern void cifs_put_tlink(struct tcon_link *tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) static inline struct tcon_link *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) cifs_get_tlink(struct tcon_link *tlink)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 	if (tlink && !IS_ERR(tlink))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 		atomic_inc(&tlink->tl_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 	return tlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) /* This function is always expected to succeed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) extern struct cifs_tcon *cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) #define CIFS_OPLOCK_NO_CHANGE 0xfe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) struct cifs_pending_open {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 	struct list_head olist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 	struct tcon_link *tlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 	__u8 lease_key[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 	__u32 oplock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238)  * This info hangs off the cifsFileInfo structure, pointed to by llist.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239)  * This is used to track byte stream locks on the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) struct cifsLockInfo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 	struct list_head llist;	/* pointer to next cifsLockInfo */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 	struct list_head blist; /* pointer to locks blocked on this */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 	wait_queue_head_t block_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 	__u64 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	__u64 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 	__u32 pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 	__u16 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 	__u16 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253)  * One of these for each open instance of a file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) struct cifs_search_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 	loff_t index_of_last_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 	__u16 entries_in_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	__u16 info_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 	__u32 resume_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 	char *ntwrk_buf_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 	char *srch_entries_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) 	char *last_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 	const char *presume_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 	unsigned int resume_name_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 	bool endOfSearch:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 	bool emptyDir:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 	bool unicode:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 	bool smallBuf:1; /* so we know which buf_release function to call */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) #define ACL_NO_MODE	((umode_t)(-1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) struct cifs_open_parms {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 	struct cifs_tcon *tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 	struct cifs_sb_info *cifs_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 	int disposition;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 	int desired_access;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) 	int create_options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 	const char *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 	struct cifs_fid *fid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 	umode_t mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 	bool reconnect:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) struct cifs_fid {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) 	__u16 netfid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 	__u64 persistent_fid;	/* persist file id for smb2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 	__u64 volatile_fid;	/* volatile file id for smb2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 	__u8 lease_key[SMB2_LEASE_KEY_SIZE];	/* lease key for smb2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 	__u8 create_guid[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 	__u32 access;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 	struct cifs_pending_open *pending_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 	unsigned int epoch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) #ifdef CONFIG_CIFS_DEBUG2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 	__u64 mid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) #endif /* CIFS_DEBUG2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 	bool purge_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) struct cifs_fid_locks {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 	struct list_head llist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) 	struct cifsFileInfo *cfile;	/* fid that owns locks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) 	struct list_head locks;		/* locks held by fid above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) struct cifsFileInfo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	/* following two lists are protected by tcon->open_file_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 	struct list_head tlist;	/* pointer to next fid owned by tcon */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 	struct list_head flist;	/* next fid (file instance) for this inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) 	/* lock list below protected by cifsi->lock_sem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 	struct cifs_fid_locks *llist;	/* brlocks held by this fid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 	kuid_t uid;		/* allows finding which FileInfo structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 	__u32 pid;		/* process id who opened file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) 	struct cifs_fid fid;	/* file id from remote */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 	struct list_head rlist; /* reconnect list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 	/* BB add lock scope info here if needed */ ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 	/* lock scope id (0 if none) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 	struct dentry *dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 	struct tcon_link *tlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 	unsigned int f_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 	bool invalidHandle:1;	/* file closed via session abend */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 	bool swapfile:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 	bool oplock_break_cancelled:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 	unsigned int oplock_epoch; /* epoch from the lease break */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 	__u32 oplock_level; /* oplock/lease level from the lease break */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 	int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 	spinlock_t file_info_lock; /* protects four flag/count fields above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 	struct mutex fh_mutex; /* prevents reopen race after dead ses*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 	struct cifs_search_info srch_inf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 	struct work_struct oplock_break; /* work for oplock breaks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 	struct work_struct put; /* work for the final part of _put */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) struct cifs_io_parms {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 	__u16 netfid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 	__u64 persistent_fid;	/* persist file id for smb2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 	__u64 volatile_fid;	/* volatile file id for smb2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 	__u32 pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 	__u64 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 	unsigned int length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 	struct cifs_tcon *tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 	struct TCP_Server_Info *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) struct cifs_aio_ctx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 	struct kref		refcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 	struct list_head	list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 	struct mutex		aio_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 	struct completion	done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 	struct iov_iter		iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 	struct kiocb		*iocb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) 	struct cifsFileInfo	*cfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 	struct bio_vec		*bv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 	loff_t			pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 	unsigned int		npages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 	ssize_t			rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 	unsigned int		len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 	unsigned int		total_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 	bool			should_dirty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 	 * Indicates if this aio_ctx is for direct_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 	 * If yes, iter is a copy of the user passed iov_iter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 	bool			direct_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) struct cifs_readdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) /* asynchronous read support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) struct cifs_readdata {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 	struct kref			refcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 	struct list_head		list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) 	struct completion		done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 	struct cifsFileInfo		*cfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 	struct address_space		*mapping;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 	struct cifs_aio_ctx		*ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 	__u64				offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 	unsigned int			bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 	unsigned int			got_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 	pid_t				pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 	int				result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 	struct work_struct		work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 	int (*read_into_pages)(struct TCP_Server_Info *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) 				struct cifs_readdata *rdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) 				unsigned int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) 	int (*copy_into_pages)(struct TCP_Server_Info *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 				struct cifs_readdata *rdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) 				struct iov_iter *iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 	struct kvec			iov[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 	struct TCP_Server_Info		*server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) #ifdef CONFIG_CIFS_SMB_DIRECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 	struct smbd_mr			*mr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 	unsigned int			pagesz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 	unsigned int			page_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 	unsigned int			tailsz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) 	struct cifs_credits		credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 	unsigned int			nr_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 	struct page			**pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) struct cifs_writedata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) /* asynchronous write support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) struct cifs_writedata {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 	struct kref			refcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 	struct list_head		list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 	struct completion		done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 	enum writeback_sync_modes	sync_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 	struct work_struct		work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 	struct cifsFileInfo		*cfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 	struct cifs_aio_ctx		*ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 	__u64				offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 	pid_t				pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 	unsigned int			bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 	int				result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 	struct TCP_Server_Info		*server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) #ifdef CONFIG_CIFS_SMB_DIRECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) 	struct smbd_mr			*mr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) 	unsigned int			pagesz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 	unsigned int			page_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 	unsigned int			tailsz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 	struct cifs_credits		credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) 	unsigned int			nr_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) 	struct page			**pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429)  * Take a reference on the file private data. Must be called with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430)  * cfile->file_info_lock held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) cifsFileInfo_get_locked(struct cifsFileInfo *cifs_file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) 	++cifs_file->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) struct cifsFileInfo *cifsFileInfo_get(struct cifsFileInfo *cifs_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) void _cifsFileInfo_put(struct cifsFileInfo *cifs_file, bool wait_oplock_hdlr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 		       bool offload);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) #define CIFS_CACHE_READ_FLG	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) #define CIFS_CACHE_HANDLE_FLG	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) #define CIFS_CACHE_RH_FLG	(CIFS_CACHE_READ_FLG | CIFS_CACHE_HANDLE_FLG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) #define CIFS_CACHE_WRITE_FLG	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) #define CIFS_CACHE_RW_FLG	(CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) #define CIFS_CACHE_RHW_FLG	(CIFS_CACHE_RW_FLG | CIFS_CACHE_HANDLE_FLG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) #define CIFS_CACHE_READ(cinode) ((cinode->oplock & CIFS_CACHE_READ_FLG) || (CIFS_SB(cinode->vfs_inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) #define CIFS_CACHE_HANDLE(cinode) (cinode->oplock & CIFS_CACHE_HANDLE_FLG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) #define CIFS_CACHE_WRITE(cinode) ((cinode->oplock & CIFS_CACHE_WRITE_FLG) || (CIFS_SB(cinode->vfs_inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455)  * One of these for each file inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) struct cifsInodeInfo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) 	bool can_cache_brlcks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 	struct list_head llist;	/* locks helb by this inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 	 * NOTE: Some code paths call down_read(lock_sem) twice, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 	 * we must always use cifs_down_write() instead of down_write()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 	 * for this semaphore to avoid deadlocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 	struct rw_semaphore lock_sem;	/* protect the fields above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) 	/* BB add in lists for dirty pages i.e. write caching info for oplock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 	struct list_head openFileList;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) 	spinlock_t	open_file_lock;	/* protects openFileList */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 	__u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) 	unsigned int oplock;		/* oplock/lease level we have */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 	unsigned int epoch;		/* used to track lease state changes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) #define CIFS_INODE_PENDING_OPLOCK_BREAK   (0) /* oplock break in progress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) #define CIFS_INODE_PENDING_WRITERS	  (1) /* Writes in progress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) #define CIFS_INODE_FLAG_UNUSED		  (2) /* Unused flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) #define CIFS_INO_DELETE_PENDING		  (3) /* delete pending on server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) #define CIFS_INO_INVALID_MAPPING	  (4) /* pagecache is invalid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) #define CIFS_INO_LOCK			  (5) /* lock bit for synchronization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) 	spinlock_t writers_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) 	unsigned int writers;		/* Number of writers on this inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 	unsigned long time;		/* jiffies of last update of inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) 	u64  server_eof;		/* current file size on server -- protected by i_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) 	u64  uniqueid;			/* server inode number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) 	u64  createtime;		/* creation time on server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) 	__u8 lease_key[SMB2_LEASE_KEY_SIZE];	/* lease key for this inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) #ifdef CONFIG_CIFS_FSCACHE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) 	struct fscache_cookie *fscache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) 	struct inode vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) static inline struct cifsInodeInfo *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) CIFS_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) 	return container_of(inode, struct cifsInodeInfo, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) static inline struct cifs_sb_info *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) CIFS_SB(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) 	return sb->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) static inline struct cifs_sb_info *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) CIFS_FILE_SB(struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) 	return CIFS_SB(file_inode(file)->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) 		return '/';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) 		return '\\';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) convert_delimiter(char *path, char delim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) 	char old_delim, *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) 	if (delim == '/')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) 		old_delim = '\\';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 		old_delim = '/';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 	pos = path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) 	while ((pos = strchr(pos, old_delim)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 		*pos = delim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) #define cifs_stats_inc atomic_inc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 					    unsigned int bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 	if (bytes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) 		spin_lock(&tcon->stat_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) 		tcon->bytes_written += bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) 		spin_unlock(&tcon->stat_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) 					 unsigned int bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 	spin_lock(&tcon->stat_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) 	tcon->bytes_read += bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) 	spin_unlock(&tcon->stat_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556)  * This is the prototype for the mid receive function. This function is for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557)  * receiving the rest of the SMB frame, starting with the WordCount (which is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558)  * just after the MID in struct smb_hdr). Note:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560)  * - This will be called by cifsd, with no locks held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561)  * - The mid will still be on the pending_mid_q.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562)  * - mid->resp_buf will point to the current buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)  * Returns zero on a successful receive, or an error. The receive state in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565)  * the TCP_Server_Info will also be updated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) typedef int (mid_receive_t)(struct TCP_Server_Info *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) 			    struct mid_q_entry *mid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571)  * This is the prototype for the mid callback function. This is called once the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572)  * mid has been received off of the socket. When creating one, take special
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573)  * care to avoid deadlocks. Things to bear in mind:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575)  * - it will be called by cifsd, with no locks held
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576)  * - the mid will be removed from any lists
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) typedef void (mid_callback_t)(struct mid_q_entry *mid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581)  * This is the protopyte for mid handle function. This is called once the mid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582)  * has been recognized after decryption of the message.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) typedef int (mid_handle_t)(struct TCP_Server_Info *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) 			    struct mid_q_entry *mid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) /* one of these for every pending CIFS request to the server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) struct mid_q_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) 	struct list_head qhead;	/* mids waiting on reply from this server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) 	struct kref refcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) 	struct TCP_Server_Info *server;	/* server corresponding to this mid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) 	__u64 mid;		/* multiplex id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) 	__u16 credits;		/* number of credits consumed by this mid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) 	__u16 credits_received;	/* number of credits from the response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) 	__u32 pid;		/* process id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) 	__u32 sequence_number;  /* for CIFS signing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) 	unsigned long when_alloc;  /* when mid was created */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) 	unsigned long when_sent; /* time when smb send finished */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) 	unsigned long when_received; /* when demux complete (taken off wire) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) 	mid_receive_t *receive; /* call receive callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) 	mid_callback_t *callback; /* call completion callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) 	mid_handle_t *handle; /* call handle mid callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) 	void *callback_data;	  /* general purpose pointer for callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) 	struct task_struct *creator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) 	void *resp_buf;		/* pointer to received SMB header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) 	unsigned int resp_buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) 	int mid_state;	/* wish this were enum but can not pass to wait_event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) 	unsigned int mid_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) 	__le16 command;		/* smb command code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) 	unsigned int optype;	/* operation type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) 	bool large_buf:1;	/* if valid response, is pointer to large buf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) 	bool multiRsp:1;	/* multiple trans2 responses for one request  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) 	bool multiEnd:1;	/* both received */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) 	bool decrypted:1;	/* decrypted entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) struct close_cancelled_open {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) 	struct cifs_fid         fid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) 	struct cifs_tcon        *tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) 	struct work_struct      work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) 	__u64 mid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) 	__u16 cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) /*	Make code in transport.c a little cleaner by moving
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) 	update of optional stats into function below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) static inline void cifs_in_send_inc(struct TCP_Server_Info *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) 	atomic_inc(&server->in_send);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) static inline void cifs_in_send_dec(struct TCP_Server_Info *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) 	atomic_dec(&server->in_send);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) static inline void cifs_num_waiters_inc(struct TCP_Server_Info *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) 	atomic_inc(&server->num_waiters);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) static inline void cifs_num_waiters_dec(struct TCP_Server_Info *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) 	atomic_dec(&server->num_waiters);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) static inline void cifs_save_when_sent(struct mid_q_entry *mid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) 	mid->when_sent = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) static inline void cifs_save_when_sent(struct mid_q_entry *mid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) /* for pending dnotify requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) struct dir_notify_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) 	struct list_head lhead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) 	__le16 Pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) 	__le16 PidHigh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) 	__u16 Mid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) 	__u16 Tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) 	__u16 Uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) 	__u16 netfid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) 	__u32 filter; /* CompletionFilter (for multishot) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) 	int multishot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) 	struct file *pfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) struct dfs_info3_param {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) 	int flags; /* DFSREF_REFERRAL_SERVER, DFSREF_STORAGE_SERVER*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) 	int path_consumed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) 	int server_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) 	int ref_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) 	char *path_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) 	char *node_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) 	int ttl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685)  * common struct for holding inode info when searching for or updating an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686)  * inode with new info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) #define CIFS_FATTR_DFS_REFERRAL		0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) #define CIFS_FATTR_DELETE_PENDING	0x2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) #define CIFS_FATTR_NEED_REVAL		0x4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) #define CIFS_FATTR_INO_COLLISION	0x8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) #define CIFS_FATTR_UNKNOWN_NLINK	0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) #define CIFS_FATTR_FAKE_ROOT_INO	0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) struct cifs_fattr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) 	u32		cf_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) 	u32		cf_cifsattrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) 	u64		cf_uniqueid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) 	u64		cf_eof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) 	u64		cf_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) 	u64		cf_createtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) 	kuid_t		cf_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) 	kgid_t		cf_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) 	umode_t		cf_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) 	dev_t		cf_rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) 	unsigned int	cf_nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) 	unsigned int	cf_dtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) 	struct timespec64 cf_atime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) 	struct timespec64 cf_mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) 	struct timespec64 cf_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) 	u32             cf_cifstag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) static inline void free_dfs_info_param(struct dfs_info3_param *param)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) 	if (param) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) 		kfree(param->path_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) 		kfree(param->node_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) static inline void free_dfs_info_array(struct dfs_info3_param *param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) 				       int number_of_items)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) 	if ((number_of_items == 0) || (param == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) 	for (i = 0; i < number_of_items; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) 		kfree(param[i].path_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) 		kfree(param[i].node_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) 	kfree(param);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) static inline bool is_interrupt_error(int error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) 	switch (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) 	case -EINTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) 	case -ERESTARTSYS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) 	case -ERESTARTNOHAND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) 	case -ERESTARTNOINTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) static inline bool is_retryable_error(int error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) 	if (is_interrupt_error(error) || error == -EAGAIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) /* cifs_get_writable_file() flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) #define FIND_WR_ANY         0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) #define FIND_WR_FSUID_ONLY  1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) #define FIND_WR_WITH_DELETE 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) #define   MID_FREE 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) #define   MID_REQUEST_ALLOCATED 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) #define   MID_REQUEST_SUBMITTED 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) #define   MID_RESPONSE_RECEIVED 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) #define   MID_RETRY_NEEDED      8 /* session closed while this request out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) #define   MID_RESPONSE_MALFORMED 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) #define   MID_SHUTDOWN		 0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) /* Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) #define   MID_WAIT_CANCELLED	 1 /* Cancelled while waiting for response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) #define   MID_DELETED            2 /* Mid has been dequeued/deleted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) /* Types of response buffer returned from SendReceive2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) #define   CIFS_NO_BUFFER        0    /* Response buffer not returned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) #define   CIFS_SMALL_BUFFER     1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) #define   CIFS_LARGE_BUFFER     2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) #define   CIFS_IOVEC            4    /* array of response buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) /* Type of Request to SendReceive2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) #define   CIFS_BLOCKING_OP      1    /* operation can block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) #define   CIFS_NON_BLOCKING     2    /* do not block waiting for credits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) #define   CIFS_TIMEOUT_MASK 0x003    /* only one of above set in req */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) #define   CIFS_LOG_ERROR    0x010    /* log NT STATUS if non-zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) #define   CIFS_LARGE_BUF_OP 0x020    /* large request buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) #define   CIFS_NO_RSP_BUF   0x040    /* no response buffer required */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) /* Type of request operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) #define   CIFS_ECHO_OP            0x080  /* echo request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) #define   CIFS_OBREAK_OP          0x0100 /* oplock break request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) #define   CIFS_NEG_OP             0x0200 /* negotiate request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) #define   CIFS_CP_CREATE_CLOSE_OP 0x0400 /* compound create+close request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) #define   CIFS_OP_MASK            0x0780 /* mask request type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) #define   CIFS_HAS_CREDITS 0x0400    /* already has credits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) #define   CIFS_TRANSFORM_REQ 0x0800    /* transform request before sending */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) #define   CIFS_NO_SRV_RSP    0x1000    /* there is no server response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) /* Security Flags: indicate type of session setup needed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) #define   CIFSSEC_MAY_SIGN	0x00001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) #define   CIFSSEC_MAY_NTLM	0x00002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) #define   CIFSSEC_MAY_NTLMV2	0x00004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) #define   CIFSSEC_MAY_KRB5	0x00008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) #ifdef CONFIG_CIFS_WEAK_PW_HASH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) #define   CIFSSEC_MAY_LANMAN	0x00010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) #define   CIFSSEC_MAY_PLNTXT	0x00020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) #define   CIFSSEC_MAY_LANMAN    0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) #define   CIFSSEC_MAY_PLNTXT    0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) #endif /* weak passwords */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) #define   CIFSSEC_MAY_SEAL	0x00040 /* not supported yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) #define   CIFSSEC_MAY_NTLMSSP	0x00080 /* raw ntlmssp with ntlmv2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) #define   CIFSSEC_MUST_SIGN	0x01001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) /* note that only one of the following can be set so the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) result of setting MUST flags more than once will be to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) require use of the stronger protocol */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) #define   CIFSSEC_MUST_NTLM	0x02002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) #define   CIFSSEC_MUST_NTLMV2	0x04004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) #define   CIFSSEC_MUST_KRB5	0x08008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) #ifdef CONFIG_CIFS_WEAK_PW_HASH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) #define   CIFSSEC_MUST_LANMAN	0x10010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) #define   CIFSSEC_MUST_PLNTXT	0x20020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) #ifdef CONFIG_CIFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) #define   CIFSSEC_MASK          0xBF0BF /* allows weak security but also krb5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) #define   CIFSSEC_MASK          0xB70B7 /* current flags supported if weak */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) #endif /* UPCALL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) #else /* do not allow weak pw hash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) #define   CIFSSEC_MUST_LANMAN	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) #define   CIFSSEC_MUST_PLNTXT	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) #ifdef CONFIG_CIFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) #define   CIFSSEC_MASK          0x8F08F /* flags supported if no weak allowed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) #define	  CIFSSEC_MASK          0x87087 /* flags supported if no weak allowed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) #endif /* UPCALL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) #endif /* WEAK_PW_HASH */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) #define   CIFSSEC_MUST_SEAL	0x40040 /* not supported yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) #define   CIFSSEC_MUST_NTLMSSP	0x80080 /* raw ntlmssp with ntlmv2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) #define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_NTLMSSP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) #define   CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) #define   CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844)  *****************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845)  * All constants go here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846)  *****************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) #define UID_HASH (16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852)  * Note that ONE module should define _DECLARE_GLOBALS_HERE to cause the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853)  * following to be declared.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) /****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857)  *  Locking notes.  All updates to global variables and lists should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858)  *                  protected by spinlocks or semaphores.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860)  *  Spinlocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861)  *  ---------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862)  *  GlobalMid_Lock protects:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863)  *	list operations on pending_mid_q and oplockQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864)  *      updates to XID counters, multiplex id  and SMB sequence numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865)  *      list operations on global DnotifyReqList
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866)  *      updates to ses->status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867)  *  tcp_ses_lock protects:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868)  *	list operations on tcp and SMB session lists
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869)  *  tcon->open_file_lock protects the list of open files hanging off the tcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870)  *  inode->open_file_lock protects the openFileList hanging off the inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871)  *  cfile->file_info_lock protects counters and fields in cifs file struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872)  *  f_owner.lock protects certain per file struct operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873)  *  mapping->page_lock protects certain per page operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875)  *  Note that the cifs_tcon.open_file_lock should be taken before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876)  *  not after the cifsInodeInfo.open_file_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878)  *  Semaphores
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879)  *  ----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880)  *  sesSem     operations on smb session
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881)  *  tconSem    operations on tree connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882)  *  fh_sem      file handle reconnection operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884)  ****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) #ifdef DECLARE_GLOBALS_HERE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) #define GLOBAL_EXTERN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) #define GLOBAL_EXTERN extern
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893)  * the list of TCP_Server_Info structures, ie each of the sockets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894)  * connecting our client to a distinct server (ip address), is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895)  * chained together by cifs_tcp_ses_list. The list of all our SMB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896)  * sessions (and from that the tree connections) can be found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897)  * by iterating over cifs_tcp_ses_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) GLOBAL_EXTERN struct list_head		cifs_tcp_ses_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902)  * This lock protects the cifs_tcp_ses_list, the list of smb sessions per
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903)  * tcp session, and the list of tcon's per smb session. It also protects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904)  * the reference counters for the server, smb session, and tcon. It also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905)  * protects some fields in the TCP_Server_Info struct such as dstaddr. Finally,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906)  * changes to the tcon->tidStatus should be done while holding this lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907)  * generally the locks should be taken in order tcp_ses_lock before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908)  * tcon->open_file_lock and that before file->file_info_lock since the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909)  * structure order is cifs_socket-->cifs_ses-->cifs_tcon-->cifs_file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) GLOBAL_EXTERN spinlock_t		cifs_tcp_ses_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) #ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) /* Outstanding dir notify requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) GLOBAL_EXTERN struct list_head GlobalDnotifyReqList;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) /* DirNotify response queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) #endif /* was needed for dnotify, and will be needed for inotify when VFS fix */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921)  * Global transaction id (XID) information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) GLOBAL_EXTERN unsigned int GlobalCurrentXid;	/* protected by GlobalMid_Sem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) GLOBAL_EXTERN unsigned int GlobalMaxActiveXid;	/* prot by GlobalMid_Sem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) GLOBAL_EXTERN spinlock_t GlobalMid_Lock;  /* protects above & list operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) 					  /* on midQ entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929)  *  Global counters, updated atomically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) GLOBAL_EXTERN atomic_t sesInfoAllocCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) GLOBAL_EXTERN atomic_t tconInfoAllocCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) GLOBAL_EXTERN atomic_t tcpSesAllocCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) GLOBAL_EXTERN atomic_t tcpSesReconnectCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) /* Various Debug counters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) GLOBAL_EXTERN atomic_t bufAllocCount;    /* current number allocated  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) GLOBAL_EXTERN atomic_t totSmBufAllocCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) extern unsigned int slow_rsp_threshold; /* number of secs before logging */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) GLOBAL_EXTERN atomic_t smBufAllocCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) GLOBAL_EXTERN atomic_t midCount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) /* Misc globals */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) extern bool enable_oplocks; /* enable or disable oplocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) extern bool lookupCacheEnabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) extern unsigned int global_secflags;	/* if on, session setup sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) 				with more secure ntlmssp2 challenge/resp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) extern unsigned int sign_CIFS_PDUs;  /* enable smb packet signing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) extern bool enable_gcm_256; /* allow optional negotiate of strongest signing (aes-gcm-256) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) extern bool require_gcm_256; /* require use of strongest signing (aes-gcm-256) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) extern bool linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) extern unsigned int CIFSMaxBufSize;  /* max size not including hdr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) extern unsigned int cifs_min_rcv;    /* min size of big ntwrk buf pool */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) extern unsigned int cifs_min_small;  /* min size of small buf pool */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) extern unsigned int cifs_max_pending; /* MAX requests at once to server*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) extern bool disable_legacy_dialects;  /* forbid vers=1.0 and vers=2.0 mounts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) GLOBAL_EXTERN struct rb_root uidtree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) GLOBAL_EXTERN struct rb_root gidtree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) GLOBAL_EXTERN spinlock_t siduidlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) GLOBAL_EXTERN spinlock_t sidgidlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) GLOBAL_EXTERN struct rb_root siduidtree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) GLOBAL_EXTERN struct rb_root sidgidtree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) GLOBAL_EXTERN spinlock_t uidsidlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) GLOBAL_EXTERN spinlock_t gidsidlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) void cifs_oplock_break(struct work_struct *work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) void cifs_queue_oplock_break(struct cifsFileInfo *cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) extern const struct slow_work_ops cifs_oplock_break_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) extern struct workqueue_struct *cifsiod_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) extern struct workqueue_struct *decrypt_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) extern struct workqueue_struct *fileinfo_put_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) extern struct workqueue_struct *cifsoplockd_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) extern __u32 cifs_lock_secret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) extern mempool_t *cifs_mid_poolp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) /* Operations for different SMB versions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) #define SMB1_VERSION_STRING	"1.0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) extern struct smb_version_operations smb1_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) extern struct smb_version_values smb1_values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) #define SMB20_VERSION_STRING	"2.0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) extern struct smb_version_operations smb20_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) extern struct smb_version_values smb20_values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) #define SMB21_VERSION_STRING	"2.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) extern struct smb_version_operations smb21_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) extern struct smb_version_values smb21_values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) #define SMBDEFAULT_VERSION_STRING "default"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) extern struct smb_version_values smbdefault_values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) #define SMB3ANY_VERSION_STRING "3"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) extern struct smb_version_values smb3any_values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) #define SMB30_VERSION_STRING	"3.0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) extern struct smb_version_operations smb30_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) extern struct smb_version_values smb30_values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) #define SMB302_VERSION_STRING	"3.02"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) #define ALT_SMB302_VERSION_STRING "3.0.2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) /*extern struct smb_version_operations smb302_operations;*/ /* not needed yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) extern struct smb_version_values smb302_values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) #define SMB311_VERSION_STRING	"3.1.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) #define ALT_SMB311_VERSION_STRING "3.11"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) extern struct smb_version_operations smb311_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) extern struct smb_version_values smb311_values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) static inline char *get_security_type_str(enum securityEnum sectype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) 	switch (sectype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) 	case RawNTLMSSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) 		return "RawNTLMSSP";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) 	case Kerberos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) 		return "Kerberos";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) 	case NTLMv2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) 		return "NTLMv2";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) 	case NTLM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) 		return "NTLM";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) 	case LANMAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) 		return "LANMAN";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) 		return "Unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) static inline bool is_smb1_server(struct TCP_Server_Info *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) 	return strcmp(server->vals->version_string, SMB1_VERSION_STRING) == 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) static inline bool is_tcon_dfs(struct cifs_tcon *tcon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) 	 * For SMB1, see MS-CIFS 2.4.55 SMB_COM_TREE_CONNECT_ANDX (0x75) and MS-CIFS 3.3.4.4 DFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) 	 * Subsystem Notifies That a Share Is a DFS Share.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) 	 * For SMB2+, see MS-SMB2 2.2.10 SMB2 TREE_CONNECT Response and MS-SMB2 3.3.4.14 Server
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) 	 * Application Updates a Share.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) 	if (!tcon || !tcon->ses || !tcon->ses->server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) 	return is_smb1_server(tcon->ses->server) ? tcon->Flags & SMB_SHARE_IS_IN_DFS :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) 		tcon->share_flags & (SHI1005_FLAGS_DFS | SHI1005_FLAGS_DFS_ROOT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) #endif	/* _CIFS_GLOB_H */