fs_context.h 7.2 KB

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