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