1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2020, Microsoft Corporation.
5 * Author(s): Steve French <stfrench@microsoft.com>
6 * David Howells <dhowells@redhat.com>
13 #include <linux/parser.h>
14 #include <linux/fs_parser.h>
16 /* Log errors in fs_context (new mount api) but also in dmesg (old style) */
17 #define cifs_errorf(fc, fmt, ...) \
19 errorf(fc, fmt, ## __VA_ARGS__); \
20 cifs_dbg(VFS, fmt, ## __VA_ARGS__); \
44 enum cifs_reparse_parm
{
64 enum cifs_upcall_target_param
{
65 Opt_upcall_target_mount
,
66 Opt_upcall_target_application
,
71 /* Mount options that take no arguments */
93 Opt_forcemandatorylock
,
105 Opt_ignore_signature
,
123 Opt_is_upcall_target_mount
,
124 Opt_is_upcall_target_application
,
126 /* Mount options which take numeric value */
152 /* Mount options which take string value */
170 /* Mount options to be ignored */
176 struct smb3_fs_context
{
177 bool forceuid_specified
;
178 bool forcegid_specified
;
180 bool cruid_specified
;
195 char *server_hostname
;
198 char workstation_name
[CIFS_MAX_WORKSTATION_LEN
];
199 char *iocharset
; /* local code page for mapping to and from Unicode */
200 char source_rfc1001_name
[RFC1001_NAME_LEN_WITH_NULL
]; /* clnt nb name */
201 char target_rfc1001_name
[RFC1001_NAME_LEN_WITH_NULL
]; /* srvr nb name */
209 enum securityEnum sectype
; /* sectype requested via mnt opts */
210 enum upcall_target_enum upcall_target
; /* where to upcall for mount */
211 bool sign
; /* was signing requested via mnt opts? */
212 bool ignore_signature
:1;
216 bool setuidfromacl
:1;
223 bool no_psx_acl
:1; /* set if posix acl support should be disabled */
225 bool backupuid_specified
; /* mount option backupuid is specified */
226 bool backupgid_specified
; /* mount option backupgid is specified */
227 bool no_xattr
:1; /* set if xattr (EA) support should be disabled*/
228 bool server_ino
:1; /* use inode numbers from server ie UniqueId */
230 bool strict_io
:1; /* strict cache behavior */
233 bool remap
:1; /* set to remap seven reserved chars in filenames */
234 bool sfu_remap
:1; /* remap seven reserved chars ala SFU */
235 bool posix_paths
:1; /* unset to not ask for posix pathnames. */
239 bool nullauth
:1; /* attempt to authenticate with null user */
240 bool nocase
:1; /* request case insensitive filenames */
241 bool nobrl
:1; /* disable sending byte range locks to srv */
242 bool nohandlecache
:1; /* disable caching dir handles if srvr probs */
243 bool mand_lock
:1; /* send mandatory not posix byte range lock reqs */
244 bool seal
:1; /* request transport encryption on share */
245 bool nodfs
:1; /* Do not request DFS, even if available */
246 bool local_lease
:1; /* check leases only on local system, not remote */
249 bool nostrictsync
:1; /* do not force expensive SMBflush on every sync */
250 bool no_lease
:1; /* disable requesting leases */
251 bool no_sparse
:1; /* do not attempt to set files sparse */
252 bool fsc
:1; /* enable fscache */
253 bool mfsymlinks
:1; /* use Minshall+French Symlinks */
255 bool rwpidforward
:1; /* pid forward for read/write operations */
259 bool resilient
:1; /* noresilient not required since not fored for CA */
263 bool use_client_guid
:1;
264 /* reuse existing guid for multichannel */
265 u8 client_guid
[SMB2_CLIENT_GUID_SIZE
];
270 unsigned int min_offload
;
271 unsigned int retrans
;
272 bool sockopt_tcp_nodelay
:1;
273 /* attribute cache timeout for files and directories in jiffies */
274 unsigned long acregmax
;
275 unsigned long acdirmax
;
276 /* timeout for deferred close of files in jiffies */
277 unsigned long closetimeo
;
278 struct smb_version_operations
*ops
;
279 struct smb_version_values
*vals
;
281 struct sockaddr_storage dstaddr
; /* destination address */
282 struct sockaddr_storage srcaddr
; /* allow binding to a local IP */
283 struct nls_table
*local_nls
; /* This is a copy of the pointer in cifs_sb */
284 unsigned int echo_interval
; /* echo interval in secs */
285 __u64 snapshot_time
; /* needed for timewarp tokens */
286 __u32 handle_timeout
; /* persistent and durable handle timeout in ms */
287 unsigned int max_credits
; /* smb3 max_credits 10 < credits < 60000 */
288 unsigned int max_channels
;
289 unsigned int max_cached_dirs
;
290 bool compress
; /* enable SMB2 messages (READ/WRITE) de/compression */
291 bool rootfs
:1; /* if it's a SMB root file system */
292 bool witness
:1; /* use witness protocol */
294 struct cifs_ses
*dfs_root_ses
;
295 bool dfs_automount
:1; /* set for dfs automount only */
296 enum cifs_reparse_type reparse_type
;
297 bool dfs_conn
:1; /* set for dfs mounts */
300 extern const struct fs_parameter_spec smb3_fs_parameters
[];
302 extern int smb3_init_fs_context(struct fs_context
*fc
);
303 extern void smb3_cleanup_fs_context_contents(struct smb3_fs_context
*ctx
);
304 extern void smb3_cleanup_fs_context(struct smb3_fs_context
*ctx
);
306 static inline struct smb3_fs_context
*smb3_fc2context(const struct fs_context
*fc
)
308 return fc
->fs_private
;
311 extern int smb3_fs_context_dup(struct smb3_fs_context
*new_ctx
, struct smb3_fs_context
*ctx
);
312 extern int smb3_sync_session_ctx_passwords(struct cifs_sb_info
*cifs_sb
, struct cifs_ses
*ses
);
313 extern void smb3_update_mnt_flags(struct cifs_sb_info
*cifs_sb
);
316 * max deferred close timeout (jiffies) - 2^30
318 #define SMB3_MAX_DCLOSETIMEO (1 << 30)
319 #define SMB3_DEF_DCLOSETIMEO (1 * HZ) /* even 1 sec enough to help eg open/write/close/open/read */
320 #define MAX_CACHED_FIDS 16
321 extern char *cifs_sanitize_prepath(char *prepath
, gfp_t gfp
);
323 extern struct mutex cifs_mount_mutex
;
325 static inline void cifs_mount_lock(void)
327 mutex_lock(&cifs_mount_mutex
);
330 static inline void cifs_mount_unlock(void)
332 mutex_unlock(&cifs_mount_mutex
);