2020-10-21 00:22:33 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2020, Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Author(s): Steve French <stfrench@microsoft.com>
|
|
|
|
* David Howells <dhowells@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _FS_CONTEXT_H
|
|
|
|
#define _FS_CONTEXT_H
|
|
|
|
|
2020-10-21 00:37:11 +00:00
|
|
|
#include "cifsglob.h"
|
2020-12-10 06:06:02 +00:00
|
|
|
#include <linux/parser.h>
|
|
|
|
#include <linux/fs_parser.h>
|
|
|
|
|
2021-03-01 18:25:00 +00:00
|
|
|
/* Log errors in fs_context (new mount api) but also in dmesg (old style) */
|
|
|
|
#define cifs_errorf(fc, fmt, ...) \
|
|
|
|
do { \
|
|
|
|
errorf(fc, fmt, ## __VA_ARGS__); \
|
|
|
|
cifs_dbg(VFS, fmt, ## __VA_ARGS__); \
|
|
|
|
} while (0)
|
2020-10-21 00:22:33 +00:00
|
|
|
|
2020-10-21 02:10:44 +00:00
|
|
|
enum smb_version {
|
|
|
|
Smb_1 = 1,
|
|
|
|
Smb_20,
|
|
|
|
Smb_21,
|
|
|
|
Smb_30,
|
|
|
|
Smb_302,
|
|
|
|
Smb_311,
|
|
|
|
Smb_3any,
|
|
|
|
Smb_default,
|
|
|
|
Smb_version_err
|
|
|
|
};
|
|
|
|
|
2020-10-21 01:30:35 +00:00
|
|
|
enum {
|
|
|
|
Opt_cache_loose,
|
|
|
|
Opt_cache_strict,
|
|
|
|
Opt_cache_none,
|
|
|
|
Opt_cache_ro,
|
|
|
|
Opt_cache_rw,
|
|
|
|
Opt_cache_err
|
|
|
|
};
|
|
|
|
|
2024-01-21 16:28:21 +00:00
|
|
|
enum cifs_reparse_parm {
|
|
|
|
Opt_reparse_default,
|
|
|
|
Opt_reparse_nfs,
|
|
|
|
Opt_reparse_wsl,
|
|
|
|
Opt_reparse_err
|
|
|
|
};
|
|
|
|
|
2020-10-21 00:37:11 +00:00
|
|
|
enum cifs_sec_param {
|
|
|
|
Opt_sec_krb5,
|
|
|
|
Opt_sec_krb5i,
|
|
|
|
Opt_sec_krb5p,
|
|
|
|
Opt_sec_ntlmsspi,
|
|
|
|
Opt_sec_ntlmssp,
|
|
|
|
Opt_sec_ntlmv2,
|
|
|
|
Opt_sec_ntlmv2i,
|
|
|
|
Opt_sec_none,
|
2020-10-21 00:22:33 +00:00
|
|
|
|
2020-10-21 00:37:11 +00:00
|
|
|
Opt_sec_err
|
|
|
|
};
|
|
|
|
|
2020-11-02 00:59:55 +00:00
|
|
|
enum cifs_param {
|
|
|
|
/* Mount options that take no arguments */
|
2020-12-10 06:06:02 +00:00
|
|
|
Opt_user_xattr,
|
|
|
|
Opt_forceuid,
|
|
|
|
Opt_forcegid,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_noblocksend,
|
|
|
|
Opt_noautotune,
|
|
|
|
Opt_nolease,
|
2022-05-24 04:17:12 +00:00
|
|
|
Opt_nosparse,
|
2020-12-10 06:06:02 +00:00
|
|
|
Opt_hard,
|
|
|
|
Opt_soft,
|
|
|
|
Opt_perm,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_nodelete,
|
2020-12-10 06:06:02 +00:00
|
|
|
Opt_mapposix,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_mapchars,
|
|
|
|
Opt_nomapchars,
|
2020-12-10 06:06:02 +00:00
|
|
|
Opt_sfu,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_nodfs,
|
2020-12-10 06:06:02 +00:00
|
|
|
Opt_posixpaths,
|
|
|
|
Opt_unix,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_nocase,
|
2020-12-10 06:06:02 +00:00
|
|
|
Opt_brl,
|
|
|
|
Opt_handlecache,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_forcemandatorylock,
|
|
|
|
Opt_setuidfromacl,
|
2020-12-10 06:06:02 +00:00
|
|
|
Opt_setuids,
|
|
|
|
Opt_dynperm,
|
|
|
|
Opt_intr,
|
|
|
|
Opt_strictsync,
|
|
|
|
Opt_serverino,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_rwpidforward,
|
2020-12-10 06:06:02 +00:00
|
|
|
Opt_cifsacl,
|
|
|
|
Opt_acl,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_locallease,
|
|
|
|
Opt_sign,
|
|
|
|
Opt_ignore_signature,
|
|
|
|
Opt_seal,
|
|
|
|
Opt_noac,
|
|
|
|
Opt_fsc,
|
|
|
|
Opt_mfsymlinks,
|
|
|
|
Opt_multiuser,
|
|
|
|
Opt_sloppy,
|
|
|
|
Opt_nosharesock,
|
2020-12-10 06:06:02 +00:00
|
|
|
Opt_persistent,
|
|
|
|
Opt_resilient,
|
2021-10-14 20:54:26 +00:00
|
|
|
Opt_tcp_nodelay,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_domainauto,
|
|
|
|
Opt_rdma,
|
|
|
|
Opt_modesid,
|
|
|
|
Opt_rootfs,
|
2020-12-10 06:06:02 +00:00
|
|
|
Opt_multichannel,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_compress,
|
2020-12-12 04:59:29 +00:00
|
|
|
Opt_witness,
|
2020-11-02 00:59:55 +00:00
|
|
|
|
|
|
|
/* Mount options which take numeric value */
|
|
|
|
Opt_backupuid,
|
|
|
|
Opt_backupgid,
|
|
|
|
Opt_uid,
|
|
|
|
Opt_cruid,
|
|
|
|
Opt_gid,
|
|
|
|
Opt_port,
|
|
|
|
Opt_file_mode,
|
|
|
|
Opt_dirmode,
|
|
|
|
Opt_min_enc_offload,
|
2024-01-17 06:09:16 +00:00
|
|
|
Opt_retrans,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_blocksize,
|
2021-04-25 02:46:23 +00:00
|
|
|
Opt_rasize,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_rsize,
|
|
|
|
Opt_wsize,
|
|
|
|
Opt_actimeo,
|
2021-02-23 21:50:57 +00:00
|
|
|
Opt_acdirmax,
|
2021-02-24 18:12:53 +00:00
|
|
|
Opt_acregmax,
|
2022-08-11 05:53:00 +00:00
|
|
|
Opt_closetimeo,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_echo_interval,
|
|
|
|
Opt_max_credits,
|
2023-09-01 07:15:14 +00:00
|
|
|
Opt_max_cached_dirs,
|
2020-11-02 00:59:55 +00:00
|
|
|
Opt_snapshot,
|
|
|
|
Opt_max_channels,
|
|
|
|
Opt_handletimeout,
|
|
|
|
|
|
|
|
/* Mount options which take string value */
|
|
|
|
Opt_source,
|
|
|
|
Opt_user,
|
|
|
|
Opt_pass,
|
|
|
|
Opt_ip,
|
|
|
|
Opt_domain,
|
|
|
|
Opt_srcaddr,
|
|
|
|
Opt_iocharset,
|
|
|
|
Opt_netbiosname,
|
|
|
|
Opt_servern,
|
|
|
|
Opt_ver,
|
|
|
|
Opt_vers,
|
|
|
|
Opt_sec,
|
|
|
|
Opt_cache,
|
2024-01-21 16:28:21 +00:00
|
|
|
Opt_reparse,
|
2020-11-02 00:59:55 +00:00
|
|
|
|
|
|
|
/* Mount options to be ignored */
|
|
|
|
Opt_ignore,
|
|
|
|
|
|
|
|
Opt_err
|
|
|
|
};
|
|
|
|
|
2020-12-10 05:07:12 +00:00
|
|
|
struct smb3_fs_context {
|
|
|
|
bool uid_specified;
|
2021-07-07 23:24:16 +00:00
|
|
|
bool cruid_specified;
|
2020-12-10 05:07:12 +00:00
|
|
|
bool gid_specified;
|
|
|
|
bool sloppy;
|
|
|
|
bool got_ip;
|
|
|
|
bool got_version;
|
2020-12-14 06:40:17 +00:00
|
|
|
bool got_rsize;
|
|
|
|
bool got_wsize;
|
|
|
|
bool got_bsize;
|
2020-12-10 05:07:12 +00:00
|
|
|
unsigned short port;
|
|
|
|
|
|
|
|
char *username;
|
|
|
|
char *password;
|
|
|
|
char *domainname;
|
2021-02-11 06:06:16 +00:00
|
|
|
char *source;
|
2021-10-14 11:52:39 +00:00
|
|
|
char *server_hostname;
|
2020-12-10 05:07:12 +00:00
|
|
|
char *UNC;
|
2020-12-14 06:40:19 +00:00
|
|
|
char *nodename;
|
2022-05-25 12:37:04 +00:00
|
|
|
char workstation_name[CIFS_MAX_WORKSTATION_LEN];
|
2020-12-10 05:07:12 +00:00
|
|
|
char *iocharset; /* local code page for mapping to and from Unicode */
|
|
|
|
char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
|
|
|
|
char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
|
|
|
|
kuid_t cred_uid;
|
|
|
|
kuid_t linux_uid;
|
|
|
|
kgid_t linux_gid;
|
|
|
|
kuid_t backupuid;
|
|
|
|
kgid_t backupgid;
|
|
|
|
umode_t file_mode;
|
|
|
|
umode_t dir_mode;
|
|
|
|
enum securityEnum sectype; /* sectype requested via mnt opts */
|
|
|
|
bool sign; /* was signing requested via mnt opts? */
|
|
|
|
bool ignore_signature:1;
|
|
|
|
bool retry:1;
|
|
|
|
bool intr:1;
|
|
|
|
bool setuids:1;
|
|
|
|
bool setuidfromacl:1;
|
|
|
|
bool override_uid:1;
|
|
|
|
bool override_gid:1;
|
|
|
|
bool dynperm:1;
|
|
|
|
bool noperm:1;
|
|
|
|
bool nodelete:1;
|
|
|
|
bool mode_ace:1;
|
|
|
|
bool no_psx_acl:1; /* set if posix acl support should be disabled */
|
|
|
|
bool cifs_acl:1;
|
|
|
|
bool backupuid_specified; /* mount option backupuid is specified */
|
|
|
|
bool backupgid_specified; /* mount option backupgid is specified */
|
|
|
|
bool no_xattr:1; /* set if xattr (EA) support should be disabled*/
|
|
|
|
bool server_ino:1; /* use inode numbers from server ie UniqueId */
|
|
|
|
bool direct_io:1;
|
|
|
|
bool strict_io:1; /* strict cache behavior */
|
|
|
|
bool cache_ro:1;
|
|
|
|
bool cache_rw:1;
|
|
|
|
bool remap:1; /* set to remap seven reserved chars in filenames */
|
|
|
|
bool sfu_remap:1; /* remap seven reserved chars ala SFU */
|
|
|
|
bool posix_paths:1; /* unset to not ask for posix pathnames. */
|
|
|
|
bool no_linux_ext:1;
|
|
|
|
bool linux_ext:1;
|
|
|
|
bool sfu_emul:1;
|
|
|
|
bool nullauth:1; /* attempt to authenticate with null user */
|
|
|
|
bool nocase:1; /* request case insensitive filenames */
|
|
|
|
bool nobrl:1; /* disable sending byte range locks to srv */
|
|
|
|
bool nohandlecache:1; /* disable caching dir handles if srvr probs */
|
|
|
|
bool mand_lock:1; /* send mandatory not posix byte range lock reqs */
|
|
|
|
bool seal:1; /* request transport encryption on share */
|
|
|
|
bool nodfs:1; /* Do not request DFS, even if available */
|
|
|
|
bool local_lease:1; /* check leases only on local system, not remote */
|
|
|
|
bool noblocksnd:1;
|
|
|
|
bool noautotune:1;
|
|
|
|
bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
|
|
|
|
bool no_lease:1; /* disable requesting leases */
|
2022-05-24 04:17:12 +00:00
|
|
|
bool no_sparse:1; /* do not attempt to set files sparse */
|
2020-12-10 05:07:12 +00:00
|
|
|
bool fsc:1; /* enable fscache */
|
|
|
|
bool mfsymlinks:1; /* use Minshall+French Symlinks */
|
|
|
|
bool multiuser:1;
|
|
|
|
bool rwpidforward:1; /* pid forward for read/write operations */
|
|
|
|
bool nosharesock:1;
|
|
|
|
bool persistent:1;
|
|
|
|
bool nopersistent:1;
|
|
|
|
bool resilient:1; /* noresilient not required since not fored for CA */
|
|
|
|
bool domainauto:1;
|
|
|
|
bool rdma:1;
|
|
|
|
bool multichannel:1;
|
|
|
|
bool use_client_guid:1;
|
|
|
|
/* reuse existing guid for multichannel */
|
|
|
|
u8 client_guid[SMB2_CLIENT_GUID_SIZE];
|
|
|
|
unsigned int bsize;
|
2021-04-25 02:46:23 +00:00
|
|
|
unsigned int rasize;
|
2020-12-10 05:07:12 +00:00
|
|
|
unsigned int rsize;
|
|
|
|
unsigned int wsize;
|
|
|
|
unsigned int min_offload;
|
2024-01-17 06:09:16 +00:00
|
|
|
unsigned int retrans;
|
2020-12-10 05:07:12 +00:00
|
|
|
bool sockopt_tcp_nodelay:1;
|
2021-02-24 18:12:53 +00:00
|
|
|
/* attribute cache timemout for files and directories in jiffies */
|
|
|
|
unsigned long acregmax;
|
|
|
|
unsigned long acdirmax;
|
2022-08-11 05:53:00 +00:00
|
|
|
/* timeout for deferred close of files in jiffies */
|
|
|
|
unsigned long closetimeo;
|
2020-12-10 05:07:12 +00:00
|
|
|
struct smb_version_operations *ops;
|
|
|
|
struct smb_version_values *vals;
|
|
|
|
char *prepath;
|
|
|
|
struct sockaddr_storage dstaddr; /* destination address */
|
|
|
|
struct sockaddr_storage srcaddr; /* allow binding to a local IP */
|
2020-12-14 06:40:20 +00:00
|
|
|
struct nls_table *local_nls; /* This is a copy of the pointer in cifs_sb */
|
2020-12-10 05:07:12 +00:00
|
|
|
unsigned int echo_interval; /* echo interval in secs */
|
|
|
|
__u64 snapshot_time; /* needed for timewarp tokens */
|
|
|
|
__u32 handle_timeout; /* persistent and durable handle timeout in ms */
|
|
|
|
unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
|
|
|
|
unsigned int max_channels;
|
2023-09-01 07:15:14 +00:00
|
|
|
unsigned int max_cached_dirs;
|
2024-02-23 14:58:57 +00:00
|
|
|
bool compress; /* enable SMB2 messages (READ/WRITE) de/compression */
|
2020-12-10 05:07:12 +00:00
|
|
|
bool rootfs:1; /* if it's a SMB root file system */
|
2020-12-12 04:59:29 +00:00
|
|
|
bool witness:1; /* use witness protocol */
|
2022-11-17 16:23:49 +00:00
|
|
|
char *leaf_fullpath;
|
2023-03-14 23:32:53 +00:00
|
|
|
struct cifs_ses *dfs_root_ses;
|
2023-11-09 15:01:48 +00:00
|
|
|
bool dfs_automount:1; /* set for dfs automount only */
|
2024-01-21 16:28:21 +00:00
|
|
|
enum cifs_reparse_type reparse_type;
|
2020-12-10 05:07:12 +00:00
|
|
|
};
|
|
|
|
|
2020-12-10 06:06:02 +00:00
|
|
|
extern const struct fs_parameter_spec smb3_fs_parameters[];
|
|
|
|
|
|
|
|
extern int smb3_init_fs_context(struct fs_context *fc);
|
2020-12-14 06:40:16 +00:00
|
|
|
extern void smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx);
|
|
|
|
extern void smb3_cleanup_fs_context(struct smb3_fs_context *ctx);
|
2020-12-10 06:06:02 +00:00
|
|
|
|
|
|
|
static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *fc)
|
|
|
|
{
|
|
|
|
return fc->fs_private;
|
|
|
|
}
|
|
|
|
|
2020-11-01 23:36:24 +00:00
|
|
|
extern int smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx);
|
2020-12-14 06:40:25 +00:00
|
|
|
extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
|
2020-10-21 00:22:33 +00:00
|
|
|
|
2022-08-11 05:53:00 +00:00
|
|
|
/*
|
|
|
|
* max deferred close timeout (jiffies) - 2^30
|
|
|
|
*/
|
|
|
|
#define SMB3_MAX_DCLOSETIMEO (1 << 30)
|
2023-03-23 20:10:26 +00:00
|
|
|
#define SMB3_DEF_DCLOSETIMEO (1 * HZ) /* even 1 sec enough to help eg open/write/close/open/read */
|
2023-09-01 07:15:14 +00:00
|
|
|
#define MAX_CACHED_FIDS 16
|
2023-04-05 13:16:48 +00:00
|
|
|
extern char *cifs_sanitize_prepath(char *prepath, gfp_t gfp);
|
|
|
|
|
2024-04-02 01:44:09 +00:00
|
|
|
extern struct mutex cifs_mount_mutex;
|
|
|
|
|
|
|
|
static inline void cifs_mount_lock(void)
|
|
|
|
{
|
|
|
|
mutex_lock(&cifs_mount_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void cifs_mount_unlock(void)
|
|
|
|
{
|
|
|
|
mutex_unlock(&cifs_mount_mutex);
|
|
|
|
}
|
|
|
|
|
2020-10-21 00:37:11 +00:00
|
|
|
#endif
|