cifsglob.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. /*
  2. * fs/cifs/cifsglob.h
  3. *
  4. * Copyright (C) International Business Machines Corp., 2002,2008
  5. * Author(s): Steve French (sfrench@us.ibm.com)
  6. * Jeremy Allison (jra@samba.org)
  7. *
  8. * This library is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published
  10. * by the Free Software Foundation; either version 2.1 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  16. * the GNU Lesser General Public License for more details.
  17. *
  18. */
  19. #include <linux/in.h>
  20. #include <linux/in6.h>
  21. #include "cifs_fs_sb.h"
  22. #include "cifsacl.h"
  23. /*
  24. * The sizes of various internal tables and strings
  25. */
  26. #define MAX_UID_INFO 16
  27. #define MAX_SES_INFO 2
  28. #define MAX_TCON_INFO 4
  29. #define MAX_TREE_SIZE 2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1
  30. #define MAX_SERVER_SIZE 15
  31. #define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */
  32. #define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null
  33. termination then *2 for unicode versions */
  34. #define MAX_PASSWORD_SIZE 16
  35. #define CIFS_MIN_RCV_POOL 4
  36. /*
  37. * MAX_REQ is the maximum number of requests that WE will send
  38. * on one socket concurently. It also matches the most common
  39. * value of max multiplex returned by servers. We may
  40. * eventually want to use the negotiated value (in case
  41. * future servers can handle more) when we are more confident that
  42. * we will not have problems oveloading the socket with pending
  43. * write data.
  44. */
  45. #define CIFS_MAX_REQ 50
  46. #define SERVER_NAME_LENGTH 15
  47. #define SERVER_NAME_LEN_WITH_NULL (SERVER_NAME_LENGTH + 1)
  48. /* used to define string lengths for reversing unicode strings */
  49. /* (256+1)*2 = 514 */
  50. /* (max path length + 1 for null) * 2 for unicode */
  51. #define MAX_NAME 514
  52. #include "cifspdu.h"
  53. #ifndef XATTR_DOS_ATTRIB
  54. #define XATTR_DOS_ATTRIB "user.DOSATTRIB"
  55. #endif
  56. /*
  57. * CIFS vfs client Status information (based on what we know.)
  58. */
  59. /* associated with each tcp and smb session */
  60. enum statusEnum {
  61. CifsNew = 0,
  62. CifsGood,
  63. CifsExiting,
  64. CifsNeedReconnect
  65. };
  66. enum securityEnum {
  67. PLAINTXT = 0, /* Legacy with Plaintext passwords */
  68. LANMAN, /* Legacy LANMAN auth */
  69. NTLM, /* Legacy NTLM012 auth with NTLM hash */
  70. NTLMv2, /* Legacy NTLM auth with NTLMv2 hash */
  71. RawNTLMSSP, /* NTLMSSP without SPNEGO */
  72. NTLMSSP, /* NTLMSSP via SPNEGO */
  73. Kerberos /* Kerberos via SPNEGO */
  74. };
  75. enum protocolEnum {
  76. IPV4 = 0,
  77. IPV6,
  78. SCTP
  79. /* Netbios frames protocol not supported at this time */
  80. };
  81. struct mac_key {
  82. unsigned int len;
  83. union {
  84. char ntlm[CIFS_SESS_KEY_SIZE + 16];
  85. char krb5[CIFS_SESS_KEY_SIZE + 16]; /* BB: length correct? */
  86. struct {
  87. char key[16];
  88. struct ntlmv2_resp resp;
  89. } ntlmv2;
  90. } data;
  91. };
  92. struct cifs_cred {
  93. int uid;
  94. int gid;
  95. int mode;
  96. int cecount;
  97. struct cifs_sid osid;
  98. struct cifs_sid gsid;
  99. struct cifs_ntace *ntaces;
  100. struct cifs_ace *aces;
  101. };
  102. /*
  103. *****************************************************************
  104. * Except the CIFS PDUs themselves all the
  105. * globally interesting structs should go here
  106. *****************************************************************
  107. */
  108. struct TCP_Server_Info {
  109. /* 15 character server name + 0x20 16th byte indicating type = srv */
  110. char server_RFC1001_name[SERVER_NAME_LEN_WITH_NULL];
  111. char unicode_server_Name[SERVER_NAME_LEN_WITH_NULL * 2];
  112. char *hostname; /* hostname portion of UNC string */
  113. struct socket *ssocket;
  114. union {
  115. struct sockaddr_in sockAddr;
  116. struct sockaddr_in6 sockAddr6;
  117. } addr;
  118. wait_queue_head_t response_q;
  119. wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/
  120. struct list_head pending_mid_q;
  121. void *Server_NlsInfo; /* BB - placeholder for future NLS info */
  122. unsigned short server_codepage; /* codepage for the server */
  123. unsigned long ip_address; /* IP addr for the server if known */
  124. enum protocolEnum protocolType;
  125. char versionMajor;
  126. char versionMinor;
  127. bool svlocal:1; /* local server or remote */
  128. atomic_t socketUseCount; /* number of open cifs sessions on socket */
  129. atomic_t inFlight; /* number of requests on the wire to server */
  130. #ifdef CONFIG_CIFS_STATS2
  131. atomic_t inSend; /* requests trying to send */
  132. atomic_t num_waiters; /* blocked waiting to get in sendrecv */
  133. #endif
  134. enum statusEnum tcpStatus; /* what we think the status is */
  135. struct semaphore tcpSem;
  136. struct task_struct *tsk;
  137. char server_GUID[16];
  138. char secMode;
  139. enum securityEnum secType;
  140. unsigned int maxReq; /* Clients should submit no more */
  141. /* than maxReq distinct unanswered SMBs to the server when using */
  142. /* multiplexed reads or writes */
  143. unsigned int maxBuf; /* maxBuf specifies the maximum */
  144. /* message size the server can send or receive for non-raw SMBs */
  145. unsigned int maxRw; /* maxRw specifies the maximum */
  146. /* message size the server can send or receive for */
  147. /* SMB_COM_WRITE_RAW or SMB_COM_READ_RAW. */
  148. char sessid[4]; /* unique token id for this session */
  149. /* (returned on Negotiate */
  150. int capabilities; /* allow selective disabling of caps by smb sess */
  151. int timeAdj; /* Adjust for difference in server time zone in sec */
  152. __u16 CurrentMid; /* multiplex id - rotating counter */
  153. char cryptKey[CIFS_CRYPTO_KEY_SIZE];
  154. /* 16th byte of RFC1001 workstation name is always null */
  155. char workstation_RFC1001_name[SERVER_NAME_LEN_WITH_NULL];
  156. __u32 sequence_number; /* needed for CIFS PDU signature */
  157. struct mac_key mac_signing_key;
  158. char ntlmv2_hash[16];
  159. unsigned long lstrp; /* when we got last response from this server */
  160. };
  161. /*
  162. * The following is our shortcut to user information. We surface the uid,
  163. * and name. We always get the password on the fly in case it
  164. * has changed. We also hang a list of sessions owned by this user off here.
  165. */
  166. struct cifsUidInfo {
  167. struct list_head userList;
  168. struct list_head sessionList; /* SMB sessions for this user */
  169. uid_t linux_uid;
  170. char user[MAX_USERNAME_SIZE + 1]; /* ascii name of user */
  171. /* BB may need ptr or callback for PAM or WinBind info */
  172. };
  173. /*
  174. * Session structure. One of these for each uid session with a particular host
  175. */
  176. struct cifsSesInfo {
  177. struct list_head cifsSessionList;
  178. struct semaphore sesSem;
  179. #if 0
  180. struct cifsUidInfo *uidInfo; /* pointer to user info */
  181. #endif
  182. struct TCP_Server_Info *server; /* pointer to server info */
  183. atomic_t inUse; /* # of mounts (tree connections) on this ses */
  184. enum statusEnum status;
  185. unsigned overrideSecFlg; /* if non-zero override global sec flags */
  186. __u16 ipc_tid; /* special tid for connection to IPC share */
  187. __u16 flags;
  188. char *serverOS; /* name of operating system underlying server */
  189. char *serverNOS; /* name of network operating system of server */
  190. char *serverDomain; /* security realm of server */
  191. int Suid; /* remote smb uid */
  192. uid_t linux_uid; /* local Linux uid */
  193. int capabilities;
  194. char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for
  195. TCP names - will ipv6 and sctp addresses fit? */
  196. char userName[MAX_USERNAME_SIZE + 1];
  197. char *domainName;
  198. char *password;
  199. };
  200. /* no more than one of the following three session flags may be set */
  201. #define CIFS_SES_NT4 1
  202. #define CIFS_SES_OS2 2
  203. #define CIFS_SES_W9X 4
  204. /* following flag is set for old servers such as OS2 (and Win95?)
  205. which do not negotiate NTLM or POSIX dialects, but instead
  206. negotiate one of the older LANMAN dialects */
  207. #define CIFS_SES_LANMAN 8
  208. /*
  209. * there is one of these for each connection to a resource on a particular
  210. * session
  211. */
  212. struct cifsTconInfo {
  213. struct list_head cifsConnectionList;
  214. struct list_head openFileList;
  215. struct semaphore tconSem;
  216. struct cifsSesInfo *ses; /* pointer to session associated with */
  217. char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */
  218. char *nativeFileSystem;
  219. __u16 tid; /* The 2 byte tree id */
  220. __u16 Flags; /* optional support bits */
  221. enum statusEnum tidStatus;
  222. atomic_t useCount; /* how many explicit/implicit mounts to share */
  223. #ifdef CONFIG_CIFS_STATS
  224. atomic_t num_smbs_sent;
  225. atomic_t num_writes;
  226. atomic_t num_reads;
  227. atomic_t num_oplock_brks;
  228. atomic_t num_opens;
  229. atomic_t num_closes;
  230. atomic_t num_deletes;
  231. atomic_t num_mkdirs;
  232. atomic_t num_rmdirs;
  233. atomic_t num_renames;
  234. atomic_t num_t2renames;
  235. atomic_t num_ffirst;
  236. atomic_t num_fnext;
  237. atomic_t num_fclose;
  238. atomic_t num_hardlinks;
  239. atomic_t num_symlinks;
  240. atomic_t num_locks;
  241. atomic_t num_acl_get;
  242. atomic_t num_acl_set;
  243. #ifdef CONFIG_CIFS_STATS2
  244. unsigned long long time_writes;
  245. unsigned long long time_reads;
  246. unsigned long long time_opens;
  247. unsigned long long time_deletes;
  248. unsigned long long time_closes;
  249. unsigned long long time_mkdirs;
  250. unsigned long long time_rmdirs;
  251. unsigned long long time_renames;
  252. unsigned long long time_t2renames;
  253. unsigned long long time_ffirst;
  254. unsigned long long time_fnext;
  255. unsigned long long time_fclose;
  256. #endif /* CONFIG_CIFS_STATS2 */
  257. __u64 bytes_read;
  258. __u64 bytes_written;
  259. spinlock_t stat_lock;
  260. #endif /* CONFIG_CIFS_STATS */
  261. FILE_SYSTEM_DEVICE_INFO fsDevInfo;
  262. FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */
  263. FILE_SYSTEM_UNIX_INFO fsUnixInfo;
  264. bool ipc:1; /* set if connection to IPC$ eg for RPC/PIPES */
  265. bool retry:1;
  266. bool nocase:1;
  267. bool seal:1; /* transport encryption for this mounted share */
  268. bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol
  269. for this mount even if server would support */
  270. /* BB add field for back pointer to sb struct(s)? */
  271. };
  272. /*
  273. * This info hangs off the cifsFileInfo structure, pointed to by llist.
  274. * This is used to track byte stream locks on the file
  275. */
  276. struct cifsLockInfo {
  277. struct list_head llist; /* pointer to next cifsLockInfo */
  278. __u64 offset;
  279. __u64 length;
  280. __u8 type;
  281. };
  282. /*
  283. * One of these for each open instance of a file
  284. */
  285. struct cifs_search_info {
  286. loff_t index_of_last_entry;
  287. __u16 entries_in_buffer;
  288. __u16 info_level;
  289. __u32 resume_key;
  290. char *ntwrk_buf_start;
  291. char *srch_entries_start;
  292. char *presume_name;
  293. unsigned int resume_name_len;
  294. bool endOfSearch:1;
  295. bool emptyDir:1;
  296. bool unicode:1;
  297. bool smallBuf:1; /* so we know which buf_release function to call */
  298. };
  299. struct cifsFileInfo {
  300. struct list_head tlist; /* pointer to next fid owned by tcon */
  301. struct list_head flist; /* next fid (file instance) for this inode */
  302. unsigned int uid; /* allows finding which FileInfo structure */
  303. __u32 pid; /* process id who opened file */
  304. __u16 netfid; /* file id from remote */
  305. /* BB add lock scope info here if needed */ ;
  306. /* lock scope id (0 if none) */
  307. struct file *pfile; /* needed for writepage */
  308. struct inode *pInode; /* needed for oplock break */
  309. struct mutex lock_mutex;
  310. struct list_head llist; /* list of byte range locks we have. */
  311. bool closePend:1; /* file is marked to close */
  312. bool invalidHandle:1; /* file closed via session abend */
  313. bool messageMode:1; /* for pipes: message vs byte mode */
  314. atomic_t wrtPending; /* handle in use - defer close */
  315. struct semaphore fh_sem; /* prevents reopen race after dead ses*/
  316. struct cifs_search_info srch_inf;
  317. };
  318. /*
  319. * One of these for each file inode
  320. */
  321. struct cifsInodeInfo {
  322. struct list_head lockList;
  323. /* BB add in lists for dirty pages i.e. write caching info for oplock */
  324. struct list_head openFileList;
  325. int write_behind_rc;
  326. __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
  327. atomic_t inUse; /* num concurrent users (local openers cifs) of file*/
  328. unsigned long time; /* jiffies of last update/check of inode */
  329. bool clientCanCacheRead:1; /* read oplock */
  330. bool clientCanCacheAll:1; /* read and writebehind oplock */
  331. bool oplockPending:1;
  332. struct inode vfs_inode;
  333. };
  334. static inline struct cifsInodeInfo *
  335. CIFS_I(struct inode *inode)
  336. {
  337. return container_of(inode, struct cifsInodeInfo, vfs_inode);
  338. }
  339. static inline struct cifs_sb_info *
  340. CIFS_SB(struct super_block *sb)
  341. {
  342. return sb->s_fs_info;
  343. }
  344. static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
  345. {
  346. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
  347. return '/';
  348. else
  349. return '\\';
  350. }
  351. #ifdef CONFIG_CIFS_STATS
  352. #define cifs_stats_inc atomic_inc
  353. static inline void cifs_stats_bytes_written(struct cifsTconInfo *tcon,
  354. unsigned int bytes)
  355. {
  356. if (bytes) {
  357. spin_lock(&tcon->stat_lock);
  358. tcon->bytes_written += bytes;
  359. spin_unlock(&tcon->stat_lock);
  360. }
  361. }
  362. static inline void cifs_stats_bytes_read(struct cifsTconInfo *tcon,
  363. unsigned int bytes)
  364. {
  365. spin_lock(&tcon->stat_lock);
  366. tcon->bytes_read += bytes;
  367. spin_unlock(&tcon->stat_lock);
  368. }
  369. #else
  370. #define cifs_stats_inc(field) do {} while (0)
  371. #define cifs_stats_bytes_written(tcon, bytes) do {} while (0)
  372. #define cifs_stats_bytes_read(tcon, bytes) do {} while (0)
  373. #endif
  374. /* one of these for every pending CIFS request to the server */
  375. struct mid_q_entry {
  376. struct list_head qhead; /* mids waiting on reply from this server */
  377. __u16 mid; /* multiplex id */
  378. __u16 pid; /* process id */
  379. __u32 sequence_number; /* for CIFS signing */
  380. unsigned long when_alloc; /* when mid was created */
  381. #ifdef CONFIG_CIFS_STATS2
  382. unsigned long when_sent; /* time when smb send finished */
  383. unsigned long when_received; /* when demux complete (taken off wire) */
  384. #endif
  385. struct cifsSesInfo *ses; /* smb was sent to this server */
  386. struct task_struct *tsk; /* task waiting for response */
  387. struct smb_hdr *resp_buf; /* response buffer */
  388. int midState; /* wish this were enum but can not pass to wait_event */
  389. __u8 command; /* smb command code */
  390. bool largeBuf:1; /* if valid response, is pointer to large buf */
  391. bool multiRsp:1; /* multiple trans2 responses for one request */
  392. bool multiEnd:1; /* both received */
  393. };
  394. struct oplock_q_entry {
  395. struct list_head qhead;
  396. struct inode *pinode;
  397. struct cifsTconInfo *tcon;
  398. __u16 netfid;
  399. };
  400. /* for pending dnotify requests */
  401. struct dir_notify_req {
  402. struct list_head lhead;
  403. __le16 Pid;
  404. __le16 PidHigh;
  405. __u16 Mid;
  406. __u16 Tid;
  407. __u16 Uid;
  408. __u16 netfid;
  409. __u32 filter; /* CompletionFilter (for multishot) */
  410. int multishot;
  411. struct file *pfile;
  412. };
  413. struct dfs_info3_param {
  414. int flags; /* DFSREF_REFERRAL_SERVER, DFSREF_STORAGE_SERVER*/
  415. int path_consumed;
  416. int server_type;
  417. int ref_flag;
  418. char *path_name;
  419. char *node_name;
  420. };
  421. static inline void free_dfs_info_param(struct dfs_info3_param *param)
  422. {
  423. if (param) {
  424. kfree(param->path_name);
  425. kfree(param->node_name);
  426. kfree(param);
  427. }
  428. }
  429. static inline void free_dfs_info_array(struct dfs_info3_param *param,
  430. int number_of_items)
  431. {
  432. int i;
  433. if ((number_of_items == 0) || (param == NULL))
  434. return;
  435. for (i = 0; i < number_of_items; i++) {
  436. kfree(param[i].path_name);
  437. kfree(param[i].node_name);
  438. }
  439. kfree(param);
  440. }
  441. #define MID_FREE 0
  442. #define MID_REQUEST_ALLOCATED 1
  443. #define MID_REQUEST_SUBMITTED 2
  444. #define MID_RESPONSE_RECEIVED 4
  445. #define MID_RETRY_NEEDED 8 /* session closed while this request out */
  446. #define MID_NO_RESP_NEEDED 0x10
  447. /* Types of response buffer returned from SendReceive2 */
  448. #define CIFS_NO_BUFFER 0 /* Response buffer not returned */
  449. #define CIFS_SMALL_BUFFER 1
  450. #define CIFS_LARGE_BUFFER 2
  451. #define CIFS_IOVEC 4 /* array of response buffers */
  452. /* Type of Request to SendReceive2 */
  453. #define CIFS_STD_OP 0 /* normal request timeout */
  454. #define CIFS_LONG_OP 1 /* long op (up to 45 sec, oplock time) */
  455. #define CIFS_VLONG_OP 2 /* sloow op - can take up to 180 seconds */
  456. #define CIFS_BLOCKING_OP 4 /* operation can block */
  457. #define CIFS_ASYNC_OP 8 /* do not wait for response */
  458. #define CIFS_TIMEOUT_MASK 0x00F /* only one of 5 above set in req */
  459. #define CIFS_LOG_ERROR 0x010 /* log NT STATUS if non-zero */
  460. #define CIFS_LARGE_BUF_OP 0x020 /* large request buffer */
  461. #define CIFS_NO_RESP 0x040 /* no response buffer required */
  462. /* Security Flags: indicate type of session setup needed */
  463. #define CIFSSEC_MAY_SIGN 0x00001
  464. #define CIFSSEC_MAY_NTLM 0x00002
  465. #define CIFSSEC_MAY_NTLMV2 0x00004
  466. #define CIFSSEC_MAY_KRB5 0x00008
  467. #ifdef CONFIG_CIFS_WEAK_PW_HASH
  468. #define CIFSSEC_MAY_LANMAN 0x00010
  469. #define CIFSSEC_MAY_PLNTXT 0x00020
  470. #else
  471. #define CIFSSEC_MAY_LANMAN 0
  472. #define CIFSSEC_MAY_PLNTXT 0
  473. #endif /* weak passwords */
  474. #define CIFSSEC_MAY_SEAL 0x00040 /* not supported yet */
  475. #define CIFSSEC_MUST_SIGN 0x01001
  476. /* note that only one of the following can be set so the
  477. result of setting MUST flags more than once will be to
  478. require use of the stronger protocol */
  479. #define CIFSSEC_MUST_NTLM 0x02002
  480. #define CIFSSEC_MUST_NTLMV2 0x04004
  481. #define CIFSSEC_MUST_KRB5 0x08008
  482. #ifdef CONFIG_CIFS_WEAK_PW_HASH
  483. #define CIFSSEC_MUST_LANMAN 0x10010
  484. #define CIFSSEC_MUST_PLNTXT 0x20020
  485. #ifdef CONFIG_CIFS_UPCALL
  486. #define CIFSSEC_MASK 0x3F03F /* allows weak security but also krb5 */
  487. #else
  488. #define CIFSSEC_MASK 0x37037 /* current flags supported if weak */
  489. #endif /* UPCALL */
  490. #else /* do not allow weak pw hash */
  491. #ifdef CONFIG_CIFS_UPCALL
  492. #define CIFSSEC_MASK 0x0F00F /* flags supported if no weak allowed */
  493. #else
  494. #define CIFSSEC_MASK 0x07007 /* flags supported if no weak allowed */
  495. #endif /* UPCALL */
  496. #endif /* WEAK_PW_HASH */
  497. #define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */
  498. #define CIFSSEC_DEF CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2
  499. #define CIFSSEC_MAX CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2
  500. #define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5)
  501. /*
  502. *****************************************************************
  503. * All constants go here
  504. *****************************************************************
  505. */
  506. #define UID_HASH (16)
  507. /*
  508. * Note that ONE module should define _DECLARE_GLOBALS_HERE to cause the
  509. * following to be declared.
  510. */
  511. /****************************************************************************
  512. * Locking notes. All updates to global variables and lists should be
  513. * protected by spinlocks or semaphores.
  514. *
  515. * Spinlocks
  516. * ---------
  517. * GlobalMid_Lock protects:
  518. * list operations on pending_mid_q and oplockQ
  519. * updates to XID counters, multiplex id and SMB sequence numbers
  520. * GlobalSMBSesLock protects:
  521. * list operations on tcp and SMB session lists and tCon lists
  522. * f_owner.lock protects certain per file struct operations
  523. * mapping->page_lock protects certain per page operations
  524. *
  525. * Semaphores
  526. * ----------
  527. * sesSem operations on smb session
  528. * tconSem operations on tree connection
  529. * fh_sem file handle reconnection operations
  530. *
  531. ****************************************************************************/
  532. #ifdef DECLARE_GLOBALS_HERE
  533. #define GLOBAL_EXTERN
  534. #else
  535. #define GLOBAL_EXTERN extern
  536. #endif
  537. /*
  538. * The list of servers that did not respond with NT LM 0.12.
  539. * This list helps improve performance and eliminate the messages indicating
  540. * that we had a communications error talking to the server in this list.
  541. */
  542. /* Feature not supported */
  543. /* GLOBAL_EXTERN struct servers_not_supported *NotSuppList; */
  544. /*
  545. * The following is a hash table of all the users we know about.
  546. */
  547. GLOBAL_EXTERN struct smbUidInfo *GlobalUidList[UID_HASH];
  548. /* GLOBAL_EXTERN struct list_head GlobalServerList; BB not implemented yet */
  549. GLOBAL_EXTERN struct list_head GlobalSMBSessionList;
  550. GLOBAL_EXTERN struct list_head GlobalTreeConnectionList;
  551. GLOBAL_EXTERN rwlock_t GlobalSMBSeslock; /* protects list inserts on 3 above */
  552. GLOBAL_EXTERN struct list_head GlobalOplock_Q;
  553. /* Outstanding dir notify requests */
  554. GLOBAL_EXTERN struct list_head GlobalDnotifyReqList;
  555. /* DirNotify response queue */
  556. GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q;
  557. /*
  558. * Global transaction id (XID) information
  559. */
  560. GLOBAL_EXTERN unsigned int GlobalCurrentXid; /* protected by GlobalMid_Sem */
  561. GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */
  562. GLOBAL_EXTERN unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */
  563. GLOBAL_EXTERN spinlock_t GlobalMid_Lock; /* protects above & list operations */
  564. /* on midQ entries */
  565. GLOBAL_EXTERN char Local_System_Name[15];
  566. /*
  567. * Global counters, updated atomically
  568. */
  569. GLOBAL_EXTERN atomic_t sesInfoAllocCount;
  570. GLOBAL_EXTERN atomic_t tconInfoAllocCount;
  571. GLOBAL_EXTERN atomic_t tcpSesAllocCount;
  572. GLOBAL_EXTERN atomic_t tcpSesReconnectCount;
  573. GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
  574. /* Various Debug counters */
  575. GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
  576. #ifdef CONFIG_CIFS_STATS2
  577. GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
  578. GLOBAL_EXTERN atomic_t totSmBufAllocCount;
  579. #endif
  580. GLOBAL_EXTERN atomic_t smBufAllocCount;
  581. GLOBAL_EXTERN atomic_t midCount;
  582. /* Misc globals */
  583. GLOBAL_EXTERN unsigned int multiuser_mount; /* if enabled allows new sessions
  584. to be established on existing mount if we
  585. have the uid/password or Kerberos credential
  586. or equivalent for current user */
  587. GLOBAL_EXTERN unsigned int oplockEnabled;
  588. GLOBAL_EXTERN unsigned int experimEnabled;
  589. GLOBAL_EXTERN unsigned int lookupCacheEnabled;
  590. GLOBAL_EXTERN unsigned int extended_security; /* if on, session setup sent
  591. with more secure ntlmssp2 challenge/resp */
  592. GLOBAL_EXTERN unsigned int sign_CIFS_PDUs; /* enable smb packet signing */
  593. GLOBAL_EXTERN unsigned int linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/
  594. GLOBAL_EXTERN unsigned int CIFSMaxBufSize; /* max size not including hdr */
  595. GLOBAL_EXTERN unsigned int cifs_min_rcv; /* min size of big ntwrk buf pool */
  596. GLOBAL_EXTERN unsigned int cifs_min_small; /* min size of small buf pool */
  597. GLOBAL_EXTERN unsigned int cifs_max_pending; /* MAX requests at once to server*/