138c8a9a5SSteve French /* SPDX-License-Identifier: GPL-2.0-or-later */
238c8a9a5SSteve French /*
338c8a9a5SSteve French * Copyright (C) 2020, Microsoft Corporation.
438c8a9a5SSteve French *
538c8a9a5SSteve French * Author(s): Steve French <stfrench@microsoft.com>
638c8a9a5SSteve French * David Howells <dhowells@redhat.com>
738c8a9a5SSteve French */
838c8a9a5SSteve French
938c8a9a5SSteve French #ifndef _FS_CONTEXT_H
1038c8a9a5SSteve French #define _FS_CONTEXT_H
1138c8a9a5SSteve French
1238c8a9a5SSteve French #include "cifsglob.h"
1338c8a9a5SSteve French #include <linux/parser.h>
1438c8a9a5SSteve French #include <linux/fs_parser.h>
1538c8a9a5SSteve French
1638c8a9a5SSteve French /* Log errors in fs_context (new mount api) but also in dmesg (old style) */
1738c8a9a5SSteve French #define cifs_errorf(fc, fmt, ...) \
1838c8a9a5SSteve French do { \
1938c8a9a5SSteve French errorf(fc, fmt, ## __VA_ARGS__); \
2038c8a9a5SSteve French cifs_dbg(VFS, fmt, ## __VA_ARGS__); \
2138c8a9a5SSteve French } while (0)
2238c8a9a5SSteve French
2338c8a9a5SSteve French enum smb_version {
2438c8a9a5SSteve French Smb_1 = 1,
2538c8a9a5SSteve French Smb_20,
2638c8a9a5SSteve French Smb_21,
2738c8a9a5SSteve French Smb_30,
2838c8a9a5SSteve French Smb_302,
2938c8a9a5SSteve French Smb_311,
3038c8a9a5SSteve French Smb_3any,
3138c8a9a5SSteve French Smb_default,
3238c8a9a5SSteve French Smb_version_err
3338c8a9a5SSteve French };
3438c8a9a5SSteve French
3538c8a9a5SSteve French enum {
3638c8a9a5SSteve French Opt_cache_loose,
3738c8a9a5SSteve French Opt_cache_strict,
3838c8a9a5SSteve French Opt_cache_none,
3938c8a9a5SSteve French Opt_cache_ro,
4038c8a9a5SSteve French Opt_cache_rw,
4138c8a9a5SSteve French Opt_cache_err
4238c8a9a5SSteve French };
4338c8a9a5SSteve French
44c1468c7eSPaulo Alcantara enum cifs_reparse_parm {
45c1468c7eSPaulo Alcantara Opt_reparse_default,
46c1468c7eSPaulo Alcantara Opt_reparse_nfs,
47c1468c7eSPaulo Alcantara Opt_reparse_wsl,
48c1468c7eSPaulo Alcantara Opt_reparse_err
49c1468c7eSPaulo Alcantara };
50c1468c7eSPaulo Alcantara
5138c8a9a5SSteve French enum cifs_sec_param {
5238c8a9a5SSteve French Opt_sec_krb5,
5338c8a9a5SSteve French Opt_sec_krb5i,
5438c8a9a5SSteve French Opt_sec_krb5p,
5538c8a9a5SSteve French Opt_sec_ntlmsspi,
5638c8a9a5SSteve French Opt_sec_ntlmssp,
5738c8a9a5SSteve French Opt_sec_ntlmv2,
5838c8a9a5SSteve French Opt_sec_ntlmv2i,
5938c8a9a5SSteve French Opt_sec_none,
6038c8a9a5SSteve French
6138c8a9a5SSteve French Opt_sec_err
6238c8a9a5SSteve French };
6338c8a9a5SSteve French
6438c8a9a5SSteve French enum cifs_param {
6538c8a9a5SSteve French /* Mount options that take no arguments */
6638c8a9a5SSteve French Opt_user_xattr,
6738c8a9a5SSteve French Opt_forceuid,
6838c8a9a5SSteve French Opt_forcegid,
6938c8a9a5SSteve French Opt_noblocksend,
7038c8a9a5SSteve French Opt_noautotune,
7138c8a9a5SSteve French Opt_nolease,
7238c8a9a5SSteve French Opt_nosparse,
7338c8a9a5SSteve French Opt_hard,
7438c8a9a5SSteve French Opt_soft,
7538c8a9a5SSteve French Opt_perm,
7638c8a9a5SSteve French Opt_nodelete,
7738c8a9a5SSteve French Opt_mapposix,
7838c8a9a5SSteve French Opt_mapchars,
7938c8a9a5SSteve French Opt_nomapchars,
8038c8a9a5SSteve French Opt_sfu,
8138c8a9a5SSteve French Opt_nodfs,
8238c8a9a5SSteve French Opt_posixpaths,
8338c8a9a5SSteve French Opt_unix,
8438c8a9a5SSteve French Opt_nocase,
8538c8a9a5SSteve French Opt_brl,
8638c8a9a5SSteve French Opt_handlecache,
8738c8a9a5SSteve French Opt_forcemandatorylock,
8838c8a9a5SSteve French Opt_setuidfromacl,
8938c8a9a5SSteve French Opt_setuids,
9038c8a9a5SSteve French Opt_dynperm,
9138c8a9a5SSteve French Opt_intr,
9238c8a9a5SSteve French Opt_strictsync,
9338c8a9a5SSteve French Opt_serverino,
9438c8a9a5SSteve French Opt_rwpidforward,
9538c8a9a5SSteve French Opt_cifsacl,
9638c8a9a5SSteve French Opt_acl,
9738c8a9a5SSteve French Opt_locallease,
9838c8a9a5SSteve French Opt_sign,
9938c8a9a5SSteve French Opt_ignore_signature,
10038c8a9a5SSteve French Opt_seal,
10138c8a9a5SSteve French Opt_noac,
10238c8a9a5SSteve French Opt_fsc,
10338c8a9a5SSteve French Opt_mfsymlinks,
10438c8a9a5SSteve French Opt_multiuser,
10538c8a9a5SSteve French Opt_sloppy,
10638c8a9a5SSteve French Opt_nosharesock,
10738c8a9a5SSteve French Opt_persistent,
10838c8a9a5SSteve French Opt_resilient,
10938c8a9a5SSteve French Opt_tcp_nodelay,
11038c8a9a5SSteve French Opt_domainauto,
11138c8a9a5SSteve French Opt_rdma,
11238c8a9a5SSteve French Opt_modesid,
11338c8a9a5SSteve French Opt_rootfs,
11438c8a9a5SSteve French Opt_multichannel,
11538c8a9a5SSteve French Opt_compress,
11638c8a9a5SSteve French Opt_witness,
11738c8a9a5SSteve French
11838c8a9a5SSteve French /* Mount options which take numeric value */
11938c8a9a5SSteve French Opt_backupuid,
12038c8a9a5SSteve French Opt_backupgid,
12138c8a9a5SSteve French Opt_uid,
12238c8a9a5SSteve French Opt_cruid,
12338c8a9a5SSteve French Opt_gid,
12438c8a9a5SSteve French Opt_port,
12538c8a9a5SSteve French Opt_file_mode,
12638c8a9a5SSteve French Opt_dirmode,
12738c8a9a5SSteve French Opt_min_enc_offload,
128b4ca2942SShyam Prasad N Opt_retrans,
12938c8a9a5SSteve French Opt_blocksize,
13038c8a9a5SSteve French Opt_rasize,
13138c8a9a5SSteve French Opt_rsize,
13238c8a9a5SSteve French Opt_wsize,
13338c8a9a5SSteve French Opt_actimeo,
13438c8a9a5SSteve French Opt_acdirmax,
13538c8a9a5SSteve French Opt_acregmax,
13638c8a9a5SSteve French Opt_closetimeo,
13738c8a9a5SSteve French Opt_echo_interval,
13838c8a9a5SSteve French Opt_max_credits,
1396a50d71dSSteve French Opt_max_cached_dirs,
14038c8a9a5SSteve French Opt_snapshot,
14138c8a9a5SSteve French Opt_max_channels,
14238c8a9a5SSteve French Opt_handletimeout,
14338c8a9a5SSteve French
14438c8a9a5SSteve French /* Mount options which take string value */
14538c8a9a5SSteve French Opt_source,
14638c8a9a5SSteve French Opt_user,
14738c8a9a5SSteve French Opt_pass,
14808bedfbcSSteve French Opt_pass2,
14938c8a9a5SSteve French Opt_ip,
15038c8a9a5SSteve French Opt_domain,
15138c8a9a5SSteve French Opt_srcaddr,
15238c8a9a5SSteve French Opt_iocharset,
15338c8a9a5SSteve French Opt_netbiosname,
15438c8a9a5SSteve French Opt_servern,
15538c8a9a5SSteve French Opt_ver,
15638c8a9a5SSteve French Opt_vers,
15738c8a9a5SSteve French Opt_sec,
15838c8a9a5SSteve French Opt_cache,
159c1468c7eSPaulo Alcantara Opt_reparse,
16038c8a9a5SSteve French
16138c8a9a5SSteve French /* Mount options to be ignored */
16238c8a9a5SSteve French Opt_ignore,
16338c8a9a5SSteve French
16438c8a9a5SSteve French Opt_err
16538c8a9a5SSteve French };
16638c8a9a5SSteve French
16738c8a9a5SSteve French struct smb3_fs_context {
168fc1860a1STakayuki Nagata bool forceuid_specified;
169fc1860a1STakayuki Nagata bool forcegid_specified;
17038c8a9a5SSteve French bool uid_specified;
17138c8a9a5SSteve French bool cruid_specified;
17238c8a9a5SSteve French bool gid_specified;
17338c8a9a5SSteve French bool sloppy;
17438c8a9a5SSteve French bool got_ip;
17538c8a9a5SSteve French bool got_version;
17638c8a9a5SSteve French bool got_rsize;
17738c8a9a5SSteve French bool got_wsize;
17838c8a9a5SSteve French bool got_bsize;
17938c8a9a5SSteve French unsigned short port;
18038c8a9a5SSteve French
18138c8a9a5SSteve French char *username;
18238c8a9a5SSteve French char *password;
18308bedfbcSSteve French char *password2;
18438c8a9a5SSteve French char *domainname;
18538c8a9a5SSteve French char *source;
18638c8a9a5SSteve French char *server_hostname;
18738c8a9a5SSteve French char *UNC;
18838c8a9a5SSteve French char *nodename;
18938c8a9a5SSteve French char workstation_name[CIFS_MAX_WORKSTATION_LEN];
19038c8a9a5SSteve French char *iocharset; /* local code page for mapping to and from Unicode */
19138c8a9a5SSteve French char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
19238c8a9a5SSteve French char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
19338c8a9a5SSteve French kuid_t cred_uid;
19438c8a9a5SSteve French kuid_t linux_uid;
19538c8a9a5SSteve French kgid_t linux_gid;
19638c8a9a5SSteve French kuid_t backupuid;
19738c8a9a5SSteve French kgid_t backupgid;
19838c8a9a5SSteve French umode_t file_mode;
19938c8a9a5SSteve French umode_t dir_mode;
20038c8a9a5SSteve French enum securityEnum sectype; /* sectype requested via mnt opts */
20138c8a9a5SSteve French bool sign; /* was signing requested via mnt opts? */
20238c8a9a5SSteve French bool ignore_signature:1;
20338c8a9a5SSteve French bool retry:1;
20438c8a9a5SSteve French bool intr:1;
20538c8a9a5SSteve French bool setuids:1;
20638c8a9a5SSteve French bool setuidfromacl:1;
20738c8a9a5SSteve French bool override_uid:1;
20838c8a9a5SSteve French bool override_gid:1;
20938c8a9a5SSteve French bool dynperm:1;
21038c8a9a5SSteve French bool noperm:1;
21138c8a9a5SSteve French bool nodelete:1;
21238c8a9a5SSteve French bool mode_ace:1;
21338c8a9a5SSteve French bool no_psx_acl:1; /* set if posix acl support should be disabled */
21438c8a9a5SSteve French bool cifs_acl:1;
21538c8a9a5SSteve French bool backupuid_specified; /* mount option backupuid is specified */
21638c8a9a5SSteve French bool backupgid_specified; /* mount option backupgid is specified */
21738c8a9a5SSteve French bool no_xattr:1; /* set if xattr (EA) support should be disabled*/
21838c8a9a5SSteve French bool server_ino:1; /* use inode numbers from server ie UniqueId */
21938c8a9a5SSteve French bool direct_io:1;
22038c8a9a5SSteve French bool strict_io:1; /* strict cache behavior */
22138c8a9a5SSteve French bool cache_ro:1;
22238c8a9a5SSteve French bool cache_rw:1;
22338c8a9a5SSteve French bool remap:1; /* set to remap seven reserved chars in filenames */
22438c8a9a5SSteve French bool sfu_remap:1; /* remap seven reserved chars ala SFU */
22538c8a9a5SSteve French bool posix_paths:1; /* unset to not ask for posix pathnames. */
22638c8a9a5SSteve French bool no_linux_ext:1;
22738c8a9a5SSteve French bool linux_ext:1;
22838c8a9a5SSteve French bool sfu_emul:1;
22938c8a9a5SSteve French bool nullauth:1; /* attempt to authenticate with null user */
23038c8a9a5SSteve French bool nocase:1; /* request case insensitive filenames */
23138c8a9a5SSteve French bool nobrl:1; /* disable sending byte range locks to srv */
23238c8a9a5SSteve French bool nohandlecache:1; /* disable caching dir handles if srvr probs */
23338c8a9a5SSteve French bool mand_lock:1; /* send mandatory not posix byte range lock reqs */
23438c8a9a5SSteve French bool seal:1; /* request transport encryption on share */
23538c8a9a5SSteve French bool nodfs:1; /* Do not request DFS, even if available */
23638c8a9a5SSteve French bool local_lease:1; /* check leases only on local system, not remote */
23738c8a9a5SSteve French bool noblocksnd:1;
23838c8a9a5SSteve French bool noautotune:1;
23938c8a9a5SSteve French bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
24038c8a9a5SSteve French bool no_lease:1; /* disable requesting leases */
24138c8a9a5SSteve French bool no_sparse:1; /* do not attempt to set files sparse */
24238c8a9a5SSteve French bool fsc:1; /* enable fscache */
24338c8a9a5SSteve French bool mfsymlinks:1; /* use Minshall+French Symlinks */
24438c8a9a5SSteve French bool multiuser:1;
24538c8a9a5SSteve French bool rwpidforward:1; /* pid forward for read/write operations */
24638c8a9a5SSteve French bool nosharesock:1;
24738c8a9a5SSteve French bool persistent:1;
24838c8a9a5SSteve French bool nopersistent:1;
24938c8a9a5SSteve French bool resilient:1; /* noresilient not required since not fored for CA */
25038c8a9a5SSteve French bool domainauto:1;
25138c8a9a5SSteve French bool rdma:1;
25238c8a9a5SSteve French bool multichannel:1;
25338c8a9a5SSteve French bool use_client_guid:1;
25438c8a9a5SSteve French /* reuse existing guid for multichannel */
25538c8a9a5SSteve French u8 client_guid[SMB2_CLIENT_GUID_SIZE];
25638c8a9a5SSteve French unsigned int bsize;
25738c8a9a5SSteve French unsigned int rasize;
25838c8a9a5SSteve French unsigned int rsize;
25938c8a9a5SSteve French unsigned int wsize;
26038c8a9a5SSteve French unsigned int min_offload;
261b4ca2942SShyam Prasad N unsigned int retrans;
26238c8a9a5SSteve French bool sockopt_tcp_nodelay:1;
26338c8a9a5SSteve French /* attribute cache timemout for files and directories in jiffies */
26438c8a9a5SSteve French unsigned long acregmax;
26538c8a9a5SSteve French unsigned long acdirmax;
26638c8a9a5SSteve French /* timeout for deferred close of files in jiffies */
26738c8a9a5SSteve French unsigned long closetimeo;
26838c8a9a5SSteve French struct smb_version_operations *ops;
26938c8a9a5SSteve French struct smb_version_values *vals;
27038c8a9a5SSteve French char *prepath;
27138c8a9a5SSteve French struct sockaddr_storage dstaddr; /* destination address */
27238c8a9a5SSteve French struct sockaddr_storage srcaddr; /* allow binding to a local IP */
27338c8a9a5SSteve French struct nls_table *local_nls; /* This is a copy of the pointer in cifs_sb */
27438c8a9a5SSteve French unsigned int echo_interval; /* echo interval in secs */
27538c8a9a5SSteve French __u64 snapshot_time; /* needed for timewarp tokens */
27638c8a9a5SSteve French __u32 handle_timeout; /* persistent and durable handle timeout in ms */
27738c8a9a5SSteve French unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
27838c8a9a5SSteve French unsigned int max_channels;
2796a50d71dSSteve French unsigned int max_cached_dirs;
280e8aee4f4SEnzo Matsumiya bool compress; /* enable SMB2 messages (READ/WRITE) de/compression */
28138c8a9a5SSteve French bool rootfs:1; /* if it's a SMB root file system */
28238c8a9a5SSteve French bool witness:1; /* use witness protocol */
28338c8a9a5SSteve French char *leaf_fullpath;
28438c8a9a5SSteve French struct cifs_ses *dfs_root_ses;
285390c08fdSPaulo Alcantara bool dfs_automount:1; /* set for dfs automount only */
286c1468c7eSPaulo Alcantara enum cifs_reparse_type reparse_type;
28738c8a9a5SSteve French };
28838c8a9a5SSteve French
28938c8a9a5SSteve French extern const struct fs_parameter_spec smb3_fs_parameters[];
29038c8a9a5SSteve French
29138c8a9a5SSteve French extern int smb3_init_fs_context(struct fs_context *fc);
29238c8a9a5SSteve French extern void smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx);
29338c8a9a5SSteve French extern void smb3_cleanup_fs_context(struct smb3_fs_context *ctx);
29438c8a9a5SSteve French
smb3_fc2context(const struct fs_context * fc)29538c8a9a5SSteve French static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *fc)
29638c8a9a5SSteve French {
29738c8a9a5SSteve French return fc->fs_private;
29838c8a9a5SSteve French }
29938c8a9a5SSteve French
30038c8a9a5SSteve French extern int smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx);
301*880a661eSShyam Prasad N extern int smb3_sync_session_ctx_passwords(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses);
30238c8a9a5SSteve French extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
30338c8a9a5SSteve French
30438c8a9a5SSteve French /*
30538c8a9a5SSteve French * max deferred close timeout (jiffies) - 2^30
30638c8a9a5SSteve French */
30738c8a9a5SSteve French #define SMB3_MAX_DCLOSETIMEO (1 << 30)
30838c8a9a5SSteve French #define SMB3_DEF_DCLOSETIMEO (1 * HZ) /* even 1 sec enough to help eg open/write/close/open/read */
3096a50d71dSSteve French #define MAX_CACHED_FIDS 16
31038c8a9a5SSteve French extern char *cifs_sanitize_prepath(char *prepath, gfp_t gfp);
31138c8a9a5SSteve French
312ba55f8a9SPaulo Alcantara extern struct mutex cifs_mount_mutex;
313ba55f8a9SPaulo Alcantara
cifs_mount_lock(void)314ba55f8a9SPaulo Alcantara static inline void cifs_mount_lock(void)
315ba55f8a9SPaulo Alcantara {
316ba55f8a9SPaulo Alcantara mutex_lock(&cifs_mount_mutex);
317ba55f8a9SPaulo Alcantara }
318ba55f8a9SPaulo Alcantara
cifs_mount_unlock(void)319ba55f8a9SPaulo Alcantara static inline void cifs_mount_unlock(void)
320ba55f8a9SPaulo Alcantara {
321ba55f8a9SPaulo Alcantara mutex_unlock(&cifs_mount_mutex);
322ba55f8a9SPaulo Alcantara }
323ba55f8a9SPaulo Alcantara
32438c8a9a5SSteve French #endif
325