1*38c8a9a5SSteve French /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*38c8a9a5SSteve French /* 3*38c8a9a5SSteve French * Copyright (C) 2020, Microsoft Corporation. 4*38c8a9a5SSteve French * 5*38c8a9a5SSteve French * Author(s): Steve French <stfrench@microsoft.com> 6*38c8a9a5SSteve French * David Howells <dhowells@redhat.com> 7*38c8a9a5SSteve French */ 8*38c8a9a5SSteve French 9*38c8a9a5SSteve French #ifndef _FS_CONTEXT_H 10*38c8a9a5SSteve French #define _FS_CONTEXT_H 11*38c8a9a5SSteve French 12*38c8a9a5SSteve French #include "cifsglob.h" 13*38c8a9a5SSteve French #include <linux/parser.h> 14*38c8a9a5SSteve French #include <linux/fs_parser.h> 15*38c8a9a5SSteve French 16*38c8a9a5SSteve French /* Log errors in fs_context (new mount api) but also in dmesg (old style) */ 17*38c8a9a5SSteve French #define cifs_errorf(fc, fmt, ...) \ 18*38c8a9a5SSteve French do { \ 19*38c8a9a5SSteve French errorf(fc, fmt, ## __VA_ARGS__); \ 20*38c8a9a5SSteve French cifs_dbg(VFS, fmt, ## __VA_ARGS__); \ 21*38c8a9a5SSteve French } while (0) 22*38c8a9a5SSteve French 23*38c8a9a5SSteve French enum smb_version { 24*38c8a9a5SSteve French Smb_1 = 1, 25*38c8a9a5SSteve French Smb_20, 26*38c8a9a5SSteve French Smb_21, 27*38c8a9a5SSteve French Smb_30, 28*38c8a9a5SSteve French Smb_302, 29*38c8a9a5SSteve French Smb_311, 30*38c8a9a5SSteve French Smb_3any, 31*38c8a9a5SSteve French Smb_default, 32*38c8a9a5SSteve French Smb_version_err 33*38c8a9a5SSteve French }; 34*38c8a9a5SSteve French 35*38c8a9a5SSteve French enum { 36*38c8a9a5SSteve French Opt_cache_loose, 37*38c8a9a5SSteve French Opt_cache_strict, 38*38c8a9a5SSteve French Opt_cache_none, 39*38c8a9a5SSteve French Opt_cache_ro, 40*38c8a9a5SSteve French Opt_cache_rw, 41*38c8a9a5SSteve French Opt_cache_err 42*38c8a9a5SSteve French }; 43*38c8a9a5SSteve French 44*38c8a9a5SSteve French enum cifs_sec_param { 45*38c8a9a5SSteve French Opt_sec_krb5, 46*38c8a9a5SSteve French Opt_sec_krb5i, 47*38c8a9a5SSteve French Opt_sec_krb5p, 48*38c8a9a5SSteve French Opt_sec_ntlmsspi, 49*38c8a9a5SSteve French Opt_sec_ntlmssp, 50*38c8a9a5SSteve French Opt_sec_ntlmv2, 51*38c8a9a5SSteve French Opt_sec_ntlmv2i, 52*38c8a9a5SSteve French Opt_sec_none, 53*38c8a9a5SSteve French 54*38c8a9a5SSteve French Opt_sec_err 55*38c8a9a5SSteve French }; 56*38c8a9a5SSteve French 57*38c8a9a5SSteve French enum cifs_param { 58*38c8a9a5SSteve French /* Mount options that take no arguments */ 59*38c8a9a5SSteve French Opt_user_xattr, 60*38c8a9a5SSteve French Opt_forceuid, 61*38c8a9a5SSteve French Opt_forcegid, 62*38c8a9a5SSteve French Opt_noblocksend, 63*38c8a9a5SSteve French Opt_noautotune, 64*38c8a9a5SSteve French Opt_nolease, 65*38c8a9a5SSteve French Opt_nosparse, 66*38c8a9a5SSteve French Opt_hard, 67*38c8a9a5SSteve French Opt_soft, 68*38c8a9a5SSteve French Opt_perm, 69*38c8a9a5SSteve French Opt_nodelete, 70*38c8a9a5SSteve French Opt_mapposix, 71*38c8a9a5SSteve French Opt_mapchars, 72*38c8a9a5SSteve French Opt_nomapchars, 73*38c8a9a5SSteve French Opt_sfu, 74*38c8a9a5SSteve French Opt_nodfs, 75*38c8a9a5SSteve French Opt_posixpaths, 76*38c8a9a5SSteve French Opt_unix, 77*38c8a9a5SSteve French Opt_nocase, 78*38c8a9a5SSteve French Opt_brl, 79*38c8a9a5SSteve French Opt_handlecache, 80*38c8a9a5SSteve French Opt_forcemandatorylock, 81*38c8a9a5SSteve French Opt_setuidfromacl, 82*38c8a9a5SSteve French Opt_setuids, 83*38c8a9a5SSteve French Opt_dynperm, 84*38c8a9a5SSteve French Opt_intr, 85*38c8a9a5SSteve French Opt_strictsync, 86*38c8a9a5SSteve French Opt_serverino, 87*38c8a9a5SSteve French Opt_rwpidforward, 88*38c8a9a5SSteve French Opt_cifsacl, 89*38c8a9a5SSteve French Opt_acl, 90*38c8a9a5SSteve French Opt_locallease, 91*38c8a9a5SSteve French Opt_sign, 92*38c8a9a5SSteve French Opt_ignore_signature, 93*38c8a9a5SSteve French Opt_seal, 94*38c8a9a5SSteve French Opt_noac, 95*38c8a9a5SSteve French Opt_fsc, 96*38c8a9a5SSteve French Opt_mfsymlinks, 97*38c8a9a5SSteve French Opt_multiuser, 98*38c8a9a5SSteve French Opt_sloppy, 99*38c8a9a5SSteve French Opt_nosharesock, 100*38c8a9a5SSteve French Opt_persistent, 101*38c8a9a5SSteve French Opt_resilient, 102*38c8a9a5SSteve French Opt_tcp_nodelay, 103*38c8a9a5SSteve French Opt_domainauto, 104*38c8a9a5SSteve French Opt_rdma, 105*38c8a9a5SSteve French Opt_modesid, 106*38c8a9a5SSteve French Opt_rootfs, 107*38c8a9a5SSteve French Opt_multichannel, 108*38c8a9a5SSteve French Opt_compress, 109*38c8a9a5SSteve French Opt_witness, 110*38c8a9a5SSteve French 111*38c8a9a5SSteve French /* Mount options which take numeric value */ 112*38c8a9a5SSteve French Opt_backupuid, 113*38c8a9a5SSteve French Opt_backupgid, 114*38c8a9a5SSteve French Opt_uid, 115*38c8a9a5SSteve French Opt_cruid, 116*38c8a9a5SSteve French Opt_gid, 117*38c8a9a5SSteve French Opt_port, 118*38c8a9a5SSteve French Opt_file_mode, 119*38c8a9a5SSteve French Opt_dirmode, 120*38c8a9a5SSteve French Opt_min_enc_offload, 121*38c8a9a5SSteve French Opt_blocksize, 122*38c8a9a5SSteve French Opt_rasize, 123*38c8a9a5SSteve French Opt_rsize, 124*38c8a9a5SSteve French Opt_wsize, 125*38c8a9a5SSteve French Opt_actimeo, 126*38c8a9a5SSteve French Opt_acdirmax, 127*38c8a9a5SSteve French Opt_acregmax, 128*38c8a9a5SSteve French Opt_closetimeo, 129*38c8a9a5SSteve French Opt_echo_interval, 130*38c8a9a5SSteve French Opt_max_credits, 131*38c8a9a5SSteve French Opt_snapshot, 132*38c8a9a5SSteve French Opt_max_channels, 133*38c8a9a5SSteve French Opt_handletimeout, 134*38c8a9a5SSteve French 135*38c8a9a5SSteve French /* Mount options which take string value */ 136*38c8a9a5SSteve French Opt_source, 137*38c8a9a5SSteve French Opt_user, 138*38c8a9a5SSteve French Opt_pass, 139*38c8a9a5SSteve French Opt_ip, 140*38c8a9a5SSteve French Opt_domain, 141*38c8a9a5SSteve French Opt_srcaddr, 142*38c8a9a5SSteve French Opt_iocharset, 143*38c8a9a5SSteve French Opt_netbiosname, 144*38c8a9a5SSteve French Opt_servern, 145*38c8a9a5SSteve French Opt_ver, 146*38c8a9a5SSteve French Opt_vers, 147*38c8a9a5SSteve French Opt_sec, 148*38c8a9a5SSteve French Opt_cache, 149*38c8a9a5SSteve French 150*38c8a9a5SSteve French /* Mount options to be ignored */ 151*38c8a9a5SSteve French Opt_ignore, 152*38c8a9a5SSteve French 153*38c8a9a5SSteve French Opt_err 154*38c8a9a5SSteve French }; 155*38c8a9a5SSteve French 156*38c8a9a5SSteve French struct smb3_fs_context { 157*38c8a9a5SSteve French bool uid_specified; 158*38c8a9a5SSteve French bool cruid_specified; 159*38c8a9a5SSteve French bool gid_specified; 160*38c8a9a5SSteve French bool sloppy; 161*38c8a9a5SSteve French bool got_ip; 162*38c8a9a5SSteve French bool got_version; 163*38c8a9a5SSteve French bool got_rsize; 164*38c8a9a5SSteve French bool got_wsize; 165*38c8a9a5SSteve French bool got_bsize; 166*38c8a9a5SSteve French unsigned short port; 167*38c8a9a5SSteve French 168*38c8a9a5SSteve French char *username; 169*38c8a9a5SSteve French char *password; 170*38c8a9a5SSteve French char *domainname; 171*38c8a9a5SSteve French char *source; 172*38c8a9a5SSteve French char *server_hostname; 173*38c8a9a5SSteve French char *UNC; 174*38c8a9a5SSteve French char *nodename; 175*38c8a9a5SSteve French char workstation_name[CIFS_MAX_WORKSTATION_LEN]; 176*38c8a9a5SSteve French char *iocharset; /* local code page for mapping to and from Unicode */ 177*38c8a9a5SSteve French char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */ 178*38c8a9a5SSteve French char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */ 179*38c8a9a5SSteve French kuid_t cred_uid; 180*38c8a9a5SSteve French kuid_t linux_uid; 181*38c8a9a5SSteve French kgid_t linux_gid; 182*38c8a9a5SSteve French kuid_t backupuid; 183*38c8a9a5SSteve French kgid_t backupgid; 184*38c8a9a5SSteve French umode_t file_mode; 185*38c8a9a5SSteve French umode_t dir_mode; 186*38c8a9a5SSteve French enum securityEnum sectype; /* sectype requested via mnt opts */ 187*38c8a9a5SSteve French bool sign; /* was signing requested via mnt opts? */ 188*38c8a9a5SSteve French bool ignore_signature:1; 189*38c8a9a5SSteve French bool retry:1; 190*38c8a9a5SSteve French bool intr:1; 191*38c8a9a5SSteve French bool setuids:1; 192*38c8a9a5SSteve French bool setuidfromacl:1; 193*38c8a9a5SSteve French bool override_uid:1; 194*38c8a9a5SSteve French bool override_gid:1; 195*38c8a9a5SSteve French bool dynperm:1; 196*38c8a9a5SSteve French bool noperm:1; 197*38c8a9a5SSteve French bool nodelete:1; 198*38c8a9a5SSteve French bool mode_ace:1; 199*38c8a9a5SSteve French bool no_psx_acl:1; /* set if posix acl support should be disabled */ 200*38c8a9a5SSteve French bool cifs_acl:1; 201*38c8a9a5SSteve French bool backupuid_specified; /* mount option backupuid is specified */ 202*38c8a9a5SSteve French bool backupgid_specified; /* mount option backupgid is specified */ 203*38c8a9a5SSteve French bool no_xattr:1; /* set if xattr (EA) support should be disabled*/ 204*38c8a9a5SSteve French bool server_ino:1; /* use inode numbers from server ie UniqueId */ 205*38c8a9a5SSteve French bool direct_io:1; 206*38c8a9a5SSteve French bool strict_io:1; /* strict cache behavior */ 207*38c8a9a5SSteve French bool cache_ro:1; 208*38c8a9a5SSteve French bool cache_rw:1; 209*38c8a9a5SSteve French bool remap:1; /* set to remap seven reserved chars in filenames */ 210*38c8a9a5SSteve French bool sfu_remap:1; /* remap seven reserved chars ala SFU */ 211*38c8a9a5SSteve French bool posix_paths:1; /* unset to not ask for posix pathnames. */ 212*38c8a9a5SSteve French bool no_linux_ext:1; 213*38c8a9a5SSteve French bool linux_ext:1; 214*38c8a9a5SSteve French bool sfu_emul:1; 215*38c8a9a5SSteve French bool nullauth:1; /* attempt to authenticate with null user */ 216*38c8a9a5SSteve French bool nocase:1; /* request case insensitive filenames */ 217*38c8a9a5SSteve French bool nobrl:1; /* disable sending byte range locks to srv */ 218*38c8a9a5SSteve French bool nohandlecache:1; /* disable caching dir handles if srvr probs */ 219*38c8a9a5SSteve French bool mand_lock:1; /* send mandatory not posix byte range lock reqs */ 220*38c8a9a5SSteve French bool seal:1; /* request transport encryption on share */ 221*38c8a9a5SSteve French bool nodfs:1; /* Do not request DFS, even if available */ 222*38c8a9a5SSteve French bool local_lease:1; /* check leases only on local system, not remote */ 223*38c8a9a5SSteve French bool noblocksnd:1; 224*38c8a9a5SSteve French bool noautotune:1; 225*38c8a9a5SSteve French bool nostrictsync:1; /* do not force expensive SMBflush on every sync */ 226*38c8a9a5SSteve French bool no_lease:1; /* disable requesting leases */ 227*38c8a9a5SSteve French bool no_sparse:1; /* do not attempt to set files sparse */ 228*38c8a9a5SSteve French bool fsc:1; /* enable fscache */ 229*38c8a9a5SSteve French bool mfsymlinks:1; /* use Minshall+French Symlinks */ 230*38c8a9a5SSteve French bool multiuser:1; 231*38c8a9a5SSteve French bool rwpidforward:1; /* pid forward for read/write operations */ 232*38c8a9a5SSteve French bool nosharesock:1; 233*38c8a9a5SSteve French bool persistent:1; 234*38c8a9a5SSteve French bool nopersistent:1; 235*38c8a9a5SSteve French bool resilient:1; /* noresilient not required since not fored for CA */ 236*38c8a9a5SSteve French bool domainauto:1; 237*38c8a9a5SSteve French bool rdma:1; 238*38c8a9a5SSteve French bool multichannel:1; 239*38c8a9a5SSteve French bool use_client_guid:1; 240*38c8a9a5SSteve French /* reuse existing guid for multichannel */ 241*38c8a9a5SSteve French u8 client_guid[SMB2_CLIENT_GUID_SIZE]; 242*38c8a9a5SSteve French unsigned int bsize; 243*38c8a9a5SSteve French unsigned int rasize; 244*38c8a9a5SSteve French unsigned int rsize; 245*38c8a9a5SSteve French unsigned int wsize; 246*38c8a9a5SSteve French unsigned int min_offload; 247*38c8a9a5SSteve French bool sockopt_tcp_nodelay:1; 248*38c8a9a5SSteve French /* attribute cache timemout for files and directories in jiffies */ 249*38c8a9a5SSteve French unsigned long acregmax; 250*38c8a9a5SSteve French unsigned long acdirmax; 251*38c8a9a5SSteve French /* timeout for deferred close of files in jiffies */ 252*38c8a9a5SSteve French unsigned long closetimeo; 253*38c8a9a5SSteve French struct smb_version_operations *ops; 254*38c8a9a5SSteve French struct smb_version_values *vals; 255*38c8a9a5SSteve French char *prepath; 256*38c8a9a5SSteve French struct sockaddr_storage dstaddr; /* destination address */ 257*38c8a9a5SSteve French struct sockaddr_storage srcaddr; /* allow binding to a local IP */ 258*38c8a9a5SSteve French struct nls_table *local_nls; /* This is a copy of the pointer in cifs_sb */ 259*38c8a9a5SSteve French unsigned int echo_interval; /* echo interval in secs */ 260*38c8a9a5SSteve French __u64 snapshot_time; /* needed for timewarp tokens */ 261*38c8a9a5SSteve French __u32 handle_timeout; /* persistent and durable handle timeout in ms */ 262*38c8a9a5SSteve French unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */ 263*38c8a9a5SSteve French unsigned int max_channels; 264*38c8a9a5SSteve French __u16 compression; /* compression algorithm 0xFFFF default 0=disabled */ 265*38c8a9a5SSteve French bool rootfs:1; /* if it's a SMB root file system */ 266*38c8a9a5SSteve French bool witness:1; /* use witness protocol */ 267*38c8a9a5SSteve French char *leaf_fullpath; 268*38c8a9a5SSteve French struct cifs_ses *dfs_root_ses; 269*38c8a9a5SSteve French }; 270*38c8a9a5SSteve French 271*38c8a9a5SSteve French extern const struct fs_parameter_spec smb3_fs_parameters[]; 272*38c8a9a5SSteve French 273*38c8a9a5SSteve French extern int smb3_init_fs_context(struct fs_context *fc); 274*38c8a9a5SSteve French extern void smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx); 275*38c8a9a5SSteve French extern void smb3_cleanup_fs_context(struct smb3_fs_context *ctx); 276*38c8a9a5SSteve French 277*38c8a9a5SSteve French static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *fc) 278*38c8a9a5SSteve French { 279*38c8a9a5SSteve French return fc->fs_private; 280*38c8a9a5SSteve French } 281*38c8a9a5SSteve French 282*38c8a9a5SSteve French extern int smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx); 283*38c8a9a5SSteve French extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb); 284*38c8a9a5SSteve French 285*38c8a9a5SSteve French /* 286*38c8a9a5SSteve French * max deferred close timeout (jiffies) - 2^30 287*38c8a9a5SSteve French */ 288*38c8a9a5SSteve French #define SMB3_MAX_DCLOSETIMEO (1 << 30) 289*38c8a9a5SSteve French #define SMB3_DEF_DCLOSETIMEO (1 * HZ) /* even 1 sec enough to help eg open/write/close/open/read */ 290*38c8a9a5SSteve French 291*38c8a9a5SSteve French extern char *cifs_sanitize_prepath(char *prepath, gfp_t gfp); 292*38c8a9a5SSteve French 293*38c8a9a5SSteve French #endif 294