Blame view

fs/cifs/cifsglob.h 32.3 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
  /*
   *   fs/cifs/cifsglob.h
   *
366781c19   Steve French   [CIFS] DFS build ...
4
   *   Copyright (C) International Business Machines  Corp., 2002,2008
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
   *   Author(s): Steve French (sfrench@us.ibm.com)
7ee1af765   Jeremy Allison   [CIFS]
6
   *              Jeremy Allison (jra@samba.org)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
10
11
12
13
14
15
16
   *
   *   This library is free software; you can redistribute it and/or modify
   *   it under the terms of the GNU Lesser General Public License as published
   *   by the Free Software Foundation; either version 2.1 of the License, or
   *   (at your option) any later version.
   *
   *   This library is distributed in the hope that it will be useful,
   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
   *   the GNU Lesser General Public License for more details.
d38d8c74c   Steve French   [CIFS] whitespace...
17
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18
   */
abd2e44dc   Suresh Jayaraman   cifs: guard cifsg...
19
20
  #ifndef _CIFS_GLOB_H
  #define _CIFS_GLOB_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
22
  #include <linux/in.h>
  #include <linux/in6.h>
5a0e3ad6a   Tejun Heo   include cleanup: ...
23
  #include <linux/slab.h>
9b6469724   Tejun Heo   cifs: use workque...
24
  #include <linux/workqueue.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
  #include "cifs_fs_sb.h"
442aa310f   Steve French   [CIFS] Support fo...
26
  #include "cifsacl.h"
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
27
28
  #include <crypto/internal/hash.h>
  #include <linux/scatterlist.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29
30
31
32
33
34
  /*
   * The sizes of various internal tables and strings
   */
  #define MAX_UID_INFO 16
  #define MAX_SES_INFO 2
  #define MAX_TCON_INFO 4
ef571cadd   Shirish Pargaonkar   [CIFS] Fix warnin...
35
  #define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36
  #define MAX_SERVER_SIZE 15
2e325d597   Steve French   Max share size is...
37
  #define MAX_SHARE_SIZE 80
8727c8a85   Steve French   Allow user names ...
38
39
  #define MAX_USERNAME_SIZE 256	/* reasonable maximum for current servers */
  #define MAX_PASSWORD_SIZE 512	/* max for windows seems to be 256 wide chars */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
41
42
43
  
  #define CIFS_MIN_RCV_POOL 4
  
  /*
6d20e8406   Suresh Jayaraman   cifs: add attribu...
44
45
46
47
48
49
50
51
52
53
   * default attribute cache timeout (jiffies)
   */
  #define CIFS_DEF_ACTIMEO (1 * HZ)
  
  /*
   * max attribute cache timeout (jiffies) - 2^30
   */
  #define CIFS_MAX_ACTIMEO (1 << 30)
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
54
   * MAX_REQ is the maximum number of requests that WE will send
af901ca18   AndrĂ© Goddard Rosa   tree-wide: fix as...
55
   * on one socket concurrently. It also matches the most common
d38d8c74c   Steve French   [CIFS] whitespace...
56
   * value of max multiplex returned by servers.  We may
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
57
58
59
60
61
   * eventually want to use the negotiated value (in case
   * future servers can handle more) when we are more confident that
   * we will not have problems oveloading the socket with pending
   * write data.
   */
d38d8c74c   Steve French   [CIFS] whitespace...
62
  #define CIFS_MAX_REQ 50
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63

8ecaf67a8   Jeff Layton   cifs: account for...
64
65
66
67
68
  #define RFC1001_NAME_LEN 15
  #define RFC1001_NAME_LEN_WITH_NULL (RFC1001_NAME_LEN + 1)
  
  /* currently length of NIP6_FMT */
  #define SERVER_NAME_LENGTH 40
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
69
70
71
72
73
74
75
76
  #define SERVER_NAME_LEN_WITH_NULL     (SERVER_NAME_LENGTH + 1)
  
  /* used to define string lengths for reversing unicode strings */
  /*         (256+1)*2 = 514                                     */
  /*           (max path length + 1 for null) * 2 for unicode    */
  #define MAX_NAME 514
  
  #include "cifspdu.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77
78
79
80
81
  #ifndef XATTR_DOS_ATTRIB
  #define XATTR_DOS_ATTRIB "user.DOSATTRIB"
  #endif
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82
83
   * CIFS vfs client Status information (based on what we know.)
   */
6c0f6218b   Steve French   [CIFS] Fix checkp...
84
  /* associated with each tcp and smb session */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
85
86
87
88
  enum statusEnum {
  	CifsNew = 0,
  	CifsGood,
  	CifsExiting,
fd88ce931   Steve French   [CIFS] cifs: clar...
89
90
  	CifsNeedReconnect,
  	CifsNeedNegotiate
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
91
92
93
  };
  
  enum securityEnum {
daf5b0b6f   Jeff Layton   cifs: match secTy...
94
  	LANMAN = 0,			/* Legacy LANMAN auth */
3979877e5   Steve French   [CIFS] Support fo...
95
  	NTLM,			/* Legacy NTLM012 auth with NTLM hash */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
96
  	NTLMv2,			/* Legacy NTLM auth with NTLMv2 hash */
ac6839246   Steve French   [CIFS] Allow raw ...
97
  	RawNTLMSSP,		/* NTLMSSP without SPNEGO, NTLMv2 hash */
f46c7234e   Steve French   [CIFS] cleanup as...
98
  /*	NTLMSSP, */ /* can use rawNTLMSSP instead of NTLMSSP via SPNEGO */
c16fefa56   Steve French   [CIFS] distinguis...
99
  	Kerberos,		/* Kerberos via SPNEGO */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
101
102
  };
  
  enum protocolEnum {
3ec332ef7   Steve French   [CIFS] clean up s...
103
  	TCP = 0,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
104
105
106
  	SCTP
  	/* Netbios frames protocol not supported at this time */
  };
5f98ca9af   Shirish Pargaonkar   cifs NTLMv2/NTLMS...
107
  struct session_key {
b609f06ac   Steve French   [CIFS] Fix packet...
108
  	unsigned int len;
21e733930   Shirish Pargaonkar   NTLM auth and sig...
109
  	char *response;
b609f06ac   Steve French   [CIFS] Fix packet...
110
  };
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
111
112
113
114
115
  /* crypto security descriptor definition */
  struct sdesc {
  	struct shash_desc shash;
  	char ctx[];
  };
f7c5445a9   Shirish Pargaonkar   NTLM auth and sig...
116
  /* crypto hashing related structure/fields, not specific to a sec mech */
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
117
118
119
120
121
122
  struct cifs_secmech {
  	struct crypto_shash *hmacmd5; /* hmac-md5 hash function */
  	struct crypto_shash *md5; /* md5 hash function */
  	struct sdesc *sdeschmacmd5;  /* ctxt to generate ntlmv2 hash, CR1 */
  	struct sdesc *sdescmd5; /* ctxt to generate cifs/smb signature */
  };
d3686d54c   Shirish Pargaonkar   cifs: Cleanup and...
123
  /* per smb session structure/fields */
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
124
125
126
127
  struct ntlmssp_auth {
  	__u32 client_flags; /* sent by client in type 1 ntlmsssp exchange */
  	__u32 server_flags; /* sent by server in type 2 ntlmssp exchange */
  	unsigned char ciphertext[CIFS_CPHTXT_SIZE]; /* sent to server */
d3686d54c   Shirish Pargaonkar   cifs: Cleanup and...
128
  	char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlmssp */
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
129
  };
442aa310f   Steve French   [CIFS] Support fo...
130
131
132
133
134
135
136
137
138
139
  struct cifs_cred {
  	int uid;
  	int gid;
  	int mode;
  	int cecount;
  	struct cifs_sid osid;
  	struct cifs_sid gsid;
  	struct cifs_ntace *ntaces;
  	struct cifs_ace *aces;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140
141
142
143
144
145
  /*
   *****************************************************************
   * Except the CIFS PDUs themselves all the
   * globally interesting structs should go here
   *****************************************************************
   */
f87d39d95   Steve French   [CIFS] Migrate fr...
146
147
148
149
150
151
152
153
154
155
156
157
  struct smb_vol {
  	char *username;
  	char *password;
  	char *domainname;
  	char *UNC;
  	char *UNCip;
  	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 */
  	uid_t cred_uid;
  	uid_t linux_uid;
  	gid_t linux_gid;
3d3ea8e64   Shirish Pargaonkar   cifs: Add mount o...
158
159
  	uid_t backupuid;
  	gid_t backupgid;
5206efd62   Al Viro   cifs: propagate u...
160
161
  	umode_t file_mode;
  	umode_t dir_mode;
f87d39d95   Steve French   [CIFS] Migrate fr...
162
163
164
165
166
167
168
169
170
171
  	unsigned secFlg;
  	bool retry:1;
  	bool intr:1;
  	bool setuids:1;
  	bool override_uid:1;
  	bool override_gid:1;
  	bool dynperm:1;
  	bool noperm:1;
  	bool no_psx_acl:1; /* set if posix acl support should be disabled */
  	bool cifs_acl:1;
3d3ea8e64   Shirish Pargaonkar   cifs: Add mount o...
172
173
  	bool backupuid_specified; /* mount option  backupuid  is specified */
  	bool backupgid_specified; /* mount option  backupgid  is specified */
f87d39d95   Steve French   [CIFS] Migrate fr...
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
  	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 remap:1;      /* set to remap seven reserved chars in filenames */
  	bool posix_paths:1; /* unset to not ask for posix pathnames. */
  	bool no_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 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 fsc:1;	/* enable fscache */
  	bool mfsymlinks:1; /* use Minshall+French Symlinks */
  	bool multiuser:1;
d4ffff1fa   Pavel Shilovsky   CIFS: Add rwpidfo...
195
  	bool rwpidforward:1; /* pid forward for read/write operations */
f87d39d95   Steve French   [CIFS] Migrate fr...
196
197
198
199
200
201
202
203
204
  	unsigned int rsize;
  	unsigned int wsize;
  	bool sockopt_tcp_nodelay:1;
  	unsigned short int port;
  	unsigned long actimeo; /* attribute cache timeout (jiffies) */
  	char *prepath;
  	struct sockaddr_storage srcaddr; /* allow binding to a local IP */
  	struct nls_table *local_nls;
  };
25c7f41e9   Pavel Shilovsky   CIFS: Migrate to ...
205
206
207
208
209
210
211
212
  #define CIFS_MOUNT_MASK (CIFS_MOUNT_NO_PERM | CIFS_MOUNT_SET_UID | \
  			 CIFS_MOUNT_SERVER_INUM | CIFS_MOUNT_DIRECT_IO | \
  			 CIFS_MOUNT_NO_XATTR | CIFS_MOUNT_MAP_SPECIAL_CHR | \
  			 CIFS_MOUNT_UNX_EMUL | CIFS_MOUNT_NO_BRL | \
  			 CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_OVERR_UID | \
  			 CIFS_MOUNT_OVERR_GID | CIFS_MOUNT_DYNPERM | \
  			 CIFS_MOUNT_NOPOSIXBRL | CIFS_MOUNT_NOSSYNC | \
  			 CIFS_MOUNT_FSCACHE | CIFS_MOUNT_MF_SYMLINKS | \
3d3ea8e64   Shirish Pargaonkar   cifs: Add mount o...
213
214
  			 CIFS_MOUNT_MULTIUSER | CIFS_MOUNT_STRICT_IO | \
  			 CIFS_MOUNT_CIFS_BACKUPUID | CIFS_MOUNT_CIFS_BACKUPGID)
25c7f41e9   Pavel Shilovsky   CIFS: Migrate to ...
215
216
217
218
219
220
221
222
223
  
  #define CIFS_MS_MASK (MS_RDONLY | MS_MANDLOCK | MS_NOEXEC | MS_NOSUID | \
  		      MS_NODEV | MS_SYNCHRONOUS)
  
  struct cifs_mnt_data {
  	struct cifs_sb_info *cifs_sb;
  	struct smb_vol *vol;
  	int flags;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
224
  struct TCP_Server_Info {
3b7952109   Steve French   [CIFS] Fix cifs r...
225
226
  	struct list_head tcp_ses_list;
  	struct list_head smb_ses_list;
e7ddee903   Jeff Layton   cifs: disable sha...
227
  	int srv_count; /* reference counter */
a10faeb2a   Steve French   [CIFS] Support fo...
228
  	/* 15 character server name + 0x20 16th byte indicating type = srv */
8ecaf67a8   Jeff Layton   cifs: account for...
229
  	char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
c3dccf481   Jeff Layton   cifs: TCP_Server_...
230
  	enum statusEnum tcpStatus; /* what we think the status is */
c359cf3c6   Jeff Layton   [CIFS] add hostna...
231
  	char *hostname; /* hostname portion of UNC string */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
232
  	struct socket *ssocket;
a9f1b85e5   Pavel Shilovsky   CIFS: Simplify ip...
233
  	struct sockaddr_storage dstaddr;
3eb9a8893   Ben Greear   cifs: Allow bindi...
234
  	struct sockaddr_storage srcaddr; /* locally bind to this IP */
f1d0c9986   Rob Landley   Make CIFS mount w...
235
236
237
  #ifdef CONFIG_NET_NS
  	struct net *net;
  #endif
d38d8c74c   Steve French   [CIFS] whitespace...
238
  	wait_queue_head_t response_q;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
239
240
  	wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/
  	struct list_head pending_mid_q;
edf1ae403   Steve French   [CIFS] Reduce num...
241
242
  	bool noblocksnd;		/* use blocking sendmsg */
  	bool noautotune;		/* do not autotune send buf sizes */
6a5fa2362   Steve French   [CIFS] Add suppor...
243
  	bool tcp_nodelay;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
244
  	atomic_t inFlight;  /* number of requests on the wire to server */
72ca545b2   Jeff Layton   cifs: convert tcp...
245
  	struct mutex srv_mutex;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
246
247
  	struct task_struct *tsk;
  	char server_GUID[16];
96daf2b09   Steve French   [CIFS] Rename thr...
248
  	char sec_mode;
c3dccf481   Jeff Layton   cifs: TCP_Server_...
249
250
  	bool session_estab; /* mark when very first sess is established */
  	u16 dialect; /* dialect index that server chose */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
251
252
253
254
255
256
  	enum securityEnum secType;
  	unsigned int maxReq;	/* Clients should submit no more */
  	/* than maxReq distinct unanswered SMBs to the server when using  */
  	/* multiplexed reads or writes */
  	unsigned int maxBuf;	/* maxBuf specifies the maximum */
  	/* message size the server can send or receive for non-raw SMBs */
7e90d705f   Steve French   [CIFS] Do not sen...
257
258
  	/* maxBuf is returned by SMB NegotiateProtocol so maxBuf is only 0 */
  	/* when socket is setup (and during reconnect) before NegProt sent */
eca6acf91   Steve French   [CIFS] Fix multiu...
259
  	unsigned int max_rw;	/* maxRw specifies the maximum */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
260
261
  	/* message size the server can send or receive for */
  	/* SMB_COM_WRITE_RAW or SMB_COM_READ_RAW. */
eca6acf91   Steve French   [CIFS] Fix multiu...
262
263
264
  	unsigned int max_vcs;	/* maximum number of smb sessions, at least
  				   those that can be specified uniquely with
  				   vcnumbers */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
265
  	int capabilities; /* allow selective disabling of caps by smb sess */
de7ed55db   Steve French   [CIFS] Make use o...
266
  	int timeAdj;  /* Adjust for difference in server time zone in sec */
1982c344f   Steve French   [CIFS] Ensure tha...
267
  	__u16 CurrentMid;         /* multiplex id - rotating counter */
d3ba50b17   Shirish Pargaonkar   NTLM auth and sig...
268
  	char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlm, ntlmv2 etc */
a10faeb2a   Steve French   [CIFS] Support fo...
269
  	/* 16th byte of RFC1001 workstation name is always null */
8ecaf67a8   Jeff Layton   cifs: account for...
270
  	char workstation_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
a0f8b4fb4   Jeff Layton   cifs: remove unne...
271
  	__u32 sequence_number; /* for signing, protected by srv_mutex */
5f98ca9af   Shirish Pargaonkar   cifs NTLMv2/NTLMS...
272
  	struct session_key session_key;
3a5ff61c1   Steve French   [CIFS] Do not tim...
273
  	unsigned long lstrp; /* when we got last response from this server */
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
274
  	struct cifs_secmech secmech; /* crypto sec mech functs, descriptors */
26efa0bac   Jeff Layton   cifs: have decode...
275
  	/* extended security flavors that server supports */
c3dccf481   Jeff Layton   cifs: TCP_Server_...
276
277
  	bool	sec_ntlmssp;		/* supports NTLMSSP */
  	bool	sec_kerberosu2u;	/* supports U2U Kerberos */
26efa0bac   Jeff Layton   cifs: have decode...
278
279
  	bool	sec_kerberos;		/* supports plain Kerberos */
  	bool	sec_mskerberos;		/* supports legacy MS Kerberos */
2a37ef94b   Jeff Layton   cifs: move buffer...
280
  	bool	large_buf;		/* is current buffer large? */
c74093b69   Jeff Layton   cifs: set up recu...
281
  	struct delayed_work	echo; /* echo ping workqueue job */
1041e3f99   Jeff Layton   cifs: keep a reus...
282
283
  	struct kvec *iov;	/* reusable kvec array for receives */
  	unsigned int nr_iov;	/* number of kvecs in array */
2a37ef94b   Jeff Layton   cifs: move buffer...
284
285
286
  	char	*smallbuf;	/* pointer to current "small" buffer */
  	char	*bigbuf;	/* pointer to current "big" buffer */
  	unsigned int total_read; /* total amount of data read in this pass */
488f1d2d6   Suresh Jayaraman   cifs: define serv...
287
288
289
  #ifdef CONFIG_CIFS_FSCACHE
  	struct fscache_cookie   *fscache; /* client index cache cookie */
  #endif
c3dccf481   Jeff Layton   cifs: TCP_Server_...
290
  #ifdef CONFIG_CIFS_STATS2
789e66612   Steve French   [CIFS] Cleanup us...
291
  	atomic_t in_send; /* requests trying to send */
c3dccf481   Jeff Layton   cifs: TCP_Server_...
292
293
  	atomic_t num_waiters;   /* blocked waiting to get in sendrecv */
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
294
295
296
  };
  
  /*
f1d0c9986   Rob Landley   Make CIFS mount w...
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
   * Macros to allow the TCP_Server_Info->net field and related code to drop out
   * when CONFIG_NET_NS isn't set.
   */
  
  #ifdef CONFIG_NET_NS
  
  static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv)
  {
  	return srv->net;
  }
  
  static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net)
  {
  	srv->net = net;
  }
  
  #else
  
  static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv)
  {
  	return &init_net;
  }
  
  static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net)
  {
  }
  
  #endif
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
327
328
   * Session structure.  One of these for each uid session with a particular host
   */
96daf2b09   Steve French   [CIFS] Rename thr...
329
  struct cifs_ses {
14fbf50d6   Jeff Layton   cifs: reinstate s...
330
  	struct list_head smb_ses_list;
3b7952109   Steve French   [CIFS] Fix cifs r...
331
  	struct list_head tcon_list;
d7b619cf5   Steve French   [CIFS] pSesInfo->...
332
  	struct mutex session_mutex;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
333
  	struct TCP_Server_Info *server;	/* pointer to server info */
14fbf50d6   Jeff Layton   cifs: reinstate s...
334
  	int ses_count;		/* reference counter */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
335
  	enum statusEnum status;
750d1151a   Steve French   [CIFS] Fix alloca...
336
  	unsigned overrideSecFlg;  /* if non-zero override global sec flags */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
337
338
  	__u16 ipc_tid;		/* special tid for connection to IPC share */
  	__u16 flags;
eca6acf91   Steve French   [CIFS] Fix multiu...
339
  	__u16 vcnum;
ad009ac96   Steve French   [PATCH] cifs: Fix...
340
341
  	char *serverOS;		/* name of operating system underlying server */
  	char *serverNOS;	/* name of network operating system of server */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
342
343
  	char *serverDomain;	/* security realm of server */
  	int Suid;		/* remote smb uid  */
3e4b3e1f6   Jeff Layton   cifs: add separat...
344
345
  	uid_t linux_uid;        /* overriding owner of files on the mount */
  	uid_t cred_uid;		/* owner of credentials */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
346
  	int capabilities;
d38d8c74c   Steve French   [CIFS] whitespace...
347
  	char serverName[SERVER_NAME_LEN_WITH_NULL * 2];	/* BB make bigger for
ad009ac96   Steve French   [PATCH] cifs: Fix...
348
  				TCP names - will ipv6 and sctp addresses fit? */
34c87901e   Steve French   Shrink stack spac...
349
350
  	char *user_name;	/* must not be null except during init of sess
  				   and after mount option parsing we fill it */
d38d8c74c   Steve French   [CIFS] whitespace...
351
352
  	char *domainName;
  	char *password;
5d0d28824   Shirish Pargaonkar   NTLM authenticati...
353
  	struct session_key auth_key;
d3686d54c   Shirish Pargaonkar   cifs: Cleanup and...
354
  	struct ntlmssp_auth *ntlmssp; /* ciphertext, flags, server challenge */
3b7952109   Steve French   [CIFS] Fix cifs r...
355
  	bool need_reconnect:1; /* connection reset, uid now invalid */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
356
  };
9ac00b7d9   Steve French   [CIFS] Do not sen...
357
  /* no more than one of the following three session flags may be set */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
358
  #define CIFS_SES_NT4 1
9ac00b7d9   Steve French   [CIFS] Do not sen...
359
360
361
362
363
364
  #define CIFS_SES_OS2 2
  #define CIFS_SES_W9X 4
  /* following flag is set for old servers such as OS2 (and Win95?)
     which do not negotiate NTLM or POSIX dialects, but instead
     negotiate one of the older LANMAN dialects */
  #define CIFS_SES_LANMAN 8
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
365
366
  /*
   * there is one of these for each connection to a resource on a particular
d38d8c74c   Steve French   [CIFS] whitespace...
367
   * session
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
368
   */
96daf2b09   Steve French   [CIFS] Rename thr...
369
  struct cifs_tcon {
f1987b44f   Jeff Layton   cifs: reinstate s...
370
371
  	struct list_head tcon_list;
  	int tc_count;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
372
  	struct list_head openFileList;
96daf2b09   Steve French   [CIFS] Rename thr...
373
  	struct cifs_ses *ses;	/* pointer to session associated with */
254e55ed0   Steve French   CIFS] Support for...
374
  	char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
375
  	char *nativeFileSystem;
00e485b01   Jeff Layton   cifs: store passw...
376
  	char *password;		/* for share-level security */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
377
378
379
  	__u16 tid;		/* The 2 byte tree id */
  	__u16 Flags;		/* optional support bits */
  	enum statusEnum tidStatus;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
380
381
382
383
  #ifdef CONFIG_CIFS_STATS
  	atomic_t num_smbs_sent;
  	atomic_t num_writes;
  	atomic_t num_reads;
b298f2235   Steve French   [CIFS] Send SMB f...
384
  	atomic_t num_flushes;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
385
386
  	atomic_t num_oplock_brks;
  	atomic_t num_opens;
a5a2b489b   Steve French   [CIFS] Make CIFS ...
387
  	atomic_t num_closes;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
388
389
  	atomic_t num_deletes;
  	atomic_t num_mkdirs;
65bc98b00   Steve French   [CIFS] Distinguis...
390
391
  	atomic_t num_posixopens;
  	atomic_t num_posixmkdirs;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
392
393
394
  	atomic_t num_rmdirs;
  	atomic_t num_renames;
  	atomic_t num_t2renames;
dfb7533b5   Steve French   [CIFS] Add stats ...
395
396
397
  	atomic_t num_ffirst;
  	atomic_t num_fnext;
  	atomic_t num_fclose;
a5a2b489b   Steve French   [CIFS] Make CIFS ...
398
399
400
  	atomic_t num_hardlinks;
  	atomic_t num_symlinks;
  	atomic_t num_locks;
0a4b92c05   Steve French   [CIFS] Add worker...
401
402
  	atomic_t num_acl_get;
  	atomic_t num_acl_set;
a5a2b489b   Steve French   [CIFS] Make CIFS ...
403
404
405
406
407
408
409
410
411
412
413
414
415
416
  #ifdef CONFIG_CIFS_STATS2
  	unsigned long long time_writes;
  	unsigned long long time_reads;
  	unsigned long long time_opens;
  	unsigned long long time_deletes;
  	unsigned long long time_closes;
  	unsigned long long time_mkdirs;
  	unsigned long long time_rmdirs;
  	unsigned long long time_renames;
  	unsigned long long time_t2renames;
  	unsigned long long time_ffirst;
  	unsigned long long time_fnext;
  	unsigned long long time_fclose;
  #endif /* CONFIG_CIFS_STATS2 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
417
418
419
  	__u64    bytes_read;
  	__u64    bytes_written;
  	spinlock_t stat_lock;
a5a2b489b   Steve French   [CIFS] Make CIFS ...
420
  #endif /* CONFIG_CIFS_STATS */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
421
  	FILE_SYSTEM_DEVICE_INFO fsDevInfo;
254e55ed0   Steve French   CIFS] Support for...
422
  	FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
423
  	FILE_SYSTEM_UNIX_INFO fsUnixInfo;
4b18f2a9c   Steve French   [CIFS] convert us...
424
425
426
  	bool ipc:1;		/* set if connection to IPC$ eg for RPC/PIPES */
  	bool retry:1;
  	bool nocase:1;
95b1cb90b   Steve French   [CIFS] enable par...
427
  	bool seal:1;      /* transport encryption for this mounted share */
4b18f2a9c   Steve French   [CIFS] convert us...
428
  	bool unix_ext:1;  /* if false disable Linux extensions to CIFS protocol
c18c842b1   Steve French   [CIFS] Allow disa...
429
  				for this mount even if server would support */
84210e912   Steve French   [CIFS] improve se...
430
  	bool local_lease:1; /* check leases (only) on local system not remote */
64cc2c636   Steve French   [CIFS] work aroun...
431
  	bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */
3b7952109   Steve French   [CIFS] Fix cifs r...
432
  	bool need_reconnect:1; /* connection reset, tid now invalid */
d03382ce9   Suresh Jayaraman   cifs: define supe...
433
434
435
436
  #ifdef CONFIG_CIFS_FSCACHE
  	u64 resource_id;		/* server resource id */
  	struct fscache_cookie *fscache;	/* cookie for share */
  #endif
c18c842b1   Steve French   [CIFS] Allow disa...
437
  	/* BB add field for back pointer to sb struct(s)? */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
438
439
440
  };
  
  /*
7ffec3724   Jeff Layton   cifs: add refcoun...
441
442
443
444
445
446
   * This is a refcounted and timestamped container for a tcon pointer. The
   * container holds a tcon reference. It is considered safe to free one of
   * these when the tl_count goes to 0. The tl_time is the time of the last
   * "get" on the container.
   */
  struct tcon_link {
b647c35f7   Jeff Layton   cifs: convert tli...
447
448
  	struct rb_node		tl_rbnode;
  	uid_t			tl_uid;
9d002df49   Jeff Layton   cifs: add routine...
449
450
451
452
453
454
  	unsigned long		tl_flags;
  #define TCON_LINK_MASTER	0
  #define TCON_LINK_PENDING	1
  #define TCON_LINK_IN_TREE	2
  	unsigned long		tl_time;
  	atomic_t		tl_count;
96daf2b09   Steve French   [CIFS] Rename thr...
455
  	struct cifs_tcon	*tl_tcon;
7ffec3724   Jeff Layton   cifs: add refcoun...
456
  };
9d002df49   Jeff Layton   cifs: add routine...
457
  extern struct tcon_link *cifs_sb_tlink(struct cifs_sb_info *cifs_sb);
7ffec3724   Jeff Layton   cifs: add refcoun...
458

96daf2b09   Steve French   [CIFS] Rename thr...
459
  static inline struct cifs_tcon *
7ffec3724   Jeff Layton   cifs: add refcoun...
460
461
  tlink_tcon(struct tcon_link *tlink)
  {
9d002df49   Jeff Layton   cifs: add routine...
462
  	return tlink->tl_tcon;
7ffec3724   Jeff Layton   cifs: add refcoun...
463
  }
9d002df49   Jeff Layton   cifs: add routine...
464
  extern void cifs_put_tlink(struct tcon_link *tlink);
7ffec3724   Jeff Layton   cifs: add refcoun...
465

13cfb7334   Jeff Layton   cifs: have cifsFi...
466
467
468
  static inline struct tcon_link *
  cifs_get_tlink(struct tcon_link *tlink)
  {
9d002df49   Jeff Layton   cifs: add routine...
469
470
  	if (tlink && !IS_ERR(tlink))
  		atomic_inc(&tlink->tl_count);
13cfb7334   Jeff Layton   cifs: have cifsFi...
471
472
  	return tlink;
  }
7ffec3724   Jeff Layton   cifs: add refcoun...
473
  /* This function is always expected to succeed */
96daf2b09   Steve French   [CIFS] Rename thr...
474
  extern struct cifs_tcon *cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb);
7ffec3724   Jeff Layton   cifs: add refcoun...
475
476
  
  /*
7ee1af765   Jeremy Allison   [CIFS]
477
478
   * This info hangs off the cifsFileInfo structure, pointed to by llist.
   * This is used to track byte stream locks on the file
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
479
480
   */
  struct cifsLockInfo {
7ee1af765   Jeremy Allison   [CIFS]
481
  	struct list_head llist;	/* pointer to next cifsLockInfo */
85160e03a   Pavel Shilovsky   CIFS: Implement c...
482
483
  	struct list_head blist; /* pointer to locks blocked on this */
  	wait_queue_head_t block_q;
7ee1af765   Jeremy Allison   [CIFS]
484
485
  	__u64 offset;
  	__u64 length;
03776f451   Pavel Shilovsky   CIFS: Simplify by...
486
  	__u32 pid;
7ee1af765   Jeremy Allison   [CIFS]
487
  	__u8 type;
d59dad2be   Pavel Shilovsky   CIFS: Move byte r...
488
  	__u16 netfid;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
489
490
491
492
493
494
495
496
497
498
  };
  
  /*
   * One of these for each open instance of a file
   */
  struct cifs_search_info {
  	loff_t index_of_last_entry;
  	__u16 entries_in_buffer;
  	__u16 info_level;
  	__u32 resume_key;
d38d8c74c   Steve French   [CIFS] whitespace...
499
500
  	char *ntwrk_buf_start;
  	char *srch_entries_start;
0752f1522   Steve French   [CIFS] make sure ...
501
  	char *last_entry;
eaf35b1ea   Christoph Hellwig   cifs: use cifs_di...
502
  	const char *presume_name;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
503
  	unsigned int resume_name_len;
4b18f2a9c   Steve French   [CIFS] convert us...
504
505
506
507
  	bool endOfSearch:1;
  	bool emptyDir:1;
  	bool unicode:1;
  	bool smallBuf:1; /* so we know which buf_release function to call */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
508
509
510
511
512
513
514
515
516
517
  };
  
  struct cifsFileInfo {
  	struct list_head tlist;	/* pointer to next fid owned by tcon */
  	struct list_head flist;	/* next fid (file instance) for this inode */
  	unsigned int uid;	/* allows finding which FileInfo structure */
  	__u32 pid;		/* process id who opened file */
  	__u16 netfid;		/* file id from remote */
  	/* BB add lock scope info here if needed */ ;
  	/* lock scope id (0 if none) */
a5e18bc36   Jeff Layton   cifs: keep dentry...
518
  	struct dentry *dentry;
15886177e   Jeff Layton   cifs: clean up ci...
519
  	unsigned int f_flags;
13cfb7334   Jeff Layton   cifs: have cifsFi...
520
  	struct tcon_link *tlink;
4b18f2a9c   Steve French   [CIFS] convert us...
521
  	bool invalidHandle:1;	/* file closed via session abend */
3bc303c25   Jeff Layton   cifs: convert opl...
522
  	bool oplock_break_cancelled:1;
6c0f6218b   Steve French   [CIFS] Fix checkp...
523
  	int count;		/* refcount protected by cifs_file_list_lock */
a6ce4932f   Steve French   [CIFS] Add suppor...
524
  	struct mutex fh_mutex; /* prevents reopen race after dead ses*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
525
  	struct cifs_search_info srch_inf;
9b6469724   Tejun Heo   cifs: use workque...
526
  	struct work_struct oplock_break; /* work for oplock breaks */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
527
  };
fa2989f44   Pavel Shilovsky   CIFS: Use pid sav...
528
529
530
531
532
  struct cifs_io_parms {
  	__u16 netfid;
  	__u32 pid;
  	__u64 offset;
  	unsigned int length;
96daf2b09   Steve French   [CIFS] Rename thr...
533
  	struct cifs_tcon *tcon;
fa2989f44   Pavel Shilovsky   CIFS: Use pid sav...
534
  };
5f6dbc9e4   Jeff Layton   cifs: convert cif...
535
536
537
538
  /*
   * Take a reference on the file private data. Must be called with
   * cifs_file_list_lock held.
   */
6ab409b53   Dave Kleikamp   cifs: Replace wrt...
539
540
  static inline void cifsFileInfo_get(struct cifsFileInfo *cifs_file)
  {
5f6dbc9e4   Jeff Layton   cifs: convert cif...
541
  	++cifs_file->count;
6ab409b53   Dave Kleikamp   cifs: Replace wrt...
542
  }
b33879aa8   Jeff Layton   cifs: move cifsFi...
543
  void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
6ab409b53   Dave Kleikamp   cifs: Replace wrt...
544

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
545
546
547
548
549
  /*
   * One of these for each file inode
   */
  
  struct cifsInodeInfo {
d59dad2be   Pavel Shilovsky   CIFS: Move byte r...
550
551
552
  	struct list_head llist;		/* brlocks for this inode */
  	bool can_cache_brlcks;
  	struct mutex lock_mutex;	/* protect two fields above */
d38d8c74c   Steve French   [CIFS] whitespace...
553
  	/* BB add in lists for dirty pages i.e. write caching info for oplock */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
554
  	struct list_head openFileList;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
555
  	__u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
aae62fdb6   Jeff Layton   cifs: move time f...
556
557
558
559
560
  	bool clientCanCacheRead;	/* read oplock */
  	bool clientCanCacheAll;		/* read and writebehind oplock */
  	bool delete_pending;		/* DELETE_ON_CLOSE is set */
  	bool invalid_mapping;		/* pagecache is invalid */
  	unsigned long time;		/* jiffies of last update of inode */
fbec9ab95   Jeff Layton   cifs: vary timeou...
561
  	u64  server_eof;		/* current file size on server */
cc0bad755   Jeff Layton   cifs: add new cif...
562
  	u64  uniqueid;			/* server inode number */
20054bd65   Jeff Layton   cifs: use Creatio...
563
  	u64  createtime;		/* creation time on server */
9451a9a52   Suresh Jayaraman   cifs: define inod...
564
565
566
  #ifdef CONFIG_CIFS_FSCACHE
  	struct fscache_cookie *fscache;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
567
568
569
570
571
572
573
574
575
576
577
578
579
580
  	struct inode vfs_inode;
  };
  
  static inline struct cifsInodeInfo *
  CIFS_I(struct inode *inode)
  {
  	return container_of(inode, struct cifsInodeInfo, vfs_inode);
  }
  
  static inline struct cifs_sb_info *
  CIFS_SB(struct super_block *sb)
  {
  	return sb->s_fs_info;
  }
ab2f218f4   Steve French   [CIFS] Fix compil...
581
  static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
ac67055ef   Jeremy Allison   [CIFS] POSIX exte...
582
583
584
585
586
587
  {
  	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
  		return '/';
  	else
  		return '\\';
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
588

f87d39d95   Steve French   [CIFS] Migrate fr...
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
  static inline void
  convert_delimiter(char *path, char delim)
  {
  	int i;
  	char old_delim;
  
  	if (path == NULL)
  		return;
  
  	if (delim == '/')
  		old_delim = '\\';
  	else
  		old_delim = '/';
  
  	for (i = 0; path[i] != '\0'; i++) {
  		if (path[i] == old_delim)
  			path[i] = delim;
  	}
  }
a45443475   Steve French   CIFS: Reduce CONF...
608
609
  #ifdef CONFIG_CIFS_STATS
  #define cifs_stats_inc atomic_inc
96daf2b09   Steve French   [CIFS] Rename thr...
610
  static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
a45443475   Steve French   CIFS: Reduce CONF...
611
612
613
614
615
616
617
618
  					    unsigned int bytes)
  {
  	if (bytes) {
  		spin_lock(&tcon->stat_lock);
  		tcon->bytes_written += bytes;
  		spin_unlock(&tcon->stat_lock);
  	}
  }
96daf2b09   Steve French   [CIFS] Rename thr...
619
  static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon,
a45443475   Steve French   CIFS: Reduce CONF...
620
621
622
623
624
625
626
  					 unsigned int bytes)
  {
  	spin_lock(&tcon->stat_lock);
  	tcon->bytes_read += bytes;
  	spin_unlock(&tcon->stat_lock);
  }
  #else
d38d8c74c   Steve French   [CIFS] whitespace...
627
628
629
  #define  cifs_stats_inc(field) do {} while (0)
  #define  cifs_stats_bytes_written(tcon, bytes) do {} while (0)
  #define  cifs_stats_bytes_read(tcon, bytes) do {} while (0)
a45443475   Steve French   CIFS: Reduce CONF...
630
631
  
  #endif
2b84a36c5   Jeff Layton   cifs: allow for d...
632
633
634
  struct mid_q_entry;
  
  /*
44d22d846   Jeff Layton   cifs: add a callb...
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
   * This is the prototype for the mid receive function. This function is for
   * receiving the rest of the SMB frame, starting with the WordCount (which is
   * just after the MID in struct smb_hdr). Note:
   *
   * - This will be called by cifsd, with no locks held.
   * - The mid will still be on the pending_mid_q.
   * - mid->resp_buf will point to the current buffer.
   *
   * Returns zero on a successful receive, or an error. The receive state in
   * the TCP_Server_Info will also be updated.
   */
  typedef int (mid_receive_t)(struct TCP_Server_Info *server,
  			    struct mid_q_entry *mid);
  
  /*
   * This is the prototype for the mid callback function. This is called once the
   * mid has been received off of the socket. When creating one, take special
   * care to avoid deadlocks. Things to bear in mind:
2b84a36c5   Jeff Layton   cifs: allow for d...
653
   *
3c1105df6   Jeff Layton   cifs: don't call ...
654
655
   * - it will be called by cifsd, with no locks held
   * - the mid will be removed from any lists
2b84a36c5   Jeff Layton   cifs: allow for d...
656
657
   */
  typedef void (mid_callback_t)(struct mid_q_entry *mid);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
658
659
660
661
662
663
  /* one of these for every pending CIFS request to the server */
  struct mid_q_entry {
  	struct list_head qhead;	/* mids waiting on reply from this server */
  	__u16 mid;		/* multiplex id */
  	__u16 pid;		/* process id */
  	__u32 sequence_number;  /* for CIFS signing */
1047abc15   Steve French   [CIFS] CIFS Stats...
664
665
666
667
668
  	unsigned long when_alloc;  /* when mid was created */
  #ifdef CONFIG_CIFS_STATS2
  	unsigned long when_sent; /* time when smb send finished */
  	unsigned long when_received; /* when demux complete (taken off wire) */
  #endif
44d22d846   Jeff Layton   cifs: add a callb...
669
  	mid_receive_t *receive; /* call receive callback */
2b84a36c5   Jeff Layton   cifs: allow for d...
670
671
  	mid_callback_t *callback; /* call completion callback */
  	void *callback_data;	  /* general purpose pointer for callback */
44d22d846   Jeff Layton   cifs: add a callb...
672
  	struct smb_hdr *resp_buf;	/* pointer to received SMB header */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
673
  	int midState;	/* wish this were enum but can not pass to wait_event */
c81156dd2   Steve French   [PATCH] cifs: cle...
674
  	__u8 command;	/* smb command code */
4b18f2a9c   Steve French   [CIFS] convert us...
675
676
677
  	bool largeBuf:1;	/* if valid response, is pointer to large buf */
  	bool multiRsp:1;	/* multiple trans2 responses for one request  */
  	bool multiEnd:1;	/* both received */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
678
  };
789e66612   Steve French   [CIFS] Cleanup us...
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
  /*	Make code in transport.c a little cleaner by moving
  	update of optional stats into function below */
  #ifdef CONFIG_CIFS_STATS2
  
  static inline void cifs_in_send_inc(struct TCP_Server_Info *server)
  {
  	atomic_inc(&server->in_send);
  }
  
  static inline void cifs_in_send_dec(struct TCP_Server_Info *server)
  {
  	atomic_dec(&server->in_send);
  }
  
  static inline void cifs_num_waiters_inc(struct TCP_Server_Info *server)
  {
  	atomic_inc(&server->num_waiters);
  }
  
  static inline void cifs_num_waiters_dec(struct TCP_Server_Info *server)
  {
  	atomic_dec(&server->num_waiters);
  }
  
  static inline void cifs_save_when_sent(struct mid_q_entry *mid)
  {
  	mid->when_sent = jiffies;
  }
  #else
  static inline void cifs_in_send_inc(struct TCP_Server_Info *server)
  {
  }
  static inline void cifs_in_send_dec(struct TCP_Server_Info *server)
  {
  }
  
  static inline void cifs_num_waiters_inc(struct TCP_Server_Info *server)
  {
  }
  
  static inline void cifs_num_waiters_dec(struct TCP_Server_Info *server)
  {
  }
  
  static inline void cifs_save_when_sent(struct mid_q_entry *mid)
  {
  }
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
727

ff5dbd9ea   Steve French   [CIFS] Change not...
728
729
  /* for pending dnotify requests */
  struct dir_notify_req {
13cd4b7f7   Steve French   [CIFS] Various sm...
730
731
732
733
734
735
736
737
738
739
  	struct list_head lhead;
  	__le16 Pid;
  	__le16 PidHigh;
  	__u16 Mid;
  	__u16 Tid;
  	__u16 Uid;
  	__u16 netfid;
  	__u32 filter; /* CompletionFilter (for multishot) */
  	int multishot;
  	struct file *pfile;
ff5dbd9ea   Steve French   [CIFS] Change not...
740
  };
366781c19   Steve French   [CIFS] DFS build ...
741
742
  struct dfs_info3_param {
  	int flags; /* DFSREF_REFERRAL_SERVER, DFSREF_STORAGE_SERVER*/
8aad018b6   Igor Mammedov   [CIFS] Fix mixed ...
743
  	int path_consumed;
366781c19   Steve French   [CIFS] DFS build ...
744
745
746
747
748
  	int server_type;
  	int ref_flag;
  	char *path_name;
  	char *node_name;
  };
cc0bad755   Jeff Layton   cifs: add new cif...
749
750
751
752
753
754
  /*
   * common struct for holding inode info when searching for or updating an
   * inode with new info
   */
  
  #define CIFS_FATTR_DFS_REFERRAL		0x1
0b8f18e35   Jeff Layton   cifs: convert cif...
755
756
  #define CIFS_FATTR_DELETE_PENDING	0x2
  #define CIFS_FATTR_NEED_REVAL		0x4
3d6943803   Jeff Layton   cifs: guard again...
757
  #define CIFS_FATTR_INO_COLLISION	0x8
cc0bad755   Jeff Layton   cifs: add new cif...
758
759
760
761
762
763
764
  
  struct cifs_fattr {
  	u32		cf_flags;
  	u32		cf_cifsattrs;
  	u64		cf_uniqueid;
  	u64		cf_eof;
  	u64		cf_bytes;
20054bd65   Jeff Layton   cifs: use Creatio...
765
  	u64		cf_createtime;
cc0bad755   Jeff Layton   cifs: add new cif...
766
767
768
769
770
771
772
773
774
775
  	uid_t		cf_uid;
  	gid_t		cf_gid;
  	umode_t		cf_mode;
  	dev_t		cf_rdev;
  	unsigned int	cf_nlink;
  	unsigned int	cf_dtype;
  	struct timespec	cf_atime;
  	struct timespec	cf_mtime;
  	struct timespec	cf_ctime;
  };
366781c19   Steve French   [CIFS] DFS build ...
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
  static inline void free_dfs_info_param(struct dfs_info3_param *param)
  {
  	if (param) {
  		kfree(param->path_name);
  		kfree(param->node_name);
  		kfree(param);
  	}
  }
  
  static inline void free_dfs_info_array(struct dfs_info3_param *param,
  				       int number_of_items)
  {
  	int i;
  	if ((number_of_items == 0) || (param == NULL))
  		return;
  	for (i = 0; i < number_of_items; i++) {
  		kfree(param[i].path_name);
  		kfree(param[i].node_name);
  	}
  	kfree(param);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
797
798
799
800
801
  #define   MID_FREE 0
  #define   MID_REQUEST_ALLOCATED 1
  #define   MID_REQUEST_SUBMITTED 2
  #define   MID_RESPONSE_RECEIVED 4
  #define   MID_RETRY_NEEDED      8 /* session closed while this request out */
71823baff   Jeff Layton   cifs: don't alway...
802
  #define   MID_RESPONSE_MALFORMED 0x10
3c1105df6   Jeff Layton   cifs: don't call ...
803
  #define   MID_SHUTDOWN		 0x20
ec637e3ff   Steve French   [CIFS] Avoid extr...
804
805
806
807
808
809
  
  /* Types of response buffer returned from SendReceive2 */
  #define   CIFS_NO_BUFFER        0    /* Response buffer not returned */
  #define   CIFS_SMALL_BUFFER     1
  #define   CIFS_LARGE_BUFFER     2
  #define   CIFS_IOVEC            4    /* array of response buffers */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
810

133672efb   Steve French   [CIFS] Fix buffer...
811
  /* Type of Request to SendReceive2 */
7749981ec   Jeff Layton   cifs: remove code...
812
813
814
  #define   CIFS_BLOCKING_OP      1    /* operation can block */
  #define   CIFS_ASYNC_OP         2    /* do not wait for response */
  #define   CIFS_TIMEOUT_MASK 0x003    /* only one of above set in req */
133672efb   Steve French   [CIFS] Fix buffer...
815
816
817
  #define   CIFS_LOG_ERROR    0x010    /* log NT STATUS if non-zero */
  #define   CIFS_LARGE_BUF_OP 0x020    /* large request buffer */
  #define   CIFS_NO_RESP      0x040    /* no response buffer required */
3979877e5   Steve French   [CIFS] Support fo...
818
819
820
821
822
823
824
825
  /* Security Flags: indicate type of session setup needed */
  #define   CIFSSEC_MAY_SIGN	0x00001
  #define   CIFSSEC_MAY_NTLM	0x00002
  #define   CIFSSEC_MAY_NTLMV2	0x00004
  #define   CIFSSEC_MAY_KRB5	0x00008
  #ifdef CONFIG_CIFS_WEAK_PW_HASH
  #define   CIFSSEC_MAY_LANMAN	0x00010
  #define   CIFSSEC_MAY_PLNTXT	0x00020
516897a20   Steve French   [CIFS] fix build ...
826
827
828
  #else
  #define   CIFSSEC_MAY_LANMAN    0
  #define   CIFSSEC_MAY_PLNTXT    0
3979877e5   Steve French   [CIFS] Support fo...
829
830
  #endif /* weak passwords */
  #define   CIFSSEC_MAY_SEAL	0x00040 /* not supported yet */
ac6839246   Steve French   [CIFS] Allow raw ...
831
  #define   CIFSSEC_MAY_NTLMSSP	0x00080 /* raw ntlmssp with ntlmv2 */
3979877e5   Steve French   [CIFS] Support fo...
832
833
834
835
836
837
838
839
840
841
842
  
  #define   CIFSSEC_MUST_SIGN	0x01001
  /* note that only one of the following can be set so the
  result of setting MUST flags more than once will be to
  require use of the stronger protocol */
  #define   CIFSSEC_MUST_NTLM	0x02002
  #define   CIFSSEC_MUST_NTLMV2	0x04004
  #define   CIFSSEC_MUST_KRB5	0x08008
  #ifdef CONFIG_CIFS_WEAK_PW_HASH
  #define   CIFSSEC_MUST_LANMAN	0x10010
  #define   CIFSSEC_MUST_PLNTXT	0x20020
0d3a01fad   Jeff Layton   [CIFS] Break up u...
843
  #ifdef CONFIG_CIFS_UPCALL
20d1752f3   Chuck Ebbert   [CIFS] Re-enable ...
844
  #define   CIFSSEC_MASK          0xBF0BF /* allows weak security but also krb5 */
0d3a01fad   Jeff Layton   [CIFS] Break up u...
845
  #else
20d1752f3   Chuck Ebbert   [CIFS] Re-enable ...
846
  #define   CIFSSEC_MASK          0xB70B7 /* current flags supported if weak */
016ec75f1   Steve French   [CIFS] missing #e...
847
  #endif /* UPCALL */
0d3a01fad   Jeff Layton   [CIFS] Break up u...
848
849
  #else /* do not allow weak pw hash */
  #ifdef CONFIG_CIFS_UPCALL
ac6839246   Steve French   [CIFS] Allow raw ...
850
  #define   CIFSSEC_MASK          0x8F08F /* flags supported if no weak allowed */
d38d8c74c   Steve French   [CIFS] whitespace...
851
  #else
ac6839246   Steve French   [CIFS] Allow raw ...
852
  #define	  CIFSSEC_MASK          0x87087 /* flags supported if no weak allowed */
016ec75f1   Steve French   [CIFS] missing #e...
853
  #endif /* UPCALL */
3979877e5   Steve French   [CIFS] Support fo...
854
855
  #endif /* WEAK_PW_HASH */
  #define   CIFSSEC_MUST_SEAL	0x40040 /* not supported yet */
ac6839246   Steve French   [CIFS] Allow raw ...
856
  #define   CIFSSEC_MUST_NTLMSSP	0x80080 /* raw ntlmssp with ntlmv2 */
3979877e5   Steve French   [CIFS] Support fo...
857

ef571cadd   Shirish Pargaonkar   [CIFS] Fix warnin...
858
859
  #define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
  #define   CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
ac6839246   Steve French   [CIFS] Allow raw ...
860
  #define   CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
  /*
   *****************************************************************
   * All constants go here
   *****************************************************************
   */
  
  #define UID_HASH (16)
  
  /*
   * Note that ONE module should define _DECLARE_GLOBALS_HERE to cause the
   * following to be declared.
   */
  
  /****************************************************************************
   *  Locking notes.  All updates to global variables and lists should be
   *                  protected by spinlocks or semaphores.
   *
   *  Spinlocks
   *  ---------
   *  GlobalMid_Lock protects:
   *	list operations on pending_mid_q and oplockQ
   *      updates to XID counters, multiplex id  and SMB sequence numbers
6573e9b73   Suresh Jayaraman   cifs: update comm...
883
   *  cifs_file_list_lock protects:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
884
885
886
887
888
889
890
891
   *	list operations on tcp and SMB session lists and tCon lists
   *  f_owner.lock protects certain per file struct operations
   *  mapping->page_lock protects certain per page operations
   *
   *  Semaphores
   *  ----------
   *  sesSem     operations on smb session
   *  tconSem    operations on tree connection
d38d8c74c   Steve French   [CIFS] whitespace...
892
   *  fh_sem      file handle reconnection operations
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
893
894
895
896
897
898
899
900
   *
   ****************************************************************************/
  
  #ifdef DECLARE_GLOBALS_HERE
  #define GLOBAL_EXTERN
  #else
  #define GLOBAL_EXTERN extern
  #endif
e7ddee903   Jeff Layton   cifs: disable sha...
901
902
  /*
   * the list of TCP_Server_Info structures, ie each of the sockets
fb3960166   Steve French   [CIFS] remove unu...
903
   * connecting our client to a distinct server (ip address), is
e7ddee903   Jeff Layton   cifs: disable sha...
904
   * chained together by cifs_tcp_ses_list. The list of all our SMB
fb3960166   Steve French   [CIFS] remove unu...
905
   * sessions (and from that the tree connections) can be found
e7ddee903   Jeff Layton   cifs: disable sha...
906
907
908
   * by iterating over cifs_tcp_ses_list
   */
  GLOBAL_EXTERN struct list_head		cifs_tcp_ses_list;
f1987b44f   Jeff Layton   cifs: reinstate s...
909
910
911
912
913
914
  /*
   * This lock protects the cifs_tcp_ses_list, the list of smb sessions per
   * tcp session, and the list of tcon's per smb session. It also protects
   * the reference counters for the server, smb session, and tcon. Finally,
   * changes to the tcon->tidStatus should be done while holding this lock.
   */
3f9bcca78   Suresh Jayaraman   cifs: convert cif...
915
  GLOBAL_EXTERN spinlock_t		cifs_tcp_ses_lock;
ddb4cbfc5   Steve French   [CIFS] Do not att...
916
917
918
919
920
921
922
923
  
  /*
   * This lock protects the cifs_file->llist and cifs_file->flist
   * list operations, and updates to some flags (cifs_file->invalidHandle)
   * It will be moved to either use the tcon->stat_lock or equivalent later.
   * If cifs_tcp_ses_lock and the lock below are both needed to be held, then
   * the cifs_tcp_ses_lock must be grabbed first and released last.
   */
4477288a1   Jeff Layton   cifs: convert Glo...
924
  GLOBAL_EXTERN spinlock_t	cifs_file_list_lock;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
925

0eff0e267   Steve French   Remove unused CIF...
926
  #ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */
99ee4dbd7   Steve French   [CIFS] Remove som...
927
928
929
930
  /* Outstanding dir notify requests */
  GLOBAL_EXTERN struct list_head GlobalDnotifyReqList;
  /* DirNotify response queue */
  GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q;
0eff0e267   Steve French   Remove unused CIF...
931
  #endif /* was needed for dnotify, and will be needed for inotify when VFS fix */
ff5dbd9ea   Steve French   [CIFS] Change not...
932

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
933
934
935
936
  /*
   * Global transaction id (XID) information
   */
  GLOBAL_EXTERN unsigned int GlobalCurrentXid;	/* protected by GlobalMid_Sem */
254e55ed0   Steve French   CIFS] Support for...
937
  GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
938
  GLOBAL_EXTERN unsigned int GlobalMaxActiveXid;	/* prot by GlobalMid_Sem */
254e55ed0   Steve French   CIFS] Support for...
939
940
  GLOBAL_EXTERN spinlock_t GlobalMid_Lock;  /* protects above & list operations */
  					  /* on midQ entries */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
941
942
943
944
945
946
947
948
  /*
   *  Global counters, updated atomically
   */
  GLOBAL_EXTERN atomic_t sesInfoAllocCount;
  GLOBAL_EXTERN atomic_t tconInfoAllocCount;
  GLOBAL_EXTERN atomic_t tcpSesAllocCount;
  GLOBAL_EXTERN atomic_t tcpSesReconnectCount;
  GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
aaa9bbe03   Steve French   [CIFS] remove unu...
949
  /* Various Debug counters */
4498eed50   Steve French   [CIFS] Add extend...
950
951
952
953
954
955
  GLOBAL_EXTERN atomic_t bufAllocCount;    /* current number allocated  */
  #ifdef CONFIG_CIFS_STATS2
  GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
  GLOBAL_EXTERN atomic_t totSmBufAllocCount;
  #endif
  GLOBAL_EXTERN atomic_t smBufAllocCount;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
956
957
958
  GLOBAL_EXTERN atomic_t midCount;
  
  /* Misc globals */
254e55ed0   Steve French   CIFS] Support for...
959
  GLOBAL_EXTERN unsigned int multiuser_mount; /* if enabled allows new sessions
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
960
  				to be established on existing mount if we
d38d8c74c   Steve French   [CIFS] whitespace...
961
  				have the uid/password or Kerberos credential
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
962
  				or equivalent for current user */
e75047344   Steve French   add new module pa...
963
964
  /* enable or disable oplocks */
  GLOBAL_EXTERN bool enable_oplocks;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
965
  GLOBAL_EXTERN unsigned int lookupCacheEnabled;
04912d6a2   Jeff Layton   cifs: rename "ext...
966
  GLOBAL_EXTERN unsigned int global_secflags;	/* if on, session setup sent
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
967
  				with more secure ntlmssp2 challenge/resp */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
968
969
970
971
972
973
  GLOBAL_EXTERN unsigned int sign_CIFS_PDUs;  /* enable smb packet signing */
  GLOBAL_EXTERN unsigned int linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/
  GLOBAL_EXTERN unsigned int CIFSMaxBufSize;  /* max size not including hdr */
  GLOBAL_EXTERN unsigned int cifs_min_rcv;    /* min size of big ntwrk buf pool */
  GLOBAL_EXTERN unsigned int cifs_min_small;  /* min size of small buf pool */
  GLOBAL_EXTERN unsigned int cifs_max_pending; /* MAX requests at once to server*/
fda359436   Steve French   [CIFS] cifs: reco...
974
975
  /* reconnect after this many failed echo attempts */
  GLOBAL_EXTERN unsigned short echo_retries;
21fed0d5b   Shirish Pargaonkar   cifs: Add data st...
976
  #ifdef CONFIG_CIFS_ACL
4d79dba0e   Shirish Pargaonkar   cifs: Add idmap k...
977
978
979
980
  GLOBAL_EXTERN struct rb_root uidtree;
  GLOBAL_EXTERN struct rb_root gidtree;
  GLOBAL_EXTERN spinlock_t siduidlock;
  GLOBAL_EXTERN spinlock_t sidgidlock;
21fed0d5b   Shirish Pargaonkar   cifs: Add data st...
981
982
983
984
985
  GLOBAL_EXTERN struct rb_root siduidtree;
  GLOBAL_EXTERN struct rb_root sidgidtree;
  GLOBAL_EXTERN spinlock_t uidsidlock;
  GLOBAL_EXTERN spinlock_t gidsidlock;
  #endif /* CONFIG_CIFS_ACL */
4d79dba0e   Shirish Pargaonkar   cifs: Add idmap k...
986

9b6469724   Tejun Heo   cifs: use workque...
987
  void cifs_oplock_break(struct work_struct *work);
3b7433b8a   Linus Torvalds   Merge branch 'for...
988

3bc303c25   Jeff Layton   cifs: convert opl...
989
  extern const struct slow_work_ops cifs_oplock_break_ops;
abd2e44dc   Suresh Jayaraman   cifs: guard cifsg...
990
991
  
  #endif	/* _CIFS_GLOB_H */