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