blob: 29601a4eb411659d63488b66c05b22a97a8d4a46 [file] [log] [blame]
Ronnie Sahlberga6a9cff2020-10-21 10:22:33 +10001/* 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 Sahlberg5c6e5aa2020-10-21 10:37:11 +100012#include "cifsglob.h"
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -060013#include <linux/parser.h>
14#include <linux/fs_parser.h>
15
Aurelien Aptel9d4ac8b2021-03-01 19:25:00 +010016/* 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 Sahlberga6a9cff2020-10-21 10:22:33 +100022
Ronnie Sahlberg555782a2020-10-21 12:10:44 +100023enum 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 Sahlberg2f20f072020-10-21 11:30:35 +100035enum {
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 Sahlberg5c6e5aa2020-10-21 10:37:11 +100044enum cifs_sec_param {
45 Opt_sec_krb5,
46 Opt_sec_krb5i,
47 Opt_sec_krb5p,
48 Opt_sec_ntlmsspi,
49 Opt_sec_ntlmssp,
Ronnie Sahlberg5c6e5aa2020-10-21 10:37:11 +100050 Opt_sec_ntlmv2,
51 Opt_sec_ntlmv2i,
Ronnie Sahlberg5c6e5aa2020-10-21 10:37:11 +100052 Opt_sec_none,
53
54 Opt_sec_err
55};
56
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +100057enum cifs_param {
58 /* Mount options that take no arguments */
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -060059 Opt_user_xattr,
60 Opt_forceuid,
61 Opt_forcegid,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +100062 Opt_noblocksend,
63 Opt_noautotune,
64 Opt_nolease,
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -060065 Opt_hard,
66 Opt_soft,
67 Opt_perm,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +100068 Opt_nodelete,
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -060069 Opt_mapposix,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +100070 Opt_mapchars,
71 Opt_nomapchars,
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -060072 Opt_sfu,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +100073 Opt_nodfs,
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -060074 Opt_posixpaths,
75 Opt_unix,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +100076 Opt_nocase,
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -060077 Opt_brl,
78 Opt_handlecache,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +100079 Opt_forcemandatorylock,
80 Opt_setuidfromacl,
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -060081 Opt_setuids,
82 Opt_dynperm,
83 Opt_intr,
84 Opt_strictsync,
85 Opt_serverino,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +100086 Opt_rwpidforward,
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -060087 Opt_cifsacl,
88 Opt_acl,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +100089 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 Sahlberg24e0a1e2020-12-10 00:06:02 -060099 Opt_persistent,
100 Opt_resilient,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +1000101 Opt_domainauto,
102 Opt_rdma,
103 Opt_modesid,
104 Opt_rootfs,
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -0600105 Opt_multichannel,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +1000106 Opt_compress,
Samuel Cabrero0ac4e292020-12-11 22:59:29 -0600107 Opt_witness,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +1000108
109 /* Mount options which take numeric value */
110 Opt_backupuid,
111 Opt_backupgid,
112 Opt_uid,
113 Opt_cruid,
114 Opt_gid,
115 Opt_port,
116 Opt_file_mode,
117 Opt_dirmode,
118 Opt_min_enc_offload,
119 Opt_blocksize,
Steve Frenchb8d64f82021-04-24 21:46:23 -0500120 Opt_rasize,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +1000121 Opt_rsize,
122 Opt_wsize,
123 Opt_actimeo,
Steve French4c9f9482021-02-23 15:50:57 -0600124 Opt_acdirmax,
Steve French57804642021-02-24 12:12:53 -0600125 Opt_acregmax,
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +1000126 Opt_echo_interval,
127 Opt_max_credits,
128 Opt_snapshot,
129 Opt_max_channels,
130 Opt_handletimeout,
131
132 /* Mount options which take string value */
133 Opt_source,
134 Opt_user,
135 Opt_pass,
136 Opt_ip,
137 Opt_domain,
138 Opt_srcaddr,
139 Opt_iocharset,
140 Opt_netbiosname,
141 Opt_servern,
142 Opt_ver,
143 Opt_vers,
144 Opt_sec,
145 Opt_cache,
146
147 /* Mount options to be ignored */
148 Opt_ignore,
149
Ronnie Sahlberg15c7d092020-11-02 10:59:55 +1000150 Opt_err
151};
152
Ronnie Sahlberg3fa1c6d2020-12-09 23:07:12 -0600153struct smb3_fs_context {
154 bool uid_specified;
Ronnie Sahlberge0a3cbc2021-07-08 09:24:16 +1000155 bool cruid_specified;
Ronnie Sahlberg3fa1c6d2020-12-09 23:07:12 -0600156 bool gid_specified;
157 bool sloppy;
Ronnie Sahlberg3fa1c6d2020-12-09 23:07:12 -0600158 bool got_ip;
159 bool got_version;
Ronnie Sahlberg522aa3b2020-12-14 16:40:17 +1000160 bool got_rsize;
161 bool got_wsize;
162 bool got_bsize;
Ronnie Sahlberg3fa1c6d2020-12-09 23:07:12 -0600163 unsigned short port;
164
165 char *username;
166 char *password;
167 char *domainname;
Ronnie Sahlbergaf1a3d22021-02-11 16:06:16 +1000168 char *source;
Shyam Prasad N7be32482021-10-14 11:52:39 +0000169 char *server_hostname;
Ronnie Sahlberg3fa1c6d2020-12-09 23:07:12 -0600170 char *UNC;
Ronnie Sahlberg9ccecae2020-12-14 16:40:19 +1000171 char *nodename;
Ronnie Sahlberg3fa1c6d2020-12-09 23:07:12 -0600172 char *iocharset; /* local code page for mapping to and from Unicode */
173 char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
174 char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
175 kuid_t cred_uid;
176 kuid_t linux_uid;
177 kgid_t linux_gid;
178 kuid_t backupuid;
179 kgid_t backupgid;
180 umode_t file_mode;
181 umode_t dir_mode;
182 enum securityEnum sectype; /* sectype requested via mnt opts */
183 bool sign; /* was signing requested via mnt opts? */
184 bool ignore_signature:1;
185 bool retry:1;
186 bool intr:1;
187 bool setuids:1;
188 bool setuidfromacl:1;
189 bool override_uid:1;
190 bool override_gid:1;
191 bool dynperm:1;
192 bool noperm:1;
193 bool nodelete:1;
194 bool mode_ace:1;
195 bool no_psx_acl:1; /* set if posix acl support should be disabled */
196 bool cifs_acl:1;
197 bool backupuid_specified; /* mount option backupuid is specified */
198 bool backupgid_specified; /* mount option backupgid is specified */
199 bool no_xattr:1; /* set if xattr (EA) support should be disabled*/
200 bool server_ino:1; /* use inode numbers from server ie UniqueId */
201 bool direct_io:1;
202 bool strict_io:1; /* strict cache behavior */
203 bool cache_ro:1;
204 bool cache_rw:1;
205 bool remap:1; /* set to remap seven reserved chars in filenames */
206 bool sfu_remap:1; /* remap seven reserved chars ala SFU */
207 bool posix_paths:1; /* unset to not ask for posix pathnames. */
208 bool no_linux_ext:1;
209 bool linux_ext:1;
210 bool sfu_emul:1;
211 bool nullauth:1; /* attempt to authenticate with null user */
212 bool nocase:1; /* request case insensitive filenames */
213 bool nobrl:1; /* disable sending byte range locks to srv */
214 bool nohandlecache:1; /* disable caching dir handles if srvr probs */
215 bool mand_lock:1; /* send mandatory not posix byte range lock reqs */
216 bool seal:1; /* request transport encryption on share */
217 bool nodfs:1; /* Do not request DFS, even if available */
218 bool local_lease:1; /* check leases only on local system, not remote */
219 bool noblocksnd:1;
220 bool noautotune:1;
221 bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
222 bool no_lease:1; /* disable requesting leases */
223 bool fsc:1; /* enable fscache */
224 bool mfsymlinks:1; /* use Minshall+French Symlinks */
225 bool multiuser:1;
226 bool rwpidforward:1; /* pid forward for read/write operations */
227 bool nosharesock:1;
228 bool persistent:1;
229 bool nopersistent:1;
230 bool resilient:1; /* noresilient not required since not fored for CA */
231 bool domainauto:1;
232 bool rdma:1;
233 bool multichannel:1;
234 bool use_client_guid:1;
235 /* reuse existing guid for multichannel */
236 u8 client_guid[SMB2_CLIENT_GUID_SIZE];
237 unsigned int bsize;
Steve Frenchb8d64f82021-04-24 21:46:23 -0500238 unsigned int rasize;
Ronnie Sahlberg3fa1c6d2020-12-09 23:07:12 -0600239 unsigned int rsize;
240 unsigned int wsize;
241 unsigned int min_offload;
242 bool sockopt_tcp_nodelay:1;
Steve French57804642021-02-24 12:12:53 -0600243 /* attribute cache timemout for files and directories in jiffies */
244 unsigned long acregmax;
245 unsigned long acdirmax;
Ronnie Sahlberg3fa1c6d2020-12-09 23:07:12 -0600246 struct smb_version_operations *ops;
247 struct smb_version_values *vals;
248 char *prepath;
249 struct sockaddr_storage dstaddr; /* destination address */
250 struct sockaddr_storage srcaddr; /* allow binding to a local IP */
Ronnie Sahlberg387ec582020-12-14 16:40:20 +1000251 struct nls_table *local_nls; /* This is a copy of the pointer in cifs_sb */
Ronnie Sahlberg3fa1c6d2020-12-09 23:07:12 -0600252 unsigned int echo_interval; /* echo interval in secs */
253 __u64 snapshot_time; /* needed for timewarp tokens */
254 __u32 handle_timeout; /* persistent and durable handle timeout in ms */
255 unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
256 unsigned int max_channels;
257 __u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
258 bool rootfs:1; /* if it's a SMB root file system */
Samuel Cabrero0ac4e292020-12-11 22:59:29 -0600259 bool witness:1; /* use witness protocol */
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -0600260
261 char *mount_options;
Ronnie Sahlberg3fa1c6d2020-12-09 23:07:12 -0600262};
263
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -0600264extern const struct fs_parameter_spec smb3_fs_parameters[];
265
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -0600266extern int smb3_init_fs_context(struct fs_context *fc);
Ronnie Sahlbergc741cba2020-12-14 16:40:16 +1000267extern void smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx);
268extern void smb3_cleanup_fs_context(struct smb3_fs_context *ctx);
Ronnie Sahlberg24e0a1e2020-12-10 00:06:02 -0600269
270static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *fc)
271{
272 return fc->fs_private;
273}
274
Ronnie Sahlberg837e3a12020-11-02 09:36:24 +1000275extern int smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx);
Ronnie Sahlberg2d39f502020-12-14 16:40:25 +1000276extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
Ronnie Sahlberga6a9cff2020-10-21 10:22:33 +1000277
278#endif