aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2007-07-07 15:25:05 -0400
committerSteve French <sfrench@us.ibm.com>2007-07-07 15:25:05 -0400
commit790fe579f5006b72dfd2814f9263a73b0b455e81 (patch)
tree8d0749bb66bcd8993ae66101c6706e0ba432e155
parent6dc0f87e351142e224b396f29b59527c4b2d834c (diff)
[CIFS] more whitespace cleanup
Signed-off-by: Steve French <sfrench@us.ibm.com>
-rw-r--r--fs/cifs/cifsfs.c18
-rw-r--r--fs/cifs/cifssmb.c540
-rw-r--r--fs/cifs/misc.c64
-rw-r--r--fs/cifs/netmisc.c18
-rw-r--r--fs/cifs/readdir.c179
-rw-r--r--fs/cifs/sess.c225
-rw-r--r--fs/cifs/smbencrypt.c38
7 files changed, 544 insertions, 538 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 9122ef5c3174..17ed7cf750af 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -98,7 +98,7 @@ cifs_read_super(struct super_block *sb, void *data,
98 98
99 /* BB should we make this contingent on mount parm? */ 99 /* BB should we make this contingent on mount parm? */
100 sb->s_flags |= MS_NODIRATIME | MS_NOATIME; 100 sb->s_flags |= MS_NODIRATIME | MS_NOATIME;
101 sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info),GFP_KERNEL); 101 sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
102 cifs_sb = CIFS_SB(sb); 102 cifs_sb = CIFS_SB(sb);
103 if (cifs_sb == NULL) 103 if (cifs_sb == NULL)
104 return -ENOMEM; 104 return -ENOMEM;
@@ -117,9 +117,10 @@ cifs_read_super(struct super_block *sb, void *data,
117#ifdef CONFIG_CIFS_EXPERIMENTAL 117#ifdef CONFIG_CIFS_EXPERIMENTAL
118 if (experimEnabled != 0) 118 if (experimEnabled != 0)
119 sb->s_export_op = &cifs_export_ops; 119 sb->s_export_op = &cifs_export_ops;
120#endif /* EXPERIMENTAL */ 120#endif /* EXPERIMENTAL */
121/* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512) 121/* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
122 sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */ 122 sb->s_blocksize =
123 cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
123#ifdef CONFIG_CIFS_QUOTA 124#ifdef CONFIG_CIFS_QUOTA
124 sb->s_qcop = &cifs_quotactl_ops; 125 sb->s_qcop = &cifs_quotactl_ops;
125#endif 126#endif
@@ -164,10 +165,10 @@ cifs_put_super(struct super_block *sb)
164 cFYI(1, ("In cifs_put_super")); 165 cFYI(1, ("In cifs_put_super"));
165 cifs_sb = CIFS_SB(sb); 166 cifs_sb = CIFS_SB(sb);
166 if (cifs_sb == NULL) { 167 if (cifs_sb == NULL) {
167 cFYI(1,("Empty cifs superblock info passed to unmount")); 168 cFYI(1, ("Empty cifs superblock info passed to unmount"));
168 return; 169 return;
169 } 170 }
170 rc = cifs_umount(sb, cifs_sb); 171 rc = cifs_umount(sb, cifs_sb);
171 if (rc) { 172 if (rc) {
172 cERROR(1, ("cifs_umount failed with return code %d", rc)); 173 cERROR(1, ("cifs_umount failed with return code %d", rc));
173 } 174 }
@@ -180,7 +181,7 @@ static int
180cifs_statfs(struct dentry *dentry, struct kstatfs *buf) 181cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
181{ 182{
182 struct super_block *sb = dentry->d_sb; 183 struct super_block *sb = dentry->d_sb;
183 int xid; 184 int xid;
184 int rc = -EOPNOTSUPP; 185 int rc = -EOPNOTSUPP;
185 struct cifs_sb_info *cifs_sb; 186 struct cifs_sb_info *cifs_sb;
186 struct cifsTconInfo *pTcon; 187 struct cifsTconInfo *pTcon;
@@ -193,7 +194,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
193 buf->f_type = CIFS_MAGIC_NUMBER; 194 buf->f_type = CIFS_MAGIC_NUMBER;
194 195
195 /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */ 196 /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */
196 buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would 197 buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would
197 presumably be total path, but note 198 presumably be total path, but note
198 that some servers (includinng Samba 3) 199 that some servers (includinng Samba 3)
199 have a shorter maximum path */ 200 have a shorter maximum path */
@@ -217,8 +218,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
217 bypassed it because we detected that this was an older LANMAN sess */ 218 bypassed it because we detected that this was an older LANMAN sess */
218 if (rc) 219 if (rc)
219 rc = SMBOldQFSInfo(xid, pTcon, buf); 220 rc = SMBOldQFSInfo(xid, pTcon, buf);
220 /* 221 /* int f_type;
221 int f_type;
222 __fsid_t f_fsid; 222 __fsid_t f_fsid;
223 int f_namelen; */ 223 int f_namelen; */
224 /* BB get from info in tcon struct at mount time call to QFSAttrInfo */ 224 /* BB get from info in tcon struct at mount time call to QFSAttrInfo */
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index b4916eb6fd43..5b19ce2e4351 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -61,7 +61,7 @@ static struct {
61 {LANMAN_PROT, "\2LM1.2X002"}, 61 {LANMAN_PROT, "\2LM1.2X002"},
62 {LANMAN2_PROT, "\2LANMAN2.1"}, 62 {LANMAN2_PROT, "\2LANMAN2.1"},
63#endif /* weak password hashing for legacy clients */ 63#endif /* weak password hashing for legacy clients */
64 {CIFS_PROT, "\2NT LM 0.12"}, 64 {CIFS_PROT, "\2NT LM 0.12"},
65 {BAD_PROT, "\2"} 65 {BAD_PROT, "\2"}
66}; 66};
67#endif 67#endif
@@ -84,17 +84,17 @@ static struct {
84 84
85/* Mark as invalid, all open files on tree connections since they 85/* Mark as invalid, all open files on tree connections since they
86 were closed when session to server was lost */ 86 were closed when session to server was lost */
87static void mark_open_files_invalid(struct cifsTconInfo * pTcon) 87static void mark_open_files_invalid(struct cifsTconInfo *pTcon)
88{ 88{
89 struct cifsFileInfo *open_file = NULL; 89 struct cifsFileInfo *open_file = NULL;
90 struct list_head * tmp; 90 struct list_head *tmp;
91 struct list_head * tmp1; 91 struct list_head *tmp1;
92 92
93/* list all files open on tree connection and mark them invalid */ 93/* list all files open on tree connection and mark them invalid */
94 write_lock(&GlobalSMBSeslock); 94 write_lock(&GlobalSMBSeslock);
95 list_for_each_safe(tmp, tmp1, &pTcon->openFileList) { 95 list_for_each_safe(tmp, tmp1, &pTcon->openFileList) {
96 open_file = list_entry(tmp,struct cifsFileInfo, tlist); 96 open_file = list_entry(tmp, struct cifsFileInfo, tlist);
97 if(open_file) { 97 if (open_file) {
98 open_file->invalidHandle = TRUE; 98 open_file->invalidHandle = TRUE;
99 } 99 }
100 } 100 }
@@ -113,20 +113,20 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
113 /* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so 113 /* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so
114 check for tcp and smb session status done differently 114 check for tcp and smb session status done differently
115 for those three - in the calling routine */ 115 for those three - in the calling routine */
116 if(tcon) { 116 if (tcon) {
117 if(tcon->tidStatus == CifsExiting) { 117 if (tcon->tidStatus == CifsExiting) {
118 /* only tree disconnect, open, and write, 118 /* only tree disconnect, open, and write,
119 (and ulogoff which does not have tcon) 119 (and ulogoff which does not have tcon)
120 are allowed as we start force umount */ 120 are allowed as we start force umount */
121 if((smb_command != SMB_COM_WRITE_ANDX) && 121 if ((smb_command != SMB_COM_WRITE_ANDX) &&
122 (smb_command != SMB_COM_OPEN_ANDX) && 122 (smb_command != SMB_COM_OPEN_ANDX) &&
123 (smb_command != SMB_COM_TREE_DISCONNECT)) { 123 (smb_command != SMB_COM_TREE_DISCONNECT)) {
124 cFYI(1,("can not send cmd %d while umounting", 124 cFYI(1, ("can not send cmd %d while umounting",
125 smb_command)); 125 smb_command));
126 return -ENODEV; 126 return -ENODEV;
127 } 127 }
128 } 128 }
129 if((tcon->ses) && (tcon->ses->status != CifsExiting) && 129 if ((tcon->ses) && (tcon->ses->status != CifsExiting) &&
130 (tcon->ses->server)){ 130 (tcon->ses->server)){
131 struct nls_table *nls_codepage; 131 struct nls_table *nls_codepage;
132 /* Give Demultiplex thread up to 10 seconds to 132 /* Give Demultiplex thread up to 10 seconds to
@@ -135,9 +135,9 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
135 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { 135 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) {
136 wait_event_interruptible_timeout(tcon->ses->server->response_q, 136 wait_event_interruptible_timeout(tcon->ses->server->response_q,
137 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); 137 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ);
138 if(tcon->ses->server->tcpStatus == CifsNeedReconnect) { 138 if (tcon->ses->server->tcpStatus == CifsNeedReconnect) {
139 /* on "soft" mounts we wait once */ 139 /* on "soft" mounts we wait once */
140 if((tcon->retry == FALSE) || 140 if ((tcon->retry == FALSE) ||
141 (tcon->ses->status == CifsExiting)) { 141 (tcon->ses->status == CifsExiting)) {
142 cFYI(1,("gave up waiting on reconnect in smb_init")); 142 cFYI(1,("gave up waiting on reconnect in smb_init"));
143 return -EHOSTDOWN; 143 return -EHOSTDOWN;
@@ -153,10 +153,10 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
153 /* need to prevent multiple threads trying to 153 /* need to prevent multiple threads trying to
154 simultaneously reconnect the same SMB session */ 154 simultaneously reconnect the same SMB session */
155 down(&tcon->ses->sesSem); 155 down(&tcon->ses->sesSem);
156 if(tcon->ses->status == CifsNeedReconnect) 156 if (tcon->ses->status == CifsNeedReconnect)
157 rc = cifs_setup_session(0, tcon->ses, 157 rc = cifs_setup_session(0, tcon->ses,
158 nls_codepage); 158 nls_codepage);
159 if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { 159 if (!rc && (tcon->tidStatus == CifsNeedReconnect)) {
160 mark_open_files_invalid(tcon); 160 mark_open_files_invalid(tcon);
161 rc = CIFSTCon(0, tcon->ses, tcon->treeName, 161 rc = CIFSTCon(0, tcon->ses, tcon->treeName,
162 tcon, nls_codepage); 162 tcon, nls_codepage);
@@ -170,7 +170,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
170 /* BB FIXME add code to check if wsize needs 170 /* BB FIXME add code to check if wsize needs
171 update due to negotiated smb buffer size 171 update due to negotiated smb buffer size
172 shrinking */ 172 shrinking */
173 if(rc == 0) 173 if (rc == 0)
174 atomic_inc(&tconInfoReconnectCount); 174 atomic_inc(&tconInfoReconnectCount);
175 175
176 cFYI(1, ("reconnect tcon rc = %d", rc)); 176 cFYI(1, ("reconnect tcon rc = %d", rc));
@@ -200,7 +200,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
200 return -EIO; 200 return -EIO;
201 } 201 }
202 } 202 }
203 if(rc) 203 if (rc)
204 return rc; 204 return rc;
205 205
206 *request_buf = cifs_small_buf_get(); 206 *request_buf = cifs_small_buf_get();
@@ -211,8 +211,8 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
211 211
212 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,wct); 212 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,wct);
213 213
214 if(tcon != NULL) 214 if (tcon != NULL)
215 cifs_stats_inc(&tcon->num_smbs_sent); 215 cifs_stats_inc(&tcon->num_smbs_sent);
216 216
217 return rc; 217 return rc;
218} 218}
@@ -225,7 +225,7 @@ small_smb_init_no_tc(const int smb_command, const int wct,
225 struct smb_hdr * buffer; 225 struct smb_hdr * buffer;
226 226
227 rc = small_smb_init(smb_command, wct, NULL, request_buf); 227 rc = small_smb_init(smb_command, wct, NULL, request_buf);
228 if(rc) 228 if (rc)
229 return rc; 229 return rc;
230 230
231 buffer = (struct smb_hdr *)*request_buf; 231 buffer = (struct smb_hdr *)*request_buf;
@@ -254,21 +254,21 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
254 /* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so 254 /* SMBs NegProt, SessSetup, uLogoff do not have tcon yet so
255 check for tcp and smb session status done differently 255 check for tcp and smb session status done differently
256 for those three - in the calling routine */ 256 for those three - in the calling routine */
257 if(tcon) { 257 if (tcon) {
258 if(tcon->tidStatus == CifsExiting) { 258 if (tcon->tidStatus == CifsExiting) {
259 /* only tree disconnect, open, and write, 259 /* only tree disconnect, open, and write,
260 (and ulogoff which does not have tcon) 260 (and ulogoff which does not have tcon)
261 are allowed as we start force umount */ 261 are allowed as we start force umount */
262 if((smb_command != SMB_COM_WRITE_ANDX) && 262 if ((smb_command != SMB_COM_WRITE_ANDX) &&
263 (smb_command != SMB_COM_OPEN_ANDX) && 263 (smb_command != SMB_COM_OPEN_ANDX) &&
264 (smb_command != SMB_COM_TREE_DISCONNECT)) { 264 (smb_command != SMB_COM_TREE_DISCONNECT)) {
265 cFYI(1,("can not send cmd %d while umounting", 265 cFYI(1, ("can not send cmd %d while umounting",
266 smb_command)); 266 smb_command));
267 return -ENODEV; 267 return -ENODEV;
268 } 268 }
269 } 269 }
270 270
271 if((tcon->ses) && (tcon->ses->status != CifsExiting) && 271 if ((tcon->ses) && (tcon->ses->status != CifsExiting) &&
272 (tcon->ses->server)){ 272 (tcon->ses->server)){
273 struct nls_table *nls_codepage; 273 struct nls_table *nls_codepage;
274 /* Give Demultiplex thread up to 10 seconds to 274 /* Give Demultiplex thread up to 10 seconds to
@@ -277,10 +277,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
277 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { 277 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) {
278 wait_event_interruptible_timeout(tcon->ses->server->response_q, 278 wait_event_interruptible_timeout(tcon->ses->server->response_q,
279 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); 279 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ);
280 if(tcon->ses->server->tcpStatus == 280 if (tcon->ses->server->tcpStatus ==
281 CifsNeedReconnect) { 281 CifsNeedReconnect) {
282 /* on "soft" mounts we wait once */ 282 /* on "soft" mounts we wait once */
283 if((tcon->retry == FALSE) || 283 if ((tcon->retry == FALSE) ||
284 (tcon->ses->status == CifsExiting)) { 284 (tcon->ses->status == CifsExiting)) {
285 cFYI(1,("gave up waiting on reconnect in smb_init")); 285 cFYI(1,("gave up waiting on reconnect in smb_init"));
286 return -EHOSTDOWN; 286 return -EHOSTDOWN;
@@ -296,10 +296,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
296 /* need to prevent multiple threads trying to 296 /* need to prevent multiple threads trying to
297 simultaneously reconnect the same SMB session */ 297 simultaneously reconnect the same SMB session */
298 down(&tcon->ses->sesSem); 298 down(&tcon->ses->sesSem);
299 if(tcon->ses->status == CifsNeedReconnect) 299 if (tcon->ses->status == CifsNeedReconnect)
300 rc = cifs_setup_session(0, tcon->ses, 300 rc = cifs_setup_session(0, tcon->ses,
301 nls_codepage); 301 nls_codepage);
302 if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { 302 if (!rc && (tcon->tidStatus == CifsNeedReconnect)) {
303 mark_open_files_invalid(tcon); 303 mark_open_files_invalid(tcon);
304 rc = CIFSTCon(0, tcon->ses, tcon->treeName, 304 rc = CIFSTCon(0, tcon->ses, tcon->treeName,
305 tcon, nls_codepage); 305 tcon, nls_codepage);
@@ -313,7 +313,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
313 /* BB FIXME add code to check if wsize needs 313 /* BB FIXME add code to check if wsize needs
314 update due to negotiated smb buffer size 314 update due to negotiated smb buffer size
315 shrinking */ 315 shrinking */
316 if(rc == 0) 316 if (rc == 0)
317 atomic_inc(&tconInfoReconnectCount); 317 atomic_inc(&tconInfoReconnectCount);
318 318
319 cFYI(1, ("reconnect tcon rc = %d", rc)); 319 cFYI(1, ("reconnect tcon rc = %d", rc));
@@ -343,7 +343,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
343 return -EIO; 343 return -EIO;
344 } 344 }
345 } 345 }
346 if(rc) 346 if (rc)
347 return rc; 347 return rc;
348 348
349 *request_buf = cifs_buf_get(); 349 *request_buf = cifs_buf_get();
@@ -355,14 +355,14 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
355 /* potential retries of smb operations it turns out we can determine */ 355 /* potential retries of smb operations it turns out we can determine */
356 /* from the mid flags when the request buffer can be resent without */ 356 /* from the mid flags when the request buffer can be resent without */
357 /* having to use a second distinct buffer for the response */ 357 /* having to use a second distinct buffer for the response */
358 if(response_buf) 358 if (response_buf)
359 *response_buf = *request_buf; 359 *response_buf = *request_buf;
360 360
361 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon, 361 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,
362 wct /*wct */ ); 362 wct /*wct */ );
363 363
364 if(tcon != NULL) 364 if (tcon != NULL)
365 cifs_stats_inc(&tcon->num_smbs_sent); 365 cifs_stats_inc(&tcon->num_smbs_sent);
366 366
367 return rc; 367 return rc;
368} 368}
@@ -375,19 +375,19 @@ static int validate_t2(struct smb_t2_rsp * pSMB)
375 375
376 /* check for plausible wct, bcc and t2 data and parm sizes */ 376 /* check for plausible wct, bcc and t2 data and parm sizes */
377 /* check for parm and data offset going beyond end of smb */ 377 /* check for parm and data offset going beyond end of smb */
378 if(pSMB->hdr.WordCount >= 10) { 378 if (pSMB->hdr.WordCount >= 10) {
379 if((le16_to_cpu(pSMB->t2_rsp.ParameterOffset) <= 1024) && 379 if ((le16_to_cpu(pSMB->t2_rsp.ParameterOffset) <= 1024) &&
380 (le16_to_cpu(pSMB->t2_rsp.DataOffset) <= 1024)) { 380 (le16_to_cpu(pSMB->t2_rsp.DataOffset) <= 1024)) {
381 /* check that bcc is at least as big as parms + data */ 381 /* check that bcc is at least as big as parms + data */
382 /* check that bcc is less than negotiated smb buffer */ 382 /* check that bcc is less than negotiated smb buffer */
383 total_size = le16_to_cpu(pSMB->t2_rsp.ParameterCount); 383 total_size = le16_to_cpu(pSMB->t2_rsp.ParameterCount);
384 if(total_size < 512) { 384 if (total_size < 512) {
385 total_size+=le16_to_cpu(pSMB->t2_rsp.DataCount); 385 total_size+=le16_to_cpu(pSMB->t2_rsp.DataCount);
386 /* BCC le converted in SendReceive */ 386 /* BCC le converted in SendReceive */
387 pBCC = (pSMB->hdr.WordCount * 2) + 387 pBCC = (pSMB->hdr.WordCount * 2) +
388 sizeof(struct smb_hdr) + 388 sizeof(struct smb_hdr) +
389 (char *)pSMB; 389 (char *)pSMB;
390 if((total_size <= (*(u16 *)pBCC)) && 390 if ((total_size <= (*(u16 *)pBCC)) &&
391 (total_size < 391 (total_size <
392 CIFSMaxBufSize+MAX_CIFS_HDR_SIZE)) { 392 CIFSMaxBufSize+MAX_CIFS_HDR_SIZE)) {
393 return 0; 393 return 0;
@@ -413,7 +413,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
413 unsigned int secFlags; 413 unsigned int secFlags;
414 u16 dialect; 414 u16 dialect;
415 415
416 if(ses->server) 416 if (ses->server)
417 server = ses->server; 417 server = ses->server;
418 else { 418 else {
419 rc = -EIO; 419 rc = -EIO;
@@ -425,7 +425,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
425 return rc; 425 return rc;
426 426
427 /* if any of auth flags (ie not sign or seal) are overriden use them */ 427 /* if any of auth flags (ie not sign or seal) are overriden use them */
428 if(ses->overrideSecFlg & (~(CIFSSEC_MUST_SIGN | CIFSSEC_MUST_SEAL))) 428 if (ses->overrideSecFlg & (~(CIFSSEC_MUST_SIGN | CIFSSEC_MUST_SEAL)))
429 secFlags = ses->overrideSecFlg; /* BB FIXME fix sign flags? */ 429 secFlags = ses->overrideSecFlg; /* BB FIXME fix sign flags? */
430 else /* if override flags set only sign/seal OR them with global auth */ 430 else /* if override flags set only sign/seal OR them with global auth */
431 secFlags = extended_security | ses->overrideSecFlg; 431 secFlags = extended_security | ses->overrideSecFlg;
@@ -452,22 +452,22 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
452 goto neg_err_exit; 452 goto neg_err_exit;
453 453
454 dialect = le16_to_cpu(pSMBr->DialectIndex); 454 dialect = le16_to_cpu(pSMBr->DialectIndex);
455 cFYI(1,("Dialect: %d", dialect)); 455 cFYI(1, ("Dialect: %d", dialect));
456 /* Check wct = 1 error case */ 456 /* Check wct = 1 error case */
457 if((pSMBr->hdr.WordCount < 13) || (dialect == BAD_PROT)) { 457 if ((pSMBr->hdr.WordCount < 13) || (dialect == BAD_PROT)) {
458 /* core returns wct = 1, but we do not ask for core - otherwise 458 /* core returns wct = 1, but we do not ask for core - otherwise
459 small wct just comes when dialect index is -1 indicating we 459 small wct just comes when dialect index is -1 indicating we
460 could not negotiate a common dialect */ 460 could not negotiate a common dialect */
461 rc = -EOPNOTSUPP; 461 rc = -EOPNOTSUPP;
462 goto neg_err_exit; 462 goto neg_err_exit;
463#ifdef CONFIG_CIFS_WEAK_PW_HASH 463#ifdef CONFIG_CIFS_WEAK_PW_HASH
464 } else if((pSMBr->hdr.WordCount == 13) 464 } else if ((pSMBr->hdr.WordCount == 13)
465 && ((dialect == LANMAN_PROT) 465 && ((dialect == LANMAN_PROT)
466 || (dialect == LANMAN2_PROT))) { 466 || (dialect == LANMAN2_PROT))) {
467 __s16 tmp; 467 __s16 tmp;
468 struct lanman_neg_rsp * rsp = (struct lanman_neg_rsp *)pSMBr; 468 struct lanman_neg_rsp * rsp = (struct lanman_neg_rsp *)pSMBr;
469 469
470 if((secFlags & CIFSSEC_MAY_LANMAN) || 470 if ((secFlags & CIFSSEC_MAY_LANMAN) ||
471 (secFlags & CIFSSEC_MAY_PLNTXT)) 471 (secFlags & CIFSSEC_MAY_PLNTXT))
472 server->secType = LANMAN; 472 server->secType = LANMAN;
473 else { 473 else {
@@ -483,7 +483,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
483 GETU32(server->sessid) = le32_to_cpu(rsp->SessionKey); 483 GETU32(server->sessid) = le32_to_cpu(rsp->SessionKey);
484 /* even though we do not use raw we might as well set this 484 /* even though we do not use raw we might as well set this
485 accurately, in case we ever find a need for it */ 485 accurately, in case we ever find a need for it */
486 if((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) { 486 if ((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) {
487 server->maxRw = 0xFF00; 487 server->maxRw = 0xFF00;
488 server->capabilities = CAP_MPX_MODE | CAP_RAW_MODE; 488 server->capabilities = CAP_MPX_MODE | CAP_RAW_MODE;
489 } else { 489 } else {
@@ -511,16 +511,16 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
511 seconds = val < 0 ? -val : val; 511 seconds = val < 0 ? -val : val;
512 result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ; 512 result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ;
513 remain = seconds % MIN_TZ_ADJ; 513 remain = seconds % MIN_TZ_ADJ;
514 if(remain >= (MIN_TZ_ADJ / 2)) 514 if (remain >= (MIN_TZ_ADJ / 2))
515 result += MIN_TZ_ADJ; 515 result += MIN_TZ_ADJ;
516 if(val < 0) 516 if (val < 0)
517 result = - result; 517 result = - result;
518 server->timeAdj = result; 518 server->timeAdj = result;
519 } else { 519 } else {
520 server->timeAdj = (int)tmp; 520 server->timeAdj = (int)tmp;
521 server->timeAdj *= 60; /* also in seconds */ 521 server->timeAdj *= 60; /* also in seconds */
522 } 522 }
523 cFYI(1,("server->timeAdj: %d seconds", server->timeAdj)); 523 cFYI(1, ("server->timeAdj: %d seconds", server->timeAdj));
524 524
525 525
526 /* BB get server time for time conversions and add 526 /* BB get server time for time conversions and add
@@ -535,39 +535,39 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
535 goto neg_err_exit; 535 goto neg_err_exit;
536 } 536 }
537 537
538 cFYI(1,("LANMAN negotiated")); 538 cFYI(1, ("LANMAN negotiated"));
539 /* we will not end up setting signing flags - as no signing 539 /* we will not end up setting signing flags - as no signing
540 was in LANMAN and server did not return the flags on */ 540 was in LANMAN and server did not return the flags on */
541 goto signing_check; 541 goto signing_check;
542#else /* weak security disabled */ 542#else /* weak security disabled */
543 } else if(pSMBr->hdr.WordCount == 13) { 543 } else if (pSMBr->hdr.WordCount == 13) {
544 cERROR(1,("mount failed, cifs module not built " 544 cERROR(1,("mount failed, cifs module not built "
545 "with CIFS_WEAK_PW_HASH support")); 545 "with CIFS_WEAK_PW_HASH support"));
546 rc = -EOPNOTSUPP; 546 rc = -EOPNOTSUPP;
547#endif /* WEAK_PW_HASH */ 547#endif /* WEAK_PW_HASH */
548 goto neg_err_exit; 548 goto neg_err_exit;
549 } else if(pSMBr->hdr.WordCount != 17) { 549 } else if (pSMBr->hdr.WordCount != 17) {
550 /* unknown wct */ 550 /* unknown wct */
551 rc = -EOPNOTSUPP; 551 rc = -EOPNOTSUPP;
552 goto neg_err_exit; 552 goto neg_err_exit;
553 } 553 }
554 /* else wct == 17 NTLM */ 554 /* else wct == 17 NTLM */
555 server->secMode = pSMBr->SecurityMode; 555 server->secMode = pSMBr->SecurityMode;
556 if((server->secMode & SECMODE_USER) == 0) 556 if ((server->secMode & SECMODE_USER) == 0)
557 cFYI(1,("share mode security")); 557 cFYI(1, ("share mode security"));
558 558
559 if((server->secMode & SECMODE_PW_ENCRYPT) == 0) 559 if ((server->secMode & SECMODE_PW_ENCRYPT) == 0)
560#ifdef CONFIG_CIFS_WEAK_PW_HASH 560#ifdef CONFIG_CIFS_WEAK_PW_HASH
561 if ((secFlags & CIFSSEC_MAY_PLNTXT) == 0) 561 if ((secFlags & CIFSSEC_MAY_PLNTXT) == 0)
562#endif /* CIFS_WEAK_PW_HASH */ 562#endif /* CIFS_WEAK_PW_HASH */
563 cERROR(1,("Server requests plain text password" 563 cERROR(1,("Server requests plain text password"
564 " but client support disabled")); 564 " but client support disabled"));
565 565
566 if((secFlags & CIFSSEC_MUST_NTLMV2) == CIFSSEC_MUST_NTLMV2) 566 if ((secFlags & CIFSSEC_MUST_NTLMV2) == CIFSSEC_MUST_NTLMV2)
567 server->secType = NTLMv2; 567 server->secType = NTLMv2;
568 else if(secFlags & CIFSSEC_MAY_NTLM) 568 else if (secFlags & CIFSSEC_MAY_NTLM)
569 server->secType = NTLM; 569 server->secType = NTLM;
570 else if(secFlags & CIFSSEC_MAY_NTLMV2) 570 else if (secFlags & CIFSSEC_MAY_NTLMV2)
571 server->secType = NTLMv2; 571 server->secType = NTLMv2;
572 /* else krb5 ... any others ... */ 572 /* else krb5 ... any others ... */
573 573
@@ -620,7 +620,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
620 SecurityBlob, 620 SecurityBlob,
621 count - 16, 621 count - 16,
622 &server->secType); 622 &server->secType);
623 if(rc == 1) { 623 if (rc == 1) {
624 /* BB Need to fill struct for sessetup here */ 624 /* BB Need to fill struct for sessetup here */
625 rc = -EOPNOTSUPP; 625 rc = -EOPNOTSUPP;
626 } else { 626 } else {
@@ -637,7 +637,7 @@ signing_check:
637 /* MUST_SIGN already includes the MAY_SIGN FLAG 637 /* MUST_SIGN already includes the MAY_SIGN FLAG
638 so if this is zero it means that signing is disabled */ 638 so if this is zero it means that signing is disabled */
639 cFYI(1, ("Signing disabled")); 639 cFYI(1, ("Signing disabled"));
640 if(server->secMode & SECMODE_SIGN_REQUIRED) 640 if (server->secMode & SECMODE_SIGN_REQUIRED)
641 cERROR(1, ("Server requires " 641 cERROR(1, ("Server requires "
642 "/proc/fs/cifs/PacketSigningEnabled " 642 "/proc/fs/cifs/PacketSigningEnabled "
643 "to be on")); 643 "to be on"));
@@ -655,7 +655,7 @@ signing_check:
655 server->secMode |= SECMODE_SIGN_REQUIRED; 655 server->secMode |= SECMODE_SIGN_REQUIRED;
656 } else { 656 } else {
657 /* signing optional ie CIFSSEC_MAY_SIGN */ 657 /* signing optional ie CIFSSEC_MAY_SIGN */
658 if((server->secMode & SECMODE_SIGN_REQUIRED) == 0) 658 if ((server->secMode & SECMODE_SIGN_REQUIRED) == 0)
659 server->secMode &= 659 server->secMode &=
660 ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED); 660 ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED);
661 } 661 }
@@ -663,7 +663,7 @@ signing_check:
663neg_err_exit: 663neg_err_exit:
664 cifs_buf_release(pSMB); 664 cifs_buf_release(pSMB);
665 665
666 cFYI(1,("negprot rc %d",rc)); 666 cFYI(1, ("negprot rc %d", rc));
667 return rc; 667 return rc;
668} 668}
669 669
@@ -696,12 +696,12 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon)
696 696
697 /* No need to return error on this operation if tid invalidated and 697 /* No need to return error on this operation if tid invalidated and
698 closed on server already e.g. due to tcp session crashing */ 698 closed on server already e.g. due to tcp session crashing */
699 if(tcon->tidStatus == CifsNeedReconnect) { 699 if (tcon->tidStatus == CifsNeedReconnect) {
700 up(&tcon->tconSem); 700 up(&tcon->tconSem);
701 return 0; 701 return 0;
702 } 702 }
703 703
704 if((tcon->ses == NULL) || (tcon->ses->server == NULL)) { 704 if ((tcon->ses == NULL) || (tcon->ses->server == NULL)) {
705 up(&tcon->tconSem); 705 up(&tcon->tconSem);
706 return -EIO; 706 return -EIO;
707 } 707 }
@@ -757,10 +757,10 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses)
757 757
758 smb_buffer_response = (struct smb_hdr *)pSMB; /* BB removeme BB */ 758 smb_buffer_response = (struct smb_hdr *)pSMB; /* BB removeme BB */
759 759
760 if(ses->server) { 760 if (ses->server) {
761 pSMB->hdr.Mid = GetNextMid(ses->server); 761 pSMB->hdr.Mid = GetNextMid(ses->server);
762 762
763 if(ses->server->secMode & 763 if (ses->server->secMode &
764 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 764 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
765 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 765 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
766 } 766 }
@@ -999,7 +999,7 @@ PsxCreat:
999 goto psx_create_err; 999 goto psx_create_err;
1000 } 1000 }
1001 1001
1002 cFYI(1,("copying inode info")); 1002 cFYI(1, ("copying inode info"));
1003 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 1003 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
1004 1004
1005 if (rc || (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP))) { 1005 if (rc || (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP))) {
@@ -1012,20 +1012,20 @@ PsxCreat:
1012 + le16_to_cpu(pSMBr->t2.DataOffset)); 1012 + le16_to_cpu(pSMBr->t2.DataOffset));
1013 1013
1014 *pOplock = le16_to_cpu(psx_rsp->OplockFlags); 1014 *pOplock = le16_to_cpu(psx_rsp->OplockFlags);
1015 if(netfid) 1015 if (netfid)
1016 *netfid = psx_rsp->Fid; /* cifs fid stays in le */ 1016 *netfid = psx_rsp->Fid; /* cifs fid stays in le */
1017 /* Let caller know file was created so we can set the mode. */ 1017 /* Let caller know file was created so we can set the mode. */
1018 /* Do we care about the CreateAction in any other cases? */ 1018 /* Do we care about the CreateAction in any other cases? */
1019 if(cpu_to_le32(FILE_CREATE) == psx_rsp->CreateAction) 1019 if (cpu_to_le32(FILE_CREATE) == psx_rsp->CreateAction)
1020 *pOplock |= CIFS_CREATE_ACTION; 1020 *pOplock |= CIFS_CREATE_ACTION;
1021 /* check to make sure response data is there */ 1021 /* check to make sure response data is there */
1022 if(psx_rsp->ReturnedLevel != SMB_QUERY_FILE_UNIX_BASIC) { 1022 if (psx_rsp->ReturnedLevel != SMB_QUERY_FILE_UNIX_BASIC) {
1023 pRetData->Type = -1; /* unknown */ 1023 pRetData->Type = -1; /* unknown */
1024#ifdef CONFIG_CIFS_DEBUG2 1024#ifdef CONFIG_CIFS_DEBUG2
1025 cFYI(1,("unknown type")); 1025 cFYI(1, ("unknown type"));
1026#endif 1026#endif
1027 } else { 1027 } else {
1028 if(pSMBr->ByteCount < sizeof(OPEN_PSX_RSP) 1028 if (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP)
1029 + sizeof(FILE_UNIX_BASIC_INFO)) { 1029 + sizeof(FILE_UNIX_BASIC_INFO)) {
1030 cERROR(1,("Open response data too small")); 1030 cERROR(1,("Open response data too small"));
1031 pRetData->Type = -1; 1031 pRetData->Type = -1;
@@ -1072,7 +1072,7 @@ static __u16 convert_disposition(int disposition)
1072 ofun = SMBOPEN_OCREATE | SMBOPEN_OTRUNC; 1072 ofun = SMBOPEN_OCREATE | SMBOPEN_OTRUNC;
1073 break; 1073 break;
1074 default: 1074 default:
1075 cFYI(1,("unknown disposition %d",disposition)); 1075 cFYI(1, ("unknown disposition %d", disposition));
1076 ofun = SMBOPEN_OAPPEND; /* regular open */ 1076 ofun = SMBOPEN_OAPPEND; /* regular open */
1077 } 1077 }
1078 return ofun; 1078 return ofun;
@@ -1131,9 +1131,9 @@ OldOpenRetry:
1131 as fifo and server expecting SFU style and 1131 as fifo and server expecting SFU style and
1132 no Unix extensions */ 1132 no Unix extensions */
1133 1133
1134 if(create_options & CREATE_OPTION_SPECIAL) 1134 if (create_options & CREATE_OPTION_SPECIAL)
1135 pSMB->FileAttributes = cpu_to_le16(ATTR_SYSTEM); 1135 pSMB->FileAttributes = cpu_to_le16(ATTR_SYSTEM);
1136 else 1136 else
1137 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/); /* BB FIXME */ 1137 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/); /* BB FIXME */
1138 1138
1139 /* if ((omode & S_IWUGO) == 0) 1139 /* if ((omode & S_IWUGO) == 0)
@@ -1167,11 +1167,11 @@ OldOpenRetry:
1167 /* Let caller know file was created so we can set the mode. */ 1167 /* Let caller know file was created so we can set the mode. */
1168 /* Do we care about the CreateAction in any other cases? */ 1168 /* Do we care about the CreateAction in any other cases? */
1169 /* BB FIXME BB */ 1169 /* BB FIXME BB */
1170/* if(cpu_to_le32(FILE_CREATE) == pSMBr->CreateAction) 1170/* if (cpu_to_le32(FILE_CREATE) == pSMBr->CreateAction)
1171 *pOplock |= CIFS_CREATE_ACTION; */ 1171 *pOplock |= CIFS_CREATE_ACTION; */
1172 /* BB FIXME END */ 1172 /* BB FIXME END */
1173 1173
1174 if(pfile_info) { 1174 if (pfile_info) {
1175 pfile_info->CreationTime = 0; /* BB convert CreateTime*/ 1175 pfile_info->CreationTime = 0; /* BB convert CreateTime*/
1176 pfile_info->LastAccessTime = 0; /* BB fixme */ 1176 pfile_info->LastAccessTime = 0; /* BB fixme */
1177 pfile_info->LastWriteTime = 0; /* BB fixme */ 1177 pfile_info->LastWriteTime = 0; /* BB fixme */
@@ -1239,7 +1239,7 @@ openRetry:
1239 /* set file as system file if special file such 1239 /* set file as system file if special file such
1240 as fifo and server expecting SFU style and 1240 as fifo and server expecting SFU style and
1241 no Unix extensions */ 1241 no Unix extensions */
1242 if(create_options & CREATE_OPTION_SPECIAL) 1242 if (create_options & CREATE_OPTION_SPECIAL)
1243 pSMB->FileAttributes = cpu_to_le32(ATTR_SYSTEM); 1243 pSMB->FileAttributes = cpu_to_le32(ATTR_SYSTEM);
1244 else 1244 else
1245 pSMB->FileAttributes = cpu_to_le32(ATTR_NORMAL); 1245 pSMB->FileAttributes = cpu_to_le32(ATTR_NORMAL);
@@ -1277,9 +1277,9 @@ openRetry:
1277 *netfid = pSMBr->Fid; /* cifs fid stays in le */ 1277 *netfid = pSMBr->Fid; /* cifs fid stays in le */
1278 /* Let caller know file was created so we can set the mode. */ 1278 /* Let caller know file was created so we can set the mode. */
1279 /* Do we care about the CreateAction in any other cases? */ 1279 /* Do we care about the CreateAction in any other cases? */
1280 if(cpu_to_le32(FILE_CREATE) == pSMBr->CreateAction) 1280 if (cpu_to_le32(FILE_CREATE) == pSMBr->CreateAction)
1281 *pOplock |= CIFS_CREATE_ACTION; 1281 *pOplock |= CIFS_CREATE_ACTION;
1282 if(pfile_info) { 1282 if (pfile_info) {
1283 memcpy((char *)pfile_info,(char *)&pSMBr->CreationTime, 1283 memcpy((char *)pfile_info,(char *)&pSMBr->CreationTime,
1284 36 /* CreationTime to Attributes */); 1284 36 /* CreationTime to Attributes */);
1285 /* the file_info buf is endian converted by caller */ 1285 /* the file_info buf is endian converted by caller */
@@ -1309,8 +1309,8 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
1309 int resp_buf_type = 0; 1309 int resp_buf_type = 0;
1310 struct kvec iov[1]; 1310 struct kvec iov[1];
1311 1311
1312 cFYI(1,("Reading %d bytes on fid %d",count,netfid)); 1312 cFYI(1, ("Reading %d bytes on fid %d", count, netfid));
1313 if(tcon->ses->capabilities & CAP_LARGE_FILES) 1313 if (tcon->ses->capabilities & CAP_LARGE_FILES)
1314 wct = 12; 1314 wct = 12;
1315 else 1315 else
1316 wct = 10; /* old style read */ 1316 wct = 10; /* old style read */
@@ -1327,15 +1327,15 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
1327 pSMB->AndXCommand = 0xFF; /* none */ 1327 pSMB->AndXCommand = 0xFF; /* none */
1328 pSMB->Fid = netfid; 1328 pSMB->Fid = netfid;
1329 pSMB->OffsetLow = cpu_to_le32(lseek & 0xFFFFFFFF); 1329 pSMB->OffsetLow = cpu_to_le32(lseek & 0xFFFFFFFF);
1330 if(wct == 12) 1330 if (wct == 12)
1331 pSMB->OffsetHigh = cpu_to_le32(lseek >> 32); 1331 pSMB->OffsetHigh = cpu_to_le32(lseek >> 32);
1332 else if((lseek >> 32) > 0) /* can not handle this big offset for old */ 1332 else if ((lseek >> 32) > 0) /* can not handle this big offset for old */
1333 return -EIO; 1333 return -EIO;
1334 1334
1335 pSMB->Remaining = 0; 1335 pSMB->Remaining = 0;
1336 pSMB->MaxCount = cpu_to_le16(count & 0xFFFF); 1336 pSMB->MaxCount = cpu_to_le16(count & 0xFFFF);
1337 pSMB->MaxCountHigh = cpu_to_le32(count >> 16); 1337 pSMB->MaxCountHigh = cpu_to_le32(count >> 16);
1338 if(wct == 12) 1338 if (wct == 12)
1339 pSMB->ByteCount = 0; /* no need to do le conversion since 0 */ 1339 pSMB->ByteCount = 0; /* no need to do le conversion since 0 */
1340 else { 1340 else {
1341 /* old style read */ 1341 /* old style read */
@@ -1368,27 +1368,27 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
1368 } else { 1368 } else {
1369 pReadData = (char *) (&pSMBr->hdr.Protocol) + 1369 pReadData = (char *) (&pSMBr->hdr.Protocol) +
1370 le16_to_cpu(pSMBr->DataOffset); 1370 le16_to_cpu(pSMBr->DataOffset);
1371/* if(rc = copy_to_user(buf, pReadData, data_length)) { 1371/* if (rc = copy_to_user(buf, pReadData, data_length)) {
1372 cERROR(1,("Faulting on read rc = %d",rc)); 1372 cERROR(1,("Faulting on read rc = %d",rc));
1373 rc = -EFAULT; 1373 rc = -EFAULT;
1374 }*/ /* can not use copy_to_user when using page cache*/ 1374 }*/ /* can not use copy_to_user when using page cache*/
1375 if(*buf) 1375 if (*buf)
1376 memcpy(*buf,pReadData,data_length); 1376 memcpy(*buf,pReadData,data_length);
1377 } 1377 }
1378 } 1378 }
1379 1379
1380/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */ 1380/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
1381 if(*buf) { 1381 if (*buf) {
1382 if(resp_buf_type == CIFS_SMALL_BUFFER) 1382 if (resp_buf_type == CIFS_SMALL_BUFFER)
1383 cifs_small_buf_release(iov[0].iov_base); 1383 cifs_small_buf_release(iov[0].iov_base);
1384 else if(resp_buf_type == CIFS_LARGE_BUFFER) 1384 else if (resp_buf_type == CIFS_LARGE_BUFFER)
1385 cifs_buf_release(iov[0].iov_base); 1385 cifs_buf_release(iov[0].iov_base);
1386 } else if(resp_buf_type != CIFS_NO_BUFFER) { 1386 } else if (resp_buf_type != CIFS_NO_BUFFER) {
1387 /* return buffer to caller to free */ 1387 /* return buffer to caller to free */
1388 *buf = iov[0].iov_base; 1388 *buf = iov[0].iov_base;
1389 if(resp_buf_type == CIFS_SMALL_BUFFER) 1389 if (resp_buf_type == CIFS_SMALL_BUFFER)
1390 *pbuf_type = CIFS_SMALL_BUFFER; 1390 *pbuf_type = CIFS_SMALL_BUFFER;
1391 else if(resp_buf_type == CIFS_LARGE_BUFFER) 1391 else if (resp_buf_type == CIFS_LARGE_BUFFER)
1392 *pbuf_type = CIFS_LARGE_BUFFER; 1392 *pbuf_type = CIFS_LARGE_BUFFER;
1393 } /* else no valid buffer on return - leave as null */ 1393 } /* else no valid buffer on return - leave as null */
1394 1394
@@ -1412,10 +1412,10 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1412 __u16 byte_count; 1412 __u16 byte_count;
1413 1413
1414 /* cFYI(1,("write at %lld %d bytes",offset,count));*/ 1414 /* cFYI(1,("write at %lld %d bytes",offset,count));*/
1415 if(tcon->ses == NULL) 1415 if (tcon->ses == NULL)
1416 return -ECONNABORTED; 1416 return -ECONNABORTED;
1417 1417
1418 if(tcon->ses->capabilities & CAP_LARGE_FILES) 1418 if (tcon->ses->capabilities & CAP_LARGE_FILES)
1419 wct = 14; 1419 wct = 14;
1420 else 1420 else
1421 wct = 12; 1421 wct = 12;
@@ -1431,9 +1431,9 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1431 pSMB->AndXCommand = 0xFF; /* none */ 1431 pSMB->AndXCommand = 0xFF; /* none */
1432 pSMB->Fid = netfid; 1432 pSMB->Fid = netfid;
1433 pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF); 1433 pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF);
1434 if(wct == 14) 1434 if (wct == 14)
1435 pSMB->OffsetHigh = cpu_to_le32(offset >> 32); 1435 pSMB->OffsetHigh = cpu_to_le32(offset >> 32);
1436 else if((offset >> 32) > 0) /* can not handle this big offset for old */ 1436 else if ((offset >> 32) > 0) /* can not handle big offset for old srv */
1437 return -EIO; 1437 return -EIO;
1438 1438
1439 pSMB->Reserved = 0xFFFFFFFF; 1439 pSMB->Reserved = 0xFFFFFFFF;
@@ -1444,7 +1444,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1444 can send more if LARGE_WRITE_X capability returned by the server and if 1444 can send more if LARGE_WRITE_X capability returned by the server and if
1445 our buffer is big enough or if we convert to iovecs on socket writes 1445 our buffer is big enough or if we convert to iovecs on socket writes
1446 and eliminate the copy to the CIFS buffer */ 1446 and eliminate the copy to the CIFS buffer */
1447 if(tcon->ses->capabilities & CAP_LARGE_WRITE_X) { 1447 if (tcon->ses->capabilities & CAP_LARGE_WRITE_X) {
1448 bytes_sent = min_t(const unsigned int, CIFSMaxBufSize, count); 1448 bytes_sent = min_t(const unsigned int, CIFSMaxBufSize, count);
1449 } else { 1449 } else {
1450 bytes_sent = (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) 1450 bytes_sent = (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE)
@@ -1455,10 +1455,10 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1455 bytes_sent = count; 1455 bytes_sent = count;
1456 pSMB->DataOffset = 1456 pSMB->DataOffset =
1457 cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4); 1457 cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4);
1458 if(buf) 1458 if (buf)
1459 memcpy(pSMB->Data,buf,bytes_sent); 1459 memcpy(pSMB->Data,buf,bytes_sent);
1460 else if(ubuf) { 1460 else if (ubuf) {
1461 if(copy_from_user(pSMB->Data,ubuf,bytes_sent)) { 1461 if (copy_from_user(pSMB->Data, ubuf, bytes_sent)) {
1462 cifs_buf_release(pSMB); 1462 cifs_buf_release(pSMB);
1463 return -EFAULT; 1463 return -EFAULT;
1464 } 1464 }
@@ -1467,7 +1467,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1467 cifs_buf_release(pSMB); 1467 cifs_buf_release(pSMB);
1468 return -EINVAL; 1468 return -EINVAL;
1469 } /* else setting file size with write of zero bytes */ 1469 } /* else setting file size with write of zero bytes */
1470 if(wct == 14) 1470 if (wct == 14)
1471 byte_count = bytes_sent + 1; /* pad */ 1471 byte_count = bytes_sent + 1; /* pad */
1472 else /* wct == 12 */ { 1472 else /* wct == 12 */ {
1473 byte_count = bytes_sent + 5; /* bigger pad, smaller smb hdr */ 1473 byte_count = bytes_sent + 5; /* bigger pad, smaller smb hdr */
@@ -1476,7 +1476,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1476 pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16); 1476 pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16);
1477 pSMB->hdr.smb_buf_length += byte_count; 1477 pSMB->hdr.smb_buf_length += byte_count;
1478 1478
1479 if(wct == 14) 1479 if (wct == 14)
1480 pSMB->ByteCount = cpu_to_le16(byte_count); 1480 pSMB->ByteCount = cpu_to_le16(byte_count);
1481 else { /* old style write has byte count 4 bytes earlier so 4 bytes pad */ 1481 else { /* old style write has byte count 4 bytes earlier so 4 bytes pad */
1482 struct smb_com_writex_req * pSMBW = 1482 struct smb_com_writex_req * pSMBW =
@@ -1516,9 +1516,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1516 int smb_hdr_len; 1516 int smb_hdr_len;
1517 int resp_buf_type = 0; 1517 int resp_buf_type = 0;
1518 1518
1519 cFYI(1,("write2 at %lld %d bytes", (long long)offset, count)); 1519 cFYI(1, ("write2 at %lld %d bytes", (long long)offset, count));
1520 1520
1521 if(tcon->ses->capabilities & CAP_LARGE_FILES) 1521 if (tcon->ses->capabilities & CAP_LARGE_FILES)
1522 wct = 14; 1522 wct = 14;
1523 else 1523 else
1524 wct = 12; 1524 wct = 12;
@@ -1532,9 +1532,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1532 pSMB->AndXCommand = 0xFF; /* none */ 1532 pSMB->AndXCommand = 0xFF; /* none */
1533 pSMB->Fid = netfid; 1533 pSMB->Fid = netfid;
1534 pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF); 1534 pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF);
1535 if(wct == 14) 1535 if (wct == 14)
1536 pSMB->OffsetHigh = cpu_to_le32(offset >> 32); 1536 pSMB->OffsetHigh = cpu_to_le32(offset >> 32);
1537 else if((offset >> 32) > 0) /* can not handle this big offset for old */ 1537 else if ((offset >> 32) > 0) /* can not handle big offset for old srv */
1538 return -EIO; 1538 return -EIO;
1539 pSMB->Reserved = 0xFFFFFFFF; 1539 pSMB->Reserved = 0xFFFFFFFF;
1540 pSMB->WriteMode = 0; 1540 pSMB->WriteMode = 0;
@@ -1546,11 +1546,11 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1546 pSMB->DataLengthLow = cpu_to_le16(count & 0xFFFF); 1546 pSMB->DataLengthLow = cpu_to_le16(count & 0xFFFF);
1547 pSMB->DataLengthHigh = cpu_to_le16(count >> 16); 1547 pSMB->DataLengthHigh = cpu_to_le16(count >> 16);
1548 smb_hdr_len = pSMB->hdr.smb_buf_length + 1; /* hdr + 1 byte pad */ 1548 smb_hdr_len = pSMB->hdr.smb_buf_length + 1; /* hdr + 1 byte pad */
1549 if(wct == 14) 1549 if (wct == 14)
1550 pSMB->hdr.smb_buf_length += count+1; 1550 pSMB->hdr.smb_buf_length += count+1;
1551 else /* wct == 12 */ 1551 else /* wct == 12 */
1552 pSMB->hdr.smb_buf_length += count+5; /* smb data starts later */ 1552 pSMB->hdr.smb_buf_length += count+5; /* smb data starts later */
1553 if(wct == 14) 1553 if (wct == 14)
1554 pSMB->ByteCount = cpu_to_le16(count + 1); 1554 pSMB->ByteCount = cpu_to_le16(count + 1);
1555 else /* wct == 12 */ /* bigger pad, smaller smb hdr, keep offset ok */ { 1555 else /* wct == 12 */ /* bigger pad, smaller smb hdr, keep offset ok */ {
1556 struct smb_com_writex_req * pSMBW = 1556 struct smb_com_writex_req * pSMBW =
@@ -1558,7 +1558,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1558 pSMBW->ByteCount = cpu_to_le16(count + 5); 1558 pSMBW->ByteCount = cpu_to_le16(count + 5);
1559 } 1559 }
1560 iov[0].iov_base = pSMB; 1560 iov[0].iov_base = pSMB;
1561 if(wct == 14) 1561 if (wct == 14)
1562 iov[0].iov_len = smb_hdr_len + 4; 1562 iov[0].iov_len = smb_hdr_len + 4;
1563 else /* wct == 12 pad bigger by four bytes */ 1563 else /* wct == 12 pad bigger by four bytes */
1564 iov[0].iov_len = smb_hdr_len + 8; 1564 iov[0].iov_len = smb_hdr_len + 8;
@@ -1570,7 +1570,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1570 if (rc) { 1570 if (rc) {
1571 cFYI(1, ("Send error Write2 = %d", rc)); 1571 cFYI(1, ("Send error Write2 = %d", rc));
1572 *nbytes = 0; 1572 *nbytes = 0;
1573 } else if(resp_buf_type == 0) { 1573 } else if (resp_buf_type == 0) {
1574 /* presumably this can not happen, but best to be safe */ 1574 /* presumably this can not happen, but best to be safe */
1575 rc = -EIO; 1575 rc = -EIO;
1576 *nbytes = 0; 1576 *nbytes = 0;
@@ -1582,9 +1582,9 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1582 } 1582 }
1583 1583
1584/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */ 1584/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
1585 if(resp_buf_type == CIFS_SMALL_BUFFER) 1585 if (resp_buf_type == CIFS_SMALL_BUFFER)
1586 cifs_small_buf_release(iov[0].iov_base); 1586 cifs_small_buf_release(iov[0].iov_base);
1587 else if(resp_buf_type == CIFS_LARGE_BUFFER) 1587 else if (resp_buf_type == CIFS_LARGE_BUFFER)
1588 cifs_buf_release(iov[0].iov_base); 1588 cifs_buf_release(iov[0].iov_base);
1589 1589
1590 /* Note: On -EAGAIN error only caller can retry on handle based calls 1590 /* Note: On -EAGAIN error only caller can retry on handle based calls
@@ -1615,7 +1615,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1615 1615
1616 pSMBr = (LOCK_RSP *)pSMB; /* BB removeme BB */ 1616 pSMBr = (LOCK_RSP *)pSMB; /* BB removeme BB */
1617 1617
1618 if(lockType == LOCKING_ANDX_OPLOCK_RELEASE) { 1618 if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
1619 timeout = -1; /* no response expected */ 1619 timeout = -1; /* no response expected */
1620 pSMB->Timeout = 0; 1620 pSMB->Timeout = 0;
1621 } else if (waitFlag == TRUE) { 1621 } else if (waitFlag == TRUE) {
@@ -1631,7 +1631,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1631 pSMB->AndXCommand = 0xFF; /* none */ 1631 pSMB->AndXCommand = 0xFF; /* none */
1632 pSMB->Fid = smb_file_id; /* netfid stays le */ 1632 pSMB->Fid = smb_file_id; /* netfid stays le */
1633 1633
1634 if((numLock != 0) || (numUnlock != 0)) { 1634 if ((numLock != 0) || (numUnlock != 0)) {
1635 pSMB->Locks[0].Pid = cpu_to_le16(current->tgid); 1635 pSMB->Locks[0].Pid = cpu_to_le16(current->tgid);
1636 /* BB where to store pid high? */ 1636 /* BB where to store pid high? */
1637 pSMB->Locks[0].LengthLow = cpu_to_le32((u32)len); 1637 pSMB->Locks[0].LengthLow = cpu_to_le32((u32)len);
@@ -1681,7 +1681,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1681 1681
1682 cFYI(1, ("Posix Lock")); 1682 cFYI(1, ("Posix Lock"));
1683 1683
1684 if(pLockData == NULL) 1684 if (pLockData == NULL)
1685 return EINVAL; 1685 return EINVAL;
1686 1686
1687 rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB); 1687 rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);
@@ -1706,7 +1706,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1706 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ 1706 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */
1707 pSMB->SetupCount = 1; 1707 pSMB->SetupCount = 1;
1708 pSMB->Reserved3 = 0; 1708 pSMB->Reserved3 = 0;
1709 if(get_flag) 1709 if (get_flag)
1710 pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION); 1710 pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION);
1711 else 1711 else
1712 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); 1712 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION);
@@ -1720,7 +1720,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1720 (((char *) &pSMB->hdr.Protocol) + offset); 1720 (((char *) &pSMB->hdr.Protocol) + offset);
1721 1721
1722 parm_data->lock_type = cpu_to_le16(lock_type); 1722 parm_data->lock_type = cpu_to_le16(lock_type);
1723 if(waitFlag) { 1723 if (waitFlag) {
1724 timeout = 3; /* blocking operation, no timeout */ 1724 timeout = 3; /* blocking operation, no timeout */
1725 parm_data->lock_flags = cpu_to_le16(1); 1725 parm_data->lock_flags = cpu_to_le16(1);
1726 pSMB->Timeout = cpu_to_le32(-1); 1726 pSMB->Timeout = cpu_to_le32(-1);
@@ -1757,19 +1757,19 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1757 rc = -EIO; /* bad smb */ 1757 rc = -EIO; /* bad smb */
1758 goto plk_err_exit; 1758 goto plk_err_exit;
1759 } 1759 }
1760 if(pLockData == NULL) { 1760 if (pLockData == NULL) {
1761 rc = -EINVAL; 1761 rc = -EINVAL;
1762 goto plk_err_exit; 1762 goto plk_err_exit;
1763 } 1763 }
1764 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 1764 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
1765 data_count = le16_to_cpu(pSMBr->t2.DataCount); 1765 data_count = le16_to_cpu(pSMBr->t2.DataCount);
1766 if(data_count < sizeof(struct cifs_posix_lock)) { 1766 if (data_count < sizeof(struct cifs_posix_lock)) {
1767 rc = -EIO; 1767 rc = -EIO;
1768 goto plk_err_exit; 1768 goto plk_err_exit;
1769 } 1769 }
1770 parm_data = (struct cifs_posix_lock *) 1770 parm_data = (struct cifs_posix_lock *)
1771 ((char *)&pSMBr->hdr.Protocol + data_offset); 1771 ((char *)&pSMBr->hdr.Protocol + data_offset);
1772 if(parm_data->lock_type == cpu_to_le16(CIFS_UNLCK)) 1772 if (parm_data->lock_type == cpu_to_le16(CIFS_UNLCK))
1773 pLockData->fl_type = F_UNLCK; 1773 pLockData->fl_type = F_UNLCK;
1774 } 1774 }
1775 1775
@@ -1795,7 +1795,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
1795 1795
1796/* do not retry on dead session on close */ 1796/* do not retry on dead session on close */
1797 rc = small_smb_init(SMB_COM_CLOSE, 3, tcon, (void **) &pSMB); 1797 rc = small_smb_init(SMB_COM_CLOSE, 3, tcon, (void **) &pSMB);
1798 if(rc == -EAGAIN) 1798 if (rc == -EAGAIN)
1799 return 0; 1799 return 0;
1800 if (rc) 1800 if (rc)
1801 return rc; 1801 return rc;
@@ -1809,7 +1809,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
1809 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1809 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1810 cifs_stats_inc(&tcon->num_closes); 1810 cifs_stats_inc(&tcon->num_closes);
1811 if (rc) { 1811 if (rc) {
1812 if(rc!=-EINTR) { 1812 if (rc != -EINTR) {
1813 /* EINTR is expected when user ctl-c to kill app */ 1813 /* EINTR is expected when user ctl-c to kill app */
1814 cERROR(1, ("Send error in Close = %d", rc)); 1814 cERROR(1, ("Send error in Close = %d", rc));
1815 } 1815 }
@@ -1818,7 +1818,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
1818 cifs_small_buf_release(pSMB); 1818 cifs_small_buf_release(pSMB);
1819 1819
1820 /* Since session is dead, file will be closed on server already */ 1820 /* Since session is dead, file will be closed on server already */
1821 if(rc == -EAGAIN) 1821 if (rc == -EAGAIN)
1822 rc = 0; 1822 rc = 0;
1823 1823
1824 return rc; 1824 return rc;
@@ -1938,7 +1938,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
1938 rename_info->overwrite = cpu_to_le32(1); 1938 rename_info->overwrite = cpu_to_le32(1);
1939 rename_info->root_fid = 0; 1939 rename_info->root_fid = 0;
1940 /* unicode only call */ 1940 /* unicode only call */
1941 if(target_name == NULL) { 1941 if (target_name == NULL) {
1942 sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid); 1942 sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid);
1943 len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name, 1943 len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name,
1944 dummy_string, 24, nls_codepage, remap); 1944 dummy_string, 24, nls_codepage, remap);
@@ -1961,7 +1961,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
1961 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1961 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1962 cifs_stats_inc(&pTcon->num_t2renames); 1962 cifs_stats_inc(&pTcon->num_t2renames);
1963 if (rc) { 1963 if (rc) {
1964 cFYI(1,("Send error in Rename (by file handle) = %d", rc)); 1964 cFYI(1, ("Send error in Rename (by file handle) = %d", rc));
1965 } 1965 }
1966 1966
1967 cifs_buf_release(pSMB); 1967 cifs_buf_release(pSMB);
@@ -2434,7 +2434,7 @@ validate_ntransact(char * buf, char ** ppparm, char ** ppdata,
2434 __u32 data_count, data_offset, parm_count, parm_offset; 2434 __u32 data_count, data_offset, parm_count, parm_offset;
2435 struct smb_com_ntransact_rsp * pSMBr; 2435 struct smb_com_ntransact_rsp * pSMBr;
2436 2436
2437 if(buf == NULL) 2437 if (buf == NULL)
2438 return -EINVAL; 2438 return -EINVAL;
2439 2439
2440 pSMBr = (struct smb_com_ntransact_rsp *)buf; 2440 pSMBr = (struct smb_com_ntransact_rsp *)buf;
@@ -2453,21 +2453,21 @@ validate_ntransact(char * buf, char ** ppparm, char ** ppdata,
2453 *ppdata = (char *)&pSMBr->hdr.Protocol + data_offset; 2453 *ppdata = (char *)&pSMBr->hdr.Protocol + data_offset;
2454 2454
2455 /* should we also check that parm and data areas do not overlap? */ 2455 /* should we also check that parm and data areas do not overlap? */
2456 if(*ppparm > end_of_smb) { 2456 if (*ppparm > end_of_smb) {
2457 cFYI(1,("parms start after end of smb")); 2457 cFYI(1, ("parms start after end of smb"));
2458 return -EINVAL; 2458 return -EINVAL;
2459 } else if(parm_count + *ppparm > end_of_smb) { 2459 } else if (parm_count + *ppparm > end_of_smb) {
2460 cFYI(1,("parm end after end of smb")); 2460 cFYI(1, ("parm end after end of smb"));
2461 return -EINVAL; 2461 return -EINVAL;
2462 } else if(*ppdata > end_of_smb) { 2462 } else if (*ppdata > end_of_smb) {
2463 cFYI(1,("data starts after end of smb")); 2463 cFYI(1, ("data starts after end of smb"));
2464 return -EINVAL; 2464 return -EINVAL;
2465 } else if(data_count + *ppdata > end_of_smb) { 2465 } else if (data_count + *ppdata > end_of_smb) {
2466 cFYI(1,("data %p + count %d (%p) ends after end of smb %p start %p", 2466 cFYI(1,("data %p + count %d (%p) ends after end of smb %p start %p",
2467 *ppdata, data_count, (data_count + *ppdata), end_of_smb, pSMBr)); /* BB FIXME */ 2467 *ppdata, data_count, (data_count + *ppdata), end_of_smb, pSMBr)); /* BB FIXME */
2468 return -EINVAL; 2468 return -EINVAL;
2469 } else if(parm_count + data_count > pSMBr->ByteCount) { 2469 } else if (parm_count + data_count > pSMBr->ByteCount) {
2470 cFYI(1,("parm count and data count larger than SMB")); 2470 cFYI(1, ("parm count and data count larger than SMB"));
2471 return -EINVAL; 2471 return -EINVAL;
2472 } 2472 }
2473 return 0; 2473 return 0;
@@ -2522,18 +2522,18 @@ CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon,
2522 /* BB also check enough total bytes returned */ 2522 /* BB also check enough total bytes returned */
2523 rc = -EIO; /* bad smb */ 2523 rc = -EIO; /* bad smb */
2524 else { 2524 else {
2525 if(data_count && (data_count < 2048)) { 2525 if (data_count && (data_count < 2048)) {
2526 char * end_of_smb = 2 /* sizeof byte count */ + 2526 char * end_of_smb = 2 /* sizeof byte count */ +
2527 pSMBr->ByteCount + 2527 pSMBr->ByteCount +
2528 (char *)&pSMBr->ByteCount; 2528 (char *)&pSMBr->ByteCount;
2529 2529
2530 struct reparse_data * reparse_buf = (struct reparse_data *) 2530 struct reparse_data * reparse_buf = (struct reparse_data *)
2531 ((char *)&pSMBr->hdr.Protocol + data_offset); 2531 ((char *)&pSMBr->hdr.Protocol + data_offset);
2532 if((char*)reparse_buf >= end_of_smb) { 2532 if ((char *)reparse_buf >= end_of_smb) {
2533 rc = -EIO; 2533 rc = -EIO;
2534 goto qreparse_out; 2534 goto qreparse_out;
2535 } 2535 }
2536 if((reparse_buf->LinkNamesBuf + 2536 if ((reparse_buf->LinkNamesBuf +
2537 reparse_buf->TargetNameOffset + 2537 reparse_buf->TargetNameOffset +
2538 reparse_buf->TargetNameLen) > 2538 reparse_buf->TargetNameLen) >
2539 end_of_smb) { 2539 end_of_smb) {
@@ -2602,17 +2602,17 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
2602 if (le16_to_cpu(cifs_acl->version) != CIFS_ACL_VERSION) 2602 if (le16_to_cpu(cifs_acl->version) != CIFS_ACL_VERSION)
2603 return -EOPNOTSUPP; 2603 return -EOPNOTSUPP;
2604 2604
2605 if(acl_type & ACL_TYPE_ACCESS) { 2605 if (acl_type & ACL_TYPE_ACCESS) {
2606 count = le16_to_cpu(cifs_acl->access_entry_count); 2606 count = le16_to_cpu(cifs_acl->access_entry_count);
2607 pACE = &cifs_acl->ace_array[0]; 2607 pACE = &cifs_acl->ace_array[0];
2608 size = sizeof(struct cifs_posix_acl); 2608 size = sizeof(struct cifs_posix_acl);
2609 size += sizeof(struct cifs_posix_ace) * count; 2609 size += sizeof(struct cifs_posix_ace) * count;
2610 /* check if we would go beyond end of SMB */ 2610 /* check if we would go beyond end of SMB */
2611 if(size_of_data_area < size) { 2611 if (size_of_data_area < size) {
2612 cFYI(1,("bad CIFS POSIX ACL size %d vs. %d",size_of_data_area,size)); 2612 cFYI(1,("bad CIFS POSIX ACL size %d vs. %d",size_of_data_area,size));
2613 return -EINVAL; 2613 return -EINVAL;
2614 } 2614 }
2615 } else if(acl_type & ACL_TYPE_DEFAULT) { 2615 } else if (acl_type & ACL_TYPE_DEFAULT) {
2616 count = le16_to_cpu(cifs_acl->access_entry_count); 2616 count = le16_to_cpu(cifs_acl->access_entry_count);
2617 size = sizeof(struct cifs_posix_acl); 2617 size = sizeof(struct cifs_posix_acl);
2618 size += sizeof(struct cifs_posix_ace) * count; 2618 size += sizeof(struct cifs_posix_ace) * count;
@@ -2621,7 +2621,7 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
2621 count = le16_to_cpu(cifs_acl->default_entry_count); 2621 count = le16_to_cpu(cifs_acl->default_entry_count);
2622 size += sizeof(struct cifs_posix_ace) * count; 2622 size += sizeof(struct cifs_posix_ace) * count;
2623 /* check if we would go beyond end of SMB */ 2623 /* check if we would go beyond end of SMB */
2624 if(size_of_data_area < size) 2624 if (size_of_data_area < size)
2625 return -EINVAL; 2625 return -EINVAL;
2626 } else { 2626 } else {
2627 /* illegal type */ 2627 /* illegal type */
@@ -2629,9 +2629,9 @@ static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
2629 } 2629 }
2630 2630
2631 size = posix_acl_xattr_size(count); 2631 size = posix_acl_xattr_size(count);
2632 if((buflen == 0) || (local_acl == NULL)) { 2632 if ((buflen == 0) || (local_acl == NULL)) {
2633 /* used to query ACL EA size */ 2633 /* used to query ACL EA size */
2634 } else if(size > buflen) { 2634 } else if (size > buflen) {
2635 return -ERANGE; 2635 return -ERANGE;
2636 } else /* buffer big enough */ { 2636 } else /* buffer big enough */ {
2637 local_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION); 2637 local_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);
@@ -2651,7 +2651,7 @@ static __u16 convert_ace_to_cifs_ace(struct cifs_posix_ace * cifs_ace,
2651 cifs_ace->cifs_e_perm = le16_to_cpu(local_ace->e_perm); 2651 cifs_ace->cifs_e_perm = le16_to_cpu(local_ace->e_perm);
2652 cifs_ace->cifs_e_tag = le16_to_cpu(local_ace->e_tag); 2652 cifs_ace->cifs_e_tag = le16_to_cpu(local_ace->e_tag);
2653 /* BB is there a better way to handle the large uid? */ 2653 /* BB is there a better way to handle the large uid? */
2654 if(local_ace->e_id == cpu_to_le32(-1)) { 2654 if (local_ace->e_id == cpu_to_le32(-1)) {
2655 /* Probably no need to le convert -1 on any arch but can not hurt */ 2655 /* Probably no need to le convert -1 on any arch but can not hurt */
2656 cifs_ace->cifs_uid = cpu_to_le64(-1); 2656 cifs_ace->cifs_uid = cpu_to_le64(-1);
2657 } else 2657 } else
@@ -2670,21 +2670,21 @@ static __u16 ACL_to_cifs_posix(char * parm_data,const char * pACL,const int bufl
2670 int count; 2670 int count;
2671 int i; 2671 int i;
2672 2672
2673 if((buflen == 0) || (pACL == NULL) || (cifs_acl == NULL)) 2673 if ((buflen == 0) || (pACL == NULL) || (cifs_acl == NULL))
2674 return 0; 2674 return 0;
2675 2675
2676 count = posix_acl_xattr_count((size_t)buflen); 2676 count = posix_acl_xattr_count((size_t)buflen);
2677 cFYI(1,("setting acl with %d entries from buf of length %d and version of %d", 2677 cFYI(1,("setting acl with %d entries from buf of length %d and version of %d",
2678 count, buflen, le32_to_cpu(local_acl->a_version))); 2678 count, buflen, le32_to_cpu(local_acl->a_version)));
2679 if(le32_to_cpu(local_acl->a_version) != 2) { 2679 if (le32_to_cpu(local_acl->a_version) != 2) {
2680 cFYI(1,("unknown POSIX ACL version %d", 2680 cFYI(1,("unknown POSIX ACL version %d",
2681 le32_to_cpu(local_acl->a_version))); 2681 le32_to_cpu(local_acl->a_version)));
2682 return 0; 2682 return 0;
2683 } 2683 }
2684 cifs_acl->version = cpu_to_le16(1); 2684 cifs_acl->version = cpu_to_le16(1);
2685 if(acl_type == ACL_TYPE_ACCESS) 2685 if (acl_type == ACL_TYPE_ACCESS)
2686 cifs_acl->access_entry_count = cpu_to_le16(count); 2686 cifs_acl->access_entry_count = cpu_to_le16(count);
2687 else if(acl_type == ACL_TYPE_DEFAULT) 2687 else if (acl_type == ACL_TYPE_DEFAULT)
2688 cifs_acl->default_entry_count = cpu_to_le16(count); 2688 cifs_acl->default_entry_count = cpu_to_le16(count);
2689 else { 2689 else {
2690 cFYI(1,("unknown ACL type %d",acl_type)); 2690 cFYI(1,("unknown ACL type %d",acl_type));
@@ -2693,12 +2693,12 @@ static __u16 ACL_to_cifs_posix(char * parm_data,const char * pACL,const int bufl
2693 for(i=0;i<count;i++) { 2693 for(i=0;i<count;i++) {
2694 rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i], 2694 rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i],
2695 &local_acl->a_entries[i]); 2695 &local_acl->a_entries[i]);
2696 if(rc != 0) { 2696 if (rc != 0) {
2697 /* ACE not converted */ 2697 /* ACE not converted */
2698 break; 2698 break;
2699 } 2699 }
2700 } 2700 }
2701 if(rc == 0) { 2701 if (rc == 0) {
2702 rc = (__u16)(count * sizeof(struct cifs_posix_ace)); 2702 rc = (__u16)(count * sizeof(struct cifs_posix_ace));
2703 rc += sizeof(struct cifs_posix_acl); 2703 rc += sizeof(struct cifs_posix_acl);
2704 /* BB add check to make sure ACL does not overflow SMB */ 2704 /* BB add check to make sure ACL does not overflow SMB */
@@ -2842,7 +2842,7 @@ setAclRetry:
2842 /* convert to on the wire format for POSIX ACL */ 2842 /* convert to on the wire format for POSIX ACL */
2843 data_count = ACL_to_cifs_posix(parm_data,local_acl,buflen,acl_type); 2843 data_count = ACL_to_cifs_posix(parm_data,local_acl,buflen,acl_type);
2844 2844
2845 if(data_count == 0) { 2845 if (data_count == 0) {
2846 rc = -EOPNOTSUPP; 2846 rc = -EOPNOTSUPP;
2847 goto setACLerrorExit; 2847 goto setACLerrorExit;
2848 } 2848 }
@@ -2883,78 +2883,77 @@ CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
2883 int bytes_returned; 2883 int bytes_returned;
2884 __u16 params, byte_count; 2884 __u16 params, byte_count;
2885 2885
2886 cFYI(1,("In GetExtAttr")); 2886 cFYI(1, ("In GetExtAttr"));
2887 if(tcon == NULL) 2887 if (tcon == NULL)
2888 return -ENODEV; 2888 return -ENODEV;
2889 2889
2890GetExtAttrRetry: 2890GetExtAttrRetry:
2891 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, 2891 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
2892 (void **) &pSMBr); 2892 (void **) &pSMBr);
2893 if (rc) 2893 if (rc)
2894 return rc; 2894 return rc;
2895 2895
2896 params = 2 /* level */ +2 /* fid */; 2896 params = 2 /* level */ +2 /* fid */;
2897 pSMB->t2.TotalDataCount = 0; 2897 pSMB->t2.TotalDataCount = 0;
2898 pSMB->t2.MaxParameterCount = cpu_to_le16(4); 2898 pSMB->t2.MaxParameterCount = cpu_to_le16(4);
2899 /* BB find exact max data count below from sess structure BB */ 2899 /* BB find exact max data count below from sess structure BB */
2900 pSMB->t2.MaxDataCount = cpu_to_le16(4000); 2900 pSMB->t2.MaxDataCount = cpu_to_le16(4000);
2901 pSMB->t2.MaxSetupCount = 0; 2901 pSMB->t2.MaxSetupCount = 0;
2902 pSMB->t2.Reserved = 0; 2902 pSMB->t2.Reserved = 0;
2903 pSMB->t2.Flags = 0; 2903 pSMB->t2.Flags = 0;
2904 pSMB->t2.Timeout = 0; 2904 pSMB->t2.Timeout = 0;
2905 pSMB->t2.Reserved2 = 0; 2905 pSMB->t2.Reserved2 = 0;
2906 pSMB->t2.ParameterOffset = cpu_to_le16(offsetof(struct smb_t2_qfi_req, 2906 pSMB->t2.ParameterOffset = cpu_to_le16(offsetof(struct smb_t2_qfi_req,
2907 Fid) - 4); 2907 Fid) - 4);
2908 pSMB->t2.DataCount = 0; 2908 pSMB->t2.DataCount = 0;
2909 pSMB->t2.DataOffset = 0; 2909 pSMB->t2.DataOffset = 0;
2910 pSMB->t2.SetupCount = 1; 2910 pSMB->t2.SetupCount = 1;
2911 pSMB->t2.Reserved3 = 0; 2911 pSMB->t2.Reserved3 = 0;
2912 pSMB->t2.SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION); 2912 pSMB->t2.SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION);
2913 byte_count = params + 1 /* pad */ ; 2913 byte_count = params + 1 /* pad */ ;
2914 pSMB->t2.TotalParameterCount = cpu_to_le16(params); 2914 pSMB->t2.TotalParameterCount = cpu_to_le16(params);
2915 pSMB->t2.ParameterCount = pSMB->t2.TotalParameterCount; 2915 pSMB->t2.ParameterCount = pSMB->t2.TotalParameterCount;
2916 pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_ATTR_FLAGS); 2916 pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_ATTR_FLAGS);
2917 pSMB->Pad = 0; 2917 pSMB->Pad = 0;
2918 pSMB->Fid = netfid; 2918 pSMB->Fid = netfid;
2919 pSMB->hdr.smb_buf_length += byte_count; 2919 pSMB->hdr.smb_buf_length += byte_count;
2920 pSMB->t2.ByteCount = cpu_to_le16(byte_count); 2920 pSMB->t2.ByteCount = cpu_to_le16(byte_count);
2921 2921
2922 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2922 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2923 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2923 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2924 if (rc) { 2924 if (rc) {
2925 cFYI(1, ("error %d in GetExtAttr", rc)); 2925 cFYI(1, ("error %d in GetExtAttr", rc));
2926 } else { 2926 } else {
2927 /* decode response */ 2927 /* decode response */
2928 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 2928 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
2929 if (rc || (pSMBr->ByteCount < 2)) 2929 if (rc || (pSMBr->ByteCount < 2))
2930 /* BB also check enough total bytes returned */ 2930 /* BB also check enough total bytes returned */
2931 /* If rc should we check for EOPNOSUPP and 2931 /* If rc should we check for EOPNOSUPP and
2932 disable the srvino flag? or in caller? */ 2932 disable the srvino flag? or in caller? */
2933 rc = -EIO; /* bad smb */ 2933 rc = -EIO; /* bad smb */
2934 else { 2934 else {
2935 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 2935 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
2936 __u16 count = le16_to_cpu(pSMBr->t2.DataCount); 2936 __u16 count = le16_to_cpu(pSMBr->t2.DataCount);
2937 struct file_chattr_info * pfinfo; 2937 struct file_chattr_info *pfinfo;
2938 /* BB Do we need a cast or hash here ? */ 2938 /* BB Do we need a cast or hash here ? */
2939 if(count != 16) { 2939 if (count != 16) {
2940 cFYI(1, ("Illegal size ret in GetExtAttr")); 2940 cFYI(1, ("Illegal size ret in GetExtAttr"));
2941 rc = -EIO; 2941 rc = -EIO;
2942 goto GetExtAttrOut; 2942 goto GetExtAttrOut;
2943 } 2943 }
2944 pfinfo = (struct file_chattr_info *) 2944 pfinfo = (struct file_chattr_info *)
2945 (data_offset + (char *) &pSMBr->hdr.Protocol); 2945 (data_offset + (char *) &pSMBr->hdr.Protocol);
2946 *pExtAttrBits = le64_to_cpu(pfinfo->mode); 2946 *pExtAttrBits = le64_to_cpu(pfinfo->mode);
2947 *pMask = le64_to_cpu(pfinfo->mask); 2947 *pMask = le64_to_cpu(pfinfo->mask);
2948 } 2948 }
2949 } 2949 }
2950GetExtAttrOut: 2950GetExtAttrOut:
2951 cifs_buf_release(pSMB); 2951 cifs_buf_release(pSMB);
2952 if (rc == -EAGAIN) 2952 if (rc == -EAGAIN)
2953 goto GetExtAttrRetry; 2953 goto GetExtAttrRetry;
2954 return rc; 2954 return rc;
2955} 2955}
2956 2956
2957
2958#endif /* CONFIG_POSIX */ 2957#endif /* CONFIG_POSIX */
2959 2958
2960 2959
@@ -3017,7 +3016,7 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
3017 (char **)&psec_desc, 3016 (char **)&psec_desc,
3018 &parm_len, &data_len); 3017 &parm_len, &data_len);
3019 3018
3020 if(rc) 3019 if (rc)
3021 goto qsec_out; 3020 goto qsec_out;
3022 pSMBr = (struct smb_com_ntransact_rsp *)iov[0].iov_base; 3021 pSMBr = (struct smb_com_ntransact_rsp *)iov[0].iov_base;
3023 3022
@@ -3031,14 +3030,14 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
3031/* BB check that data area is minimum length and as big as acl_len */ 3030/* BB check that data area is minimum length and as big as acl_len */
3032 3031
3033 acl_len = le32_to_cpu(*(__le32 *)parm); 3032 acl_len = le32_to_cpu(*(__le32 *)parm);
3034 /* BB check if(acl_len > bufsize) */ 3033 /* BB check if (acl_len > bufsize) */
3035 3034
3036 parse_sec_desc(psec_desc, acl_len); 3035 parse_sec_desc(psec_desc, acl_len);
3037 } 3036 }
3038qsec_out: 3037qsec_out:
3039 if(buf_type == CIFS_SMALL_BUFFER) 3038 if (buf_type == CIFS_SMALL_BUFFER)
3040 cifs_small_buf_release(iov[0].iov_base); 3039 cifs_small_buf_release(iov[0].iov_base);
3041 else if(buf_type == CIFS_LARGE_BUFFER) 3040 else if (buf_type == CIFS_LARGE_BUFFER)
3042 cifs_buf_release(iov[0].iov_base); 3041 cifs_buf_release(iov[0].iov_base);
3043/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */ 3042/* cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
3044 return rc; 3043 return rc;
@@ -3167,7 +3166,7 @@ QPathInfoRetry:
3167 byte_count = params + 1 /* pad */ ; 3166 byte_count = params + 1 /* pad */ ;
3168 pSMB->TotalParameterCount = cpu_to_le16(params); 3167 pSMB->TotalParameterCount = cpu_to_le16(params);
3169 pSMB->ParameterCount = pSMB->TotalParameterCount; 3168 pSMB->ParameterCount = pSMB->TotalParameterCount;
3170 if(legacy) 3169 if (legacy)
3171 pSMB->InformationLevel = cpu_to_le16(SMB_INFO_STANDARD); 3170 pSMB->InformationLevel = cpu_to_le16(SMB_INFO_STANDARD);
3172 else 3171 else
3173 pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO); 3172 pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO);
@@ -3186,14 +3185,15 @@ QPathInfoRetry:
3186 rc = -EIO; 3185 rc = -EIO;
3187 else if (!legacy && (pSMBr->ByteCount < 40)) 3186 else if (!legacy && (pSMBr->ByteCount < 40))
3188 rc = -EIO; /* bad smb */ 3187 rc = -EIO; /* bad smb */
3189 else if(legacy && (pSMBr->ByteCount < 24)) 3188 else if (legacy && (pSMBr->ByteCount < 24))
3190 rc = -EIO; /* 24 or 26 expected but we do not read last field */ 3189 rc = -EIO; /* 24 or 26 expected but we do not read last field */
3191 else if (pFindData){ 3190 else if (pFindData){
3192 int size; 3191 int size;
3193 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 3192 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
3194 if(legacy) /* we do not read the last field, EAsize, fortunately 3193 if (legacy) /* we do not read the last field, EAsize,
3195 since it varies by subdialect and on Set vs. Get, is 3194 fortunately since it varies by subdialect
3196 two bytes or 4 bytes depending but we don't care here */ 3195 and on Set vs. Get, is two bytes or 4
3196 bytes depending but we don't care here */
3197 size = sizeof(FILE_INFO_STANDARD); 3197 size = sizeof(FILE_INFO_STANDARD);
3198 else 3198 else
3199 size = sizeof(FILE_ALL_INFO); 3199 size = sizeof(FILE_ALL_INFO);
@@ -3416,7 +3416,7 @@ findFirstRetry:
3416 } else { /* BB add check for overrun of SMB buf BB */ 3416 } else { /* BB add check for overrun of SMB buf BB */
3417 name_len = strnlen(searchName, PATH_MAX); 3417 name_len = strnlen(searchName, PATH_MAX);
3418/* BB fix here and in unicode clause above ie 3418/* BB fix here and in unicode clause above ie
3419 if(name_len > buffersize-header) 3419 if (name_len > buffersize-header)
3420 free buffer exit; BB */ 3420 free buffer exit; BB */
3421 strncpy(pSMB->FileName, searchName, name_len); 3421 strncpy(pSMB->FileName, searchName, name_len);
3422 pSMB->FileName[name_len] = dirsep; 3422 pSMB->FileName[name_len] = dirsep;
@@ -3477,7 +3477,7 @@ findFirstRetry:
3477 } else { /* decode response */ 3477 } else { /* decode response */
3478 /* BB remember to free buffer if error BB */ 3478 /* BB remember to free buffer if error BB */
3479 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 3479 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
3480 if(rc == 0) { 3480 if (rc == 0) {
3481 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) 3481 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
3482 psrch_inf->unicode = TRUE; 3482 psrch_inf->unicode = TRUE;
3483 else 3483 else
@@ -3491,7 +3491,7 @@ findFirstRetry:
3491 parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol + 3491 parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol +
3492 le16_to_cpu(pSMBr->t2.ParameterOffset)); 3492 le16_to_cpu(pSMBr->t2.ParameterOffset));
3493 3493
3494 if(parms->EndofSearch) 3494 if (parms->EndofSearch)
3495 psrch_inf->endOfSearch = TRUE; 3495 psrch_inf->endOfSearch = TRUE;
3496 else 3496 else
3497 psrch_inf->endOfSearch = FALSE; 3497 psrch_inf->endOfSearch = FALSE;
@@ -3521,7 +3521,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3521 3521
3522 cFYI(1, ("In FindNext")); 3522 cFYI(1, ("In FindNext"));
3523 3523
3524 if(psrch_inf->endOfSearch == TRUE) 3524 if (psrch_inf->endOfSearch == TRUE)
3525 return -ENOENT; 3525 return -ENOENT;
3526 3526
3527 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, 3527 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
@@ -3566,7 +3566,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3566 3566
3567 name_len = psrch_inf->resume_name_len; 3567 name_len = psrch_inf->resume_name_len;
3568 params += name_len; 3568 params += name_len;
3569 if(name_len < PATH_MAX) { 3569 if (name_len < PATH_MAX) {
3570 memcpy(pSMB->ResumeFileName, psrch_inf->presume_name, name_len); 3570 memcpy(pSMB->ResumeFileName, psrch_inf->presume_name, name_len);
3571 byte_count += name_len; 3571 byte_count += name_len;
3572 /* 14 byte parm len above enough for 2 byte null terminator */ 3572 /* 14 byte parm len above enough for 2 byte null terminator */
@@ -3594,7 +3594,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3594 } else { /* decode response */ 3594 } else { /* decode response */
3595 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 3595 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
3596 3596
3597 if(rc == 0) { 3597 if (rc == 0) {
3598 /* BB fixme add lock for file (srch_info) struct here */ 3598 /* BB fixme add lock for file (srch_info) struct here */
3599 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) 3599 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
3600 psrch_inf->unicode = TRUE; 3600 psrch_inf->unicode = TRUE;
@@ -3605,7 +3605,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3605 parms = (T2_FNEXT_RSP_PARMS *)response_data; 3605 parms = (T2_FNEXT_RSP_PARMS *)response_data;
3606 response_data = (char *)&pSMBr->hdr.Protocol + 3606 response_data = (char *)&pSMBr->hdr.Protocol +
3607 le16_to_cpu(pSMBr->t2.DataOffset); 3607 le16_to_cpu(pSMBr->t2.DataOffset);
3608 if(psrch_inf->smallBuf) 3608 if (psrch_inf->smallBuf)
3609 cifs_small_buf_release( 3609 cifs_small_buf_release(
3610 psrch_inf->ntwrk_buf_start); 3610 psrch_inf->ntwrk_buf_start);
3611 else 3611 else
@@ -3613,7 +3613,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3613 psrch_inf->srch_entries_start = response_data; 3613 psrch_inf->srch_entries_start = response_data;
3614 psrch_inf->ntwrk_buf_start = (char *)pSMB; 3614 psrch_inf->ntwrk_buf_start = (char *)pSMB;
3615 psrch_inf->smallBuf = 0; 3615 psrch_inf->smallBuf = 0;
3616 if(parms->EndofSearch) 3616 if (parms->EndofSearch)
3617 psrch_inf->endOfSearch = TRUE; 3617 psrch_inf->endOfSearch = TRUE;
3618 else 3618 else
3619 psrch_inf->endOfSearch = FALSE; 3619 psrch_inf->endOfSearch = FALSE;
@@ -3653,7 +3653,7 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon, const __u16 searchHandle
3653 3653
3654 /* no sense returning error if session restarted 3654 /* no sense returning error if session restarted
3655 as file handle has been closed */ 3655 as file handle has been closed */
3656 if(rc == -EAGAIN) 3656 if (rc == -EAGAIN)
3657 return 0; 3657 return 0;
3658 if (rc) 3658 if (rc)
3659 return rc; 3659 return rc;
@@ -3689,7 +3689,7 @@ CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
3689 __u16 params, byte_count; 3689 __u16 params, byte_count;
3690 3690
3691 cFYI(1,("In GetSrvInodeNum for %s",searchName)); 3691 cFYI(1,("In GetSrvInodeNum for %s",searchName));
3692 if(tcon == NULL) 3692 if (tcon == NULL)
3693 return -ENODEV; 3693 return -ENODEV;
3694 3694
3695GetInodeNumberRetry: 3695GetInodeNumberRetry:
@@ -3753,7 +3753,7 @@ GetInodeNumberRetry:
3753 __u16 count = le16_to_cpu(pSMBr->t2.DataCount); 3753 __u16 count = le16_to_cpu(pSMBr->t2.DataCount);
3754 struct file_internal_info * pfinfo; 3754 struct file_internal_info * pfinfo;
3755 /* BB Do we need a cast or hash here ? */ 3755 /* BB Do we need a cast or hash here ? */
3756 if(count < 8) { 3756 if (count < 8) {
3757 cFYI(1, ("Illegal size ret in QryIntrnlInf")); 3757 cFYI(1, ("Illegal size ret in QryIntrnlInf"));
3758 rc = -EIO; 3758 rc = -EIO;
3759 goto GetInodeNumOut; 3759 goto GetInodeNumOut;
@@ -3824,8 +3824,8 @@ getDFSRetry:
3824 strncpy(pSMB->RequestFileName, searchName, name_len); 3824 strncpy(pSMB->RequestFileName, searchName, name_len);
3825 } 3825 }
3826 3826
3827 if(ses->server) { 3827 if (ses->server) {
3828 if(ses->server->secMode & 3828 if (ses->server->secMode &
3829 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 3829 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
3830 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 3830 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
3831 } 3831 }
@@ -3885,7 +3885,7 @@ getDFSRetry:
3885 *number_of_UNC_in_array = le16_to_cpu(pSMBr->NumberOfReferrals); 3885 *number_of_UNC_in_array = le16_to_cpu(pSMBr->NumberOfReferrals);
3886 3886
3887 /* BB Fix below so can return more than one referral */ 3887 /* BB Fix below so can return more than one referral */
3888 if(*number_of_UNC_in_array > 1) 3888 if (*number_of_UNC_in_array > 1)
3889 *number_of_UNC_in_array = 1; 3889 *number_of_UNC_in_array = 1;
3890 3890
3891 /* get the length of the strings describing refs */ 3891 /* get the length of the strings describing refs */
@@ -3913,7 +3913,7 @@ getDFSRetry:
3913 /* BB add check for name_len bigger than bcc */ 3913 /* BB add check for name_len bigger than bcc */
3914 *targetUNCs = 3914 *targetUNCs =
3915 kmalloc(name_len+1+ (*number_of_UNC_in_array),GFP_KERNEL); 3915 kmalloc(name_len+1+ (*number_of_UNC_in_array),GFP_KERNEL);
3916 if(*targetUNCs == NULL) { 3916 if (*targetUNCs == NULL) {
3917 rc = -ENOMEM; 3917 rc = -ENOMEM;
3918 goto GetDFSRefExit; 3918 goto GetDFSRefExit;
3919 } 3919 }
@@ -4458,16 +4458,16 @@ QFSPosixRetry:
4458 le64_to_cpu(response_data->TotalBlocks); 4458 le64_to_cpu(response_data->TotalBlocks);
4459 FSData->f_bfree = 4459 FSData->f_bfree =
4460 le64_to_cpu(response_data->BlocksAvail); 4460 le64_to_cpu(response_data->BlocksAvail);
4461 if(response_data->UserBlocksAvail == cpu_to_le64(-1)) { 4461 if (response_data->UserBlocksAvail == cpu_to_le64(-1)) {
4462 FSData->f_bavail = FSData->f_bfree; 4462 FSData->f_bavail = FSData->f_bfree;
4463 } else { 4463 } else {
4464 FSData->f_bavail = 4464 FSData->f_bavail =
4465 le64_to_cpu(response_data->UserBlocksAvail); 4465 le64_to_cpu(response_data->UserBlocksAvail);
4466 } 4466 }
4467 if(response_data->TotalFileNodes != cpu_to_le64(-1)) 4467 if (response_data->TotalFileNodes != cpu_to_le64(-1))
4468 FSData->f_files = 4468 FSData->f_files =
4469 le64_to_cpu(response_data->TotalFileNodes); 4469 le64_to_cpu(response_data->TotalFileNodes);
4470 if(response_data->FreeFileNodes != cpu_to_le64(-1)) 4470 if (response_data->FreeFileNodes != cpu_to_le64(-1))
4471 FSData->f_ffree = 4471 FSData->f_ffree =
4472 le64_to_cpu(response_data->FreeFileNodes); 4472 le64_to_cpu(response_data->FreeFileNodes);
4473 } 4473 }
@@ -4530,7 +4530,7 @@ SetEOFRetry:
4530 param_offset = offsetof(struct smb_com_transaction2_spi_req, 4530 param_offset = offsetof(struct smb_com_transaction2_spi_req,
4531 InformationLevel) - 4; 4531 InformationLevel) - 4;
4532 offset = param_offset + params; 4532 offset = param_offset + params;
4533 if(SetAllocation) { 4533 if (SetAllocation) {
4534 if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU) 4534 if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)
4535 pSMB->InformationLevel = 4535 pSMB->InformationLevel =
4536 cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2); 4536 cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2);
@@ -4630,7 +4630,7 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
4630 pSMB->DataOffset = cpu_to_le16(offset); 4630 pSMB->DataOffset = cpu_to_le16(offset);
4631 parm_data->FileSize = cpu_to_le64(size); 4631 parm_data->FileSize = cpu_to_le64(size);
4632 pSMB->Fid = fid; 4632 pSMB->Fid = fid;
4633 if(SetAllocation) { 4633 if (SetAllocation) {
4634 if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU) 4634 if (tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)
4635 pSMB->InformationLevel = 4635 pSMB->InformationLevel =
4636 cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2); 4636 cpu_to_le16(SMB_SET_FILE_ALLOCATION_INFO2);
@@ -4955,19 +4955,19 @@ setPermsRetry:
4955 data_offset->DevMinor = cpu_to_le64(MINOR(device)); 4955 data_offset->DevMinor = cpu_to_le64(MINOR(device));
4956 data_offset->Permissions = cpu_to_le64(mode); 4956 data_offset->Permissions = cpu_to_le64(mode);
4957 4957
4958 if(S_ISREG(mode)) 4958 if (S_ISREG(mode))
4959 data_offset->Type = cpu_to_le32(UNIX_FILE); 4959 data_offset->Type = cpu_to_le32(UNIX_FILE);
4960 else if(S_ISDIR(mode)) 4960 else if (S_ISDIR(mode))
4961 data_offset->Type = cpu_to_le32(UNIX_DIR); 4961 data_offset->Type = cpu_to_le32(UNIX_DIR);
4962 else if(S_ISLNK(mode)) 4962 else if (S_ISLNK(mode))
4963 data_offset->Type = cpu_to_le32(UNIX_SYMLINK); 4963 data_offset->Type = cpu_to_le32(UNIX_SYMLINK);
4964 else if(S_ISCHR(mode)) 4964 else if (S_ISCHR(mode))
4965 data_offset->Type = cpu_to_le32(UNIX_CHARDEV); 4965 data_offset->Type = cpu_to_le32(UNIX_CHARDEV);
4966 else if(S_ISBLK(mode)) 4966 else if (S_ISBLK(mode))
4967 data_offset->Type = cpu_to_le32(UNIX_BLOCKDEV); 4967 data_offset->Type = cpu_to_le32(UNIX_BLOCKDEV);
4968 else if(S_ISFIFO(mode)) 4968 else if (S_ISFIFO(mode))
4969 data_offset->Type = cpu_to_le32(UNIX_FIFO); 4969 data_offset->Type = cpu_to_le32(UNIX_FIFO);
4970 else if(S_ISSOCK(mode)) 4970 else if (S_ISSOCK(mode))
4971 data_offset->Type = cpu_to_le32(UNIX_SOCKET); 4971 data_offset->Type = cpu_to_le32(UNIX_SOCKET);
4972 4972
4973 4973
@@ -5019,7 +5019,7 @@ int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
5019 pSMB->SetupCount = 4; /* single byte does not need le conversion */ 5019 pSMB->SetupCount = 4; /* single byte does not need le conversion */
5020 pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_NOTIFY_CHANGE); 5020 pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_NOTIFY_CHANGE);
5021 pSMB->ParameterCount = pSMB->TotalParameterCount; 5021 pSMB->ParameterCount = pSMB->TotalParameterCount;
5022 if(notify_subdirs) 5022 if (notify_subdirs)
5023 pSMB->WatchTree = 1; /* one byte - no le conversion needed */ 5023 pSMB->WatchTree = 1; /* one byte - no le conversion needed */
5024 pSMB->Reserved2 = 0; 5024 pSMB->Reserved2 = 0;
5025 pSMB->CompletionFilter = cpu_to_le32(filter); 5025 pSMB->CompletionFilter = cpu_to_le32(filter);
@@ -5036,7 +5036,7 @@ int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
5036 dnotify_req = kmalloc( 5036 dnotify_req = kmalloc(
5037 sizeof(struct dir_notify_req), 5037 sizeof(struct dir_notify_req),
5038 GFP_KERNEL); 5038 GFP_KERNEL);
5039 if(dnotify_req) { 5039 if (dnotify_req) {
5040 dnotify_req->Pid = pSMB->hdr.Pid; 5040 dnotify_req->Pid = pSMB->hdr.Pid;
5041 dnotify_req->PidHigh = pSMB->hdr.PidHigh; 5041 dnotify_req->PidHigh = pSMB->hdr.PidHigh;
5042 dnotify_req->Mid = pSMB->hdr.Mid; 5042 dnotify_req->Mid = pSMB->hdr.Mid;
@@ -5142,13 +5142,13 @@ QAllEAsRetry:
5142 struct fealist * ea_response_data; 5142 struct fealist * ea_response_data;
5143 rc = 0; 5143 rc = 0;
5144 /* validate_trans2_offsets() */ 5144 /* validate_trans2_offsets() */
5145 /* BB to check if(start of smb + data_offset > &bcc+ bcc)*/ 5145 /* BB check if start of smb + data_offset > &bcc+ bcc */
5146 ea_response_data = (struct fealist *) 5146 ea_response_data = (struct fealist *)
5147 (((char *) &pSMBr->hdr.Protocol) + 5147 (((char *) &pSMBr->hdr.Protocol) +
5148 data_offset); 5148 data_offset);
5149 name_len = le32_to_cpu(ea_response_data->list_len); 5149 name_len = le32_to_cpu(ea_response_data->list_len);
5150 cFYI(1,("ea length %d", name_len)); 5150 cFYI(1,("ea length %d", name_len));
5151 if(name_len <= 8) { 5151 if (name_len <= 8) {
5152 /* returned EA size zeroed at top of function */ 5152 /* returned EA size zeroed at top of function */
5153 cFYI(1,("empty EA list returned from server")); 5153 cFYI(1,("empty EA list returned from server"));
5154 } else { 5154 } else {
@@ -5162,8 +5162,8 @@ QAllEAsRetry:
5162 temp_ptr += 4; 5162 temp_ptr += 4;
5163 rc += temp_fea->name_len; 5163 rc += temp_fea->name_len;
5164 /* account for prefix user. and trailing null */ 5164 /* account for prefix user. and trailing null */
5165 rc = rc + 5 + 1; 5165 rc = rc + 5 + 1;
5166 if(rc<(int)buf_size) { 5166 if (rc < (int)buf_size) {
5167 memcpy(EAData,"user.",5); 5167 memcpy(EAData,"user.",5);
5168 EAData+=5; 5168 EAData+=5;
5169 memcpy(EAData,temp_ptr,temp_fea->name_len); 5169 memcpy(EAData,temp_ptr,temp_fea->name_len);
@@ -5171,7 +5171,7 @@ QAllEAsRetry:
5171 /* null terminate name */ 5171 /* null terminate name */
5172 *EAData = 0; 5172 *EAData = 0;
5173 EAData = EAData + 1; 5173 EAData = EAData + 1;
5174 } else if(buf_size == 0) { 5174 } else if (buf_size == 0) {
5175 /* skip copy - calc size only */ 5175 /* skip copy - calc size only */
5176 } else { 5176 } else {
5177 /* stop before overrun buffer */ 5177 /* stop before overrun buffer */
@@ -5285,13 +5285,13 @@ QEARetry:
5285 struct fealist * ea_response_data; 5285 struct fealist * ea_response_data;
5286 rc = -ENODATA; 5286 rc = -ENODATA;
5287 /* validate_trans2_offsets() */ 5287 /* validate_trans2_offsets() */
5288 /* BB to check if(start of smb + data_offset > &bcc+ bcc)*/ 5288 /* BB check if start of smb + data_offset > &bcc+ bcc*/
5289 ea_response_data = (struct fealist *) 5289 ea_response_data = (struct fealist *)
5290 (((char *) &pSMBr->hdr.Protocol) + 5290 (((char *) &pSMBr->hdr.Protocol) +
5291 data_offset); 5291 data_offset);
5292 name_len = le32_to_cpu(ea_response_data->list_len); 5292 name_len = le32_to_cpu(ea_response_data->list_len);
5293 cFYI(1,("ea length %d", name_len)); 5293 cFYI(1,("ea length %d", name_len));
5294 if(name_len <= 8) { 5294 if (name_len <= 8) {
5295 /* returned EA size zeroed at top of function */ 5295 /* returned EA size zeroed at top of function */
5296 cFYI(1,("empty EA list returned from server")); 5296 cFYI(1,("empty EA list returned from server"));
5297 } else { 5297 } else {
@@ -5308,18 +5308,18 @@ QEARetry:
5308 value_len = le16_to_cpu(temp_fea->value_len); 5308 value_len = le16_to_cpu(temp_fea->value_len);
5309 /* BB validate that value_len falls within SMB, 5309 /* BB validate that value_len falls within SMB,
5310 even though maximum for name_len is 255 */ 5310 even though maximum for name_len is 255 */
5311 if(memcmp(temp_fea->name,ea_name, 5311 if (memcmp(temp_fea->name, ea_name,
5312 temp_fea->name_len) == 0) { 5312 temp_fea->name_len) == 0) {
5313 /* found a match */ 5313 /* found a match */
5314 rc = value_len; 5314 rc = value_len;
5315 /* account for prefix user. and trailing null */ 5315 /* account for prefix user. and trailing null */
5316 if(rc<=(int)buf_size) { 5316 if (rc <= (int)buf_size) {
5317 memcpy(ea_value, 5317 memcpy(ea_value,
5318 temp_fea->name+temp_fea->name_len+1, 5318 temp_fea->name+temp_fea->name_len+1,
5319 rc); 5319 rc);
5320 /* ea values, unlike ea names, 5320 /* ea values, unlike ea names,
5321 are not null terminated */ 5321 are not null terminated */
5322 } else if(buf_size == 0) { 5322 } else if (buf_size == 0) {
5323 /* skip copy - calc size only */ 5323 /* skip copy - calc size only */
5324 } else { 5324 } else {
5325 /* stop before overrun buffer */ 5325 /* stop before overrun buffer */
@@ -5387,7 +5387,7 @@ SetEARetry:
5387 /* done calculating parms using name_len of file name, 5387 /* done calculating parms using name_len of file name,
5388 now use name_len to calculate length of ea name 5388 now use name_len to calculate length of ea name
5389 we are going to create in the inode xattrs */ 5389 we are going to create in the inode xattrs */
5390 if(ea_name == NULL) 5390 if (ea_name == NULL)
5391 name_len = 0; 5391 name_len = 0;
5392 else 5392 else
5393 name_len = strnlen(ea_name,255); 5393 name_len = strnlen(ea_name,255);
@@ -5421,7 +5421,7 @@ SetEARetry:
5421 /* we checked above that name len is less than 255 */ 5421 /* we checked above that name len is less than 255 */
5422 parm_data->list[0].name_len = (__u8)name_len; 5422 parm_data->list[0].name_len = (__u8)name_len;
5423 /* EA names are always ASCII */ 5423 /* EA names are always ASCII */
5424 if(ea_name) 5424 if (ea_name)
5425 strncpy(parm_data->list[0].name,ea_name,name_len); 5425 strncpy(parm_data->list[0].name,ea_name,name_len);
5426 parm_data->list[0].name[name_len] = 0; 5426 parm_data->list[0].name[name_len] = 0;
5427 parm_data->list[0].value_len = cpu_to_le16(ea_value_len); 5427 parm_data->list[0].value_len = cpu_to_le16(ea_value_len);
@@ -5429,8 +5429,8 @@ SetEARetry:
5429 we need to ensure that it fits within the smb */ 5429 we need to ensure that it fits within the smb */
5430 5430
5431 /*BB add length check that it would fit in negotiated SMB buffer size BB */ 5431 /*BB add length check that it would fit in negotiated SMB buffer size BB */
5432 /* if(ea_value_len > buffer_size - 512 (enough for header)) */ 5432 /* if (ea_value_len > buffer_size - 512 (enough for header)) */
5433 if(ea_value_len) 5433 if (ea_value_len)
5434 memcpy(parm_data->list[0].name+name_len+1,ea_value,ea_value_len); 5434 memcpy(parm_data->list[0].name+name_len+1,ea_value,ea_value_len);
5435 5435
5436 pSMB->TotalDataCount = pSMB->DataCount; 5436 pSMB->TotalDataCount = pSMB->DataCount;
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 19cc294c7c70..0211e0651b50 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/misc.c 2 * fs/cifs/misc.c
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2002,2005 4 * Copyright (C) International Business Machines Corp., 2002,2007
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 6 *
7 * This library is free software; you can redistribute it and/or modify 7 * This library is free software; you can redistribute it and/or modify
@@ -49,7 +49,7 @@ _GetXid(void)
49 GlobalTotalActiveXid++; 49 GlobalTotalActiveXid++;
50 if (GlobalTotalActiveXid > GlobalMaxActiveXid) 50 if (GlobalTotalActiveXid > GlobalMaxActiveXid)
51 GlobalMaxActiveXid = GlobalTotalActiveXid; /* keep high water mark for number of simultaneous vfs ops in our filesystem */ 51 GlobalMaxActiveXid = GlobalTotalActiveXid; /* keep high water mark for number of simultaneous vfs ops in our filesystem */
52 if(GlobalTotalActiveXid > 65000) 52 if (GlobalTotalActiveXid > 65000)
53 cFYI(1,("warning: more than 65000 requests active")); 53 cFYI(1,("warning: more than 65000 requests active"));
54 xid = GlobalCurrentXid++; 54 xid = GlobalCurrentXid++;
55 spin_unlock(&GlobalMid_Lock); 55 spin_unlock(&GlobalMid_Lock);
@@ -60,7 +60,7 @@ void
60_FreeXid(unsigned int xid) 60_FreeXid(unsigned int xid)
61{ 61{
62 spin_lock(&GlobalMid_Lock); 62 spin_lock(&GlobalMid_Lock);
63 /* if(GlobalTotalActiveXid == 0) 63 /* if (GlobalTotalActiveXid == 0)
64 BUG(); */ 64 BUG(); */
65 GlobalTotalActiveXid--; 65 GlobalTotalActiveXid--;
66 spin_unlock(&GlobalMid_Lock); 66 spin_unlock(&GlobalMid_Lock);
@@ -242,7 +242,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
242 __u16 last_mid; 242 __u16 last_mid;
243 int collision; 243 int collision;
244 244
245 if(server == NULL) 245 if (server == NULL)
246 return mid; 246 return mid;
247 247
248 spin_lock(&GlobalMid_Lock); 248 spin_lock(&GlobalMid_Lock);
@@ -260,7 +260,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
260 struct mid_q_entry *mid_entry; 260 struct mid_q_entry *mid_entry;
261 261
262 collision = 0; 262 collision = 0;
263 if(server->CurrentMid == 0) 263 if (server->CurrentMid == 0)
264 server->CurrentMid++; 264 server->CurrentMid++;
265 265
266 list_for_each(tmp, &server->pending_mid_q) { 266 list_for_each(tmp, &server->pending_mid_q) {
@@ -273,7 +273,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server)
273 break; 273 break;
274 } 274 }
275 } 275 }
276 if(collision == 0) { 276 if (collision == 0) {
277 mid = server->CurrentMid; 277 mid = server->CurrentMid;
278 break; 278 break;
279 } 279 }
@@ -325,7 +325,7 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
325 /* Uid is not converted */ 325 /* Uid is not converted */
326 buffer->Uid = treeCon->ses->Suid; 326 buffer->Uid = treeCon->ses->Suid;
327 buffer->Mid = GetNextMid(treeCon->ses->server); 327 buffer->Mid = GetNextMid(treeCon->ses->server);
328 if(multiuser_mount != 0) { 328 if (multiuser_mount != 0) {
329 /* For the multiuser case, there are few obvious technically */ 329 /* For the multiuser case, there are few obvious technically */
330 /* possible mechanisms to match the local linux user (uid) */ 330 /* possible mechanisms to match the local linux user (uid) */
331 /* to a valid remote smb user (smb_uid): */ 331 /* to a valid remote smb user (smb_uid): */
@@ -350,13 +350,13 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
350 /* BB Add support for establishing new tCon and SMB Session */ 350 /* BB Add support for establishing new tCon and SMB Session */
351 /* with userid/password pairs found on the smb session */ 351 /* with userid/password pairs found on the smb session */
352 /* for other target tcp/ip addresses BB */ 352 /* for other target tcp/ip addresses BB */
353 if(current->fsuid != treeCon->ses->linux_uid) { 353 if (current->fsuid != treeCon->ses->linux_uid) {
354 cFYI(1,("Multiuser mode and UID did not match tcon uid")); 354 cFYI(1,("Multiuser mode and UID did not match tcon uid"));
355 read_lock(&GlobalSMBSeslock); 355 read_lock(&GlobalSMBSeslock);
356 list_for_each(temp_item, &GlobalSMBSessionList) { 356 list_for_each(temp_item, &GlobalSMBSessionList) {
357 ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList); 357 ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList);
358 if(ses->linux_uid == current->fsuid) { 358 if (ses->linux_uid == current->fsuid) {
359 if(ses->server == treeCon->ses->server) { 359 if (ses->server == treeCon->ses->server) {
360 cFYI(1,("found matching uid substitute right smb_uid")); 360 cFYI(1,("found matching uid substitute right smb_uid"));
361 buffer->Uid = ses->Suid; 361 buffer->Uid = ses->Suid;
362 break; 362 break;
@@ -374,8 +374,8 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
374 buffer->Flags2 |= SMBFLG2_DFS; 374 buffer->Flags2 |= SMBFLG2_DFS;
375 if (treeCon->nocase) 375 if (treeCon->nocase)
376 buffer->Flags |= SMBFLG_CASELESS; 376 buffer->Flags |= SMBFLG_CASELESS;
377 if((treeCon->ses) && (treeCon->ses->server)) 377 if ((treeCon->ses) && (treeCon->ses->server))
378 if(treeCon->ses->server->secMode & 378 if (treeCon->ses->server->secMode &
379 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 379 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
380 buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 380 buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
381 } 381 }
@@ -392,11 +392,11 @@ checkSMBhdr(struct smb_hdr *smb, __u16 mid)
392 and that the message ids match */ 392 and that the message ids match */
393 if ((*(__le32 *) smb->Protocol == cpu_to_le32(0x424d53ff)) && 393 if ((*(__le32 *) smb->Protocol == cpu_to_le32(0x424d53ff)) &&
394 (mid == smb->Mid)) { 394 (mid == smb->Mid)) {
395 if(smb->Flags & SMBFLG_RESPONSE) 395 if (smb->Flags & SMBFLG_RESPONSE)
396 return 0; 396 return 0;
397 else { 397 else {
398 /* only one valid case where server sends us request */ 398 /* only one valid case where server sends us request */
399 if(smb->Command == SMB_COM_LOCKING_ANDX) 399 if (smb->Command == SMB_COM_LOCKING_ANDX)
400 return 0; 400 return 0;
401 else 401 else
402 cERROR(1, ("Rcvd Request not response")); 402 cERROR(1, ("Rcvd Request not response"));
@@ -458,16 +458,16 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
458 return 1; 458 return 1;
459 clc_len = smbCalcSize_LE(smb); 459 clc_len = smbCalcSize_LE(smb);
460 460
461 if(4 + len != length) { 461 if (4 + len != length) {
462 cERROR(1, ("Length read does not match RFC1001 length %d",len)); 462 cERROR(1, ("Length read does not match RFC1001 length %d",len));
463 return 1; 463 return 1;
464 } 464 }
465 465
466 if (4 + len != clc_len) { 466 if (4 + len != clc_len) {
467 /* check if bcc wrapped around for large read responses */ 467 /* check if bcc wrapped around for large read responses */
468 if((len > 64 * 1024) && (len > clc_len)) { 468 if ((len > 64 * 1024) && (len > clc_len)) {
469 /* check if lengths match mod 64K */ 469 /* check if lengths match mod 64K */
470 if(((4 + len) & 0xFFFF) == (clc_len & 0xFFFF)) 470 if (((4 + len) & 0xFFFF) == (clc_len & 0xFFFF))
471 return 0; /* bcc wrapped */ 471 return 0; /* bcc wrapped */
472 } 472 }
473 cFYI(1, ("Calculated size %d vs length %d mismatch for mid %d", 473 cFYI(1, ("Calculated size %d vs length %d mismatch for mid %d",
@@ -483,7 +483,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
483 but server says length is 0x21 bytes too long as if the server 483 but server says length is 0x21 bytes too long as if the server
484 forget to reset the smb rfc1001 length when it reset the 484 forget to reset the smb rfc1001 length when it reset the
485 wct and bcc to minimum size and drop the t2 parms and data */ 485 wct and bcc to minimum size and drop the t2 parms and data */
486 if((4+len > clc_len) && (len <= clc_len + 512)) 486 if ((4+len > clc_len) && (len <= clc_len + 512))
487 return 0; 487 return 0;
488 else { 488 else {
489 cERROR(1, ("RFC1001 size %d bigger than SMB for Mid=%d", 489 cERROR(1, ("RFC1001 size %d bigger than SMB for Mid=%d",
@@ -503,13 +503,13 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
503 struct cifsFileInfo *netfile; 503 struct cifsFileInfo *netfile;
504 504
505 cFYI(1,("Checking for oplock break or dnotify response")); 505 cFYI(1,("Checking for oplock break or dnotify response"));
506 if((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) && 506 if ((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) &&
507 (pSMB->hdr.Flags & SMBFLG_RESPONSE)) { 507 (pSMB->hdr.Flags & SMBFLG_RESPONSE)) {
508 struct smb_com_transaction_change_notify_rsp * pSMBr = 508 struct smb_com_transaction_change_notify_rsp * pSMBr =
509 (struct smb_com_transaction_change_notify_rsp *)buf; 509 (struct smb_com_transaction_change_notify_rsp *)buf;
510 struct file_notify_information * pnotify; 510 struct file_notify_information * pnotify;
511 __u32 data_offset = 0; 511 __u32 data_offset = 0;
512 if(pSMBr->ByteCount > sizeof(struct file_notify_information)) { 512 if (pSMBr->ByteCount > sizeof(struct file_notify_information)) {
513 data_offset = le32_to_cpu(pSMBr->DataOffset); 513 data_offset = le32_to_cpu(pSMBr->DataOffset);
514 514
515 pnotify = (struct file_notify_information *) 515 pnotify = (struct file_notify_information *)
@@ -520,15 +520,15 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
520 sizeof(struct smb_hdr)+60); */ 520 sizeof(struct smb_hdr)+60); */
521 return TRUE; 521 return TRUE;
522 } 522 }
523 if(pSMBr->hdr.Status.CifsError) { 523 if (pSMBr->hdr.Status.CifsError) {
524 cFYI(1,("notify err 0x%d",pSMBr->hdr.Status.CifsError)); 524 cFYI(1,("notify err 0x%d",pSMBr->hdr.Status.CifsError));
525 return TRUE; 525 return TRUE;
526 } 526 }
527 return FALSE; 527 return FALSE;
528 } 528 }
529 if(pSMB->hdr.Command != SMB_COM_LOCKING_ANDX) 529 if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX)
530 return FALSE; 530 return FALSE;
531 if(pSMB->hdr.Flags & SMBFLG_RESPONSE) { 531 if (pSMB->hdr.Flags & SMBFLG_RESPONSE) {
532 /* no sense logging error on invalid handle on oplock 532 /* no sense logging error on invalid handle on oplock
533 break - harmless race between close request and oplock 533 break - harmless race between close request and oplock
534 break response is expected from time to time writing out 534 break response is expected from time to time writing out
@@ -544,11 +544,11 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
544 return FALSE; /* on valid oplock brk we get "request" */ 544 return FALSE; /* on valid oplock brk we get "request" */
545 } 545 }
546 } 546 }
547 if(pSMB->hdr.WordCount != 8) 547 if (pSMB->hdr.WordCount != 8)
548 return FALSE; 548 return FALSE;
549 549
550 cFYI(1,(" oplock type 0x%d level 0x%d",pSMB->LockType,pSMB->OplockLevel)); 550 cFYI(1,(" oplock type 0x%d level 0x%d",pSMB->LockType,pSMB->OplockLevel));
551 if(!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)) 551 if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE))
552 return FALSE; 552 return FALSE;
553 553
554 /* look up tcon based on tid & uid */ 554 /* look up tcon based on tid & uid */
@@ -560,14 +560,14 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
560 list_for_each(tmp1,&tcon->openFileList){ 560 list_for_each(tmp1,&tcon->openFileList){
561 netfile = list_entry(tmp1,struct cifsFileInfo, 561 netfile = list_entry(tmp1,struct cifsFileInfo,
562 tlist); 562 tlist);
563 if(pSMB->Fid == netfile->netfid) { 563 if (pSMB->Fid == netfile->netfid) {
564 struct cifsInodeInfo *pCifsInode; 564 struct cifsInodeInfo *pCifsInode;
565 read_unlock(&GlobalSMBSeslock); 565 read_unlock(&GlobalSMBSeslock);
566 cFYI(1,("file id match, oplock break")); 566 cFYI(1,("file id match, oplock break"));
567 pCifsInode = 567 pCifsInode =
568 CIFS_I(netfile->pInode); 568 CIFS_I(netfile->pInode);
569 pCifsInode->clientCanCacheAll = FALSE; 569 pCifsInode->clientCanCacheAll = FALSE;
570 if(pSMB->OplockLevel == 0) 570 if (pSMB->OplockLevel == 0)
571 pCifsInode->clientCanCacheRead 571 pCifsInode->clientCanCacheRead
572 = FALSE; 572 = FALSE;
573 pCifsInode->oplockPending = TRUE; 573 pCifsInode->oplockPending = TRUE;
@@ -575,7 +575,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
575 netfile->netfid, 575 netfile->netfid,
576 tcon); 576 tcon);
577 cFYI(1,("about to wake up oplock thd")); 577 cFYI(1,("about to wake up oplock thd"));
578 if(oplockThread) 578 if (oplockThread)
579 wake_up_process(oplockThread); 579 wake_up_process(oplockThread);
580 return TRUE; 580 return TRUE;
581 } 581 }
@@ -681,7 +681,7 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
681 default: 681 default:
682 len = cp->uni2char(src_char, &target[j], 682 len = cp->uni2char(src_char, &target[j],
683 NLS_MAX_CHARSET_SIZE); 683 NLS_MAX_CHARSET_SIZE);
684 if(len > 0) { 684 if (len > 0) {
685 j += len; 685 j += len;
686 continue; 686 continue;
687 } else { 687 } else {
@@ -690,7 +690,7 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
690 } 690 }
691 j++; 691 j++;
692 /* make sure we do not overrun callers allocated temp buffer */ 692 /* make sure we do not overrun callers allocated temp buffer */
693 if(j >= (2 * NAME_MAX)) 693 if (j >= (2 * NAME_MAX))
694 break; 694 break;
695 } 695 }
696cUCS_out: 696cUCS_out:
@@ -711,7 +711,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
711 char src_char; 711 char src_char;
712 __u16 temp; 712 __u16 temp;
713 713
714 if(!mapChars) 714 if (!mapChars)
715 return cifs_strtoUCS(target, source, PATH_MAX, cp); 715 return cifs_strtoUCS(target, source, PATH_MAX, cp);
716 716
717 for(i = 0, j = 0; i < maxlen; j++) { 717 for(i = 0, j = 0; i < maxlen; j++) {
@@ -749,7 +749,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
749 len_remaining, &temp); 749 len_remaining, &temp);
750 /* if no match, use question mark, which 750 /* if no match, use question mark, which
751 at least in some cases servers as wild card */ 751 at least in some cases servers as wild card */
752 if(charlen < 1) { 752 if (charlen < 1) {
753 target[j] = cpu_to_le16(0x003f); 753 target[j] = cpu_to_le16(0x003f);
754 charlen = 1; 754 charlen = 1;
755 } else 755 } else
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index b388c356fde0..20a3fe7cbd7b 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -140,9 +140,9 @@ cifs_inet_pton(int address_family, char *cp,void *dst)
140 /* calculate length by finding first slash or NULL */ 140 /* calculate length by finding first slash or NULL */
141 /* BB Should we convert '/' slash to '\' here since it seems already done 141 /* BB Should we convert '/' slash to '\' here since it seems already done
142 before this */ 142 before this */
143 if( address_family == AF_INET ){ 143 if ( address_family == AF_INET ) {
144 ret = in4_pton(cp, -1 /* len */, dst , '\\', NULL); 144 ret = in4_pton(cp, -1 /* len */, dst , '\\', NULL);
145 } else if( address_family == AF_INET6 ){ 145 } else if ( address_family == AF_INET6 ) {
146 ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL); 146 ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL);
147 } 147 }
148#ifdef CONFIG_CIFS_DEBUG2 148#ifdef CONFIG_CIFS_DEBUG2
@@ -773,7 +773,7 @@ map_smb_to_linux_error(struct smb_hdr *smb)
773 if (smb->Flags2 & SMBFLG2_ERR_STATUS) { 773 if (smb->Flags2 & SMBFLG2_ERR_STATUS) {
774 /* translate the newer STATUS codes to old style errors and then to POSIX errors */ 774 /* translate the newer STATUS codes to old style errors and then to POSIX errors */
775 __u32 err = le32_to_cpu(smb->Status.CifsError); 775 __u32 err = le32_to_cpu(smb->Status.CifsError);
776 if(cifsFYI & CIFS_RC) 776 if (cifsFYI & CIFS_RC)
777 cifs_print_status(err); 777 cifs_print_status(err);
778 ntstatus_to_dos(err, &smberrclass, &smberrcode); 778 ntstatus_to_dos(err, &smberrclass, &smberrcode);
779 } else { 779 } else {
@@ -889,15 +889,15 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
889 889
890 sec = 2 * st->TwoSeconds; 890 sec = 2 * st->TwoSeconds;
891 min = st->Minutes; 891 min = st->Minutes;
892 if((sec > 59) || (min > 59)) 892 if ((sec > 59) || (min > 59))
893 cERROR(1,("illegal time min %d sec %d", min, sec)); 893 cERROR(1,("illegal time min %d sec %d", min, sec));
894 sec += (min * 60); 894 sec += (min * 60);
895 sec += 60 * 60 * st->Hours; 895 sec += 60 * 60 * st->Hours;
896 if(st->Hours > 24) 896 if (st->Hours > 24)
897 cERROR(1,("illegal hours %d",st->Hours)); 897 cERROR(1,("illegal hours %d",st->Hours));
898 days = sd->Day; 898 days = sd->Day;
899 month = sd->Month; 899 month = sd->Month;
900 if((days > 31) || (month > 12)) 900 if ((days > 31) || (month > 12))
901 cERROR(1,("illegal date, month %d day: %d", month, days)); 901 cERROR(1,("illegal date, month %d day: %d", month, days));
902 month -= 1; 902 month -= 1;
903 days += total_days_of_prev_months[month]; 903 days += total_days_of_prev_months[month];
@@ -911,13 +911,13 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
911 consider 2 special case years, ie the years 2000 and 2100, and only 911 consider 2 special case years, ie the years 2000 and 2100, and only
912 adjust for the lack of leap year for the year 2100, as 2000 was a 912 adjust for the lack of leap year for the year 2100, as 2000 was a
913 leap year (divisable by 400) */ 913 leap year (divisable by 400) */
914 if(year >= 120) /* the year 2100 */ 914 if (year >= 120) /* the year 2100 */
915 days = days - 1; /* do not count leap year for the year 2100 */ 915 days = days - 1; /* do not count leap year for the year 2100 */
916 916
917 /* adjust for leap year where we are still before leap day */ 917 /* adjust for leap year where we are still before leap day */
918 if(year != 120) 918 if (year != 120)
919 days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0); 919 days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
920 sec += 24 * 60 * 60 * days; 920 sec += 24 * 60 * 60 * days;
921 921
922 ts.tv_sec = sec; 922 ts.tv_sec = sec;
923 923
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 52e657ec1f18..19c8be4696f9 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -110,7 +110,7 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
110 return rc; 110 return rc;
111} 111}
112 112
113static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode) 113static void AdjustForTZ(struct cifsTconInfo *tcon, struct inode *inode)
114{ 114{
115 if ((tcon) && (tcon->ses) && (tcon->ses->server)) { 115 if ((tcon) && (tcon->ses) && (tcon->ses->server)) {
116 inode->i_ctime.tv_sec += tcon->ses->server->timeAdj; 116 inode->i_ctime.tv_sec += tcon->ses->server->timeAdj;
@@ -122,7 +122,7 @@ static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode)
122 122
123 123
124static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, 124static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
125 char * buf, int *pobject_type, int isNewInode) 125 char *buf, int *pobject_type, int isNewInode)
126{ 126{
127 loff_t local_size; 127 loff_t local_size;
128 struct timespec local_mtime; 128 struct timespec local_mtime;
@@ -151,7 +151,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
151 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); 151 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
152 } else { /* legacy, OS2 and DOS style */ 152 } else { /* legacy, OS2 and DOS style */
153/* struct timespec ts;*/ 153/* struct timespec ts;*/
154 FIND_FILE_STANDARD_INFO * pfindData = 154 FIND_FILE_STANDARD_INFO * pfindData =
155 (FIND_FILE_STANDARD_INFO *)buf; 155 (FIND_FILE_STANDARD_INFO *)buf;
156 156
157 tmp_inode->i_mtime = cnvrtDosUnixTm( 157 tmp_inode->i_mtime = cnvrtDosUnixTm(
@@ -176,7 +176,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
176 176
177 /* treat dos attribute of read-only as read-only mode bit e.g. 555? */ 177 /* treat dos attribute of read-only as read-only mode bit e.g. 555? */
178 /* 2767 perms - indicate mandatory locking */ 178 /* 2767 perms - indicate mandatory locking */
179 /* BB fill in uid and gid here? with help from winbind? 179 /* BB fill in uid and gid here? with help from winbind?
180 or retrieve from NTFS stream extended attribute */ 180 or retrieve from NTFS stream extended attribute */
181 if (atomic_read(&cifsInfo->inUse) == 0) { 181 if (atomic_read(&cifsInfo->inUse) == 0) {
182 tmp_inode->i_uid = cifs_sb->mnt_uid; 182 tmp_inode->i_uid = cifs_sb->mnt_uid;
@@ -197,7 +197,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
197 tmp_inode->i_mode = cifs_sb->mnt_dir_mode; 197 tmp_inode->i_mode = cifs_sb->mnt_dir_mode;
198 } 198 }
199 tmp_inode->i_mode |= S_IFDIR; 199 tmp_inode->i_mode |= S_IFDIR;
200 } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && 200 } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) &&
201 (attr & ATTR_SYSTEM)) { 201 (attr & ATTR_SYSTEM)) {
202 if (end_of_file == 0) { 202 if (end_of_file == 0) {
203 *pobject_type = DT_FIFO; 203 *pobject_type = DT_FIFO;
@@ -207,13 +207,13 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
207 inode as needing revalidate and get the real type 207 inode as needing revalidate and get the real type
208 (blk vs chr vs. symlink) later ie in lookup */ 208 (blk vs chr vs. symlink) later ie in lookup */
209 *pobject_type = DT_REG; 209 *pobject_type = DT_REG;
210 tmp_inode->i_mode |= S_IFREG; 210 tmp_inode->i_mode |= S_IFREG;
211 cifsInfo->time = 0; 211 cifsInfo->time = 0;
212 } 212 }
213/* we no longer mark these because we could not follow them */ 213/* we no longer mark these because we could not follow them */
214/* } else if (attr & ATTR_REPARSE) { 214/* } else if (attr & ATTR_REPARSE) {
215 *pobject_type = DT_LNK; 215 *pobject_type = DT_LNK;
216 tmp_inode->i_mode |= S_IFLNK; */ 216 tmp_inode->i_mode |= S_IFLNK; */
217 } else { 217 } else {
218 *pobject_type = DT_REG; 218 *pobject_type = DT_REG;
219 tmp_inode->i_mode |= S_IFREG; 219 tmp_inode->i_mode |= S_IFREG;
@@ -221,7 +221,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
221 tmp_inode->i_mode &= ~(S_IWUGO); 221 tmp_inode->i_mode &= ~(S_IWUGO);
222 else if ((tmp_inode->i_mode & S_IWUGO) == 0) 222 else if ((tmp_inode->i_mode & S_IWUGO) == 0)
223 /* the ATTR_READONLY flag may have been changed on */ 223 /* the ATTR_READONLY flag may have been changed on */
224 /* server -- set any w bits allowed by mnt_file_mode */ 224 /* server -- set any w bits allowed by mnt_file_mode */
225 tmp_inode->i_mode |= (S_IWUGO & cifs_sb->mnt_file_mode); 225 tmp_inode->i_mode |= (S_IWUGO & cifs_sb->mnt_file_mode);
226 } /* could add code here - to validate if device or weird share type? */ 226 } /* could add code here - to validate if device or weird share type? */
227 227
@@ -232,7 +232,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
232 232
233 spin_lock(&tmp_inode->i_lock); 233 spin_lock(&tmp_inode->i_lock);
234 if (is_size_safe_to_change(cifsInfo, end_of_file)) { 234 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
235 /* can not safely change the file size here if the 235 /* can not safely change the file size here if the
236 client is writing to it due to potential races */ 236 client is writing to it due to potential races */
237 i_size_write(tmp_inode, end_of_file); 237 i_size_write(tmp_inode, end_of_file);
238 238
@@ -323,8 +323,8 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
323 323
324 tmp_inode->i_mode = le64_to_cpu(pfindData->Permissions); 324 tmp_inode->i_mode = le64_to_cpu(pfindData->Permissions);
325 /* since we set the inode type below we need to mask off type 325 /* since we set the inode type below we need to mask off type
326 to avoid strange results if bits above were corrupt */ 326 to avoid strange results if bits above were corrupt */
327 tmp_inode->i_mode &= ~S_IFMT; 327 tmp_inode->i_mode &= ~S_IFMT;
328 if (type == UNIX_FILE) { 328 if (type == UNIX_FILE) {
329 *pobject_type = DT_REG; 329 *pobject_type = DT_REG;
330 tmp_inode->i_mode |= S_IFREG; 330 tmp_inode->i_mode |= S_IFREG;
@@ -354,7 +354,7 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
354 /* safest to just call it a file */ 354 /* safest to just call it a file */
355 *pobject_type = DT_REG; 355 *pobject_type = DT_REG;
356 tmp_inode->i_mode |= S_IFREG; 356 tmp_inode->i_mode |= S_IFREG;
357 cFYI(1,("unknown inode type %d",type)); 357 cFYI(1, ("unknown inode type %d", type));
358 } 358 }
359 359
360 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) 360 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
@@ -369,7 +369,7 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
369 369
370 spin_lock(&tmp_inode->i_lock); 370 spin_lock(&tmp_inode->i_lock);
371 if (is_size_safe_to_change(cifsInfo, end_of_file)) { 371 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
372 /* can not safely change the file size here if the 372 /* can not safely change the file size here if the
373 client is writing to it due to potential races */ 373 client is writing to it due to potential races */
374 i_size_write(tmp_inode, end_of_file); 374 i_size_write(tmp_inode, end_of_file);
375 375
@@ -394,15 +394,16 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
394 tmp_inode->i_fop = &cifs_file_ops; 394 tmp_inode->i_fop = &cifs_file_ops;
395 395
396 if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) && 396 if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
397 (cifs_sb->tcon->ses->server->maxBuf < 397 (cifs_sb->tcon->ses->server->maxBuf <
398 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) 398 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
399 tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; 399 tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
400 else 400 else
401 tmp_inode->i_data.a_ops = &cifs_addr_ops; 401 tmp_inode->i_data.a_ops = &cifs_addr_ops;
402 402
403 if (isNewInode) 403 if (isNewInode)
404 return; /* No sense invalidating pages for new inode since we 404 return; /* No sense invalidating pages for new inode
405 have not started caching readahead file data yet */ 405 since we have not started caching readahead
406 file data for it yet */
406 407
407 if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) && 408 if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) &&
408 (local_size == tmp_inode->i_size)) { 409 (local_size == tmp_inode->i_size)) {
@@ -421,7 +422,7 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
421 tmp_inode->i_op = &cifs_symlink_inode_ops; 422 tmp_inode->i_op = &cifs_symlink_inode_ops;
422/* tmp_inode->i_fop = *//* do not need to set to anything */ 423/* tmp_inode->i_fop = *//* do not need to set to anything */
423 } else { 424 } else {
424 cFYI(1, ("Special inode")); 425 cFYI(1, ("Special inode"));
425 init_special_inode(tmp_inode, tmp_inode->i_mode, 426 init_special_inode(tmp_inode, tmp_inode->i_mode,
426 tmp_inode->i_rdev); 427 tmp_inode->i_rdev);
427 } 428 }
@@ -500,7 +501,7 @@ static int cifs_unicode_bytelen(char *str)
500 if (ustr[len] == 0) 501 if (ustr[len] == 0)
501 return len << 1; 502 return len << 1;
502 } 503 }
503 cFYI(1,("Unicode string longer than PATH_MAX found")); 504 cFYI(1, ("Unicode string longer than PATH_MAX found"));
504 return len << 1; 505 return len << 1;
505} 506}
506 507
@@ -517,7 +518,7 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
517 pfData->FileNameLength; 518 pfData->FileNameLength;
518 } else 519 } else
519 new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset); 520 new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset);
520 cFYI(1,("new entry %p old entry %p",new_entry,old_entry)); 521 cFYI(1, ("new entry %p old entry %p", new_entry, old_entry));
521 /* validate that new_entry is not past end of SMB */ 522 /* validate that new_entry is not past end of SMB */
522 if (new_entry >= end_of_smb) { 523 if (new_entry >= end_of_smb) {
523 cERROR(1, 524 cERROR(1,
@@ -583,7 +584,8 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
583 filename = &pFindData->FileName[0]; 584 filename = &pFindData->FileName[0];
584 len = pFindData->FileNameLength; 585 len = pFindData->FileNameLength;
585 } else { 586 } else {
586 cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level)); 587 cFYI(1, ("Unknown findfirst level %d",
588 cfile->srch_inf.info_level));
587 } 589 }
588 590
589 if (filename) { 591 if (filename) {
@@ -604,7 +606,7 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
604 if (filename[0] == '.') 606 if (filename[0] == '.')
605 rc = 1; 607 rc = 1;
606 } else if (len == 2) { 608 } else if (len == 2) {
607 if((filename[0] == '.') && (filename[1] == '.')) 609 if ((filename[0] == '.') && (filename[1] == '.'))
608 rc = 2; 610 rc = 2;
609 } 611 }
610 } 612 }
@@ -665,13 +667,13 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
665 is_dir_changed(file)) || 667 is_dir_changed(file)) ||
666 (index_to_find < first_entry_in_buffer)) { 668 (index_to_find < first_entry_in_buffer)) {
667 /* close and restart search */ 669 /* close and restart search */
668 cFYI(1,("search backing up - close and restart search")); 670 cFYI(1, ("search backing up - close and restart search"));
669 cifsFile->invalidHandle = TRUE; 671 cifsFile->invalidHandle = TRUE;
670 CIFSFindClose(xid, pTcon, cifsFile->netfid); 672 CIFSFindClose(xid, pTcon, cifsFile->netfid);
671 kfree(cifsFile->search_resume_name); 673 kfree(cifsFile->search_resume_name);
672 cifsFile->search_resume_name = NULL; 674 cifsFile->search_resume_name = NULL;
673 if (cifsFile->srch_inf.ntwrk_buf_start) { 675 if (cifsFile->srch_inf.ntwrk_buf_start) {
674 cFYI(1,("freeing SMB ff cache buf on search rewind")); 676 cFYI(1, ("freeing SMB ff cache buf on search rewind"));
675 if (cifsFile->srch_inf.smallBuf) 677 if (cifsFile->srch_inf.smallBuf)
676 cifs_small_buf_release(cifsFile->srch_inf. 678 cifs_small_buf_release(cifsFile->srch_inf.
677 ntwrk_buf_start); 679 ntwrk_buf_start);
@@ -681,14 +683,15 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
681 } 683 }
682 rc = initiate_cifs_search(xid,file); 684 rc = initiate_cifs_search(xid,file);
683 if (rc) { 685 if (rc) {
684 cFYI(1,("error %d reinitiating a search on rewind",rc)); 686 cFYI(1, ("error %d reinitiating a search on rewind",
687 rc));
685 return rc; 688 return rc;
686 } 689 }
687 } 690 }
688 691
689 while((index_to_find >= cifsFile->srch_inf.index_of_last_entry) && 692 while((index_to_find >= cifsFile->srch_inf.index_of_last_entry) &&
690 (rc == 0) && (cifsFile->srch_inf.endOfSearch == FALSE)){ 693 (rc == 0) && (cifsFile->srch_inf.endOfSearch == FALSE)){
691 cFYI(1,("calling findnext2")); 694 cFYI(1, ("calling findnext2"));
692 rc = CIFSFindNext(xid,pTcon,cifsFile->netfid, 695 rc = CIFSFindNext(xid,pTcon,cifsFile->netfid,
693 &cifsFile->srch_inf); 696 &cifsFile->srch_inf);
694 if (rc) 697 if (rc)
@@ -707,14 +710,14 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
707 first_entry_in_buffer = cifsFile->srch_inf.index_of_last_entry 710 first_entry_in_buffer = cifsFile->srch_inf.index_of_last_entry
708 - cifsFile->srch_inf.entries_in_buffer; 711 - cifsFile->srch_inf.entries_in_buffer;
709 pos_in_buf = index_to_find - first_entry_in_buffer; 712 pos_in_buf = index_to_find - first_entry_in_buffer;
710 cFYI(1,("found entry - pos_in_buf %d",pos_in_buf)); 713 cFYI(1, ("found entry - pos_in_buf %d", pos_in_buf));
711 714
712 for(i=0;(i<(pos_in_buf)) && (current_entry != NULL);i++) { 715 for(i=0;(i<(pos_in_buf)) && (current_entry != NULL);i++) {
713 /* go entry by entry figuring out which is first */ 716 /* go entry by entry figuring out which is first */
714 current_entry = nxt_dir_entry(current_entry,end_of_smb, 717 current_entry = nxt_dir_entry(current_entry,end_of_smb,
715 cifsFile->srch_inf.info_level); 718 cifsFile->srch_inf.info_level);
716 } 719 }
717 if((current_entry == NULL) && (i < pos_in_buf)) { 720 if ((current_entry == NULL) && (i < pos_in_buf)) {
718 /* BB fixme - check if we should flag this error */ 721 /* BB fixme - check if we should flag this error */
719 cERROR(1,("reached end of buf searching for pos in buf" 722 cERROR(1,("reached end of buf searching for pos in buf"
720 " %d index to find %lld rc %d", 723 " %d index to find %lld rc %d",
@@ -723,12 +726,12 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
723 rc = 0; 726 rc = 0;
724 *ppCurrentEntry = current_entry; 727 *ppCurrentEntry = current_entry;
725 } else { 728 } else {
726 cFYI(1,("index not in buffer - could not findnext into it")); 729 cFYI(1, ("index not in buffer - could not findnext into it"));
727 return 0; 730 return 0;
728 } 731 }
729 732
730 if(pos_in_buf >= cifsFile->srch_inf.entries_in_buffer) { 733 if (pos_in_buf >= cifsFile->srch_inf.entries_in_buffer) {
731 cFYI(1,("can not return entries pos_in_buf beyond last entry")); 734 cFYI(1, ("can not return entries pos_in_buf beyond last"));
732 *num_to_ret = 0; 735 *num_to_ret = 0;
733 } else 736 } else
734 *num_to_ret = cifsFile->srch_inf.entries_in_buffer - pos_in_buf; 737 *num_to_ret = cifsFile->srch_inf.entries_in_buffer - pos_in_buf;
@@ -748,11 +751,11 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
748 751
749 *pinum = 0; 752 *pinum = 0;
750 753
751 if(level == SMB_FIND_FILE_UNIX) { 754 if (level == SMB_FIND_FILE_UNIX) {
752 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; 755 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
753 756
754 filename = &pFindData->FileName[0]; 757 filename = &pFindData->FileName[0];
755 if(unicode) { 758 if (unicode) {
756 len = cifs_unicode_bytelen(filename); 759 len = cifs_unicode_bytelen(filename);
757 } else { 760 } else {
758 /* BB should we make this strnlen of PATH_MAX? */ 761 /* BB should we make this strnlen of PATH_MAX? */
@@ -760,49 +763,49 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
760 } 763 }
761 764
762 /* BB fixme - hash low and high 32 bits if not 64 bit arch BB fixme */ 765 /* BB fixme - hash low and high 32 bits if not 64 bit arch BB fixme */
763 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) 766 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
764 *pinum = pFindData->UniqueId; 767 *pinum = pFindData->UniqueId;
765 } else if(level == SMB_FIND_FILE_DIRECTORY_INFO) { 768 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
766 FILE_DIRECTORY_INFO * pFindData = 769 FILE_DIRECTORY_INFO * pFindData =
767 (FILE_DIRECTORY_INFO *)current_entry; 770 (FILE_DIRECTORY_INFO *)current_entry;
768 filename = &pFindData->FileName[0]; 771 filename = &pFindData->FileName[0];
769 len = le32_to_cpu(pFindData->FileNameLength); 772 len = le32_to_cpu(pFindData->FileNameLength);
770 } else if(level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) { 773 } else if (level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
771 FILE_FULL_DIRECTORY_INFO * pFindData = 774 FILE_FULL_DIRECTORY_INFO * pFindData =
772 (FILE_FULL_DIRECTORY_INFO *)current_entry; 775 (FILE_FULL_DIRECTORY_INFO *)current_entry;
773 filename = &pFindData->FileName[0]; 776 filename = &pFindData->FileName[0];
774 len = le32_to_cpu(pFindData->FileNameLength); 777 len = le32_to_cpu(pFindData->FileNameLength);
775 } else if(level == SMB_FIND_FILE_ID_FULL_DIR_INFO) { 778 } else if (level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
776 SEARCH_ID_FULL_DIR_INFO * pFindData = 779 SEARCH_ID_FULL_DIR_INFO * pFindData =
777 (SEARCH_ID_FULL_DIR_INFO *)current_entry; 780 (SEARCH_ID_FULL_DIR_INFO *)current_entry;
778 filename = &pFindData->FileName[0]; 781 filename = &pFindData->FileName[0];
779 len = le32_to_cpu(pFindData->FileNameLength); 782 len = le32_to_cpu(pFindData->FileNameLength);
780 *pinum = pFindData->UniqueId; 783 *pinum = pFindData->UniqueId;
781 } else if(level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { 784 } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
782 FILE_BOTH_DIRECTORY_INFO * pFindData = 785 FILE_BOTH_DIRECTORY_INFO * pFindData =
783 (FILE_BOTH_DIRECTORY_INFO *)current_entry; 786 (FILE_BOTH_DIRECTORY_INFO *)current_entry;
784 filename = &pFindData->FileName[0]; 787 filename = &pFindData->FileName[0];
785 len = le32_to_cpu(pFindData->FileNameLength); 788 len = le32_to_cpu(pFindData->FileNameLength);
786 } else if(level == SMB_FIND_FILE_INFO_STANDARD) { 789 } else if (level == SMB_FIND_FILE_INFO_STANDARD) {
787 FIND_FILE_STANDARD_INFO * pFindData = 790 FIND_FILE_STANDARD_INFO * pFindData =
788 (FIND_FILE_STANDARD_INFO *)current_entry; 791 (FIND_FILE_STANDARD_INFO *)current_entry;
789 filename = &pFindData->FileName[0]; 792 filename = &pFindData->FileName[0];
790 /* one byte length, no name conversion */ 793 /* one byte length, no name conversion */
791 len = (unsigned int)pFindData->FileNameLength; 794 len = (unsigned int)pFindData->FileNameLength;
792 } else { 795 } else {
793 cFYI(1,("Unknown findfirst level %d",level)); 796 cFYI(1, ("Unknown findfirst level %d", level));
794 return -EINVAL; 797 return -EINVAL;
795 } 798 }
796 799
797 if(len > max_len) { 800 if (len > max_len) {
798 cERROR(1,("bad search response length %d past smb end", len)); 801 cERROR(1,("bad search response length %d past smb end", len));
799 return -EINVAL; 802 return -EINVAL;
800 } 803 }
801 804
802 if(unicode) { 805 if (unicode) {
803 /* BB fixme - test with long names */ 806 /* BB fixme - test with long names */
804 /* Note converted filename can be longer than in unicode */ 807 /* Note converted filename can be longer than in unicode */
805 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR) 808 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
806 pqst->len = cifs_convertUCSpath((char *)pqst->name, 809 pqst->len = cifs_convertUCSpath((char *)pqst->name,
807 (__le16 *)filename, len/2, nlt); 810 (__le16 *)filename, len/2, nlt);
808 else 811 else
@@ -813,7 +816,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
813 pqst->len = len; 816 pqst->len = len;
814 } 817 }
815 pqst->hash = full_name_hash(pqst->name,pqst->len); 818 pqst->hash = full_name_hash(pqst->name,pqst->len);
816/* cFYI(1,("filldir on %s",pqst->name)); */ 819/* cFYI(1, ("filldir on %s",pqst->name)); */
817 return rc; 820 return rc;
818} 821}
819 822
@@ -832,17 +835,17 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
832 /* get filename and len into qstring */ 835 /* get filename and len into qstring */
833 /* get dentry */ 836 /* get dentry */
834 /* decide whether to create and populate ionde */ 837 /* decide whether to create and populate ionde */
835 if((direntry == NULL) || (file == NULL)) 838 if ((direntry == NULL) || (file == NULL))
836 return -EINVAL; 839 return -EINVAL;
837 840
838 pCifsF = file->private_data; 841 pCifsF = file->private_data;
839 842
840 if((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL)) 843 if ((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL))
841 return -ENOENT; 844 return -ENOENT;
842 845
843 rc = cifs_entry_is_dot(pfindEntry,pCifsF); 846 rc = cifs_entry_is_dot(pfindEntry,pCifsF);
844 /* skip . and .. since we added them first */ 847 /* skip . and .. since we added them first */
845 if(rc != 0) 848 if (rc != 0)
846 return 0; 849 return 0;
847 850
848 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 851 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
@@ -854,16 +857,16 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
854 max_len, 857 max_len,
855 &inum /* returned */); 858 &inum /* returned */);
856 859
857 if(rc) 860 if (rc)
858 return rc; 861 return rc;
859 862
860 rc = construct_dentry(&qstring,file,&tmp_inode, &tmp_dentry); 863 rc = construct_dentry(&qstring,file,&tmp_inode, &tmp_dentry);
861 if((tmp_inode == NULL) || (tmp_dentry == NULL)) 864 if ((tmp_inode == NULL) || (tmp_dentry == NULL))
862 return -ENOMEM; 865 return -ENOMEM;
863 866
864 if(rc) { 867 if (rc) {
865 /* inode created, we need to hash it with right inode number */ 868 /* inode created, we need to hash it with right inode number */
866 if(inum != 0) { 869 if (inum != 0) {
867 /* BB fixme - hash the 2 32 quantities bits together if necessary BB */ 870 /* BB fixme - hash the 2 32 quantities bits together if necessary BB */
868 tmp_inode->i_ino = inum; 871 tmp_inode->i_ino = inum;
869 } 872 }
@@ -873,27 +876,27 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
873 /* we pass in rc below, indicating whether it is a new inode, 876 /* we pass in rc below, indicating whether it is a new inode,
874 so we can figure out whether to invalidate the inode cached 877 so we can figure out whether to invalidate the inode cached
875 data if the file has changed */ 878 data if the file has changed */
876 if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX) 879 if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX)
877 unix_fill_in_inode(tmp_inode, 880 unix_fill_in_inode(tmp_inode,
878 (FILE_UNIX_INFO *)pfindEntry, 881 (FILE_UNIX_INFO *)pfindEntry,
879 &obj_type, rc); 882 &obj_type, rc);
880 else if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) 883 else if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD)
881 fill_in_inode(tmp_inode, 0 /* old level 1 buffer type */, 884 fill_in_inode(tmp_inode, 0 /* old level 1 buffer type */,
882 pfindEntry, &obj_type, rc); 885 pfindEntry, &obj_type, rc);
883 else 886 else
884 fill_in_inode(tmp_inode, 1 /* NT */, pfindEntry, &obj_type, rc); 887 fill_in_inode(tmp_inode, 1 /* NT */, pfindEntry, &obj_type, rc);
885 888
886 if(rc) /* new inode - needs to be tied to dentry */ { 889 if (rc) /* new inode - needs to be tied to dentry */ {
887 d_instantiate(tmp_dentry, tmp_inode); 890 d_instantiate(tmp_dentry, tmp_inode);
888 if(rc == 2) 891 if (rc == 2)
889 d_rehash(tmp_dentry); 892 d_rehash(tmp_dentry);
890 } 893 }
891 894
892 895
893 rc = filldir(direntry,qstring.name,qstring.len,file->f_pos, 896 rc = filldir(direntry,qstring.name,qstring.len,file->f_pos,
894 tmp_inode->i_ino,obj_type); 897 tmp_inode->i_ino,obj_type);
895 if(rc) { 898 if (rc) {
896 cFYI(1,("filldir rc = %d",rc)); 899 cFYI(1, ("filldir rc = %d", rc));
897 /* we can not return filldir errors to the caller 900 /* we can not return filldir errors to the caller
898 since they are "normal" when the stat blocksize 901 since they are "normal" when the stat blocksize
899 is too small - we return remapped error instead */ 902 is too small - we return remapped error instead */
@@ -912,47 +915,47 @@ static int cifs_save_resume_key(const char *current_entry,
912 __u16 level; 915 __u16 level;
913 char * filename; 916 char * filename;
914 917
915 if((cifsFile == NULL) || (current_entry == NULL)) 918 if ((cifsFile == NULL) || (current_entry == NULL))
916 return -EINVAL; 919 return -EINVAL;
917 920
918 level = cifsFile->srch_inf.info_level; 921 level = cifsFile->srch_inf.info_level;
919 922
920 if(level == SMB_FIND_FILE_UNIX) { 923 if (level == SMB_FIND_FILE_UNIX) {
921 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; 924 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
922 925
923 filename = &pFindData->FileName[0]; 926 filename = &pFindData->FileName[0];
924 if(cifsFile->srch_inf.unicode) { 927 if (cifsFile->srch_inf.unicode) {
925 len = cifs_unicode_bytelen(filename); 928 len = cifs_unicode_bytelen(filename);
926 } else { 929 } else {
927 /* BB should we make this strnlen of PATH_MAX? */ 930 /* BB should we make this strnlen of PATH_MAX? */
928 len = strnlen(filename, PATH_MAX); 931 len = strnlen(filename, PATH_MAX);
929 } 932 }
930 cifsFile->srch_inf.resume_key = pFindData->ResumeKey; 933 cifsFile->srch_inf.resume_key = pFindData->ResumeKey;
931 } else if(level == SMB_FIND_FILE_DIRECTORY_INFO) { 934 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
932 FILE_DIRECTORY_INFO * pFindData = 935 FILE_DIRECTORY_INFO * pFindData =
933 (FILE_DIRECTORY_INFO *)current_entry; 936 (FILE_DIRECTORY_INFO *)current_entry;
934 filename = &pFindData->FileName[0]; 937 filename = &pFindData->FileName[0];
935 len = le32_to_cpu(pFindData->FileNameLength); 938 len = le32_to_cpu(pFindData->FileNameLength);
936 cifsFile->srch_inf.resume_key = pFindData->FileIndex; 939 cifsFile->srch_inf.resume_key = pFindData->FileIndex;
937 } else if(level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) { 940 } else if (level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
938 FILE_FULL_DIRECTORY_INFO * pFindData = 941 FILE_FULL_DIRECTORY_INFO * pFindData =
939 (FILE_FULL_DIRECTORY_INFO *)current_entry; 942 (FILE_FULL_DIRECTORY_INFO *)current_entry;
940 filename = &pFindData->FileName[0]; 943 filename = &pFindData->FileName[0];
941 len = le32_to_cpu(pFindData->FileNameLength); 944 len = le32_to_cpu(pFindData->FileNameLength);
942 cifsFile->srch_inf.resume_key = pFindData->FileIndex; 945 cifsFile->srch_inf.resume_key = pFindData->FileIndex;
943 } else if(level == SMB_FIND_FILE_ID_FULL_DIR_INFO) { 946 } else if (level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
944 SEARCH_ID_FULL_DIR_INFO * pFindData = 947 SEARCH_ID_FULL_DIR_INFO * pFindData =
945 (SEARCH_ID_FULL_DIR_INFO *)current_entry; 948 (SEARCH_ID_FULL_DIR_INFO *)current_entry;
946 filename = &pFindData->FileName[0]; 949 filename = &pFindData->FileName[0];
947 len = le32_to_cpu(pFindData->FileNameLength); 950 len = le32_to_cpu(pFindData->FileNameLength);
948 cifsFile->srch_inf.resume_key = pFindData->FileIndex; 951 cifsFile->srch_inf.resume_key = pFindData->FileIndex;
949 } else if(level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { 952 } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
950 FILE_BOTH_DIRECTORY_INFO * pFindData = 953 FILE_BOTH_DIRECTORY_INFO * pFindData =
951 (FILE_BOTH_DIRECTORY_INFO *)current_entry; 954 (FILE_BOTH_DIRECTORY_INFO *)current_entry;
952 filename = &pFindData->FileName[0]; 955 filename = &pFindData->FileName[0];
953 len = le32_to_cpu(pFindData->FileNameLength); 956 len = le32_to_cpu(pFindData->FileNameLength);
954 cifsFile->srch_inf.resume_key = pFindData->FileIndex; 957 cifsFile->srch_inf.resume_key = pFindData->FileIndex;
955 } else if(level == SMB_FIND_FILE_INFO_STANDARD) { 958 } else if (level == SMB_FIND_FILE_INFO_STANDARD) {
956 FIND_FILE_STANDARD_INFO * pFindData = 959 FIND_FILE_STANDARD_INFO * pFindData =
957 (FIND_FILE_STANDARD_INFO *)current_entry; 960 (FIND_FILE_STANDARD_INFO *)current_entry;
958 filename = &pFindData->FileName[0]; 961 filename = &pFindData->FileName[0];
@@ -960,7 +963,7 @@ static int cifs_save_resume_key(const char *current_entry,
960 len = (unsigned int)pFindData->FileNameLength; 963 len = (unsigned int)pFindData->FileNameLength;
961 cifsFile->srch_inf.resume_key = pFindData->ResumeKey; 964 cifsFile->srch_inf.resume_key = pFindData->ResumeKey;
962 } else { 965 } else {
963 cFYI(1,("Unknown findfirst level %d",level)); 966 cFYI(1, ("Unknown findfirst level %d", level));
964 return -EINVAL; 967 return -EINVAL;
965 } 968 }
966 cifsFile->srch_inf.resume_name_len = len; 969 cifsFile->srch_inf.resume_name_len = len;
@@ -985,7 +988,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
985 988
986 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 989 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
987 pTcon = cifs_sb->tcon; 990 pTcon = cifs_sb->tcon;
988 if(pTcon == NULL) 991 if (pTcon == NULL)
989 return -EINVAL; 992 return -EINVAL;
990 993
991 switch ((int) file->f_pos) { 994 switch ((int) file->f_pos) {
@@ -1011,22 +1014,22 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
1011 if it before then restart search 1014 if it before then restart search
1012 if after then keep searching till find it */ 1015 if after then keep searching till find it */
1013 1016
1014 if(file->private_data == NULL) { 1017 if (file->private_data == NULL) {
1015 rc = initiate_cifs_search(xid,file); 1018 rc = initiate_cifs_search(xid,file);
1016 cFYI(1,("initiate cifs search rc %d",rc)); 1019 cFYI(1, ("initiate cifs search rc %d", rc));
1017 if(rc) { 1020 if (rc) {
1018 FreeXid(xid); 1021 FreeXid(xid);
1019 return rc; 1022 return rc;
1020 } 1023 }
1021 } 1024 }
1022 if(file->private_data == NULL) { 1025 if (file->private_data == NULL) {
1023 rc = -EINVAL; 1026 rc = -EINVAL;
1024 FreeXid(xid); 1027 FreeXid(xid);
1025 return rc; 1028 return rc;
1026 } 1029 }
1027 cifsFile = file->private_data; 1030 cifsFile = file->private_data;
1028 if (cifsFile->srch_inf.endOfSearch) { 1031 if (cifsFile->srch_inf.endOfSearch) {
1029 if(cifsFile->srch_inf.emptyDir) { 1032 if (cifsFile->srch_inf.emptyDir) {
1030 cFYI(1, ("End of search, empty dir")); 1033 cFYI(1, ("End of search, empty dir"));
1031 rc = 0; 1034 rc = 0;
1032 break; 1035 break;
@@ -1040,17 +1043,17 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
1040 1043
1041 rc = find_cifs_entry(xid,pTcon, file, 1044 rc = find_cifs_entry(xid,pTcon, file,
1042 &current_entry,&num_to_fill); 1045 &current_entry,&num_to_fill);
1043 if(rc) { 1046 if (rc) {
1044 cFYI(1,("fce error %d",rc)); 1047 cFYI(1, ("fce error %d", rc));
1045 goto rddir2_exit; 1048 goto rddir2_exit;
1046 } else if (current_entry != NULL) { 1049 } else if (current_entry != NULL) {
1047 cFYI(1,("entry %lld found",file->f_pos)); 1050 cFYI(1, ("entry %lld found", file->f_pos));
1048 } else { 1051 } else {
1049 cFYI(1,("could not find entry")); 1052 cFYI(1, ("could not find entry"));
1050 goto rddir2_exit; 1053 goto rddir2_exit;
1051 } 1054 }
1052 cFYI(1,("loop through %d times filling dir for net buf %p", 1055 cFYI(1, ("loop through %d times filling dir for net buf %p",
1053 num_to_fill,cifsFile->srch_inf.ntwrk_buf_start)); 1056 num_to_fill, cifsFile->srch_inf.ntwrk_buf_start));
1054 max_len = smbCalcSize((struct smb_hdr *) 1057 max_len = smbCalcSize((struct smb_hdr *)
1055 cifsFile->srch_inf.ntwrk_buf_start); 1058 cifsFile->srch_inf.ntwrk_buf_start);
1056 end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len; 1059 end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len;
@@ -1060,8 +1063,8 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
1060 such multibyte target UTF-8 characters. cifs_unicode.c, 1063 such multibyte target UTF-8 characters. cifs_unicode.c,
1061 which actually does the conversion, has the same limit */ 1064 which actually does the conversion, has the same limit */
1062 tmp_buf = kmalloc((2 * NAME_MAX) + 4, GFP_KERNEL); 1065 tmp_buf = kmalloc((2 * NAME_MAX) + 4, GFP_KERNEL);
1063 for(i=0;(i<num_to_fill) && (rc == 0);i++) { 1066 for (i = 0; (i < num_to_fill) && (rc == 0); i++) {
1064 if(current_entry == NULL) { 1067 if (current_entry == NULL) {
1065 /* evaluate whether this case is an error */ 1068 /* evaluate whether this case is an error */
1066 cERROR(1,("past end of SMB num to fill %d i %d", 1069 cERROR(1,("past end of SMB num to fill %d i %d",
1067 num_to_fill, i)); 1070 num_to_fill, i));
@@ -1071,20 +1074,20 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
1071 we want to check for that here? */ 1074 we want to check for that here? */
1072 rc = cifs_filldir(current_entry, file, 1075 rc = cifs_filldir(current_entry, file,
1073 filldir, direntry, tmp_buf, max_len); 1076 filldir, direntry, tmp_buf, max_len);
1074 if(rc == -EOVERFLOW) { 1077 if (rc == -EOVERFLOW) {
1075 rc = 0; 1078 rc = 0;
1076 break; 1079 break;
1077 } 1080 }
1078 1081
1079 file->f_pos++; 1082 file->f_pos++;
1080 if(file->f_pos == 1083 if (file->f_pos ==
1081 cifsFile->srch_inf.index_of_last_entry) { 1084 cifsFile->srch_inf.index_of_last_entry) {
1082 cFYI(1,("last entry in buf at pos %lld %s", 1085 cFYI(1, ("last entry in buf at pos %lld %s",
1083 file->f_pos,tmp_buf)); 1086 file->f_pos, tmp_buf));
1084 cifs_save_resume_key(current_entry,cifsFile); 1087 cifs_save_resume_key(current_entry, cifsFile);
1085 break; 1088 break;
1086 } else 1089 } else
1087 current_entry = 1090 current_entry =
1088 nxt_dir_entry(current_entry, end_of_smb, 1091 nxt_dir_entry(current_entry, end_of_smb,
1089 cifsFile->srch_inf.info_level); 1092 cifsFile->srch_inf.info_level);
1090 } 1093 }
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 758464630893..623c86cded24 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * SMB/CIFS session setup handling routines 4 * SMB/CIFS session setup handling routines
5 * 5 *
6 * Copyright (c) International Business Machines Corp., 2006 6 * Copyright (c) International Business Machines Corp., 2006, 2007
7 * Author(s): Steve French (sfrench@us.ibm.com) 7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or modify 9 * This library is free software; you can redistribute it and/or modify
@@ -31,7 +31,7 @@
31#include <linux/utsname.h> 31#include <linux/utsname.h>
32 32
33extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, 33extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8,
34 unsigned char *p24); 34 unsigned char *p24);
35 35
36static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB) 36static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
37{ 37{
@@ -45,13 +45,14 @@ static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
45 45
46 /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */ 46 /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */
47 47
48 /* BB verify whether signing required on neg or just on auth frame 48 /* BB verify whether signing required on neg or just on auth frame
49 (and NTLM case) */ 49 (and NTLM case) */
50 50
51 capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | 51 capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
52 CAP_LARGE_WRITE_X | CAP_LARGE_READ_X; 52 CAP_LARGE_WRITE_X | CAP_LARGE_READ_X;
53 53
54 if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 54 if (ses->server->secMode &
55 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
55 pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 56 pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
56 57
57 if (ses->capabilities & CAP_UNICODE) { 58 if (ses->capabilities & CAP_UNICODE) {
@@ -75,9 +76,9 @@ static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
75} 76}
76 77
77static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses, 78static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
78 const struct nls_table * nls_cp) 79 const struct nls_table *nls_cp)
79{ 80{
80 char * bcc_ptr = *pbcc_area; 81 char *bcc_ptr = *pbcc_area;
81 int bytes_ret = 0; 82 int bytes_ret = 0;
82 83
83 /* BB FIXME add check that strings total less 84 /* BB FIXME add check that strings total less
@@ -89,7 +90,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
89 bcc_ptr++; 90 bcc_ptr++;
90 } */ 91 } */
91 /* copy user */ 92 /* copy user */
92 if(ses->userName == NULL) { 93 if (ses->userName == NULL) {
93 /* null user mount */ 94 /* null user mount */
94 *bcc_ptr = 0; 95 *bcc_ptr = 0;
95 *(bcc_ptr+1) = 0; 96 *(bcc_ptr+1) = 0;
@@ -100,7 +101,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
100 bcc_ptr += 2 * bytes_ret; 101 bcc_ptr += 2 * bytes_ret;
101 bcc_ptr += 2; /* account for null termination */ 102 bcc_ptr += 2; /* account for null termination */
102 /* copy domain */ 103 /* copy domain */
103 if(ses->domainName == NULL) { 104 if (ses->domainName == NULL) {
104 /* Sending null domain better than using a bogus domain name (as 105 /* Sending null domain better than using a bogus domain name (as
105 we did briefly in 2.6.18) since server will use its default */ 106 we did briefly in 2.6.18) since server will use its default */
106 *bcc_ptr = 0; 107 *bcc_ptr = 0;
@@ -122,7 +123,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
122 bcc_ptr += 2; /* trailing null */ 123 bcc_ptr += 2; /* trailing null */
123 124
124 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS, 125 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
125 32, nls_cp); 126 32, nls_cp);
126 bcc_ptr += 2 * bytes_ret; 127 bcc_ptr += 2 * bytes_ret;
127 bcc_ptr += 2; /* trailing null */ 128 bcc_ptr += 2; /* trailing null */
128 129
@@ -130,29 +131,29 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
130} 131}
131 132
132static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses, 133static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
133 const struct nls_table * nls_cp) 134 const struct nls_table *nls_cp)
134{ 135{
135 char * bcc_ptr = *pbcc_area; 136 char *bcc_ptr = *pbcc_area;
136 137
137 /* copy user */ 138 /* copy user */
138 /* BB what about null user mounts - check that we do this BB */ 139 /* BB what about null user mounts - check that we do this BB */
139 /* copy user */ 140 /* copy user */
140 if(ses->userName == NULL) { 141 if (ses->userName == NULL) {
141 /* BB what about null user mounts - check that we do this BB */ 142 /* BB what about null user mounts - check that we do this BB */
142 } else { /* 300 should be long enough for any conceivable user name */ 143 } else { /* 300 should be long enough for any conceivable user name */
143 strncpy(bcc_ptr, ses->userName, 300); 144 strncpy(bcc_ptr, ses->userName, 300);
144 } 145 }
145 /* BB improve check for overflow */ 146 /* BB improve check for overflow */
146 bcc_ptr += strnlen(ses->userName, 300); 147 bcc_ptr += strnlen(ses->userName, 300);
147 *bcc_ptr = 0; 148 *bcc_ptr = 0;
148 bcc_ptr++; /* account for null termination */ 149 bcc_ptr++; /* account for null termination */
149 150
150 /* copy domain */ 151 /* copy domain */
151 152
152 if(ses->domainName != NULL) { 153 if (ses->domainName != NULL) {
153 strncpy(bcc_ptr, ses->domainName, 256); 154 strncpy(bcc_ptr, ses->domainName, 256);
154 bcc_ptr += strnlen(ses->domainName, 256); 155 bcc_ptr += strnlen(ses->domainName, 256);
155 } /* else we will send a null domain name 156 } /* else we will send a null domain name
156 so the server will default to its own domain */ 157 so the server will default to its own domain */
157 *bcc_ptr = 0; 158 *bcc_ptr = 0;
158 bcc_ptr++; 159 bcc_ptr++;
@@ -167,19 +168,20 @@ static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses,
167 strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); 168 strcpy(bcc_ptr, CIFS_NETWORK_OPSYS);
168 bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; 169 bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1;
169 170
170 *pbcc_area = bcc_ptr; 171 *pbcc_area = bcc_ptr;
171} 172}
172 173
173static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo *ses, 174static int decode_unicode_ssetup(char **pbcc_area, int bleft,
174 const struct nls_table * nls_cp) 175 struct cifsSesInfo *ses,
176 const struct nls_table *nls_cp)
175{ 177{
176 int rc = 0; 178 int rc = 0;
177 int words_left, len; 179 int words_left, len;
178 char * data = *pbcc_area; 180 char *data = *pbcc_area;
179 181
180 182
181 183
182 cFYI(1,("bleft %d",bleft)); 184 cFYI(1, ("bleft %d", bleft));
183 185
184 186
185 /* SMB header is unaligned, so cifs servers word align start of 187 /* SMB header is unaligned, so cifs servers word align start of
@@ -198,14 +200,14 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
198/* We look for obvious messed up bcc or strings in response so we do not go off 200/* We look for obvious messed up bcc or strings in response so we do not go off
199 the end since (at least) WIN2K and Windows XP have a major bug in not null 201 the end since (at least) WIN2K and Windows XP have a major bug in not null
200 terminating last Unicode string in response */ 202 terminating last Unicode string in response */
201 if(len >= words_left) 203 if (len >= words_left)
202 return rc; 204 return rc;
203 205
204 if(ses->serverOS) 206 if (ses->serverOS)
205 kfree(ses->serverOS); 207 kfree(ses->serverOS);
206 /* UTF-8 string will not grow more than four times as big as UCS-16 */ 208 /* UTF-8 string will not grow more than four times as big as UCS-16 */
207 ses->serverOS = kzalloc(4 * len, GFP_KERNEL); 209 ses->serverOS = kzalloc(4 * len, GFP_KERNEL);
208 if(ses->serverOS != NULL) { 210 if (ses->serverOS != NULL) {
209 cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len, 211 cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len,
210 nls_cp); 212 nls_cp);
211 } 213 }
@@ -215,67 +217,68 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf
215 /* save off server network operating system */ 217 /* save off server network operating system */
216 len = UniStrnlen((wchar_t *) data, words_left); 218 len = UniStrnlen((wchar_t *) data, words_left);
217 219
218 if(len >= words_left) 220 if (len >= words_left)
219 return rc; 221 return rc;
220 222
221 if(ses->serverNOS) 223 if (ses->serverNOS)
222 kfree(ses->serverNOS); 224 kfree(ses->serverNOS);
223 ses->serverNOS = kzalloc(4 * len, GFP_KERNEL); /* BB this is wrong length FIXME BB */ 225 ses->serverNOS = kzalloc(4 * len, GFP_KERNEL); /* BB this is wrong length FIXME BB */
224 if(ses->serverNOS != NULL) { 226 if (ses->serverNOS != NULL) {
225 cifs_strfromUCS_le(ses->serverNOS, (__le16 *)data, len, 227 cifs_strfromUCS_le(ses->serverNOS, (__le16 *)data, len,
226 nls_cp); 228 nls_cp);
227 if(strncmp(ses->serverNOS, "NT LAN Manager 4",16) == 0) { 229 if (strncmp(ses->serverNOS, "NT LAN Manager 4", 16) == 0) {
228 cFYI(1,("NT4 server")); 230 cFYI(1, ("NT4 server"));
229 ses->flags |= CIFS_SES_NT4; 231 ses->flags |= CIFS_SES_NT4;
230 } 232 }
231 } 233 }
232 data += 2 * (len + 1); 234 data += 2 * (len + 1);
233 words_left -= len + 1; 235 words_left -= len + 1;
234 236
235 /* save off server domain */ 237 /* save off server domain */
236 len = UniStrnlen((wchar_t *) data, words_left); 238 len = UniStrnlen((wchar_t *) data, words_left);
237 239
238 if(len > words_left) 240 if (len > words_left)
239 return rc; 241 return rc;
240 242
241 if(ses->serverDomain) 243 if (ses->serverDomain)
242 kfree(ses->serverDomain); 244 kfree(ses->serverDomain);
243 ses->serverDomain = kzalloc(2 * (len + 1), GFP_KERNEL); /* BB FIXME wrong length */ 245 ses->serverDomain = kzalloc(2 * (len + 1), GFP_KERNEL); /* BB FIXME wrong length */
244 if(ses->serverDomain != NULL) { 246 if (ses->serverDomain != NULL) {
245 cifs_strfromUCS_le(ses->serverDomain, (__le16 *)data, len, 247 cifs_strfromUCS_le(ses->serverDomain, (__le16 *)data, len,
246 nls_cp); 248 nls_cp);
247 ses->serverDomain[2*len] = 0; 249 ses->serverDomain[2*len] = 0;
248 ses->serverDomain[(2*len) + 1] = 0; 250 ses->serverDomain[(2*len) + 1] = 0;
249 } 251 }
250 data += 2 * (len + 1); 252 data += 2 * (len + 1);
251 words_left -= len + 1; 253 words_left -= len + 1;
252 254
253 cFYI(1,("words left: %d",words_left)); 255 cFYI(1, ("words left: %d", words_left));
254 256
255 return rc; 257 return rc;
256} 258}
257 259
258static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo *ses, 260static int decode_ascii_ssetup(char **pbcc_area, int bleft,
259 const struct nls_table * nls_cp) 261 struct cifsSesInfo *ses,
262 const struct nls_table *nls_cp)
260{ 263{
261 int rc = 0; 264 int rc = 0;
262 int len; 265 int len;
263 char * bcc_ptr = *pbcc_area; 266 char *bcc_ptr = *pbcc_area;
264 267
265 cFYI(1,("decode sessetup ascii. bleft %d", bleft)); 268 cFYI(1, ("decode sessetup ascii. bleft %d", bleft));
266 269
267 len = strnlen(bcc_ptr, bleft); 270 len = strnlen(bcc_ptr, bleft);
268 if(len >= bleft) 271 if (len >= bleft)
269 return rc; 272 return rc;
270 273
271 if(ses->serverOS) 274 if (ses->serverOS)
272 kfree(ses->serverOS); 275 kfree(ses->serverOS);
273 276
274 ses->serverOS = kzalloc(len + 1, GFP_KERNEL); 277 ses->serverOS = kzalloc(len + 1, GFP_KERNEL);
275 if(ses->serverOS) 278 if (ses->serverOS)
276 strncpy(ses->serverOS, bcc_ptr, len); 279 strncpy(ses->serverOS, bcc_ptr, len);
277 if(strncmp(ses->serverOS, "OS/2",4) == 0) { 280 if (strncmp(ses->serverOS, "OS/2", 4) == 0) {
278 cFYI(1,("OS/2 server")); 281 cFYI(1, ("OS/2 server"));
279 ses->flags |= CIFS_SES_OS2; 282 ses->flags |= CIFS_SES_OS2;
280 } 283 }
281 284
@@ -283,34 +286,34 @@ static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo
283 bleft -= len + 1; 286 bleft -= len + 1;
284 287
285 len = strnlen(bcc_ptr, bleft); 288 len = strnlen(bcc_ptr, bleft);
286 if(len >= bleft) 289 if (len >= bleft)
287 return rc; 290 return rc;
288 291
289 if(ses->serverNOS) 292 if (ses->serverNOS)
290 kfree(ses->serverNOS); 293 kfree(ses->serverNOS);
291 294
292 ses->serverNOS = kzalloc(len + 1, GFP_KERNEL); 295 ses->serverNOS = kzalloc(len + 1, GFP_KERNEL);
293 if(ses->serverNOS) 296 if (ses->serverNOS)
294 strncpy(ses->serverNOS, bcc_ptr, len); 297 strncpy(ses->serverNOS, bcc_ptr, len);
295 298
296 bcc_ptr += len + 1; 299 bcc_ptr += len + 1;
297 bleft -= len + 1; 300 bleft -= len + 1;
298 301
299 len = strnlen(bcc_ptr, bleft); 302 len = strnlen(bcc_ptr, bleft);
300 if(len > bleft) 303 if (len > bleft)
301 return rc; 304 return rc;
302 305
303 /* No domain field in LANMAN case. Domain is 306 /* No domain field in LANMAN case. Domain is
304 returned by old servers in the SMB negprot response */ 307 returned by old servers in the SMB negprot response */
305 /* BB For newer servers which do not support Unicode, 308 /* BB For newer servers which do not support Unicode,
306 but thus do return domain here we could add parsing 309 but thus do return domain here we could add parsing
307 for it later, but it is not very important */ 310 for it later, but it is not very important */
308 cFYI(1,("ascii: bytes left %d",bleft)); 311 cFYI(1, ("ascii: bytes left %d", bleft));
309 312
310 return rc; 313 return rc;
311} 314}
312 315
313int 316int
314CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, 317CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
315 const struct nls_table *nls_cp) 318 const struct nls_table *nls_cp)
316{ 319{
@@ -328,13 +331,13 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
328 __u16 action; 331 __u16 action;
329 int bytes_remaining; 332 int bytes_remaining;
330 333
331 if(ses == NULL) 334 if (ses == NULL)
332 return -EINVAL; 335 return -EINVAL;
333 336
334 type = ses->server->secType; 337 type = ses->server->secType;
335 338
336 cFYI(1,("sess setup type %d",type)); 339 cFYI(1, ("sess setup type %d", type));
337 if(type == LANMAN) { 340 if (type == LANMAN) {
338#ifndef CONFIG_CIFS_WEAK_PW_HASH 341#ifndef CONFIG_CIFS_WEAK_PW_HASH
339 /* LANMAN and plaintext are less secure and off by default. 342 /* LANMAN and plaintext are less secure and off by default.
340 So we make this explicitly be turned on in kconfig (in the 343 So we make this explicitly be turned on in kconfig (in the
@@ -344,15 +347,15 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
344 return -EOPNOTSUPP; 347 return -EOPNOTSUPP;
345#endif 348#endif
346 wct = 10; /* lanman 2 style sessionsetup */ 349 wct = 10; /* lanman 2 style sessionsetup */
347 } else if((type == NTLM) || (type == NTLMv2)) { 350 } else if ((type == NTLM) || (type == NTLMv2)) {
348 /* For NTLMv2 failures eventually may need to retry NTLM */ 351 /* For NTLMv2 failures eventually may need to retry NTLM */
349 wct = 13; /* old style NTLM sessionsetup */ 352 wct = 13; /* old style NTLM sessionsetup */
350 } else /* same size for negotiate or auth, NTLMSSP or extended security */ 353 } else /* same size: negotiate or auth, NTLMSSP or extended security */
351 wct = 12; 354 wct = 12;
352 355
353 rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses, 356 rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses,
354 (void **)&smb_buf); 357 (void **)&smb_buf);
355 if(rc) 358 if (rc)
356 return rc; 359 return rc;
357 360
358 pSMB = (SESSION_SETUP_ANDX *)smb_buf; 361 pSMB = (SESSION_SETUP_ANDX *)smb_buf;
@@ -364,8 +367,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
364 second part which will include the strings 367 second part which will include the strings
365 and rest of bcc area, in order to avoid having 368 and rest of bcc area, in order to avoid having
366 to do a large buffer 17K allocation */ 369 to do a large buffer 17K allocation */
367 iov[0].iov_base = (char *)pSMB; 370 iov[0].iov_base = (char *)pSMB;
368 iov[0].iov_len = smb_buf->smb_buf_length + 4; 371 iov[0].iov_len = smb_buf->smb_buf_length + 4;
369 372
370 /* 2000 big enough to fit max user, domain, NOS name etc. */ 373 /* 2000 big enough to fit max user, domain, NOS name etc. */
371 str_area = kmalloc(2000, GFP_KERNEL); 374 str_area = kmalloc(2000, GFP_KERNEL);
@@ -373,18 +376,18 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
373 376
374 ses->flags &= ~CIFS_SES_LANMAN; 377 ses->flags &= ~CIFS_SES_LANMAN;
375 378
376 if(type == LANMAN) { 379 if (type == LANMAN) {
377#ifdef CONFIG_CIFS_WEAK_PW_HASH 380#ifdef CONFIG_CIFS_WEAK_PW_HASH
378 char lnm_session_key[CIFS_SESS_KEY_SIZE]; 381 char lnm_session_key[CIFS_SESS_KEY_SIZE];
379 382
380 /* no capabilities flags in old lanman negotiation */ 383 /* no capabilities flags in old lanman negotiation */
381 384
382 pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE); 385 pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE);
383 /* BB calculate hash with password */ 386 /* BB calculate hash with password */
384 /* and copy into bcc */ 387 /* and copy into bcc */
385 388
386 calc_lanman_hash(ses, lnm_session_key); 389 calc_lanman_hash(ses, lnm_session_key);
387 ses->flags |= CIFS_SES_LANMAN; 390 ses->flags |= CIFS_SES_LANMAN;
388/* #ifdef CONFIG_CIFS_DEBUG2 391/* #ifdef CONFIG_CIFS_DEBUG2
389 cifs_dump_mem("cryptkey: ",ses->server->cryptKey, 392 cifs_dump_mem("cryptkey: ",ses->server->cryptKey,
390 CIFS_SESS_KEY_SIZE); 393 CIFS_SESS_KEY_SIZE);
@@ -397,10 +400,10 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
397 changed to do higher than lanman dialect and 400 changed to do higher than lanman dialect and
398 we reconnected would we ever calc signing_key? */ 401 we reconnected would we ever calc signing_key? */
399 402
400 cFYI(1,("Negotiating LANMAN setting up strings")); 403 cFYI(1, ("Negotiating LANMAN setting up strings"));
401 /* Unicode not allowed for LANMAN dialects */ 404 /* Unicode not allowed for LANMAN dialects */
402 ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); 405 ascii_ssetup_strings(&bcc_ptr, ses, nls_cp);
403#endif 406#endif
404 } else if (type == NTLM) { 407 } else if (type == NTLM) {
405 char ntlm_session_key[CIFS_SESS_KEY_SIZE]; 408 char ntlm_session_key[CIFS_SESS_KEY_SIZE];
406 409
@@ -414,33 +417,33 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
414 SMBNTencrypt(ses->password, ses->server->cryptKey, 417 SMBNTencrypt(ses->password, ses->server->cryptKey,
415 ntlm_session_key); 418 ntlm_session_key);
416 419
417 if(first_time) /* should this be moved into common code 420 if (first_time) /* should this be moved into common code
418 with similar ntlmv2 path? */ 421 with similar ntlmv2 path? */
419 cifs_calculate_mac_key(ses->server->mac_signing_key, 422 cifs_calculate_mac_key(ses->server->mac_signing_key,
420 ntlm_session_key, ses->password); 423 ntlm_session_key, ses->password);
421 /* copy session key */ 424 /* copy session key */
422 425
423 memcpy(bcc_ptr, (char *)ntlm_session_key,CIFS_SESS_KEY_SIZE); 426 memcpy(bcc_ptr, (char *)ntlm_session_key, CIFS_SESS_KEY_SIZE);
424 bcc_ptr += CIFS_SESS_KEY_SIZE; 427 bcc_ptr += CIFS_SESS_KEY_SIZE;
425 memcpy(bcc_ptr, (char *)ntlm_session_key,CIFS_SESS_KEY_SIZE); 428 memcpy(bcc_ptr, (char *)ntlm_session_key, CIFS_SESS_KEY_SIZE);
426 bcc_ptr += CIFS_SESS_KEY_SIZE; 429 bcc_ptr += CIFS_SESS_KEY_SIZE;
427 if(ses->capabilities & CAP_UNICODE) { 430 if (ses->capabilities & CAP_UNICODE) {
428 /* unicode strings must be word aligned */ 431 /* unicode strings must be word aligned */
429 if (iov[0].iov_len % 2) { 432 if (iov[0].iov_len % 2) {
430 *bcc_ptr = 0; 433 *bcc_ptr = 0;
431 bcc_ptr++; 434 bcc_ptr++;
432 } 435 }
433 unicode_ssetup_strings(&bcc_ptr, ses, nls_cp); 436 unicode_ssetup_strings(&bcc_ptr, ses, nls_cp);
434 } else 437 } else
435 ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); 438 ascii_ssetup_strings(&bcc_ptr, ses, nls_cp);
436 } else if (type == NTLMv2) { 439 } else if (type == NTLMv2) {
437 char * v2_sess_key = 440 char *v2_sess_key =
438 kmalloc(sizeof(struct ntlmv2_resp), GFP_KERNEL); 441 kmalloc(sizeof(struct ntlmv2_resp), GFP_KERNEL);
439 442
440 /* BB FIXME change all users of v2_sess_key to 443 /* BB FIXME change all users of v2_sess_key to
441 struct ntlmv2_resp */ 444 struct ntlmv2_resp */
442 445
443 if(v2_sess_key == NULL) { 446 if (v2_sess_key == NULL) {
444 cifs_small_buf_release(smb_buf); 447 cifs_small_buf_release(smb_buf);
445 return -ENOMEM; 448 return -ENOMEM;
446 } 449 }
@@ -456,8 +459,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
456 459
457 /* calculate session key */ 460 /* calculate session key */
458 setup_ntlmv2_rsp(ses, v2_sess_key, nls_cp); 461 setup_ntlmv2_rsp(ses, v2_sess_key, nls_cp);
459 if(first_time) /* should this be moved into common code 462 if (first_time) /* should this be moved into common code
460 with similar ntlmv2 path? */ 463 with similar ntlmv2 path? */
461 /* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key, 464 /* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key,
462 response BB FIXME, v2_sess_key); */ 465 response BB FIXME, v2_sess_key); */
463 466
@@ -468,8 +471,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
468 memcpy(bcc_ptr, (char *)v2_sess_key, sizeof(struct ntlmv2_resp)); 471 memcpy(bcc_ptr, (char *)v2_sess_key, sizeof(struct ntlmv2_resp));
469 bcc_ptr += sizeof(struct ntlmv2_resp); 472 bcc_ptr += sizeof(struct ntlmv2_resp);
470 kfree(v2_sess_key); 473 kfree(v2_sess_key);
471 if(ses->capabilities & CAP_UNICODE) { 474 if (ses->capabilities & CAP_UNICODE) {
472 if(iov[0].iov_len % 2) { 475 if (iov[0].iov_len % 2) {
473 *bcc_ptr = 0; 476 *bcc_ptr = 0;
474 } bcc_ptr++; 477 } bcc_ptr++;
475 unicode_ssetup_strings(&bcc_ptr, ses, nls_cp); 478 unicode_ssetup_strings(&bcc_ptr, ses, nls_cp);
@@ -488,20 +491,20 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
488 BCC_LE(smb_buf) = cpu_to_le16(count); 491 BCC_LE(smb_buf) = cpu_to_le16(count);
489 492
490 iov[1].iov_base = str_area; 493 iov[1].iov_base = str_area;
491 iov[1].iov_len = count; 494 iov[1].iov_len = count;
492 rc = SendReceive2(xid, ses, iov, 2 /* num_iovecs */, &resp_buf_type, 0); 495 rc = SendReceive2(xid, ses, iov, 2 /* num_iovecs */, &resp_buf_type, 0);
493 /* SMB request buf freed in SendReceive2 */ 496 /* SMB request buf freed in SendReceive2 */
494 497
495 cFYI(1,("ssetup rc from sendrecv2 is %d",rc)); 498 cFYI(1, ("ssetup rc from sendrecv2 is %d", rc));
496 if(rc) 499 if (rc)
497 goto ssetup_exit; 500 goto ssetup_exit;
498 501
499 pSMB = (SESSION_SETUP_ANDX *)iov[0].iov_base; 502 pSMB = (SESSION_SETUP_ANDX *)iov[0].iov_base;
500 smb_buf = (struct smb_hdr *)iov[0].iov_base; 503 smb_buf = (struct smb_hdr *)iov[0].iov_base;
501 504
502 if((smb_buf->WordCount != 3) && (smb_buf->WordCount != 4)) { 505 if ((smb_buf->WordCount != 3) && (smb_buf->WordCount != 4)) {
503 rc = -EIO; 506 rc = -EIO;
504 cERROR(1,("bad word count %d", smb_buf->WordCount)); 507 cERROR(1, ("bad word count %d", smb_buf->WordCount));
505 goto ssetup_exit; 508 goto ssetup_exit;
506 } 509 }
507 action = le16_to_cpu(pSMB->resp.Action); 510 action = le16_to_cpu(pSMB->resp.Action);
@@ -514,20 +517,20 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
514 bytes_remaining = BCC(smb_buf); 517 bytes_remaining = BCC(smb_buf);
515 bcc_ptr = pByteArea(smb_buf); 518 bcc_ptr = pByteArea(smb_buf);
516 519
517 if(smb_buf->WordCount == 4) { 520 if (smb_buf->WordCount == 4) {
518 __u16 blob_len; 521 __u16 blob_len;
519 blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength); 522 blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
520 bcc_ptr += blob_len; 523 bcc_ptr += blob_len;
521 if(blob_len > bytes_remaining) { 524 if (blob_len > bytes_remaining) {
522 cERROR(1,("bad security blob length %d", blob_len)); 525 cERROR(1, ("bad security blob length %d", blob_len));
523 rc = -EINVAL; 526 rc = -EINVAL;
524 goto ssetup_exit; 527 goto ssetup_exit;
525 } 528 }
526 bytes_remaining -= blob_len; 529 bytes_remaining -= blob_len;
527 } 530 }
528 531
529 /* BB check if Unicode and decode strings */ 532 /* BB check if Unicode and decode strings */
530 if(smb_buf->Flags2 & SMBFLG2_UNICODE) 533 if (smb_buf->Flags2 & SMBFLG2_UNICODE)
531 rc = decode_unicode_ssetup(&bcc_ptr, bytes_remaining, 534 rc = decode_unicode_ssetup(&bcc_ptr, bytes_remaining,
532 ses, nls_cp); 535 ses, nls_cp);
533 else 536 else
@@ -535,10 +538,10 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
535 538
536ssetup_exit: 539ssetup_exit:
537 kfree(str_area); 540 kfree(str_area);
538 if(resp_buf_type == CIFS_SMALL_BUFFER) { 541 if (resp_buf_type == CIFS_SMALL_BUFFER) {
539 cFYI(1,("ssetup freeing small buf %p", iov[0].iov_base)); 542 cFYI(1, ("ssetup freeing small buf %p", iov[0].iov_base));
540 cifs_small_buf_release(iov[0].iov_base); 543 cifs_small_buf_release(iov[0].iov_base);
541 } else if(resp_buf_type == CIFS_LARGE_BUFFER) 544 } else if (resp_buf_type == CIFS_LARGE_BUFFER)
542 cifs_buf_release(iov[0].iov_base); 545 cifs_buf_release(iov[0].iov_base);
543 546
544 return rc; 547 return rc;
diff --git a/fs/cifs/smbencrypt.c b/fs/cifs/smbencrypt.c
index 4b25ba92180d..1966adaf0b29 100644
--- a/fs/cifs/smbencrypt.c
+++ b/fs/cifs/smbencrypt.c
@@ -1,4 +1,4 @@
1/* 1/*
2 Unix SMB/Netbios implementation. 2 Unix SMB/Netbios implementation.
3 Version 1.9. 3 Version 1.9.
4 SMB parameters and setup 4 SMB parameters and setup
@@ -57,7 +57,7 @@ void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
57 57
58/* 58/*
59 This implements the X/Open SMB password encryption 59 This implements the X/Open SMB password encryption
60 It takes a password, a 8 byte "crypt key" and puts 24 bytes of 60 It takes a password, a 8 byte "crypt key" and puts 24 bytes of
61 encrypted password into p24 */ 61 encrypted password into p24 */
62/* Note that password must be uppercased and null terminated */ 62/* Note that password must be uppercased and null terminated */
63void 63void
@@ -74,8 +74,8 @@ SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24)
74 74
75 SMBOWFencrypt(p21, c8, p24); 75 SMBOWFencrypt(p21, c8, p24);
76 76
77 memset(p14,0,15); 77 memset(p14, 0, 15);
78 memset(p21,0,21); 78 memset(p21, 0, 21);
79} 79}
80 80
81/* Routines for Windows NT MD4 Hash functions. */ 81/* Routines for Windows NT MD4 Hash functions. */
@@ -90,14 +90,14 @@ _my_wcslen(__u16 * str)
90 90
91/* 91/*
92 * Convert a string into an NT UNICODE string. 92 * Convert a string into an NT UNICODE string.
93 * Note that regardless of processor type 93 * Note that regardless of processor type
94 * this must be in intel (little-endian) 94 * this must be in intel (little-endian)
95 * format. 95 * format.
96 */ 96 */
97 97
98static int 98static int
99_my_mbstowcs(__u16 * dst, const unsigned char *src, int len) 99_my_mbstowcs(__u16 * dst, const unsigned char *src, int len)
100{ /* not a very good conversion routine - change/fix */ 100{ /* BB not a very good conversion routine - change/fix */
101 int i; 101 int i;
102 __u16 val; 102 __u16 val;
103 103
@@ -112,7 +112,7 @@ _my_mbstowcs(__u16 * dst, const unsigned char *src, int len)
112 return i; 112 return i;
113} 113}
114 114
115/* 115/*
116 * Creates the MD4 Hash of the users password in NT UNICODE. 116 * Creates the MD4 Hash of the users password in NT UNICODE.
117 */ 117 */
118 118
@@ -123,7 +123,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16)
123 __u16 wpwd[129]; 123 __u16 wpwd[129];
124 124
125 /* Password cannot be longer than 128 characters */ 125 /* Password cannot be longer than 128 characters */
126 if(passwd) { 126 if (passwd) {
127 len = strlen((char *) passwd); 127 len = strlen((char *) passwd);
128 if (len > 128) { 128 if (len > 128) {
129 len = 128; 129 len = 128;
@@ -138,7 +138,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16)
138 len = _my_wcslen(wpwd) * sizeof (__u16); 138 len = _my_wcslen(wpwd) * sizeof (__u16);
139 139
140 mdfour(p16, (unsigned char *) wpwd, len); 140 mdfour(p16, (unsigned char *) wpwd, len);
141 memset(wpwd,0,129 * 2); 141 memset(wpwd, 0, 129 * 2);
142} 142}
143 143
144#if 0 /* currently unused */ 144#if 0 /* currently unused */
@@ -184,8 +184,8 @@ ntv2_owf_gen(const unsigned char owf[16], const char *user_n,
184 struct HMACMD5Context ctx; 184 struct HMACMD5Context ctx;
185 185
186 /* might as well do one alloc to hold both (user_u and dom_u) */ 186 /* might as well do one alloc to hold both (user_u and dom_u) */
187 user_u = kmalloc(2048 * sizeof(wchar_t),GFP_KERNEL); 187 user_u = kmalloc(2048 * sizeof(wchar_t), GFP_KERNEL);
188 if(user_u == NULL) 188 if (user_u == NULL)
189 return; 189 return;
190 dom_u = user_u + 1024; 190 dom_u = user_u + 1024;
191 191
@@ -206,7 +206,7 @@ ntv2_owf_gen(const unsigned char owf[16], const char *user_n,
206 206
207 kfree(user_u); 207 kfree(user_u);
208} 208}
209#endif 209#endif
210 210
211/* Does the des encryption from the NT or LM MD4 hash. */ 211/* Does the des encryption from the NT or LM MD4 hash. */
212static void 212static void
@@ -256,15 +256,15 @@ SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24)
256#if 0 256#if 0
257static void 257static void
258SMBOWFencrypt_ntv2(const unsigned char kr[16], 258SMBOWFencrypt_ntv2(const unsigned char kr[16],
259 const struct data_blob * srv_chal, 259 const struct data_blob *srv_chal,
260 const struct data_blob * cli_chal, unsigned char resp_buf[16]) 260 const struct data_blob *cli_chal, unsigned char resp_buf[16])
261{ 261{
262 struct HMACMD5Context ctx; 262 struct HMACMD5Context ctx;
263 263
264 hmac_md5_init_limK_to_64(kr, 16, &ctx); 264 hmac_md5_init_limK_to_64(kr, 16, &ctx);
265 hmac_md5_update(srv_chal->data, srv_chal->length, &ctx); 265 hmac_md5_update(srv_chal->data, srv_chal->length, &ctx);
266 hmac_md5_update(cli_chal->data, cli_chal->length, &ctx); 266 hmac_md5_update(cli_chal->data, cli_chal->length, &ctx);
267 hmac_md5_final(resp_buf, &ctx); 267 hmac_md5_final(resp_buf, &ctx);
268} 268}
269 269
270static void 270static void