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