Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *   Copyright (C) 2020, Microsoft Corporation.
0004  *
0005  *   Author(s): Steve French <stfrench@microsoft.com>
0006  *              David Howells <dhowells@redhat.com>
0007  */
0008 
0009 #ifndef _FS_CONTEXT_H
0010 #define _FS_CONTEXT_H
0011 
0012 #include "cifsglob.h"
0013 #include <linux/parser.h>
0014 #include <linux/fs_parser.h>
0015 
0016 /* Log errors in fs_context (new mount api) but also in dmesg (old style) */
0017 #define cifs_errorf(fc, fmt, ...)           \
0018     do {                        \
0019         errorf(fc, fmt, ## __VA_ARGS__);    \
0020         cifs_dbg(VFS, fmt, ## __VA_ARGS__); \
0021     } while (0)
0022 
0023 enum smb_version {
0024     Smb_1 = 1,
0025     Smb_20,
0026     Smb_21,
0027     Smb_30,
0028     Smb_302,
0029     Smb_311,
0030     Smb_3any,
0031     Smb_default,
0032     Smb_version_err
0033 };
0034 
0035 enum {
0036     Opt_cache_loose,
0037     Opt_cache_strict,
0038     Opt_cache_none,
0039     Opt_cache_ro,
0040     Opt_cache_rw,
0041     Opt_cache_err
0042 };
0043 
0044 enum cifs_sec_param {
0045     Opt_sec_krb5,
0046     Opt_sec_krb5i,
0047     Opt_sec_krb5p,
0048     Opt_sec_ntlmsspi,
0049     Opt_sec_ntlmssp,
0050     Opt_sec_ntlmv2,
0051     Opt_sec_ntlmv2i,
0052     Opt_sec_none,
0053 
0054     Opt_sec_err
0055 };
0056 
0057 enum cifs_param {
0058     /* Mount options that take no arguments */
0059     Opt_user_xattr,
0060     Opt_forceuid,
0061     Opt_forcegid,
0062     Opt_noblocksend,
0063     Opt_noautotune,
0064     Opt_nolease,
0065     Opt_nosparse,
0066     Opt_hard,
0067     Opt_soft,
0068     Opt_perm,
0069     Opt_nodelete,
0070     Opt_mapposix,
0071     Opt_mapchars,
0072     Opt_nomapchars,
0073     Opt_sfu,
0074     Opt_nodfs,
0075     Opt_posixpaths,
0076     Opt_unix,
0077     Opt_nocase,
0078     Opt_brl,
0079     Opt_handlecache,
0080     Opt_forcemandatorylock,
0081     Opt_setuidfromacl,
0082     Opt_setuids,
0083     Opt_dynperm,
0084     Opt_intr,
0085     Opt_strictsync,
0086     Opt_serverino,
0087     Opt_rwpidforward,
0088     Opt_cifsacl,
0089     Opt_acl,
0090     Opt_locallease,
0091     Opt_sign,
0092     Opt_ignore_signature,
0093     Opt_seal,
0094     Opt_noac,
0095     Opt_fsc,
0096     Opt_mfsymlinks,
0097     Opt_multiuser,
0098     Opt_sloppy,
0099     Opt_nosharesock,
0100     Opt_persistent,
0101     Opt_resilient,
0102     Opt_tcp_nodelay,
0103     Opt_domainauto,
0104     Opt_rdma,
0105     Opt_modesid,
0106     Opt_rootfs,
0107     Opt_multichannel,
0108     Opt_compress,
0109     Opt_witness,
0110 
0111     /* Mount options which take numeric value */
0112     Opt_backupuid,
0113     Opt_backupgid,
0114     Opt_uid,
0115     Opt_cruid,
0116     Opt_gid,
0117     Opt_port,
0118     Opt_file_mode,
0119     Opt_dirmode,
0120     Opt_min_enc_offload,
0121     Opt_blocksize,
0122     Opt_rasize,
0123     Opt_rsize,
0124     Opt_wsize,
0125     Opt_actimeo,
0126     Opt_acdirmax,
0127     Opt_acregmax,
0128     Opt_closetimeo,
0129     Opt_echo_interval,
0130     Opt_max_credits,
0131     Opt_snapshot,
0132     Opt_max_channels,
0133     Opt_handletimeout,
0134 
0135     /* Mount options which take string value */
0136     Opt_source,
0137     Opt_user,
0138     Opt_pass,
0139     Opt_ip,
0140     Opt_domain,
0141     Opt_srcaddr,
0142     Opt_iocharset,
0143     Opt_netbiosname,
0144     Opt_servern,
0145     Opt_ver,
0146     Opt_vers,
0147     Opt_sec,
0148     Opt_cache,
0149 
0150     /* Mount options to be ignored */
0151     Opt_ignore,
0152 
0153     Opt_err
0154 };
0155 
0156 struct smb3_fs_context {
0157     bool uid_specified;
0158     bool cruid_specified;
0159     bool gid_specified;
0160     bool sloppy;
0161     bool got_ip;
0162     bool got_version;
0163     bool got_rsize;
0164     bool got_wsize;
0165     bool got_bsize;
0166     unsigned short port;
0167 
0168     char *username;
0169     char *password;
0170     char *domainname;
0171     char *source;
0172     char *server_hostname;
0173     char *UNC;
0174     char *nodename;
0175     char workstation_name[CIFS_MAX_WORKSTATION_LEN];
0176     char *iocharset;  /* local code page for mapping to and from Unicode */
0177     char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
0178     char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
0179     kuid_t cred_uid;
0180     kuid_t linux_uid;
0181     kgid_t linux_gid;
0182     kuid_t backupuid;
0183     kgid_t backupgid;
0184     umode_t file_mode;
0185     umode_t dir_mode;
0186     enum securityEnum sectype; /* sectype requested via mnt opts */
0187     bool sign; /* was signing requested via mnt opts? */
0188     bool ignore_signature:1;
0189     bool retry:1;
0190     bool intr:1;
0191     bool setuids:1;
0192     bool setuidfromacl:1;
0193     bool override_uid:1;
0194     bool override_gid:1;
0195     bool dynperm:1;
0196     bool noperm:1;
0197     bool nodelete:1;
0198     bool mode_ace:1;
0199     bool no_psx_acl:1; /* set if posix acl support should be disabled */
0200     bool cifs_acl:1;
0201     bool backupuid_specified; /* mount option  backupuid  is specified */
0202     bool backupgid_specified; /* mount option  backupgid  is specified */
0203     bool no_xattr:1;   /* set if xattr (EA) support should be disabled*/
0204     bool server_ino:1; /* use inode numbers from server ie UniqueId */
0205     bool direct_io:1;
0206     bool strict_io:1; /* strict cache behavior */
0207     bool cache_ro:1;
0208     bool cache_rw:1;
0209     bool remap:1;      /* set to remap seven reserved chars in filenames */
0210     bool sfu_remap:1;  /* remap seven reserved chars ala SFU */
0211     bool posix_paths:1; /* unset to not ask for posix pathnames. */
0212     bool no_linux_ext:1;
0213     bool linux_ext:1;
0214     bool sfu_emul:1;
0215     bool nullauth:1;   /* attempt to authenticate with null user */
0216     bool nocase:1;     /* request case insensitive filenames */
0217     bool nobrl:1;      /* disable sending byte range locks to srv */
0218     bool nohandlecache:1; /* disable caching dir handles if srvr probs */
0219     bool mand_lock:1;  /* send mandatory not posix byte range lock reqs */
0220     bool seal:1;       /* request transport encryption on share */
0221     bool nodfs:1;      /* Do not request DFS, even if available */
0222     bool local_lease:1; /* check leases only on local system, not remote */
0223     bool noblocksnd:1;
0224     bool noautotune:1;
0225     bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
0226     bool no_lease:1;     /* disable requesting leases */
0227     bool no_sparse:1;    /* do not attempt to set files sparse */
0228     bool fsc:1; /* enable fscache */
0229     bool mfsymlinks:1; /* use Minshall+French Symlinks */
0230     bool multiuser:1;
0231     bool rwpidforward:1; /* pid forward for read/write operations */
0232     bool nosharesock:1;
0233     bool persistent:1;
0234     bool nopersistent:1;
0235     bool resilient:1; /* noresilient not required since not fored for CA */
0236     bool domainauto:1;
0237     bool rdma:1;
0238     bool multichannel:1;
0239     bool use_client_guid:1;
0240     /* reuse existing guid for multichannel */
0241     u8 client_guid[SMB2_CLIENT_GUID_SIZE];
0242     unsigned int bsize;
0243     unsigned int rasize;
0244     unsigned int rsize;
0245     unsigned int wsize;
0246     unsigned int min_offload;
0247     bool sockopt_tcp_nodelay:1;
0248     /* attribute cache timemout for files and directories in jiffies */
0249     unsigned long acregmax;
0250     unsigned long acdirmax;
0251     /* timeout for deferred close of files in jiffies */
0252     unsigned long closetimeo;
0253     struct smb_version_operations *ops;
0254     struct smb_version_values *vals;
0255     char *prepath;
0256     struct sockaddr_storage dstaddr; /* destination address */
0257     struct sockaddr_storage srcaddr; /* allow binding to a local IP */
0258     struct nls_table *local_nls; /* This is a copy of the pointer in cifs_sb */
0259     unsigned int echo_interval; /* echo interval in secs */
0260     __u64 snapshot_time; /* needed for timewarp tokens */
0261     __u32 handle_timeout; /* persistent and durable handle timeout in ms */
0262     unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
0263     unsigned int max_channels;
0264     __u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
0265     bool rootfs:1; /* if it's a SMB root file system */
0266     bool witness:1; /* use witness protocol */
0267 
0268     char *mount_options;
0269 };
0270 
0271 extern const struct fs_parameter_spec smb3_fs_parameters[];
0272 
0273 extern int smb3_init_fs_context(struct fs_context *fc);
0274 extern void smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx);
0275 extern void smb3_cleanup_fs_context(struct smb3_fs_context *ctx);
0276 
0277 static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *fc)
0278 {
0279     return fc->fs_private;
0280 }
0281 
0282 extern int smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx);
0283 extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
0284 
0285 /*
0286  * max deferred close timeout (jiffies) - 2^30
0287  */
0288 #define SMB3_MAX_DCLOSETIMEO (1 << 30)
0289 #define SMB3_DEF_DCLOSETIMEO (5 * HZ) /* Can increase later, other clients use larger */
0290 #endif