aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-06-11 14:39:25 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-06-11 14:39:25 -0400
commit3e2ce4dae98f6b246eaeb12833914d22fd83e31d (patch)
tree50e461bd4dc6cf5c2ad1466ffc472351a9d813ed /fs
parent3334500b460a5eede2e3466ca97a90fe3b91ceb5 (diff)
parent3ce53fc4c57603d99c330a6ee2fe96d94f2d350f (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6: [CIFS] CIFS should honour umask [CIFS] Missing flag on negprot needed for some servers to force packet signing [CIFS] whitespace cleanup part 2 [CIFS] whitespace cleanup [CIFS] fix mempool destroy done in wrong order in cifs error path [CIFS] typo in previous patch [CIFS] Fix oops on failed cifs mount (in kthread_stop)
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifs_debug.c252
-rw-r--r--fs/cifs/cifs_unicode.c12
-rw-r--r--fs/cifs/cifsfs.c2
-rw-r--r--fs/cifs/cifssmb.c4
-rw-r--r--fs/cifs/connect.c16
-rw-r--r--fs/cifs/dir.c184
-rw-r--r--fs/cifs/fcntl.c46
-rw-r--r--fs/cifs/inode.c5
-rw-r--r--fs/cifs/ioctl.c29
-rw-r--r--fs/cifs/rfc1002pdu.h2
10 files changed, 285 insertions, 267 deletions
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 6017c465440e..07838b2ac1ce 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -7,16 +7,16 @@
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
16 * the GNU General Public License for more details. 16 * the GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 21 */
22#include <linux/fs.h> 22#include <linux/fs.h>
@@ -39,7 +39,7 @@ cifs_dump_mem(char *label, void *data, int length)
39 char *charptr = data; 39 char *charptr = data;
40 char buf[10], line[80]; 40 char buf[10], line[80];
41 41
42 printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n", 42 printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
43 label, length, data); 43 label, length, data);
44 for (i = 0; i < length; i += 16) { 44 for (i = 0; i < length; i += 16) {
45 line[0] = 0; 45 line[0] = 0;
@@ -60,10 +60,10 @@ cifs_dump_mem(char *label, void *data, int length)
60#ifdef CONFIG_CIFS_DEBUG2 60#ifdef CONFIG_CIFS_DEBUG2
61void cifs_dump_detail(struct smb_hdr * smb) 61void cifs_dump_detail(struct smb_hdr * smb)
62{ 62{
63 cERROR(1,("Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d", 63 cERROR(1, ("Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
64 smb->Command, smb->Status.CifsError, 64 smb->Command, smb->Status.CifsError,
65 smb->Flags, smb->Flags2, smb->Mid, smb->Pid)); 65 smb->Flags, smb->Flags2, smb->Mid, smb->Pid));
66 cERROR(1,("smb buf %p len %d", smb, smbCalcSize_LE(smb))); 66 cERROR(1, ("smb buf %p len %d", smb, smbCalcSize_LE(smb)));
67} 67}
68 68
69 69
@@ -72,36 +72,35 @@ void cifs_dump_mids(struct TCP_Server_Info * server)
72 struct list_head *tmp; 72 struct list_head *tmp;
73 struct mid_q_entry * mid_entry; 73 struct mid_q_entry * mid_entry;
74 74
75 if(server == NULL) 75 if (server == NULL)
76 return; 76 return;
77 77
78 cERROR(1,("Dump pending requests:")); 78 cERROR(1, ("Dump pending requests:"));
79 spin_lock(&GlobalMid_Lock); 79 spin_lock(&GlobalMid_Lock);
80 list_for_each(tmp, &server->pending_mid_q) { 80 list_for_each(tmp, &server->pending_mid_q) {
81 mid_entry = list_entry(tmp, struct mid_q_entry, qhead); 81 mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
82 if(mid_entry) { 82 if (mid_entry) {
83 cERROR(1,("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d", 83 cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
84 mid_entry->midState, 84 mid_entry->midState,
85 (int)mid_entry->command, 85 (int)mid_entry->command,
86 mid_entry->pid, 86 mid_entry->pid,
87 mid_entry->tsk, 87 mid_entry->tsk,
88 mid_entry->mid)); 88 mid_entry->mid));
89#ifdef CONFIG_CIFS_STATS2 89#ifdef CONFIG_CIFS_STATS2
90 cERROR(1,("IsLarge: %d buf: %p time rcv: %ld now: %ld", 90 cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld",
91 mid_entry->largeBuf, 91 mid_entry->largeBuf,
92 mid_entry->resp_buf, 92 mid_entry->resp_buf,
93 mid_entry->when_received, 93 mid_entry->when_received,
94 jiffies)); 94 jiffies));
95#endif /* STATS2 */ 95#endif /* STATS2 */
96 cERROR(1,("IsMult: %d IsEnd: %d", mid_entry->multiRsp, 96 cERROR(1, ("IsMult: %d IsEnd: %d", mid_entry->multiRsp,
97 mid_entry->multiEnd)); 97 mid_entry->multiEnd));
98 if(mid_entry->resp_buf) { 98 if (mid_entry->resp_buf) {
99 cifs_dump_detail(mid_entry->resp_buf); 99 cifs_dump_detail(mid_entry->resp_buf);
100 cifs_dump_mem("existing buf: ", 100 cifs_dump_mem("existing buf: ",
101 mid_entry->resp_buf, 101 mid_entry->resp_buf,
102 62 /* fixme */); 102 62 /* fixme */);
103 } 103 }
104
105 } 104 }
106 } 105 }
107 spin_unlock(&GlobalMid_Lock); 106 spin_unlock(&GlobalMid_Lock);
@@ -129,9 +128,10 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
129 "Display Internal CIFS Data Structures for Debugging\n" 128 "Display Internal CIFS Data Structures for Debugging\n"
130 "---------------------------------------------------\n"); 129 "---------------------------------------------------\n");
131 buf += length; 130 buf += length;
132 length = sprintf(buf,"CIFS Version %s\n",CIFS_VERSION); 131 length = sprintf(buf, "CIFS Version %s\n", CIFS_VERSION);
133 buf += length; 132 buf += length;
134 length = sprintf(buf,"Active VFS Requests: %d\n", GlobalTotalActiveXid); 133 length = sprintf(buf,
134 "Active VFS Requests: %d\n", GlobalTotalActiveXid);
135 buf += length; 135 buf += length;
136 length = sprintf(buf, "Servers:"); 136 length = sprintf(buf, "Servers:");
137 buf += length; 137 buf += length;
@@ -141,7 +141,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
141 list_for_each(tmp, &GlobalSMBSessionList) { 141 list_for_each(tmp, &GlobalSMBSessionList) {
142 i++; 142 i++;
143 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 143 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
144 if((ses->serverDomain == NULL) || (ses->serverOS == NULL) || 144 if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
145 (ses->serverNOS == NULL)) { 145 (ses->serverNOS == NULL)) {
146 buf += sprintf(buf, "\nentry for %s not fully " 146 buf += sprintf(buf, "\nentry for %s not fully "
147 "displayed\n\t", ses->serverName); 147 "displayed\n\t", ses->serverName);
@@ -149,15 +149,18 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
149 } else { 149 } else {
150 length = 150 length =
151 sprintf(buf, 151 sprintf(buf,
152 "\n%d) Name: %s Domain: %s Mounts: %d OS: %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB session status: %d\t", 152 "\n%d) Name: %s Domain: %s Mounts: %d OS:"
153 " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB"
154 " session status: %d\t",
153 i, ses->serverName, ses->serverDomain, 155 i, ses->serverName, ses->serverDomain,
154 atomic_read(&ses->inUse), 156 atomic_read(&ses->inUse),
155 ses->serverOS, ses->serverNOS, 157 ses->serverOS, ses->serverNOS,
156 ses->capabilities,ses->status); 158 ses->capabilities, ses->status);
157 buf += length; 159 buf += length;
158 } 160 }
159 if(ses->server) { 161 if (ses->server) {
160 buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req On Wire: %d", 162 buf += sprintf(buf, "TCP status: %d\n\tLocal Users To "
163 "Server: %d SecMode: 0x%x Req On Wire: %d",
161 ses->server->tcpStatus, 164 ses->server->tcpStatus,
162 atomic_read(&ses->server->socketUseCount), 165 atomic_read(&ses->server->socketUseCount),
163 ses->server->secMode, 166 ses->server->secMode,
@@ -165,7 +168,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
165 168
166#ifdef CONFIG_CIFS_STATS2 169#ifdef CONFIG_CIFS_STATS2
167 buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d", 170 buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d",
168 atomic_read(&ses->server->inSend), 171 atomic_read(&ses->server->inSend),
169 atomic_read(&ses->server->num_waiters)); 172 atomic_read(&ses->server->num_waiters));
170#endif 173#endif
171 174
@@ -177,17 +180,19 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
177 mid_entry = list_entry(tmp1, struct 180 mid_entry = list_entry(tmp1, struct
178 mid_q_entry, 181 mid_q_entry,
179 qhead); 182 qhead);
180 if(mid_entry) { 183 if (mid_entry) {
181 length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n", 184 length = sprintf(buf,
182 mid_entry->midState, 185 "State: %d com: %d pid:"
183 (int)mid_entry->command, 186 " %d tsk: %p mid %d\n",
184 mid_entry->pid, 187 mid_entry->midState,
185 mid_entry->tsk, 188 (int)mid_entry->command,
186 mid_entry->mid); 189 mid_entry->pid,
190 mid_entry->tsk,
191 mid_entry->mid);
187 buf += length; 192 buf += length;
188 } 193 }
189 } 194 }
190 spin_unlock(&GlobalMid_Lock); 195 spin_unlock(&GlobalMid_Lock);
191 } 196 }
192 197
193 } 198 }
@@ -207,7 +212,8 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
207 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); 212 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
208 length = 213 length =
209 sprintf(buf, 214 sprintf(buf,
210 "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d", 215 "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x "
216 "Attributes: 0x%x\nPathComponentMax: %d Status: %d",
211 i, tcon->treeName, 217 i, tcon->treeName,
212 atomic_read(&tcon->useCount), 218 atomic_read(&tcon->useCount),
213 tcon->nativeFileSystem, 219 tcon->nativeFileSystem,
@@ -215,7 +221,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
215 le32_to_cpu(tcon->fsAttrInfo.Attributes), 221 le32_to_cpu(tcon->fsAttrInfo.Attributes),
216 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), 222 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
217 tcon->tidStatus); 223 tcon->tidStatus);
218 buf += length; 224 buf += length;
219 if (dev_type == FILE_DEVICE_DISK) 225 if (dev_type == FILE_DEVICE_DISK)
220 length = sprintf(buf, " type: DISK "); 226 length = sprintf(buf, " type: DISK ");
221 else if (dev_type == FILE_DEVICE_CD_ROM) 227 else if (dev_type == FILE_DEVICE_CD_ROM)
@@ -224,7 +230,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
224 length = 230 length =
225 sprintf(buf, " type: %d ", dev_type); 231 sprintf(buf, " type: %d ", dev_type);
226 buf += length; 232 buf += length;
227 if(tcon->tidStatus == CifsNeedReconnect) { 233 if (tcon->tidStatus == CifsNeedReconnect) {
228 buf += sprintf(buf, "\tDISCONNECTED "); 234 buf += sprintf(buf, "\tDISCONNECTED ");
229 length += 14; 235 length += 14;
230 } 236 }
@@ -238,9 +244,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
238 /* Now calculate total size of returned data */ 244 /* Now calculate total size of returned data */
239 length = buf - original_buf; 245 length = buf - original_buf;
240 246
241 if(offset + count >= length) 247 if (offset + count >= length)
242 *eof = 1; 248 *eof = 1;
243 if(length < offset) { 249 if (length < offset) {
244 *eof = 1; 250 *eof = 1;
245 return 0; 251 return 0;
246 } else { 252 } else {
@@ -256,18 +262,18 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
256 262
257static int 263static int
258cifs_stats_write(struct file *file, const char __user *buffer, 264cifs_stats_write(struct file *file, const char __user *buffer,
259 unsigned long count, void *data) 265 unsigned long count, void *data)
260{ 266{
261 char c; 267 char c;
262 int rc; 268 int rc;
263 struct list_head *tmp; 269 struct list_head *tmp;
264 struct cifsTconInfo *tcon; 270 struct cifsTconInfo *tcon;
265 271
266 rc = get_user(c, buffer); 272 rc = get_user(c, buffer);
267 if (rc) 273 if (rc)
268 return rc; 274 return rc;
269 275
270 if (c == '1' || c == 'y' || c == 'Y' || c == '0') { 276 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
271 read_lock(&GlobalSMBSeslock); 277 read_lock(&GlobalSMBSeslock);
272#ifdef CONFIG_CIFS_STATS2 278#ifdef CONFIG_CIFS_STATS2
273 atomic_set(&totBufAllocCount, 0); 279 atomic_set(&totBufAllocCount, 0);
@@ -297,14 +303,14 @@ cifs_stats_write(struct file *file, const char __user *buffer,
297 read_unlock(&GlobalSMBSeslock); 303 read_unlock(&GlobalSMBSeslock);
298 } 304 }
299 305
300 return count; 306 return count;
301} 307}
302 308
303static int 309static int
304cifs_stats_read(char *buf, char **beginBuffer, off_t offset, 310cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
305 int count, int *eof, void *data) 311 int count, int *eof, void *data)
306{ 312{
307 int item_length,i,length; 313 int item_length, i, length;
308 struct list_head *tmp; 314 struct list_head *tmp;
309 struct cifsTconInfo *tcon; 315 struct cifsTconInfo *tcon;
310 316
@@ -314,44 +320,44 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
314 "Resources in use\nCIFS Session: %d\n", 320 "Resources in use\nCIFS Session: %d\n",
315 sesInfoAllocCount.counter); 321 sesInfoAllocCount.counter);
316 buf += length; 322 buf += length;
317 item_length = 323 item_length =
318 sprintf(buf,"Share (unique mount targets): %d\n", 324 sprintf(buf, "Share (unique mount targets): %d\n",
319 tconInfoAllocCount.counter); 325 tconInfoAllocCount.counter);
320 length += item_length; 326 length += item_length;
321 buf += item_length; 327 buf += item_length;
322 item_length = 328 item_length =
323 sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n", 329 sprintf(buf, "SMB Request/Response Buffer: %d Pool size: %d\n",
324 bufAllocCount.counter, 330 bufAllocCount.counter,
325 cifs_min_rcv + tcpSesAllocCount.counter); 331 cifs_min_rcv + tcpSesAllocCount.counter);
326 length += item_length; 332 length += item_length;
327 buf += item_length; 333 buf += item_length;
328 item_length = 334 item_length =
329 sprintf(buf,"SMB Small Req/Resp Buffer: %d Pool size: %d\n", 335 sprintf(buf, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
330 smBufAllocCount.counter,cifs_min_small); 336 smBufAllocCount.counter, cifs_min_small);
331 length += item_length; 337 length += item_length;
332 buf += item_length; 338 buf += item_length;
333#ifdef CONFIG_CIFS_STATS2 339#ifdef CONFIG_CIFS_STATS2
334 item_length = sprintf(buf, "Total Large %d Small %d Allocations\n", 340 item_length = sprintf(buf, "Total Large %d Small %d Allocations\n",
335 atomic_read(&totBufAllocCount), 341 atomic_read(&totBufAllocCount),
336 atomic_read(&totSmBufAllocCount)); 342 atomic_read(&totSmBufAllocCount));
337 length += item_length; 343 length += item_length;
338 buf += item_length; 344 buf += item_length;
339#endif /* CONFIG_CIFS_STATS2 */ 345#endif /* CONFIG_CIFS_STATS2 */
340 346
341 item_length = 347 item_length =
342 sprintf(buf,"Operations (MIDs): %d\n", 348 sprintf(buf, "Operations (MIDs): %d\n",
343 midCount.counter); 349 midCount.counter);
344 length += item_length; 350 length += item_length;
345 buf += item_length; 351 buf += item_length;
346 item_length = sprintf(buf, 352 item_length = sprintf(buf,
347 "\n%d session %d share reconnects\n", 353 "\n%d session %d share reconnects\n",
348 tcpSesReconnectCount.counter,tconInfoReconnectCount.counter); 354 tcpSesReconnectCount.counter, tconInfoReconnectCount.counter);
349 length += item_length; 355 length += item_length;
350 buf += item_length; 356 buf += item_length;
351 357
352 item_length = sprintf(buf, 358 item_length = sprintf(buf,
353 "Total vfs operations: %d maximum at one time: %d\n", 359 "Total vfs operations: %d maximum at one time: %d\n",
354 GlobalCurrentXid,GlobalMaxActiveXid); 360 GlobalCurrentXid, GlobalMaxActiveXid);
355 length += item_length; 361 length += item_length;
356 buf += item_length; 362 buf += item_length;
357 363
@@ -360,10 +366,10 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
360 list_for_each(tmp, &GlobalTreeConnectionList) { 366 list_for_each(tmp, &GlobalTreeConnectionList) {
361 i++; 367 i++;
362 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 368 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
363 item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName); 369 item_length = sprintf(buf, "\n%d) %s", i, tcon->treeName);
364 buf += item_length; 370 buf += item_length;
365 length += item_length; 371 length += item_length;
366 if(tcon->tidStatus == CifsNeedReconnect) { 372 if (tcon->tidStatus == CifsNeedReconnect) {
367 buf += sprintf(buf, "\tDISCONNECTED "); 373 buf += sprintf(buf, "\tDISCONNECTED ");
368 length += 14; 374 length += 14;
369 } 375 }
@@ -380,15 +386,15 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
380 item_length = sprintf(buf, "\nWrites: %d Bytes: %lld", 386 item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
381 atomic_read(&tcon->num_writes), 387 atomic_read(&tcon->num_writes),
382 (long long)(tcon->bytes_written)); 388 (long long)(tcon->bytes_written));
383 buf += item_length; 389 buf += item_length;
384 length += item_length; 390 length += item_length;
385 item_length = sprintf(buf, 391 item_length = sprintf(buf,
386 "\nLocks: %d HardLinks: %d Symlinks: %d", 392 "\nLocks: %d HardLinks: %d Symlinks: %d",
387 atomic_read(&tcon->num_locks), 393 atomic_read(&tcon->num_locks),
388 atomic_read(&tcon->num_hardlinks), 394 atomic_read(&tcon->num_hardlinks),
389 atomic_read(&tcon->num_symlinks)); 395 atomic_read(&tcon->num_symlinks));
390 buf += item_length; 396 buf += item_length;
391 length += item_length; 397 length += item_length;
392 398
393 item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d", 399 item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d",
394 atomic_read(&tcon->num_opens), 400 atomic_read(&tcon->num_opens),
@@ -415,12 +421,12 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
415 } 421 }
416 read_unlock(&GlobalSMBSeslock); 422 read_unlock(&GlobalSMBSeslock);
417 423
418 buf += sprintf(buf,"\n"); 424 buf += sprintf(buf, "\n");
419 length++; 425 length++;
420 426
421 if(offset + count >= length) 427 if (offset + count >= length)
422 *eof = 1; 428 *eof = 1;
423 if(length < offset) { 429 if (length < offset) {
424 *eof = 1; 430 *eof = 1;
425 return 0; 431 return 0;
426 } else { 432 } else {
@@ -428,7 +434,7 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
428 } 434 }
429 if (length > count) 435 if (length > count)
430 length = count; 436 length = count;
431 437
432 return length; 438 return length;
433} 439}
434#endif 440#endif
@@ -547,11 +553,11 @@ cifs_proc_clean(void)
547 remove_proc_entry("MultiuserMount", proc_fs_cifs); 553 remove_proc_entry("MultiuserMount", proc_fs_cifs);
548 remove_proc_entry("OplockEnabled", proc_fs_cifs); 554 remove_proc_entry("OplockEnabled", proc_fs_cifs);
549/* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */ 555/* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */
550 remove_proc_entry("SecurityFlags",proc_fs_cifs); 556 remove_proc_entry("SecurityFlags", proc_fs_cifs);
551/* remove_proc_entry("PacketSigningEnabled",proc_fs_cifs); */ 557/* remove_proc_entry("PacketSigningEnabled", proc_fs_cifs); */
552 remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs); 558 remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
553 remove_proc_entry("Experimental",proc_fs_cifs); 559 remove_proc_entry("Experimental", proc_fs_cifs);
554 remove_proc_entry("LookupCacheEnabled",proc_fs_cifs); 560 remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
555 remove_proc_entry("cifs", proc_root_fs); 561 remove_proc_entry("cifs", proc_root_fs);
556} 562}
557 563
@@ -590,7 +596,7 @@ cifsFYI_write(struct file *file, const char __user *buffer,
590 cifsFYI = 0; 596 cifsFYI = 0;
591 else if (c == '1' || c == 'y' || c == 'Y') 597 else if (c == '1' || c == 'y' || c == 'Y')
592 cifsFYI = 1; 598 cifsFYI = 1;
593 else if((c > '1') && (c <= '9')) 599 else if ((c > '1') && (c <= '9'))
594 cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */ 600 cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
595 601
596 return count; 602 return count;
@@ -637,28 +643,28 @@ oplockEnabled_write(struct file *file, const char __user *buffer,
637 643
638static int 644static int
639experimEnabled_read(char *page, char **start, off_t off, 645experimEnabled_read(char *page, char **start, off_t off,
640 int count, int *eof, void *data) 646 int count, int *eof, void *data)
641{ 647{
642 int len; 648 int len;
643 649
644 len = sprintf(page, "%d\n", experimEnabled); 650 len = sprintf(page, "%d\n", experimEnabled);
645 651
646 len -= off; 652 len -= off;
647 *start = page + off; 653 *start = page + off;
648 654
649 if (len > count) 655 if (len > count)
650 len = count; 656 len = count;
651 else 657 else
652 *eof = 1; 658 *eof = 1;
653 659
654 if (len < 0) 660 if (len < 0)
655 len = 0; 661 len = 0;
656 662
657 return len; 663 return len;
658} 664}
659static int 665static int
660experimEnabled_write(struct file *file, const char __user *buffer, 666experimEnabled_write(struct file *file, const char __user *buffer,
661 unsigned long count, void *data) 667 unsigned long count, void *data)
662{ 668{
663 char c; 669 char c;
664 int rc; 670 int rc;
@@ -678,46 +684,46 @@ experimEnabled_write(struct file *file, const char __user *buffer,
678 684
679static int 685static int
680linuxExtensionsEnabled_read(char *page, char **start, off_t off, 686linuxExtensionsEnabled_read(char *page, char **start, off_t off,
681 int count, int *eof, void *data) 687 int count, int *eof, void *data)
682{ 688{
683 int len; 689 int len;
684 690
685 len = sprintf(page, "%d\n", linuxExtEnabled); 691 len = sprintf(page, "%d\n", linuxExtEnabled);
686 len -= off; 692 len -= off;
687 *start = page + off; 693 *start = page + off;
688 694
689 if (len > count) 695 if (len > count)
690 len = count; 696 len = count;
691 else 697 else
692 *eof = 1; 698 *eof = 1;
693 699
694 if (len < 0) 700 if (len < 0)
695 len = 0; 701 len = 0;
696 702
697 return len; 703 return len;
698} 704}
699static int 705static int
700linuxExtensionsEnabled_write(struct file *file, const char __user *buffer, 706linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
701 unsigned long count, void *data) 707 unsigned long count, void *data)
702{ 708{
703 char c; 709 char c;
704 int rc; 710 int rc;
705 711
706 rc = get_user(c, buffer); 712 rc = get_user(c, buffer);
707 if (rc) 713 if (rc)
708 return rc; 714 return rc;
709 if (c == '0' || c == 'n' || c == 'N') 715 if (c == '0' || c == 'n' || c == 'N')
710 linuxExtEnabled = 0; 716 linuxExtEnabled = 0;
711 else if (c == '1' || c == 'y' || c == 'Y') 717 else if (c == '1' || c == 'y' || c == 'Y')
712 linuxExtEnabled = 1; 718 linuxExtEnabled = 1;
713 719
714 return count; 720 return count;
715} 721}
716 722
717 723
718static int 724static int
719lookupFlag_read(char *page, char **start, off_t off, 725lookupFlag_read(char *page, char **start, off_t off,
720 int count, int *eof, void *data) 726 int count, int *eof, void *data)
721{ 727{
722 int len; 728 int len;
723 729
@@ -860,15 +866,15 @@ security_flags_write(struct file *file, const char __user *buffer,
860 char flags_string[12]; 866 char flags_string[12];
861 char c; 867 char c;
862 868
863 if((count < 1) || (count > 11)) 869 if ((count < 1) || (count > 11))
864 return -EINVAL; 870 return -EINVAL;
865 871
866 memset(flags_string, 0, 12); 872 memset(flags_string, 0, 12);
867 873
868 if(copy_from_user(flags_string, buffer, count)) 874 if (copy_from_user(flags_string, buffer, count))
869 return -EFAULT; 875 return -EFAULT;
870 876
871 if(count < 3) { 877 if (count < 3) {
872 /* single char or single char followed by null */ 878 /* single char or single char followed by null */
873 c = flags_string[0]; 879 c = flags_string[0];
874 if (c == '0' || c == 'n' || c == 'N') 880 if (c == '0' || c == 'n' || c == 'N')
@@ -881,15 +887,15 @@ security_flags_write(struct file *file, const char __user *buffer,
881 887
882 flags = simple_strtoul(flags_string, NULL, 0); 888 flags = simple_strtoul(flags_string, NULL, 0);
883 889
884 cFYI(1,("sec flags 0x%x", flags)); 890 cFYI(1, ("sec flags 0x%x", flags));
885 891
886 if(flags <= 0) { 892 if (flags <= 0) {
887 cERROR(1,("invalid security flags %s",flags_string)); 893 cERROR(1, ("invalid security flags %s", flags_string));
888 return -EINVAL; 894 return -EINVAL;
889 } 895 }
890 896
891 if(flags & ~CIFSSEC_MASK) { 897 if (flags & ~CIFSSEC_MASK) {
892 cERROR(1,("attempt to set unsupported security flags 0x%x", 898 cERROR(1, ("attempt to set unsupported security flags 0x%x",
893 flags & ~CIFSSEC_MASK)); 899 flags & ~CIFSSEC_MASK));
894 return -EINVAL; 900 return -EINVAL;
895 } 901 }
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index 793c4b95c164..701e9a9185f2 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -6,16 +6,16 @@
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version. 10 * (at your option) any later version.
11 * 11 *
12 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU General Public License for more details. 15 * the GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21#include <linux/fs.h> 21#include <linux/fs.h>
@@ -32,7 +32,7 @@
32 * 32 *
33 */ 33 */
34int 34int
35cifs_strfromUCS_le(char *to, const __le16 * from, 35cifs_strfromUCS_le(char *to, const __le16 * from,
36 int len, const struct nls_table *codepage) 36 int len, const struct nls_table *codepage)
37{ 37{
38 int i; 38 int i;
@@ -66,7 +66,7 @@ cifs_strtoUCS(__le16 * to, const char *from, int len,
66{ 66{
67 int charlen; 67 int charlen;
68 int i; 68 int i;
69 wchar_t * wchar_to = (wchar_t *)to; /* needed to quiet sparse */ 69 wchar_t * wchar_to = (wchar_t *)to; /* needed to quiet sparse */
70 70
71 for (i = 0; len && *from; i++, from += charlen, len -= charlen) { 71 for (i = 0; len && *from; i++, from += charlen, len -= charlen) {
72 72
@@ -79,7 +79,7 @@ cifs_strtoUCS(__le16 * to, const char *from, int len,
79 /* A question mark */ 79 /* A question mark */
80 to[i] = cpu_to_le16(0x003f); 80 to[i] = cpu_to_le16(0x003f);
81 charlen = 1; 81 charlen = 1;
82 } else 82 } else
83 to[i] = cpu_to_le16(wchar_to[i]); 83 to[i] = cpu_to_le16(wchar_to[i]);
84 84
85 } 85 }
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index d38c69b591cf..7c04752b76cb 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -825,8 +825,8 @@ cifs_init_mids(void)
825 sizeof (struct oplock_q_entry), 0, 825 sizeof (struct oplock_q_entry), 0,
826 SLAB_HWCACHE_ALIGN, NULL, NULL); 826 SLAB_HWCACHE_ALIGN, NULL, NULL);
827 if (cifs_oplock_cachep == NULL) { 827 if (cifs_oplock_cachep == NULL) {
828 kmem_cache_destroy(cifs_mid_cachep);
829 mempool_destroy(cifs_mid_poolp); 828 mempool_destroy(cifs_mid_poolp);
829 kmem_cache_destroy(cifs_mid_cachep);
830 return -ENOMEM; 830 return -ENOMEM;
831 } 831 }
832 832
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 14de58fa1437..57419a176688 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -433,8 +433,8 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
433 cFYI(1,("secFlags 0x%x",secFlags)); 433 cFYI(1,("secFlags 0x%x",secFlags));
434 434
435 pSMB->hdr.Mid = GetNextMid(server); 435 pSMB->hdr.Mid = GetNextMid(server);
436 pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; 436 pSMB->hdr.Flags2 |= (SMBFLG2_UNICODE | SMBFLG2_ERR_STATUS);
437 if((secFlags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5) 437 if ((secFlags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5)
438 pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC; 438 pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC;
439 439
440 count = 0; 440 count = 0;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 216fb625843f..f4e92661b223 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2069,8 +2069,15 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2069 srvTcp->tcpStatus = CifsExiting; 2069 srvTcp->tcpStatus = CifsExiting;
2070 spin_unlock(&GlobalMid_Lock); 2070 spin_unlock(&GlobalMid_Lock);
2071 if (srvTcp->tsk) { 2071 if (srvTcp->tsk) {
2072 struct task_struct *tsk;
2073 /* If we could verify that kthread_stop would
2074 always wake up processes blocked in
2075 tcp in recv_mesg then we could remove the
2076 send_sig call */
2072 send_sig(SIGKILL,srvTcp->tsk,1); 2077 send_sig(SIGKILL,srvTcp->tsk,1);
2073 kthread_stop(srvTcp->tsk); 2078 tsk = srvTcp->tsk;
2079 if(tsk)
2080 kthread_stop(tsk);
2074 } 2081 }
2075 } 2082 }
2076 /* If find_unc succeeded then rc == 0 so we can not end */ 2083 /* If find_unc succeeded then rc == 0 so we can not end */
@@ -2085,8 +2092,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2085 /* if the socketUseCount is now zero */ 2092 /* if the socketUseCount is now zero */
2086 if ((temp_rc == -ESHUTDOWN) && 2093 if ((temp_rc == -ESHUTDOWN) &&
2087 (pSesInfo->server) && (pSesInfo->server->tsk)) { 2094 (pSesInfo->server) && (pSesInfo->server->tsk)) {
2095 struct task_struct *tsk;
2088 send_sig(SIGKILL,pSesInfo->server->tsk,1); 2096 send_sig(SIGKILL,pSesInfo->server->tsk,1);
2089 kthread_stop(pSesInfo->server->tsk); 2097 tsk = pSesInfo->server->tsk;
2098 if (tsk)
2099 kthread_stop(tsk);
2090 } 2100 }
2091 } else 2101 } else
2092 cFYI(1, ("No session or bad tcon")); 2102 cFYI(1, ("No session or bad tcon"));
@@ -3334,7 +3344,7 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
3334 return 0; 3344 return 0;
3335 } else if (rc == -ESHUTDOWN) { 3345 } else if (rc == -ESHUTDOWN) {
3336 cFYI(1,("Waking up socket by sending it signal")); 3346 cFYI(1,("Waking up socket by sending it signal"));
3337 if(cifsd_task) { 3347 if (cifsd_task) {
3338 send_sig(SIGKILL,cifsd_task,1); 3348 send_sig(SIGKILL,cifsd_task,1);
3339 kthread_stop(cifsd_task); 3349 kthread_stop(cifsd_task);
3340 } 3350 }
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index e5210519ac4b..8e86aaceb68a 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -2,7 +2,7 @@
2 * fs/cifs/dir.c 2 * fs/cifs/dir.c
3 * 3 *
4 * vfs operations that deal with dentries 4 * vfs operations that deal with dentries
5 * 5 *
6 * Copyright (C) International Business Machines Corp., 2002,2005 6 * Copyright (C) International Business Machines Corp., 2002,2005
7 * Author(s): Steve French (sfrench@us.ibm.com) 7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * 8 *
@@ -34,11 +34,12 @@
34static void 34static void
35renew_parental_timestamps(struct dentry *direntry) 35renew_parental_timestamps(struct dentry *direntry)
36{ 36{
37 /* BB check if there is a way to get the kernel to do this or if we really need this */ 37 /* BB check if there is a way to get the kernel to do this or if we
38 really need this */
38 do { 39 do {
39 direntry->d_time = jiffies; 40 direntry->d_time = jiffies;
40 direntry = direntry->d_parent; 41 direntry = direntry->d_parent;
41 } while (!IS_ROOT(direntry)); 42 } while (!IS_ROOT(direntry));
42} 43}
43 44
44/* Note: caller must free return buffer */ 45/* Note: caller must free return buffer */
@@ -51,7 +52,7 @@ build_path_from_dentry(struct dentry *direntry)
51 char *full_path; 52 char *full_path;
52 char dirsep; 53 char dirsep;
53 54
54 if(direntry == NULL) 55 if (direntry == NULL)
55 return NULL; /* not much we can do if dentry is freed and 56 return NULL; /* not much we can do if dentry is freed and
56 we need to reopen the file after it was closed implicitly 57 we need to reopen the file after it was closed implicitly
57 when the server crashed */ 58 when the server crashed */
@@ -59,18 +60,18 @@ build_path_from_dentry(struct dentry *direntry)
59 dirsep = CIFS_DIR_SEP(CIFS_SB(direntry->d_sb)); 60 dirsep = CIFS_DIR_SEP(CIFS_SB(direntry->d_sb));
60 pplen = CIFS_SB(direntry->d_sb)->prepathlen; 61 pplen = CIFS_SB(direntry->d_sb)->prepathlen;
61cifs_bp_rename_retry: 62cifs_bp_rename_retry:
62 namelen = pplen; 63 namelen = pplen;
63 for (temp = direntry; !IS_ROOT(temp);) { 64 for (temp = direntry; !IS_ROOT(temp);) {
64 namelen += (1 + temp->d_name.len); 65 namelen += (1 + temp->d_name.len);
65 temp = temp->d_parent; 66 temp = temp->d_parent;
66 if(temp == NULL) { 67 if (temp == NULL) {
67 cERROR(1,("corrupt dentry")); 68 cERROR(1, ("corrupt dentry"));
68 return NULL; 69 return NULL;
69 } 70 }
70 } 71 }
71 72
72 full_path = kmalloc(namelen+1, GFP_KERNEL); 73 full_path = kmalloc(namelen+1, GFP_KERNEL);
73 if(full_path == NULL) 74 if (full_path == NULL)
74 return full_path; 75 return full_path;
75 full_path[namelen] = 0; /* trailing null */ 76 full_path[namelen] = 0; /* trailing null */
76 for (temp = direntry; !IS_ROOT(temp);) { 77 for (temp = direntry; !IS_ROOT(temp);) {
@@ -84,8 +85,8 @@ cifs_bp_rename_retry:
84 cFYI(0, ("name: %s", full_path + namelen)); 85 cFYI(0, ("name: %s", full_path + namelen));
85 } 86 }
86 temp = temp->d_parent; 87 temp = temp->d_parent;
87 if(temp == NULL) { 88 if (temp == NULL) {
88 cERROR(1,("corrupt dentry")); 89 cERROR(1, ("corrupt dentry"));
89 kfree(full_path); 90 kfree(full_path);
90 return NULL; 91 return NULL;
91 } 92 }
@@ -94,7 +95,7 @@ cifs_bp_rename_retry:
94 cERROR(1, 95 cERROR(1,
95 ("did not end path lookup where expected namelen is %d", 96 ("did not end path lookup where expected namelen is %d",
96 namelen)); 97 namelen));
97 /* presumably this is only possible if racing with a rename 98 /* presumably this is only possible if racing with a rename
98 of one of the parent directories (we can not lock the dentries 99 of one of the parent directories (we can not lock the dentries
99 above us to prevent this, but retrying should be harmless) */ 100 above us to prevent this, but retrying should be harmless) */
100 kfree(full_path); 101 kfree(full_path);
@@ -106,7 +107,7 @@ cifs_bp_rename_retry:
106 since the '\' is a valid posix character so we can not switch 107 since the '\' is a valid posix character so we can not switch
107 those safely to '/' if any are found in the middle of the prepath */ 108 those safely to '/' if any are found in the middle of the prepath */
108 /* BB test paths to Windows with '/' in the midst of prepath */ 109 /* BB test paths to Windows with '/' in the midst of prepath */
109 strncpy(full_path,CIFS_SB(direntry->d_sb)->prepath,pplen); 110 strncpy(full_path, CIFS_SB(direntry->d_sb)->prepath, pplen);
110 return full_path; 111 return full_path;
111} 112}
112 113
@@ -147,12 +148,12 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
147 pTcon = cifs_sb->tcon; 148 pTcon = cifs_sb->tcon;
148 149
149 full_path = build_path_from_dentry(direntry); 150 full_path = build_path_from_dentry(direntry);
150 if(full_path == NULL) { 151 if (full_path == NULL) {
151 FreeXid(xid); 152 FreeXid(xid);
152 return -ENOMEM; 153 return -ENOMEM;
153 } 154 }
154 155
155 if(nd && (nd->flags & LOOKUP_OPEN)) { 156 if (nd && (nd->flags & LOOKUP_OPEN)) {
156 int oflags = nd->intent.open.flags; 157 int oflags = nd->intent.open.flags;
157 158
158 desiredAccess = 0; 159 desiredAccess = 0;
@@ -164,28 +165,29 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
164 write_only = TRUE; 165 write_only = TRUE;
165 } 166 }
166 167
167 if((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) 168 if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
168 disposition = FILE_CREATE; 169 disposition = FILE_CREATE;
169 else if((oflags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC)) 170 else if ((oflags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC))
170 disposition = FILE_OVERWRITE_IF; 171 disposition = FILE_OVERWRITE_IF;
171 else if((oflags & O_CREAT) == O_CREAT) 172 else if ((oflags & O_CREAT) == O_CREAT)
172 disposition = FILE_OPEN_IF; 173 disposition = FILE_OPEN_IF;
173 else { 174 else {
174 cFYI(1,("Create flag not set in create function")); 175 cFYI(1, ("Create flag not set in create function"));
175 } 176 }
176 } 177 }
177 178
178 /* BB add processing to set equivalent of mode - e.g. via CreateX with ACLs */ 179 /* BB add processing to set equivalent of mode - e.g. via CreateX with
180 ACLs */
179 if (oplockEnabled) 181 if (oplockEnabled)
180 oplock = REQ_OPLOCK; 182 oplock = REQ_OPLOCK;
181 183
182 buf = kmalloc(sizeof(FILE_ALL_INFO),GFP_KERNEL); 184 buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
183 if(buf == NULL) { 185 if (buf == NULL) {
184 kfree(full_path); 186 kfree(full_path);
185 FreeXid(xid); 187 FreeXid(xid);
186 return -ENOMEM; 188 return -ENOMEM;
187 } 189 }
188 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS) 190 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
189 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, 191 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
190 desiredAccess, CREATE_NOT_DIR, 192 desiredAccess, CREATE_NOT_DIR,
191 &fileHandle, &oplock, buf, cifs_sb->local_nls, 193 &fileHandle, &oplock, buf, cifs_sb->local_nls,
@@ -193,27 +195,28 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
193 else 195 else
194 rc = -EIO; /* no NT SMB support fall into legacy open below */ 196 rc = -EIO; /* no NT SMB support fall into legacy open below */
195 197
196 if(rc == -EIO) { 198 if (rc == -EIO) {
197 /* old server, retry the open legacy style */ 199 /* old server, retry the open legacy style */
198 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition, 200 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition,
199 desiredAccess, CREATE_NOT_DIR, 201 desiredAccess, CREATE_NOT_DIR,
200 &fileHandle, &oplock, buf, cifs_sb->local_nls, 202 &fileHandle, &oplock, buf, cifs_sb->local_nls,
201 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 203 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
202 } 204 }
203 if (rc) { 205 if (rc) {
204 cFYI(1, ("cifs_create returned 0x%x", rc)); 206 cFYI(1, ("cifs_create returned 0x%x", rc));
205 } else { 207 } else {
206 /* If Open reported that we actually created a file 208 /* If Open reported that we actually created a file
207 then we now have to set the mode if possible */ 209 then we now have to set the mode if possible */
208 if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX) && 210 if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX) &&
209 (oplock & CIFS_CREATE_ACTION)) 211 (oplock & CIFS_CREATE_ACTION)) {
210 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 212 mode &= ~current->fs->umask;
213 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
211 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, 214 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
212 (__u64)current->fsuid, 215 (__u64)current->fsuid,
213 (__u64)current->fsgid, 216 (__u64)current->fsgid,
214 0 /* dev */, 217 0 /* dev */,
215 cifs_sb->local_nls, 218 cifs_sb->local_nls,
216 cifs_sb->mnt_cifs_flags & 219 cifs_sb->mnt_cifs_flags &
217 CIFS_MOUNT_MAP_SPECIAL_CHR); 220 CIFS_MOUNT_MAP_SPECIAL_CHR);
218 } else { 221 } else {
219 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, 222 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
@@ -221,26 +224,28 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
221 (__u64)-1, 224 (__u64)-1,
222 0 /* dev */, 225 0 /* dev */,
223 cifs_sb->local_nls, 226 cifs_sb->local_nls,
224 cifs_sb->mnt_cifs_flags & 227 cifs_sb->mnt_cifs_flags &
225 CIFS_MOUNT_MAP_SPECIAL_CHR); 228 CIFS_MOUNT_MAP_SPECIAL_CHR);
226 } 229 }
227 else { 230 } else {
228 /* BB implement mode setting via Windows security descriptors */ 231 /* BB implement mode setting via Windows security
229 /* eg CIFSSMBWinSetPerms(xid,pTcon,full_path,mode,-1,-1,local_nls);*/ 232 descriptors e.g. */
230 /* could set r/o dos attribute if mode & 0222 == 0 */ 233 /* CIFSSMBWinSetPerms(xid,pTcon,path,mode,-1,-1,nls);*/
234
235 /* Could set r/o dos attribute if mode & 0222 == 0 */
231 } 236 }
232 237
233 /* BB server might mask mode so we have to query for Unix case*/ 238 /* BB server might mask mode so we have to query for Unix case*/
234 if (pTcon->ses->capabilities & CAP_UNIX) 239 if (pTcon->ses->capabilities & CAP_UNIX)
235 rc = cifs_get_inode_info_unix(&newinode, full_path, 240 rc = cifs_get_inode_info_unix(&newinode, full_path,
236 inode->i_sb,xid); 241 inode->i_sb, xid);
237 else { 242 else {
238 rc = cifs_get_inode_info(&newinode, full_path, 243 rc = cifs_get_inode_info(&newinode, full_path,
239 buf, inode->i_sb,xid); 244 buf, inode->i_sb, xid);
240 if(newinode) { 245 if (newinode) {
241 newinode->i_mode = mode; 246 newinode->i_mode = mode;
242 if((oplock & CIFS_CREATE_ACTION) && 247 if ((oplock & CIFS_CREATE_ACTION) &&
243 (cifs_sb->mnt_cifs_flags & 248 (cifs_sb->mnt_cifs_flags &
244 CIFS_MOUNT_SET_UID)) { 249 CIFS_MOUNT_SET_UID)) {
245 newinode->i_uid = current->fsuid; 250 newinode->i_uid = current->fsuid;
246 newinode->i_gid = current->fsgid; 251 newinode->i_gid = current->fsgid;
@@ -259,14 +264,14 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
259 direntry->d_op = &cifs_dentry_ops; 264 direntry->d_op = &cifs_dentry_ops;
260 d_instantiate(direntry, newinode); 265 d_instantiate(direntry, newinode);
261 } 266 }
262 if((nd->flags & LOOKUP_OPEN) == FALSE) { 267 if ((nd->flags & LOOKUP_OPEN) == FALSE) {
263 /* mknod case - do not leave file open */ 268 /* mknod case - do not leave file open */
264 CIFSSMBClose(xid, pTcon, fileHandle); 269 CIFSSMBClose(xid, pTcon, fileHandle);
265 } else if(newinode) { 270 } else if (newinode) {
266 pCifsFile = 271 pCifsFile =
267 kzalloc(sizeof (struct cifsFileInfo), GFP_KERNEL); 272 kzalloc(sizeof (struct cifsFileInfo), GFP_KERNEL);
268 273
269 if(pCifsFile == NULL) 274 if (pCifsFile == NULL)
270 goto cifs_create_out; 275 goto cifs_create_out;
271 pCifsFile->netfid = fileHandle; 276 pCifsFile->netfid = fileHandle;
272 pCifsFile->pid = current->tgid; 277 pCifsFile->pid = current->tgid;
@@ -276,33 +281,33 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
276 init_MUTEX(&pCifsFile->fh_sem); 281 init_MUTEX(&pCifsFile->fh_sem);
277 mutex_init(&pCifsFile->lock_mutex); 282 mutex_init(&pCifsFile->lock_mutex);
278 INIT_LIST_HEAD(&pCifsFile->llist); 283 INIT_LIST_HEAD(&pCifsFile->llist);
279 atomic_set(&pCifsFile->wrtPending,0); 284 atomic_set(&pCifsFile->wrtPending, 0);
280 285
281 /* set the following in open now 286 /* set the following in open now
282 pCifsFile->pfile = file; */ 287 pCifsFile->pfile = file; */
283 write_lock(&GlobalSMBSeslock); 288 write_lock(&GlobalSMBSeslock);
284 list_add(&pCifsFile->tlist,&pTcon->openFileList); 289 list_add(&pCifsFile->tlist, &pTcon->openFileList);
285 pCifsInode = CIFS_I(newinode); 290 pCifsInode = CIFS_I(newinode);
286 if(pCifsInode) { 291 if (pCifsInode) {
287 /* if readable file instance put first in list*/ 292 /* if readable file instance put first in list*/
288 if (write_only == TRUE) { 293 if (write_only == TRUE) {
289 list_add_tail(&pCifsFile->flist, 294 list_add_tail(&pCifsFile->flist,
290 &pCifsInode->openFileList); 295 &pCifsInode->openFileList);
291 } else { 296 } else {
292 list_add(&pCifsFile->flist, 297 list_add(&pCifsFile->flist,
293 &pCifsInode->openFileList); 298 &pCifsInode->openFileList);
294 } 299 }
295 if((oplock & 0xF) == OPLOCK_EXCLUSIVE) { 300 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
296 pCifsInode->clientCanCacheAll = TRUE; 301 pCifsInode->clientCanCacheAll = TRUE;
297 pCifsInode->clientCanCacheRead = TRUE; 302 pCifsInode->clientCanCacheRead = TRUE;
298 cFYI(1,("Exclusive Oplock for inode %p", 303 cFYI(1, ("Exclusive Oplock inode %p",
299 newinode)); 304 newinode));
300 } else if((oplock & 0xF) == OPLOCK_READ) 305 } else if ((oplock & 0xF) == OPLOCK_READ)
301 pCifsInode->clientCanCacheRead = TRUE; 306 pCifsInode->clientCanCacheRead = TRUE;
302 } 307 }
303 write_unlock(&GlobalSMBSeslock); 308 write_unlock(&GlobalSMBSeslock);
304 } 309 }
305 } 310 }
306cifs_create_out: 311cifs_create_out:
307 kfree(buf); 312 kfree(buf);
308 kfree(full_path); 313 kfree(full_path);
@@ -310,8 +315,8 @@ cifs_create_out:
310 return rc; 315 return rc;
311} 316}
312 317
313int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, 318int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
314 dev_t device_number) 319 dev_t device_number)
315{ 320{
316 int rc = -EPERM; 321 int rc = -EPERM;
317 int xid; 322 int xid;
@@ -329,43 +334,45 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
329 pTcon = cifs_sb->tcon; 334 pTcon = cifs_sb->tcon;
330 335
331 full_path = build_path_from_dentry(direntry); 336 full_path = build_path_from_dentry(direntry);
332 if(full_path == NULL) 337 if (full_path == NULL)
333 rc = -ENOMEM; 338 rc = -ENOMEM;
334 else if (pTcon->ses->capabilities & CAP_UNIX) { 339 else if (pTcon->ses->capabilities & CAP_UNIX) {
335 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 340 mode &= ~current->fs->umask;
341 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
336 rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, 342 rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path,
337 mode,(__u64)current->fsuid,(__u64)current->fsgid, 343 mode, (__u64)current->fsuid,
344 (__u64)current->fsgid,
338 device_number, cifs_sb->local_nls, 345 device_number, cifs_sb->local_nls,
339 cifs_sb->mnt_cifs_flags & 346 cifs_sb->mnt_cifs_flags &
340 CIFS_MOUNT_MAP_SPECIAL_CHR); 347 CIFS_MOUNT_MAP_SPECIAL_CHR);
341 } else { 348 } else {
342 rc = CIFSSMBUnixSetPerms(xid, pTcon, 349 rc = CIFSSMBUnixSetPerms(xid, pTcon,
343 full_path, mode, (__u64)-1, (__u64)-1, 350 full_path, mode, (__u64)-1, (__u64)-1,
344 device_number, cifs_sb->local_nls, 351 device_number, cifs_sb->local_nls,
345 cifs_sb->mnt_cifs_flags & 352 cifs_sb->mnt_cifs_flags &
346 CIFS_MOUNT_MAP_SPECIAL_CHR); 353 CIFS_MOUNT_MAP_SPECIAL_CHR);
347 } 354 }
348 355
349 if(!rc) { 356 if (!rc) {
350 rc = cifs_get_inode_info_unix(&newinode, full_path, 357 rc = cifs_get_inode_info_unix(&newinode, full_path,
351 inode->i_sb,xid); 358 inode->i_sb, xid);
352 if (pTcon->nocase) 359 if (pTcon->nocase)
353 direntry->d_op = &cifs_ci_dentry_ops; 360 direntry->d_op = &cifs_ci_dentry_ops;
354 else 361 else
355 direntry->d_op = &cifs_dentry_ops; 362 direntry->d_op = &cifs_dentry_ops;
356 if(rc == 0) 363 if (rc == 0)
357 d_instantiate(direntry, newinode); 364 d_instantiate(direntry, newinode);
358 } 365 }
359 } else { 366 } else {
360 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { 367 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
361 int oplock = 0; 368 int oplock = 0;
362 u16 fileHandle; 369 u16 fileHandle;
363 FILE_ALL_INFO * buf; 370 FILE_ALL_INFO * buf;
364 371
365 cFYI(1,("sfu compat create special file")); 372 cFYI(1, ("sfu compat create special file"));
366 373
367 buf = kmalloc(sizeof(FILE_ALL_INFO),GFP_KERNEL); 374 buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
368 if(buf == NULL) { 375 if (buf == NULL) {
369 kfree(full_path); 376 kfree(full_path);
370 FreeXid(xid); 377 FreeXid(xid);
371 return -ENOMEM; 378 return -ENOMEM;
@@ -373,39 +380,38 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
373 380
374 rc = CIFSSMBOpen(xid, pTcon, full_path, 381 rc = CIFSSMBOpen(xid, pTcon, full_path,
375 FILE_CREATE, /* fail if exists */ 382 FILE_CREATE, /* fail if exists */
376 GENERIC_WRITE /* BB would 383 GENERIC_WRITE /* BB would
377 WRITE_OWNER | WRITE_DAC be better? */, 384 WRITE_OWNER | WRITE_DAC be better? */,
378 /* Create a file and set the 385 /* Create a file and set the
379 file attribute to SYSTEM */ 386 file attribute to SYSTEM */
380 CREATE_NOT_DIR | CREATE_OPTION_SPECIAL, 387 CREATE_NOT_DIR | CREATE_OPTION_SPECIAL,
381 &fileHandle, &oplock, buf, 388 &fileHandle, &oplock, buf,
382 cifs_sb->local_nls, 389 cifs_sb->local_nls,
383 cifs_sb->mnt_cifs_flags & 390 cifs_sb->mnt_cifs_flags &
384 CIFS_MOUNT_MAP_SPECIAL_CHR); 391 CIFS_MOUNT_MAP_SPECIAL_CHR);
385 392
386 /* BB FIXME - add handling for backlevel servers 393 /* BB FIXME - add handling for backlevel servers
387 which need legacy open and check for all 394 which need legacy open and check for all
388 calls to SMBOpen for fallback to 395 calls to SMBOpen for fallback to SMBLeagcyOpen */
389 SMBLeagcyOpen */ 396 if (!rc) {
390 if(!rc) {
391 /* BB Do not bother to decode buf since no 397 /* BB Do not bother to decode buf since no
392 local inode yet to put timestamps in, 398 local inode yet to put timestamps in,
393 but we can reuse it safely */ 399 but we can reuse it safely */
394 int bytes_written; 400 int bytes_written;
395 struct win_dev *pdev; 401 struct win_dev *pdev;
396 pdev = (struct win_dev *)buf; 402 pdev = (struct win_dev *)buf;
397 if(S_ISCHR(mode)) { 403 if (S_ISCHR(mode)) {
398 memcpy(pdev->type, "IntxCHR", 8); 404 memcpy(pdev->type, "IntxCHR", 8);
399 pdev->major = 405 pdev->major =
400 cpu_to_le64(MAJOR(device_number)); 406 cpu_to_le64(MAJOR(device_number));
401 pdev->minor = 407 pdev->minor =
402 cpu_to_le64(MINOR(device_number)); 408 cpu_to_le64(MINOR(device_number));
403 rc = CIFSSMBWrite(xid, pTcon, 409 rc = CIFSSMBWrite(xid, pTcon,
404 fileHandle, 410 fileHandle,
405 sizeof(struct win_dev), 411 sizeof(struct win_dev),
406 0, &bytes_written, (char *)pdev, 412 0, &bytes_written, (char *)pdev,
407 NULL, 0); 413 NULL, 0);
408 } else if(S_ISBLK(mode)) { 414 } else if (S_ISBLK(mode)) {
409 memcpy(pdev->type, "IntxBLK", 8); 415 memcpy(pdev->type, "IntxBLK", 8);
410 pdev->major = 416 pdev->major =
411 cpu_to_le64(MAJOR(device_number)); 417 cpu_to_le64(MAJOR(device_number));
@@ -432,7 +438,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
432 438
433 439
434struct dentry * 440struct dentry *
435cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct nameidata *nd) 441cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
442 struct nameidata *nd)
436{ 443{
437 int xid; 444 int xid;
438 int rc = 0; /* to get around spurious gcc warning, set to zero here */ 445 int rc = 0; /* to get around spurious gcc warning, set to zero here */
@@ -447,8 +454,6 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
447 (" parent inode = 0x%p name is: %s and dentry = 0x%p", 454 (" parent inode = 0x%p name is: %s and dentry = 0x%p",
448 parent_dir_inode, direntry->d_name.name, direntry)); 455 parent_dir_inode, direntry->d_name.name, direntry));
449 456
450 /* BB Add check of incoming data - e.g. frame not longer than maximum SMB - let server check the namelen BB */
451
452 /* check whether path exists */ 457 /* check whether path exists */
453 458
454 cifs_sb = CIFS_SB(parent_dir_inode->i_sb); 459 cifs_sb = CIFS_SB(parent_dir_inode->i_sb);
@@ -472,7 +477,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
472 deadlock in the cases (beginning of sys_rename itself) 477 deadlock in the cases (beginning of sys_rename itself)
473 in which we already have the sb rename sem */ 478 in which we already have the sb rename sem */
474 full_path = build_path_from_dentry(direntry); 479 full_path = build_path_from_dentry(direntry);
475 if(full_path == NULL) { 480 if (full_path == NULL) {
476 FreeXid(xid); 481 FreeXid(xid);
477 return ERR_PTR(-ENOMEM); 482 return ERR_PTR(-ENOMEM);
478 } 483 }
@@ -487,10 +492,10 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
487 492
488 if (pTcon->ses->capabilities & CAP_UNIX) 493 if (pTcon->ses->capabilities & CAP_UNIX)
489 rc = cifs_get_inode_info_unix(&newInode, full_path, 494 rc = cifs_get_inode_info_unix(&newInode, full_path,
490 parent_dir_inode->i_sb,xid); 495 parent_dir_inode->i_sb, xid);
491 else 496 else
492 rc = cifs_get_inode_info(&newInode, full_path, NULL, 497 rc = cifs_get_inode_info(&newInode, full_path, NULL,
493 parent_dir_inode->i_sb,xid); 498 parent_dir_inode->i_sb, xid);
494 499
495 if ((rc == 0) && (newInode != NULL)) { 500 if ((rc == 0) && (newInode != NULL)) {
496 if (pTcon->nocase) 501 if (pTcon->nocase)
@@ -499,7 +504,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
499 direntry->d_op = &cifs_dentry_ops; 504 direntry->d_op = &cifs_dentry_ops;
500 d_add(direntry, newInode); 505 d_add(direntry, newInode);
501 506
502 /* since paths are not looked up by component - the parent 507 /* since paths are not looked up by component - the parent
503 directories are presumed to be good here */ 508 directories are presumed to be good here */
504 renew_parental_timestamps(direntry); 509 renew_parental_timestamps(direntry);
505 510
@@ -511,13 +516,13 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
511 else 516 else
512 direntry->d_op = &cifs_dentry_ops; 517 direntry->d_op = &cifs_dentry_ops;
513 d_add(direntry, NULL); 518 d_add(direntry, NULL);
514 /* if it was once a directory (but how can we tell?) we could do 519 /* if it was once a directory (but how can we tell?) we could do
515 shrink_dcache_parent(direntry); */ 520 shrink_dcache_parent(direntry); */
516 } else { 521 } else {
517 cERROR(1,("Error 0x%x on cifs_get_inode_info in lookup of %s", 522 cERROR(1, ("Error 0x%x on cifs_get_inode_info in lookup of %s",
518 rc,full_path)); 523 rc, full_path));
519 /* BB special case check for Access Denied - watch security 524 /* BB special case check for Access Denied - watch security
520 exposure of returning dir info implicitly via different rc 525 exposure of returning dir info implicitly via different rc
521 if file exists or not but no access BB */ 526 if file exists or not but no access BB */
522 } 527 }
523 528
@@ -538,11 +543,11 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
538 } else { 543 } else {
539 cFYI(1, ("neg dentry 0x%p name = %s", 544 cFYI(1, ("neg dentry 0x%p name = %s",
540 direntry, direntry->d_name.name)); 545 direntry, direntry->d_name.name));
541 if(time_after(jiffies, direntry->d_time + HZ) || 546 if (time_after(jiffies, direntry->d_time + HZ) ||
542 !lookupCacheEnabled) { 547 !lookupCacheEnabled) {
543 d_drop(direntry); 548 d_drop(direntry);
544 isValid = 0; 549 isValid = 0;
545 } 550 }
546 } 551 }
547 552
548 return isValid; 553 return isValid;
@@ -559,8 +564,7 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
559 564
560struct dentry_operations cifs_dentry_ops = { 565struct dentry_operations cifs_dentry_ops = {
561 .d_revalidate = cifs_d_revalidate, 566 .d_revalidate = cifs_d_revalidate,
562/* d_delete: cifs_d_delete, *//* not needed except for debugging */ 567/* d_delete: cifs_d_delete, */ /* not needed except for debugging */
563 /* no need for d_hash, d_compare, d_release, d_iput ... yet. BB confirm this BB */
564}; 568};
565 569
566static int cifs_ci_hash(struct dentry *dentry, struct qstr *q) 570static int cifs_ci_hash(struct dentry *dentry, struct qstr *q)
diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
index da12b482ebe5..8e375bb4b379 100644
--- a/fs/cifs/fcntl.c
+++ b/fs/cifs/fcntl.c
@@ -2,7 +2,7 @@
2 * fs/cifs/fcntl.c 2 * fs/cifs/fcntl.c
3 * 3 *
4 * vfs operations that deal with the file control API 4 * vfs operations that deal with the file control API
5 * 5 *
6 * Copyright (C) International Business Machines Corp., 2003,2004 6 * Copyright (C) International Business Machines Corp., 2003,2004
7 * Author(s): Steve French (sfrench@us.ibm.com) 7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * 8 *
@@ -35,35 +35,34 @@ static __u32 convert_to_cifs_notify_flags(unsigned long fcntl_notify_flags)
35 35
36 /* No way on Linux VFS to ask to monitor xattr 36 /* No way on Linux VFS to ask to monitor xattr
37 changes (and no stream support either */ 37 changes (and no stream support either */
38 if(fcntl_notify_flags & DN_ACCESS) { 38 if (fcntl_notify_flags & DN_ACCESS) {
39 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_ACCESS; 39 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_ACCESS;
40 } 40 }
41 if(fcntl_notify_flags & DN_MODIFY) { 41 if (fcntl_notify_flags & DN_MODIFY) {
42 /* What does this mean on directories? */ 42 /* What does this mean on directories? */
43 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE | 43 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE |
44 FILE_NOTIFY_CHANGE_SIZE; 44 FILE_NOTIFY_CHANGE_SIZE;
45 } 45 }
46 if(fcntl_notify_flags & DN_CREATE) { 46 if (fcntl_notify_flags & DN_CREATE) {
47 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_CREATION | 47 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_CREATION |
48 FILE_NOTIFY_CHANGE_LAST_WRITE; 48 FILE_NOTIFY_CHANGE_LAST_WRITE;
49 } 49 }
50 if(fcntl_notify_flags & DN_DELETE) { 50 if (fcntl_notify_flags & DN_DELETE) {
51 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE; 51 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE;
52 } 52 }
53 if(fcntl_notify_flags & DN_RENAME) { 53 if (fcntl_notify_flags & DN_RENAME) {
54 /* BB review this - checking various server behaviors */ 54 /* BB review this - checking various server behaviors */
55 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_DIR_NAME | 55 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_DIR_NAME |
56 FILE_NOTIFY_CHANGE_FILE_NAME; 56 FILE_NOTIFY_CHANGE_FILE_NAME;
57 } 57 }
58 if(fcntl_notify_flags & DN_ATTRIB) { 58 if (fcntl_notify_flags & DN_ATTRIB) {
59 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_SECURITY | 59 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_SECURITY |
60 FILE_NOTIFY_CHANGE_ATTRIBUTES; 60 FILE_NOTIFY_CHANGE_ATTRIBUTES;
61 } 61 }
62/* if(fcntl_notify_flags & DN_MULTISHOT) { 62/* if (fcntl_notify_flags & DN_MULTISHOT) {
63 cifs_ntfy_flags |= ; 63 cifs_ntfy_flags |= ;
64 } */ /* BB fixme - not sure how to handle this with CIFS yet */ 64 } */ /* BB fixme - not sure how to handle this with CIFS yet */
65 65
66
67 return cifs_ntfy_flags; 66 return cifs_ntfy_flags;
68} 67}
69 68
@@ -78,8 +77,7 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
78 __u32 filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES; 77 __u32 filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES;
79 __u16 netfid; 78 __u16 netfid;
80 79
81 80 if (experimEnabled == 0)
82 if(experimEnabled == 0)
83 return 0; 81 return 0;
84 82
85 xid = GetXid(); 83 xid = GetXid();
@@ -88,21 +86,21 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
88 86
89 full_path = build_path_from_dentry(file->f_path.dentry); 87 full_path = build_path_from_dentry(file->f_path.dentry);
90 88
91 if(full_path == NULL) { 89 if (full_path == NULL) {
92 rc = -ENOMEM; 90 rc = -ENOMEM;
93 } else { 91 } else {
94 cFYI(1,("dir notify on file %s Arg 0x%lx",full_path,arg)); 92 cFYI(1, ("dir notify on file %s Arg 0x%lx", full_path, arg));
95 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, 93 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
96 GENERIC_READ | SYNCHRONIZE, 0 /* create options */, 94 GENERIC_READ | SYNCHRONIZE, 0 /* create options */,
97 &netfid, &oplock,NULL, cifs_sb->local_nls, 95 &netfid, &oplock, NULL, cifs_sb->local_nls,
98 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 96 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
99 /* BB fixme - add this handle to a notify handle list */ 97 /* BB fixme - add this handle to a notify handle list */
100 if(rc) { 98 if (rc) {
101 cFYI(1,("Could not open directory for notify")); 99 cFYI(1, ("Could not open directory for notify"));
102 } else { 100 } else {
103 filter = convert_to_cifs_notify_flags(arg); 101 filter = convert_to_cifs_notify_flags(arg);
104 if(filter != 0) { 102 if (filter != 0) {
105 rc = CIFSSMBNotify(xid, pTcon, 103 rc = CIFSSMBNotify(xid, pTcon,
106 0 /* no subdirs */, netfid, 104 0 /* no subdirs */, netfid,
107 filter, file, arg & DN_MULTISHOT, 105 filter, file, arg & DN_MULTISHOT,
108 cifs_sb->local_nls); 106 cifs_sb->local_nls);
@@ -113,10 +111,10 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
113 it would close automatically but may be a way 111 it would close automatically but may be a way
114 to do it easily when inode freed or when 112 to do it easily when inode freed or when
115 notify info is cleared/changed */ 113 notify info is cleared/changed */
116 cFYI(1,("notify rc %d",rc)); 114 cFYI(1, ("notify rc %d", rc));
117 } 115 }
118 } 116 }
119 117
120 FreeXid(xid); 118 FreeXid(xid);
121 return rc; 119 return rc;
122} 120}
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 3e87dad3367c..f0ff12b3f398 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -986,7 +986,8 @@ mkdir_get_info:
986 * failed to get it from the server or was set bogus */ 986 * failed to get it from the server or was set bogus */
987 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) 987 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
988 direntry->d_inode->i_nlink = 2; 988 direntry->d_inode->i_nlink = 2;
989 if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) 989 if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) {
990 mode &= ~current->fs->umask;
990 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 991 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
991 CIFSSMBUnixSetPerms(xid, pTcon, full_path, 992 CIFSSMBUnixSetPerms(xid, pTcon, full_path,
992 mode, 993 mode,
@@ -1004,7 +1005,7 @@ mkdir_get_info:
1004 cifs_sb->mnt_cifs_flags & 1005 cifs_sb->mnt_cifs_flags &
1005 CIFS_MOUNT_MAP_SPECIAL_CHR); 1006 CIFS_MOUNT_MAP_SPECIAL_CHR);
1006 } 1007 }
1007 else { 1008 } else {
1008 /* BB to be implemented via Windows secrty descriptors 1009 /* BB to be implemented via Windows secrty descriptors
1009 eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, 1010 eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode,
1010 -1, -1, local_nls); */ 1011 -1, -1, local_nls); */
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index e34c7db00f6f..a414f1775ae0 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -30,7 +30,7 @@
30 30
31#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2) 31#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2)
32 32
33int cifs_ioctl (struct inode * inode, struct file * filep, 33int cifs_ioctl (struct inode * inode, struct file * filep,
34 unsigned int command, unsigned long arg) 34 unsigned int command, unsigned long arg)
35{ 35{
36 int rc = -ENOTTY; /* strange error - but the precedent */ 36 int rc = -ENOTTY; /* strange error - but the precedent */
@@ -47,13 +47,13 @@ int cifs_ioctl (struct inode * inode, struct file * filep,
47 47
48 xid = GetXid(); 48 xid = GetXid();
49 49
50 cFYI(1,("ioctl file %p cmd %u arg %lu",filep,command,arg)); 50 cFYI(1, ("ioctl file %p cmd %u arg %lu", filep, command, arg));
51 51
52 cifs_sb = CIFS_SB(inode->i_sb); 52 cifs_sb = CIFS_SB(inode->i_sb);
53 53
54#ifdef CONFIG_CIFS_POSIX 54#ifdef CONFIG_CIFS_POSIX
55 tcon = cifs_sb->tcon; 55 tcon = cifs_sb->tcon;
56 if(tcon) 56 if (tcon)
57 caps = le64_to_cpu(tcon->fsUnixInfo.Capability); 57 caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
58 else { 58 else {
59 rc = -EIO; 59 rc = -EIO;
@@ -62,24 +62,24 @@ int cifs_ioctl (struct inode * inode, struct file * filep,
62 } 62 }
63#endif /* CONFIG_CIFS_POSIX */ 63#endif /* CONFIG_CIFS_POSIX */
64 64
65 switch(command) { 65 switch (command) {
66 case CIFS_IOC_CHECKUMOUNT: 66 case CIFS_IOC_CHECKUMOUNT:
67 cFYI(1,("User unmount attempted")); 67 cFYI(1, ("User unmount attempted"));
68 if(cifs_sb->mnt_uid == current->uid) 68 if (cifs_sb->mnt_uid == current->uid)
69 rc = 0; 69 rc = 0;
70 else { 70 else {
71 rc = -EACCES; 71 rc = -EACCES;
72 cFYI(1,("uids do not match")); 72 cFYI(1, ("uids do not match"));
73 } 73 }
74 break; 74 break;
75#ifdef CONFIG_CIFS_POSIX 75#ifdef CONFIG_CIFS_POSIX
76 case FS_IOC_GETFLAGS: 76 case FS_IOC_GETFLAGS:
77 if(CIFS_UNIX_EXTATTR_CAP & caps) { 77 if (CIFS_UNIX_EXTATTR_CAP & caps) {
78 if (pSMBFile == NULL) 78 if (pSMBFile == NULL)
79 break; 79 break;
80 rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid, 80 rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid,
81 &ExtAttrBits, &ExtAttrMask); 81 &ExtAttrBits, &ExtAttrMask);
82 if(rc == 0) 82 if (rc == 0)
83 rc = put_user(ExtAttrBits & 83 rc = put_user(ExtAttrBits &
84 FS_FL_USER_VISIBLE, 84 FS_FL_USER_VISIBLE,
85 (int __user *)arg); 85 (int __user *)arg);
@@ -87,8 +87,8 @@ int cifs_ioctl (struct inode * inode, struct file * filep,
87 break; 87 break;
88 88
89 case FS_IOC_SETFLAGS: 89 case FS_IOC_SETFLAGS:
90 if(CIFS_UNIX_EXTATTR_CAP & caps) { 90 if (CIFS_UNIX_EXTATTR_CAP & caps) {
91 if(get_user(ExtAttrBits,(int __user *)arg)) { 91 if (get_user(ExtAttrBits, (int __user *)arg)) {
92 rc = -EFAULT; 92 rc = -EFAULT;
93 break; 93 break;
94 } 94 }
@@ -96,16 +96,15 @@ int cifs_ioctl (struct inode * inode, struct file * filep,
96 break; 96 break;
97 /* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid, 97 /* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid,
98 extAttrBits, &ExtAttrMask);*/ 98 extAttrBits, &ExtAttrMask);*/
99
100 } 99 }
101 cFYI(1,("set flags not implemented yet")); 100 cFYI(1, ("set flags not implemented yet"));
102 break; 101 break;
103#endif /* CONFIG_CIFS_POSIX */ 102#endif /* CONFIG_CIFS_POSIX */
104 default: 103 default:
105 cFYI(1,("unsupported ioctl")); 104 cFYI(1, ("unsupported ioctl"));
106 break; 105 break;
107 } 106 }
108 107
109 FreeXid(xid); 108 FreeXid(xid);
110 return rc; 109 return rc;
111} 110}
diff --git a/fs/cifs/rfc1002pdu.h b/fs/cifs/rfc1002pdu.h
index aede606132aa..8b69fcceb597 100644
--- a/fs/cifs/rfc1002pdu.h
+++ b/fs/cifs/rfc1002pdu.h
@@ -18,7 +18,7 @@
18 * 18 *
19 * You should have received a copy of the GNU Lesser General Public License 19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library; if not, write to the Free Software 20 * along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23 23
24/* NB: unlike smb/cifs packets, the RFC1002 structures are big endian */ 24/* NB: unlike smb/cifs packets, the RFC1002 structures are big endian */