diff options
-rw-r--r-- | fs/cifs/asn1.c | 4 | ||||
-rw-r--r-- | fs/cifs/cifs_debug.c | 645 | ||||
-rw-r--r-- | fs/cifs/cifsacl.c | 41 | ||||
-rw-r--r-- | fs/cifs/cifsencrypt.c | 3 | ||||
-rw-r--r-- | fs/cifs/cifsglob.h | 6 | ||||
-rw-r--r-- | fs/cifs/cifspdu.h | 8 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 10 | ||||
-rw-r--r-- | fs/cifs/connect.c | 37 | ||||
-rw-r--r-- | fs/cifs/inode.c | 151 | ||||
-rw-r--r-- | fs/cifs/readdir.c | 1 |
10 files changed, 399 insertions, 507 deletions
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c index f58e41d3ba48..6bb440b257b0 100644 --- a/fs/cifs/asn1.c +++ b/fs/cifs/asn1.c | |||
@@ -400,7 +400,7 @@ asn1_oid_decode(struct asn1_ctx *ctx, | |||
400 | size = eoc - ctx->pointer + 1; | 400 | size = eoc - ctx->pointer + 1; |
401 | 401 | ||
402 | /* first subid actually encodes first two subids */ | 402 | /* first subid actually encodes first two subids */ |
403 | if (size < 2 || size > ULONG_MAX/sizeof(unsigned long)) | 403 | if (size < 2 || size > UINT_MAX/sizeof(unsigned long)) |
404 | return 0; | 404 | return 0; |
405 | 405 | ||
406 | *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); | 406 | *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); |
@@ -494,7 +494,7 @@ decode_negTokenInit(unsigned char *security_blob, int length, | |||
494 | /* remember to free obj->oid */ | 494 | /* remember to free obj->oid */ |
495 | rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag); | 495 | rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag); |
496 | if (rc) { | 496 | if (rc) { |
497 | if ((tag == ASN1_OJI) && (cls == ASN1_PRI)) { | 497 | if ((tag == ASN1_OJI) && (con == ASN1_PRI)) { |
498 | rc = asn1_oid_decode(&ctx, end, &oid, &oidlen); | 498 | rc = asn1_oid_decode(&ctx, end, &oid, &oidlen); |
499 | if (rc) { | 499 | if (rc) { |
500 | rc = compare_oid(oid, oidlen, | 500 | rc = compare_oid(oid, oidlen, |
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index cc950f69e51e..688a2d42153f 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c | |||
@@ -107,9 +107,7 @@ void cifs_dump_mids(struct TCP_Server_Info *server) | |||
107 | #endif /* CONFIG_CIFS_DEBUG2 */ | 107 | #endif /* CONFIG_CIFS_DEBUG2 */ |
108 | 108 | ||
109 | #ifdef CONFIG_PROC_FS | 109 | #ifdef CONFIG_PROC_FS |
110 | static int | 110 | static int cifs_debug_data_proc_show(struct seq_file *m, void *v) |
111 | cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | ||
112 | int count, int *eof, void *data) | ||
113 | { | 111 | { |
114 | struct list_head *tmp; | 112 | struct list_head *tmp; |
115 | struct list_head *tmp1; | 113 | struct list_head *tmp1; |
@@ -117,23 +115,13 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
117 | struct cifsSesInfo *ses; | 115 | struct cifsSesInfo *ses; |
118 | struct cifsTconInfo *tcon; | 116 | struct cifsTconInfo *tcon; |
119 | int i; | 117 | int i; |
120 | int length = 0; | ||
121 | char *original_buf = buf; | ||
122 | 118 | ||
123 | *beginBuffer = buf + offset; | 119 | seq_puts(m, |
124 | |||
125 | length = | ||
126 | sprintf(buf, | ||
127 | "Display Internal CIFS Data Structures for Debugging\n" | 120 | "Display Internal CIFS Data Structures for Debugging\n" |
128 | "---------------------------------------------------\n"); | 121 | "---------------------------------------------------\n"); |
129 | buf += length; | 122 | seq_printf(m, "CIFS Version %s\n", CIFS_VERSION); |
130 | length = sprintf(buf, "CIFS Version %s\n", CIFS_VERSION); | 123 | seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid); |
131 | buf += length; | 124 | seq_printf(m, "Servers:"); |
132 | length = sprintf(buf, | ||
133 | "Active VFS Requests: %d\n", GlobalTotalActiveXid); | ||
134 | buf += length; | ||
135 | length = sprintf(buf, "Servers:"); | ||
136 | buf += length; | ||
137 | 125 | ||
138 | i = 0; | 126 | i = 0; |
139 | read_lock(&GlobalSMBSeslock); | 127 | read_lock(&GlobalSMBSeslock); |
@@ -142,11 +130,10 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
142 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); | 130 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); |
143 | if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) || | 131 | if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) || |
144 | (ses->serverNOS == NULL)) { | 132 | (ses->serverNOS == NULL)) { |
145 | buf += sprintf(buf, "\nentry for %s not fully " | 133 | seq_printf(m, "\nentry for %s not fully " |
146 | "displayed\n\t", ses->serverName); | 134 | "displayed\n\t", ses->serverName); |
147 | } else { | 135 | } else { |
148 | length = | 136 | seq_printf(m, |
149 | sprintf(buf, | ||
150 | "\n%d) Name: %s Domain: %s Mounts: %d OS:" | 137 | "\n%d) Name: %s Domain: %s Mounts: %d OS:" |
151 | " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB" | 138 | " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB" |
152 | " session status: %d\t", | 139 | " session status: %d\t", |
@@ -154,10 +141,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
154 | atomic_read(&ses->inUse), | 141 | atomic_read(&ses->inUse), |
155 | ses->serverOS, ses->serverNOS, | 142 | ses->serverOS, ses->serverNOS, |
156 | ses->capabilities, ses->status); | 143 | ses->capabilities, ses->status); |
157 | buf += length; | ||
158 | } | 144 | } |
159 | if (ses->server) { | 145 | if (ses->server) { |
160 | buf += sprintf(buf, "TCP status: %d\n\tLocal Users To " | 146 | seq_printf(m, "TCP status: %d\n\tLocal Users To " |
161 | "Server: %d SecMode: 0x%x Req On Wire: %d", | 147 | "Server: %d SecMode: 0x%x Req On Wire: %d", |
162 | ses->server->tcpStatus, | 148 | ses->server->tcpStatus, |
163 | atomic_read(&ses->server->socketUseCount), | 149 | atomic_read(&ses->server->socketUseCount), |
@@ -165,13 +151,12 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
165 | atomic_read(&ses->server->inFlight)); | 151 | atomic_read(&ses->server->inFlight)); |
166 | 152 | ||
167 | #ifdef CONFIG_CIFS_STATS2 | 153 | #ifdef CONFIG_CIFS_STATS2 |
168 | buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d", | 154 | seq_printf(m, " In Send: %d In MaxReq Wait: %d", |
169 | atomic_read(&ses->server->inSend), | 155 | atomic_read(&ses->server->inSend), |
170 | atomic_read(&ses->server->num_waiters)); | 156 | atomic_read(&ses->server->num_waiters)); |
171 | #endif | 157 | #endif |
172 | 158 | ||
173 | length = sprintf(buf, "\nMIDs:\n"); | 159 | seq_puts(m, "\nMIDs:\n"); |
174 | buf += length; | ||
175 | 160 | ||
176 | spin_lock(&GlobalMid_Lock); | 161 | spin_lock(&GlobalMid_Lock); |
177 | list_for_each(tmp1, &ses->server->pending_mid_q) { | 162 | list_for_each(tmp1, &ses->server->pending_mid_q) { |
@@ -179,7 +164,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
179 | mid_q_entry, | 164 | mid_q_entry, |
180 | qhead); | 165 | qhead); |
181 | if (mid_entry) { | 166 | if (mid_entry) { |
182 | length = sprintf(buf, | 167 | seq_printf(m, |
183 | "State: %d com: %d pid:" | 168 | "State: %d com: %d pid:" |
184 | " %d tsk: %p mid %d\n", | 169 | " %d tsk: %p mid %d\n", |
185 | mid_entry->midState, | 170 | mid_entry->midState, |
@@ -187,7 +172,6 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
187 | mid_entry->pid, | 172 | mid_entry->pid, |
188 | mid_entry->tsk, | 173 | mid_entry->tsk, |
189 | mid_entry->mid); | 174 | mid_entry->mid); |
190 | buf += length; | ||
191 | } | 175 | } |
192 | } | 176 | } |
193 | spin_unlock(&GlobalMid_Lock); | 177 | spin_unlock(&GlobalMid_Lock); |
@@ -195,11 +179,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
195 | 179 | ||
196 | } | 180 | } |
197 | read_unlock(&GlobalSMBSeslock); | 181 | read_unlock(&GlobalSMBSeslock); |
198 | sprintf(buf, "\n"); | 182 | seq_putc(m, '\n'); |
199 | buf++; | ||
200 | 183 | ||
201 | length = sprintf(buf, "Shares:"); | 184 | seq_puts(m, "Shares:"); |
202 | buf += length; | ||
203 | 185 | ||
204 | i = 0; | 186 | i = 0; |
205 | read_lock(&GlobalSMBSeslock); | 187 | read_lock(&GlobalSMBSeslock); |
@@ -208,62 +190,52 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset, | |||
208 | i++; | 190 | i++; |
209 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 191 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
210 | dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); | 192 | dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); |
211 | length = sprintf(buf, "\n%d) %s Uses: %d ", i, | 193 | seq_printf(m, "\n%d) %s Uses: %d ", i, |
212 | tcon->treeName, atomic_read(&tcon->useCount)); | 194 | tcon->treeName, atomic_read(&tcon->useCount)); |
213 | buf += length; | ||
214 | if (tcon->nativeFileSystem) { | 195 | if (tcon->nativeFileSystem) { |
215 | length = sprintf(buf, "Type: %s ", | 196 | seq_printf(m, "Type: %s ", |
216 | tcon->nativeFileSystem); | 197 | tcon->nativeFileSystem); |
217 | buf += length; | ||
218 | } | 198 | } |
219 | length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x" | 199 | seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x" |
220 | "\nPathComponentMax: %d Status: %d", | 200 | "\nPathComponentMax: %d Status: %d", |
221 | le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), | 201 | le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), |
222 | le32_to_cpu(tcon->fsAttrInfo.Attributes), | 202 | le32_to_cpu(tcon->fsAttrInfo.Attributes), |
223 | le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), | 203 | le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), |
224 | tcon->tidStatus); | 204 | tcon->tidStatus); |
225 | buf += length; | ||
226 | if (dev_type == FILE_DEVICE_DISK) | 205 | if (dev_type == FILE_DEVICE_DISK) |
227 | length = sprintf(buf, " type: DISK "); | 206 | seq_puts(m, " type: DISK "); |
228 | else if (dev_type == FILE_DEVICE_CD_ROM) | 207 | else if (dev_type == FILE_DEVICE_CD_ROM) |
229 | length = sprintf(buf, " type: CDROM "); | 208 | seq_puts(m, " type: CDROM "); |
230 | else | 209 | else |
231 | length = | 210 | seq_printf(m, " type: %d ", dev_type); |
232 | sprintf(buf, " type: %d ", dev_type); | 211 | |
233 | buf += length; | 212 | if (tcon->tidStatus == CifsNeedReconnect) |
234 | if (tcon->tidStatus == CifsNeedReconnect) { | 213 | seq_puts(m, "\tDISCONNECTED "); |
235 | buf += sprintf(buf, "\tDISCONNECTED "); | ||
236 | length += 14; | ||
237 | } | ||
238 | } | 214 | } |
239 | read_unlock(&GlobalSMBSeslock); | 215 | read_unlock(&GlobalSMBSeslock); |
240 | 216 | ||
241 | length = sprintf(buf, "\n"); | 217 | seq_putc(m, '\n'); |
242 | buf += length; | ||
243 | 218 | ||
244 | /* BB add code to dump additional info such as TCP session info now */ | 219 | /* BB add code to dump additional info such as TCP session info now */ |
245 | /* Now calculate total size of returned data */ | 220 | return 0; |
246 | length = buf - original_buf; | 221 | } |
247 | |||
248 | if (offset + count >= length) | ||
249 | *eof = 1; | ||
250 | if (length < offset) { | ||
251 | *eof = 1; | ||
252 | return 0; | ||
253 | } else { | ||
254 | length = length - offset; | ||
255 | } | ||
256 | if (length > count) | ||
257 | length = count; | ||
258 | 222 | ||
259 | return length; | 223 | static int cifs_debug_data_proc_open(struct inode *inode, struct file *file) |
224 | { | ||
225 | return single_open(file, cifs_debug_data_proc_show, NULL); | ||
260 | } | 226 | } |
261 | 227 | ||
262 | #ifdef CONFIG_CIFS_STATS | 228 | static const struct file_operations cifs_debug_data_proc_fops = { |
229 | .owner = THIS_MODULE, | ||
230 | .open = cifs_debug_data_proc_open, | ||
231 | .read = seq_read, | ||
232 | .llseek = seq_lseek, | ||
233 | .release = single_release, | ||
234 | }; | ||
263 | 235 | ||
264 | static int | 236 | #ifdef CONFIG_CIFS_STATS |
265 | cifs_stats_write(struct file *file, const char __user *buffer, | 237 | static ssize_t cifs_stats_proc_write(struct file *file, |
266 | unsigned long count, void *data) | 238 | const char __user *buffer, size_t count, loff_t *ppos) |
267 | { | 239 | { |
268 | char c; | 240 | char c; |
269 | int rc; | 241 | int rc; |
@@ -307,236 +279,132 @@ cifs_stats_write(struct file *file, const char __user *buffer, | |||
307 | return count; | 279 | return count; |
308 | } | 280 | } |
309 | 281 | ||
310 | static int | 282 | static int cifs_stats_proc_show(struct seq_file *m, void *v) |
311 | cifs_stats_read(char *buf, char **beginBuffer, off_t offset, | ||
312 | int count, int *eof, void *data) | ||
313 | { | 283 | { |
314 | int item_length, i, length; | 284 | int i; |
315 | struct list_head *tmp; | 285 | struct list_head *tmp; |
316 | struct cifsTconInfo *tcon; | 286 | struct cifsTconInfo *tcon; |
317 | 287 | ||
318 | *beginBuffer = buf + offset; | 288 | seq_printf(m, |
319 | |||
320 | length = sprintf(buf, | ||
321 | "Resources in use\nCIFS Session: %d\n", | 289 | "Resources in use\nCIFS Session: %d\n", |
322 | sesInfoAllocCount.counter); | 290 | sesInfoAllocCount.counter); |
323 | buf += length; | 291 | seq_printf(m, "Share (unique mount targets): %d\n", |
324 | item_length = | ||
325 | sprintf(buf, "Share (unique mount targets): %d\n", | ||
326 | tconInfoAllocCount.counter); | 292 | tconInfoAllocCount.counter); |
327 | length += item_length; | 293 | seq_printf(m, "SMB Request/Response Buffer: %d Pool size: %d\n", |
328 | buf += item_length; | ||
329 | item_length = | ||
330 | sprintf(buf, "SMB Request/Response Buffer: %d Pool size: %d\n", | ||
331 | bufAllocCount.counter, | 294 | bufAllocCount.counter, |
332 | cifs_min_rcv + tcpSesAllocCount.counter); | 295 | cifs_min_rcv + tcpSesAllocCount.counter); |
333 | length += item_length; | 296 | seq_printf(m, "SMB Small Req/Resp Buffer: %d Pool size: %d\n", |
334 | buf += item_length; | ||
335 | item_length = | ||
336 | sprintf(buf, "SMB Small Req/Resp Buffer: %d Pool size: %d\n", | ||
337 | smBufAllocCount.counter, cifs_min_small); | 297 | smBufAllocCount.counter, cifs_min_small); |
338 | length += item_length; | ||
339 | buf += item_length; | ||
340 | #ifdef CONFIG_CIFS_STATS2 | 298 | #ifdef CONFIG_CIFS_STATS2 |
341 | item_length = sprintf(buf, "Total Large %d Small %d Allocations\n", | 299 | seq_printf(m, "Total Large %d Small %d Allocations\n", |
342 | atomic_read(&totBufAllocCount), | 300 | atomic_read(&totBufAllocCount), |
343 | atomic_read(&totSmBufAllocCount)); | 301 | atomic_read(&totSmBufAllocCount)); |
344 | length += item_length; | ||
345 | buf += item_length; | ||
346 | #endif /* CONFIG_CIFS_STATS2 */ | 302 | #endif /* CONFIG_CIFS_STATS2 */ |
347 | 303 | ||
348 | item_length = | 304 | seq_printf(m, "Operations (MIDs): %d\n", midCount.counter); |
349 | sprintf(buf, "Operations (MIDs): %d\n", | 305 | seq_printf(m, |
350 | midCount.counter); | ||
351 | length += item_length; | ||
352 | buf += item_length; | ||
353 | item_length = sprintf(buf, | ||
354 | "\n%d session %d share reconnects\n", | 306 | "\n%d session %d share reconnects\n", |
355 | tcpSesReconnectCount.counter, tconInfoReconnectCount.counter); | 307 | tcpSesReconnectCount.counter, tconInfoReconnectCount.counter); |
356 | length += item_length; | ||
357 | buf += item_length; | ||
358 | 308 | ||
359 | item_length = sprintf(buf, | 309 | seq_printf(m, |
360 | "Total vfs operations: %d maximum at one time: %d\n", | 310 | "Total vfs operations: %d maximum at one time: %d\n", |
361 | GlobalCurrentXid, GlobalMaxActiveXid); | 311 | GlobalCurrentXid, GlobalMaxActiveXid); |
362 | length += item_length; | ||
363 | buf += item_length; | ||
364 | 312 | ||
365 | i = 0; | 313 | i = 0; |
366 | read_lock(&GlobalSMBSeslock); | 314 | read_lock(&GlobalSMBSeslock); |
367 | list_for_each(tmp, &GlobalTreeConnectionList) { | 315 | list_for_each(tmp, &GlobalTreeConnectionList) { |
368 | i++; | 316 | i++; |
369 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 317 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
370 | item_length = sprintf(buf, "\n%d) %s", i, tcon->treeName); | 318 | seq_printf(m, "\n%d) %s", i, tcon->treeName); |
371 | buf += item_length; | 319 | if (tcon->tidStatus == CifsNeedReconnect) |
372 | length += item_length; | 320 | seq_puts(m, "\tDISCONNECTED "); |
373 | if (tcon->tidStatus == CifsNeedReconnect) { | 321 | seq_printf(m, "\nSMBs: %d Oplock Breaks: %d", |
374 | buf += sprintf(buf, "\tDISCONNECTED "); | ||
375 | length += 14; | ||
376 | } | ||
377 | item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d", | ||
378 | atomic_read(&tcon->num_smbs_sent), | 322 | atomic_read(&tcon->num_smbs_sent), |
379 | atomic_read(&tcon->num_oplock_brks)); | 323 | atomic_read(&tcon->num_oplock_brks)); |
380 | buf += item_length; | 324 | seq_printf(m, "\nReads: %d Bytes: %lld", |
381 | length += item_length; | ||
382 | item_length = sprintf(buf, "\nReads: %d Bytes: %lld", | ||
383 | atomic_read(&tcon->num_reads), | 325 | atomic_read(&tcon->num_reads), |
384 | (long long)(tcon->bytes_read)); | 326 | (long long)(tcon->bytes_read)); |
385 | buf += item_length; | 327 | seq_printf(m, "\nWrites: %d Bytes: %lld", |
386 | length += item_length; | ||
387 | item_length = sprintf(buf, "\nWrites: %d Bytes: %lld", | ||
388 | atomic_read(&tcon->num_writes), | 328 | atomic_read(&tcon->num_writes), |
389 | (long long)(tcon->bytes_written)); | 329 | (long long)(tcon->bytes_written)); |
390 | buf += item_length; | 330 | seq_printf(m, |
391 | length += item_length; | ||
392 | item_length = sprintf(buf, | ||
393 | "\nLocks: %d HardLinks: %d Symlinks: %d", | 331 | "\nLocks: %d HardLinks: %d Symlinks: %d", |
394 | atomic_read(&tcon->num_locks), | 332 | atomic_read(&tcon->num_locks), |
395 | atomic_read(&tcon->num_hardlinks), | 333 | atomic_read(&tcon->num_hardlinks), |
396 | atomic_read(&tcon->num_symlinks)); | 334 | atomic_read(&tcon->num_symlinks)); |
397 | buf += item_length; | ||
398 | length += item_length; | ||
399 | 335 | ||
400 | item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d", | 336 | seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d", |
401 | atomic_read(&tcon->num_opens), | 337 | atomic_read(&tcon->num_opens), |
402 | atomic_read(&tcon->num_closes), | 338 | atomic_read(&tcon->num_closes), |
403 | atomic_read(&tcon->num_deletes)); | 339 | atomic_read(&tcon->num_deletes)); |
404 | buf += item_length; | 340 | seq_printf(m, "\nMkdirs: %d Rmdirs: %d", |
405 | length += item_length; | ||
406 | item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d", | ||
407 | atomic_read(&tcon->num_mkdirs), | 341 | atomic_read(&tcon->num_mkdirs), |
408 | atomic_read(&tcon->num_rmdirs)); | 342 | atomic_read(&tcon->num_rmdirs)); |
409 | buf += item_length; | 343 | seq_printf(m, "\nRenames: %d T2 Renames %d", |
410 | length += item_length; | ||
411 | item_length = sprintf(buf, "\nRenames: %d T2 Renames %d", | ||
412 | atomic_read(&tcon->num_renames), | 344 | atomic_read(&tcon->num_renames), |
413 | atomic_read(&tcon->num_t2renames)); | 345 | atomic_read(&tcon->num_t2renames)); |
414 | buf += item_length; | 346 | seq_printf(m, "\nFindFirst: %d FNext %d FClose %d", |
415 | length += item_length; | ||
416 | item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d", | ||
417 | atomic_read(&tcon->num_ffirst), | 347 | atomic_read(&tcon->num_ffirst), |
418 | atomic_read(&tcon->num_fnext), | 348 | atomic_read(&tcon->num_fnext), |
419 | atomic_read(&tcon->num_fclose)); | 349 | atomic_read(&tcon->num_fclose)); |
420 | buf += item_length; | ||
421 | length += item_length; | ||
422 | } | 350 | } |
423 | read_unlock(&GlobalSMBSeslock); | 351 | read_unlock(&GlobalSMBSeslock); |
424 | 352 | ||
425 | buf += sprintf(buf, "\n"); | 353 | seq_putc(m, '\n'); |
426 | length++; | 354 | return 0; |
427 | 355 | } | |
428 | if (offset + count >= length) | ||
429 | *eof = 1; | ||
430 | if (length < offset) { | ||
431 | *eof = 1; | ||
432 | return 0; | ||
433 | } else { | ||
434 | length = length - offset; | ||
435 | } | ||
436 | if (length > count) | ||
437 | length = count; | ||
438 | 356 | ||
439 | return length; | 357 | static int cifs_stats_proc_open(struct inode *inode, struct file *file) |
358 | { | ||
359 | return single_open(file, cifs_stats_proc_show, NULL); | ||
440 | } | 360 | } |
361 | |||
362 | static const struct file_operations cifs_stats_proc_fops = { | ||
363 | .owner = THIS_MODULE, | ||
364 | .open = cifs_stats_proc_open, | ||
365 | .read = seq_read, | ||
366 | .llseek = seq_lseek, | ||
367 | .release = single_release, | ||
368 | .write = cifs_stats_proc_write, | ||
369 | }; | ||
441 | #endif /* STATS */ | 370 | #endif /* STATS */ |
442 | 371 | ||
443 | static struct proc_dir_entry *proc_fs_cifs; | 372 | static struct proc_dir_entry *proc_fs_cifs; |
444 | read_proc_t cifs_txanchor_read; | 373 | static const struct file_operations cifsFYI_proc_fops; |
445 | static read_proc_t cifsFYI_read; | 374 | static const struct file_operations cifs_oplock_proc_fops; |
446 | static write_proc_t cifsFYI_write; | 375 | static const struct file_operations cifs_lookup_cache_proc_fops; |
447 | static read_proc_t oplockEnabled_read; | 376 | static const struct file_operations traceSMB_proc_fops; |
448 | static write_proc_t oplockEnabled_write; | 377 | static const struct file_operations cifs_multiuser_mount_proc_fops; |
449 | static read_proc_t lookupFlag_read; | 378 | static const struct file_operations cifs_security_flags_proc_fops; |
450 | static write_proc_t lookupFlag_write; | 379 | static const struct file_operations cifs_experimental_proc_fops; |
451 | static read_proc_t traceSMB_read; | 380 | static const struct file_operations cifs_linux_ext_proc_fops; |
452 | static write_proc_t traceSMB_write; | ||
453 | static read_proc_t multiuser_mount_read; | ||
454 | static write_proc_t multiuser_mount_write; | ||
455 | static read_proc_t security_flags_read; | ||
456 | static write_proc_t security_flags_write; | ||
457 | /* static read_proc_t ntlmv2_enabled_read; | ||
458 | static write_proc_t ntlmv2_enabled_write; | ||
459 | static read_proc_t packet_signing_enabled_read; | ||
460 | static write_proc_t packet_signing_enabled_write;*/ | ||
461 | static read_proc_t experimEnabled_read; | ||
462 | static write_proc_t experimEnabled_write; | ||
463 | static read_proc_t linuxExtensionsEnabled_read; | ||
464 | static write_proc_t linuxExtensionsEnabled_write; | ||
465 | 381 | ||
466 | void | 382 | void |
467 | cifs_proc_init(void) | 383 | cifs_proc_init(void) |
468 | { | 384 | { |
469 | struct proc_dir_entry *pde; | ||
470 | |||
471 | proc_fs_cifs = proc_mkdir("fs/cifs", NULL); | 385 | proc_fs_cifs = proc_mkdir("fs/cifs", NULL); |
472 | if (proc_fs_cifs == NULL) | 386 | if (proc_fs_cifs == NULL) |
473 | return; | 387 | return; |
474 | 388 | ||
475 | proc_fs_cifs->owner = THIS_MODULE; | 389 | proc_fs_cifs->owner = THIS_MODULE; |
476 | create_proc_read_entry("DebugData", 0, proc_fs_cifs, | 390 | proc_create("DebugData", 0, proc_fs_cifs, &cifs_debug_data_proc_fops); |
477 | cifs_debug_data_read, NULL); | ||
478 | 391 | ||
479 | #ifdef CONFIG_CIFS_STATS | 392 | #ifdef CONFIG_CIFS_STATS |
480 | pde = create_proc_read_entry("Stats", 0, proc_fs_cifs, | 393 | proc_create("Stats", 0, proc_fs_cifs, &cifs_stats_proc_fops); |
481 | cifs_stats_read, NULL); | ||
482 | if (pde) | ||
483 | pde->write_proc = cifs_stats_write; | ||
484 | #endif /* STATS */ | 394 | #endif /* STATS */ |
485 | pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs, | 395 | proc_create("cifsFYI", 0, proc_fs_cifs, &cifsFYI_proc_fops); |
486 | cifsFYI_read, NULL); | 396 | proc_create("traceSMB", 0, proc_fs_cifs, &traceSMB_proc_fops); |
487 | if (pde) | 397 | proc_create("OplockEnabled", 0, proc_fs_cifs, &cifs_oplock_proc_fops); |
488 | pde->write_proc = cifsFYI_write; | 398 | proc_create("Experimental", 0, proc_fs_cifs, |
489 | 399 | &cifs_experimental_proc_fops); | |
490 | pde = | 400 | proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs, |
491 | create_proc_read_entry("traceSMB", 0, proc_fs_cifs, | 401 | &cifs_linux_ext_proc_fops); |
492 | traceSMB_read, NULL); | 402 | proc_create("MultiuserMount", 0, proc_fs_cifs, |
493 | if (pde) | 403 | &cifs_multiuser_mount_proc_fops); |
494 | pde->write_proc = traceSMB_write; | 404 | proc_create("SecurityFlags", 0, proc_fs_cifs, |
495 | 405 | &cifs_security_flags_proc_fops); | |
496 | pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs, | 406 | proc_create("LookupCacheEnabled", 0, proc_fs_cifs, |
497 | oplockEnabled_read, NULL); | 407 | &cifs_lookup_cache_proc_fops); |
498 | if (pde) | ||
499 | pde->write_proc = oplockEnabled_write; | ||
500 | |||
501 | pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs, | ||
502 | experimEnabled_read, NULL); | ||
503 | if (pde) | ||
504 | pde->write_proc = experimEnabled_write; | ||
505 | |||
506 | pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs, | ||
507 | linuxExtensionsEnabled_read, NULL); | ||
508 | if (pde) | ||
509 | pde->write_proc = linuxExtensionsEnabled_write; | ||
510 | |||
511 | pde = | ||
512 | create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs, | ||
513 | multiuser_mount_read, NULL); | ||
514 | if (pde) | ||
515 | pde->write_proc = multiuser_mount_write; | ||
516 | |||
517 | pde = | ||
518 | create_proc_read_entry("SecurityFlags", 0, proc_fs_cifs, | ||
519 | security_flags_read, NULL); | ||
520 | if (pde) | ||
521 | pde->write_proc = security_flags_write; | ||
522 | |||
523 | pde = | ||
524 | create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs, | ||
525 | lookupFlag_read, NULL); | ||
526 | if (pde) | ||
527 | pde->write_proc = lookupFlag_write; | ||
528 | |||
529 | /* pde = | ||
530 | create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs, | ||
531 | ntlmv2_enabled_read, NULL); | ||
532 | if (pde) | ||
533 | pde->write_proc = ntlmv2_enabled_write; | ||
534 | |||
535 | pde = | ||
536 | create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs, | ||
537 | packet_signing_enabled_read, NULL); | ||
538 | if (pde) | ||
539 | pde->write_proc = packet_signing_enabled_write;*/ | ||
540 | } | 408 | } |
541 | 409 | ||
542 | void | 410 | void |
@@ -553,39 +421,26 @@ cifs_proc_clean(void) | |||
553 | #endif | 421 | #endif |
554 | remove_proc_entry("MultiuserMount", proc_fs_cifs); | 422 | remove_proc_entry("MultiuserMount", proc_fs_cifs); |
555 | remove_proc_entry("OplockEnabled", proc_fs_cifs); | 423 | remove_proc_entry("OplockEnabled", proc_fs_cifs); |
556 | /* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */ | ||
557 | remove_proc_entry("SecurityFlags", proc_fs_cifs); | 424 | remove_proc_entry("SecurityFlags", proc_fs_cifs); |
558 | /* remove_proc_entry("PacketSigningEnabled", proc_fs_cifs); */ | ||
559 | remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); | 425 | remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); |
560 | remove_proc_entry("Experimental", proc_fs_cifs); | 426 | remove_proc_entry("Experimental", proc_fs_cifs); |
561 | remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); | 427 | remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); |
562 | remove_proc_entry("fs/cifs", NULL); | 428 | remove_proc_entry("fs/cifs", NULL); |
563 | } | 429 | } |
564 | 430 | ||
565 | static int | 431 | static int cifsFYI_proc_show(struct seq_file *m, void *v) |
566 | cifsFYI_read(char *page, char **start, off_t off, int count, | ||
567 | int *eof, void *data) | ||
568 | { | 432 | { |
569 | int len; | 433 | seq_printf(m, "%d\n", cifsFYI); |
570 | 434 | return 0; | |
571 | len = sprintf(page, "%d\n", cifsFYI); | 435 | } |
572 | |||
573 | len -= off; | ||
574 | *start = page + off; | ||
575 | |||
576 | if (len > count) | ||
577 | len = count; | ||
578 | else | ||
579 | *eof = 1; | ||
580 | |||
581 | if (len < 0) | ||
582 | len = 0; | ||
583 | 436 | ||
584 | return len; | 437 | static int cifsFYI_proc_open(struct inode *inode, struct file *file) |
438 | { | ||
439 | return single_open(file, cifsFYI_proc_show, NULL); | ||
585 | } | 440 | } |
586 | static int | 441 | |
587 | cifsFYI_write(struct file *file, const char __user *buffer, | 442 | static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer, |
588 | unsigned long count, void *data) | 443 | size_t count, loff_t *ppos) |
589 | { | 444 | { |
590 | char c; | 445 | char c; |
591 | int rc; | 446 | int rc; |
@@ -603,30 +458,28 @@ cifsFYI_write(struct file *file, const char __user *buffer, | |||
603 | return count; | 458 | return count; |
604 | } | 459 | } |
605 | 460 | ||
606 | static int | 461 | static const struct file_operations cifsFYI_proc_fops = { |
607 | oplockEnabled_read(char *page, char **start, off_t off, | 462 | .owner = THIS_MODULE, |
608 | int count, int *eof, void *data) | 463 | .open = cifsFYI_proc_open, |
609 | { | 464 | .read = seq_read, |
610 | int len; | 465 | .llseek = seq_lseek, |
611 | 466 | .release = single_release, | |
612 | len = sprintf(page, "%d\n", oplockEnabled); | 467 | .write = cifsFYI_proc_write, |
613 | 468 | }; | |
614 | len -= off; | ||
615 | *start = page + off; | ||
616 | |||
617 | if (len > count) | ||
618 | len = count; | ||
619 | else | ||
620 | *eof = 1; | ||
621 | 469 | ||
622 | if (len < 0) | 470 | static int cifs_oplock_proc_show(struct seq_file *m, void *v) |
623 | len = 0; | 471 | { |
472 | seq_printf(m, "%d\n", oplockEnabled); | ||
473 | return 0; | ||
474 | } | ||
624 | 475 | ||
625 | return len; | 476 | static int cifs_oplock_proc_open(struct inode *inode, struct file *file) |
477 | { | ||
478 | return single_open(file, cifs_oplock_proc_show, NULL); | ||
626 | } | 479 | } |
627 | static int | 480 | |
628 | oplockEnabled_write(struct file *file, const char __user *buffer, | 481 | static ssize_t cifs_oplock_proc_write(struct file *file, |
629 | unsigned long count, void *data) | 482 | const char __user *buffer, size_t count, loff_t *ppos) |
630 | { | 483 | { |
631 | char c; | 484 | char c; |
632 | int rc; | 485 | int rc; |
@@ -642,30 +495,28 @@ oplockEnabled_write(struct file *file, const char __user *buffer, | |||
642 | return count; | 495 | return count; |
643 | } | 496 | } |
644 | 497 | ||
645 | static int | 498 | static const struct file_operations cifs_oplock_proc_fops = { |
646 | experimEnabled_read(char *page, char **start, off_t off, | 499 | .owner = THIS_MODULE, |
647 | int count, int *eof, void *data) | 500 | .open = cifs_oplock_proc_open, |
648 | { | 501 | .read = seq_read, |
649 | int len; | 502 | .llseek = seq_lseek, |
650 | 503 | .release = single_release, | |
651 | len = sprintf(page, "%d\n", experimEnabled); | 504 | .write = cifs_oplock_proc_write, |
652 | 505 | }; | |
653 | len -= off; | ||
654 | *start = page + off; | ||
655 | 506 | ||
656 | if (len > count) | 507 | static int cifs_experimental_proc_show(struct seq_file *m, void *v) |
657 | len = count; | 508 | { |
658 | else | 509 | seq_printf(m, "%d\n", experimEnabled); |
659 | *eof = 1; | 510 | return 0; |
660 | 511 | } | |
661 | if (len < 0) | ||
662 | len = 0; | ||
663 | 512 | ||
664 | return len; | 513 | static int cifs_experimental_proc_open(struct inode *inode, struct file *file) |
514 | { | ||
515 | return single_open(file, cifs_experimental_proc_show, NULL); | ||
665 | } | 516 | } |
666 | static int | 517 | |
667 | experimEnabled_write(struct file *file, const char __user *buffer, | 518 | static ssize_t cifs_experimental_proc_write(struct file *file, |
668 | unsigned long count, void *data) | 519 | const char __user *buffer, size_t count, loff_t *ppos) |
669 | { | 520 | { |
670 | char c; | 521 | char c; |
671 | int rc; | 522 | int rc; |
@@ -683,29 +534,28 @@ experimEnabled_write(struct file *file, const char __user *buffer, | |||
683 | return count; | 534 | return count; |
684 | } | 535 | } |
685 | 536 | ||
686 | static int | 537 | static const struct file_operations cifs_experimental_proc_fops = { |
687 | linuxExtensionsEnabled_read(char *page, char **start, off_t off, | 538 | .owner = THIS_MODULE, |
688 | int count, int *eof, void *data) | 539 | .open = cifs_experimental_proc_open, |
689 | { | 540 | .read = seq_read, |
690 | int len; | 541 | .llseek = seq_lseek, |
691 | 542 | .release = single_release, | |
692 | len = sprintf(page, "%d\n", linuxExtEnabled); | 543 | .write = cifs_experimental_proc_write, |
693 | len -= off; | 544 | }; |
694 | *start = page + off; | ||
695 | 545 | ||
696 | if (len > count) | 546 | static int cifs_linux_ext_proc_show(struct seq_file *m, void *v) |
697 | len = count; | 547 | { |
698 | else | 548 | seq_printf(m, "%d\n", linuxExtEnabled); |
699 | *eof = 1; | 549 | return 0; |
700 | 550 | } | |
701 | if (len < 0) | ||
702 | len = 0; | ||
703 | 551 | ||
704 | return len; | 552 | static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file) |
553 | { | ||
554 | return single_open(file, cifs_linux_ext_proc_show, NULL); | ||
705 | } | 555 | } |
706 | static int | 556 | |
707 | linuxExtensionsEnabled_write(struct file *file, const char __user *buffer, | 557 | static ssize_t cifs_linux_ext_proc_write(struct file *file, |
708 | unsigned long count, void *data) | 558 | const char __user *buffer, size_t count, loff_t *ppos) |
709 | { | 559 | { |
710 | char c; | 560 | char c; |
711 | int rc; | 561 | int rc; |
@@ -721,31 +571,28 @@ linuxExtensionsEnabled_write(struct file *file, const char __user *buffer, | |||
721 | return count; | 571 | return count; |
722 | } | 572 | } |
723 | 573 | ||
574 | static const struct file_operations cifs_linux_ext_proc_fops = { | ||
575 | .owner = THIS_MODULE, | ||
576 | .open = cifs_linux_ext_proc_open, | ||
577 | .read = seq_read, | ||
578 | .llseek = seq_lseek, | ||
579 | .release = single_release, | ||
580 | .write = cifs_linux_ext_proc_write, | ||
581 | }; | ||
724 | 582 | ||
725 | static int | 583 | static int cifs_lookup_cache_proc_show(struct seq_file *m, void *v) |
726 | lookupFlag_read(char *page, char **start, off_t off, | ||
727 | int count, int *eof, void *data) | ||
728 | { | 584 | { |
729 | int len; | 585 | seq_printf(m, "%d\n", lookupCacheEnabled); |
730 | 586 | return 0; | |
731 | len = sprintf(page, "%d\n", lookupCacheEnabled); | 587 | } |
732 | |||
733 | len -= off; | ||
734 | *start = page + off; | ||
735 | |||
736 | if (len > count) | ||
737 | len = count; | ||
738 | else | ||
739 | *eof = 1; | ||
740 | |||
741 | if (len < 0) | ||
742 | len = 0; | ||
743 | 588 | ||
744 | return len; | 589 | static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file) |
590 | { | ||
591 | return single_open(file, cifs_lookup_cache_proc_show, NULL); | ||
745 | } | 592 | } |
746 | static int | 593 | |
747 | lookupFlag_write(struct file *file, const char __user *buffer, | 594 | static ssize_t cifs_lookup_cache_proc_write(struct file *file, |
748 | unsigned long count, void *data) | 595 | const char __user *buffer, size_t count, loff_t *ppos) |
749 | { | 596 | { |
750 | char c; | 597 | char c; |
751 | int rc; | 598 | int rc; |
@@ -760,30 +607,29 @@ lookupFlag_write(struct file *file, const char __user *buffer, | |||
760 | 607 | ||
761 | return count; | 608 | return count; |
762 | } | 609 | } |
763 | static int | ||
764 | traceSMB_read(char *page, char **start, off_t off, int count, | ||
765 | int *eof, void *data) | ||
766 | { | ||
767 | int len; | ||
768 | |||
769 | len = sprintf(page, "%d\n", traceSMB); | ||
770 | |||
771 | len -= off; | ||
772 | *start = page + off; | ||
773 | 610 | ||
774 | if (len > count) | 611 | static const struct file_operations cifs_lookup_cache_proc_fops = { |
775 | len = count; | 612 | .owner = THIS_MODULE, |
776 | else | 613 | .open = cifs_lookup_cache_proc_open, |
777 | *eof = 1; | 614 | .read = seq_read, |
615 | .llseek = seq_lseek, | ||
616 | .release = single_release, | ||
617 | .write = cifs_lookup_cache_proc_write, | ||
618 | }; | ||
778 | 619 | ||
779 | if (len < 0) | 620 | static int traceSMB_proc_show(struct seq_file *m, void *v) |
780 | len = 0; | 621 | { |
622 | seq_printf(m, "%d\n", traceSMB); | ||
623 | return 0; | ||
624 | } | ||
781 | 625 | ||
782 | return len; | 626 | static int traceSMB_proc_open(struct inode *inode, struct file *file) |
627 | { | ||
628 | return single_open(file, traceSMB_proc_show, NULL); | ||
783 | } | 629 | } |
784 | static int | 630 | |
785 | traceSMB_write(struct file *file, const char __user *buffer, | 631 | static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, |
786 | unsigned long count, void *data) | 632 | size_t count, loff_t *ppos) |
787 | { | 633 | { |
788 | char c; | 634 | char c; |
789 | int rc; | 635 | int rc; |
@@ -799,30 +645,28 @@ traceSMB_write(struct file *file, const char __user *buffer, | |||
799 | return count; | 645 | return count; |
800 | } | 646 | } |
801 | 647 | ||
802 | static int | 648 | static const struct file_operations traceSMB_proc_fops = { |
803 | multiuser_mount_read(char *page, char **start, off_t off, | 649 | .owner = THIS_MODULE, |
804 | int count, int *eof, void *data) | 650 | .open = traceSMB_proc_open, |
805 | { | 651 | .read = seq_read, |
806 | int len; | 652 | .llseek = seq_lseek, |
807 | 653 | .release = single_release, | |
808 | len = sprintf(page, "%d\n", multiuser_mount); | 654 | .write = traceSMB_proc_write, |
809 | 655 | }; | |
810 | len -= off; | ||
811 | *start = page + off; | ||
812 | 656 | ||
813 | if (len > count) | 657 | static int cifs_multiuser_mount_proc_show(struct seq_file *m, void *v) |
814 | len = count; | 658 | { |
815 | else | 659 | seq_printf(m, "%d\n", multiuser_mount); |
816 | *eof = 1; | 660 | return 0; |
817 | 661 | } | |
818 | if (len < 0) | ||
819 | len = 0; | ||
820 | 662 | ||
821 | return len; | 663 | static int cifs_multiuser_mount_proc_open(struct inode *inode, struct file *fh) |
664 | { | ||
665 | return single_open(fh, cifs_multiuser_mount_proc_show, NULL); | ||
822 | } | 666 | } |
823 | static int | 667 | |
824 | multiuser_mount_write(struct file *file, const char __user *buffer, | 668 | static ssize_t cifs_multiuser_mount_proc_write(struct file *file, |
825 | unsigned long count, void *data) | 669 | const char __user *buffer, size_t count, loff_t *ppos) |
826 | { | 670 | { |
827 | char c; | 671 | char c; |
828 | int rc; | 672 | int rc; |
@@ -838,30 +682,28 @@ multiuser_mount_write(struct file *file, const char __user *buffer, | |||
838 | return count; | 682 | return count; |
839 | } | 683 | } |
840 | 684 | ||
841 | static int | 685 | static const struct file_operations cifs_multiuser_mount_proc_fops = { |
842 | security_flags_read(char *page, char **start, off_t off, | 686 | .owner = THIS_MODULE, |
843 | int count, int *eof, void *data) | 687 | .open = cifs_multiuser_mount_proc_open, |
844 | { | 688 | .read = seq_read, |
845 | int len; | 689 | .llseek = seq_lseek, |
846 | 690 | .release = single_release, | |
847 | len = sprintf(page, "0x%x\n", extended_security); | 691 | .write = cifs_multiuser_mount_proc_write, |
848 | 692 | }; | |
849 | len -= off; | ||
850 | *start = page + off; | ||
851 | 693 | ||
852 | if (len > count) | 694 | static int cifs_security_flags_proc_show(struct seq_file *m, void *v) |
853 | len = count; | 695 | { |
854 | else | 696 | seq_printf(m, "0x%x\n", extended_security); |
855 | *eof = 1; | 697 | return 0; |
856 | 698 | } | |
857 | if (len < 0) | ||
858 | len = 0; | ||
859 | 699 | ||
860 | return len; | 700 | static int cifs_security_flags_proc_open(struct inode *inode, struct file *file) |
701 | { | ||
702 | return single_open(file, cifs_security_flags_proc_show, NULL); | ||
861 | } | 703 | } |
862 | static int | 704 | |
863 | security_flags_write(struct file *file, const char __user *buffer, | 705 | static ssize_t cifs_security_flags_proc_write(struct file *file, |
864 | unsigned long count, void *data) | 706 | const char __user *buffer, size_t count, loff_t *ppos) |
865 | { | 707 | { |
866 | unsigned int flags; | 708 | unsigned int flags; |
867 | char flags_string[12]; | 709 | char flags_string[12]; |
@@ -917,6 +759,15 @@ security_flags_write(struct file *file, const char __user *buffer, | |||
917 | /* BB should we turn on MAY flags for other MUST options? */ | 759 | /* BB should we turn on MAY flags for other MUST options? */ |
918 | return count; | 760 | return count; |
919 | } | 761 | } |
762 | |||
763 | static const struct file_operations cifs_security_flags_proc_fops = { | ||
764 | .owner = THIS_MODULE, | ||
765 | .open = cifs_security_flags_proc_open, | ||
766 | .read = seq_read, | ||
767 | .llseek = seq_lseek, | ||
768 | .release = single_release, | ||
769 | .write = cifs_security_flags_proc_write, | ||
770 | }; | ||
920 | #else | 771 | #else |
921 | inline void cifs_proc_init(void) | 772 | inline void cifs_proc_init(void) |
922 | { | 773 | { |
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 0e9fc2ba90ee..57ecdc83c26f 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
@@ -56,7 +56,7 @@ int match_sid(struct cifs_sid *ctsid) | |||
56 | struct cifs_sid *cwsid; | 56 | struct cifs_sid *cwsid; |
57 | 57 | ||
58 | if (!ctsid) | 58 | if (!ctsid) |
59 | return (-1); | 59 | return -1; |
60 | 60 | ||
61 | for (i = 0; i < NUM_WK_SIDS; ++i) { | 61 | for (i = 0; i < NUM_WK_SIDS; ++i) { |
62 | cwsid = &(wksidarr[i].cifssid); | 62 | cwsid = &(wksidarr[i].cifssid); |
@@ -87,11 +87,11 @@ int match_sid(struct cifs_sid *ctsid) | |||
87 | } | 87 | } |
88 | 88 | ||
89 | cFYI(1, ("matching sid: %s\n", wksidarr[i].sidname)); | 89 | cFYI(1, ("matching sid: %s\n", wksidarr[i].sidname)); |
90 | return (0); /* sids compare/match */ | 90 | return 0; /* sids compare/match */ |
91 | } | 91 | } |
92 | 92 | ||
93 | cFYI(1, ("No matching sid")); | 93 | cFYI(1, ("No matching sid")); |
94 | return (-1); | 94 | return -1; |
95 | } | 95 | } |
96 | 96 | ||
97 | /* if the two SIDs (roughly equivalent to a UUID for a user or group) are | 97 | /* if the two SIDs (roughly equivalent to a UUID for a user or group) are |
@@ -102,16 +102,16 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid) | |||
102 | int num_subauth, num_sat, num_saw; | 102 | int num_subauth, num_sat, num_saw; |
103 | 103 | ||
104 | if ((!ctsid) || (!cwsid)) | 104 | if ((!ctsid) || (!cwsid)) |
105 | return (0); | 105 | return 0; |
106 | 106 | ||
107 | /* compare the revision */ | 107 | /* compare the revision */ |
108 | if (ctsid->revision != cwsid->revision) | 108 | if (ctsid->revision != cwsid->revision) |
109 | return (0); | 109 | return 0; |
110 | 110 | ||
111 | /* compare all of the six auth values */ | 111 | /* compare all of the six auth values */ |
112 | for (i = 0; i < 6; ++i) { | 112 | for (i = 0; i < 6; ++i) { |
113 | if (ctsid->authority[i] != cwsid->authority[i]) | 113 | if (ctsid->authority[i] != cwsid->authority[i]) |
114 | return (0); | 114 | return 0; |
115 | } | 115 | } |
116 | 116 | ||
117 | /* compare all of the subauth values if any */ | 117 | /* compare all of the subauth values if any */ |
@@ -121,11 +121,11 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid) | |||
121 | if (num_subauth) { | 121 | if (num_subauth) { |
122 | for (i = 0; i < num_subauth; ++i) { | 122 | for (i = 0; i < num_subauth; ++i) { |
123 | if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) | 123 | if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) |
124 | return (0); | 124 | return 0; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | return (1); /* sids compare/match */ | 128 | return 1; /* sids compare/match */ |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
@@ -169,8 +169,7 @@ static void copy_sec_desc(const struct cifs_ntsd *pntsd, | |||
169 | for (i = 0; i < 6; i++) | 169 | for (i = 0; i < 6; i++) |
170 | ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i]; | 170 | ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i]; |
171 | for (i = 0; i < 5; i++) | 171 | for (i = 0; i < 5; i++) |
172 | ngroup_sid_ptr->sub_auth[i] = | 172 | ngroup_sid_ptr->sub_auth[i] = group_sid_ptr->sub_auth[i]; |
173 | cpu_to_le32(group_sid_ptr->sub_auth[i]); | ||
174 | 173 | ||
175 | return; | 174 | return; |
176 | } | 175 | } |
@@ -285,7 +284,7 @@ static __u16 fill_ace_for_sid(struct cifs_ace *pntace, | |||
285 | size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4); | 284 | size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4); |
286 | pntace->size = cpu_to_le16(size); | 285 | pntace->size = cpu_to_le16(size); |
287 | 286 | ||
288 | return (size); | 287 | return size; |
289 | } | 288 | } |
290 | 289 | ||
291 | 290 | ||
@@ -426,7 +425,7 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid, | |||
426 | pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); | 425 | pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); |
427 | pndacl->num_aces = cpu_to_le32(3); | 426 | pndacl->num_aces = cpu_to_le32(3); |
428 | 427 | ||
429 | return (0); | 428 | return 0; |
430 | } | 429 | } |
431 | 430 | ||
432 | 431 | ||
@@ -510,7 +509,7 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len, | |||
510 | sizeof(struct cifs_sid)); */ | 509 | sizeof(struct cifs_sid)); */ |
511 | 510 | ||
512 | 511 | ||
513 | return (0); | 512 | return 0; |
514 | } | 513 | } |
515 | 514 | ||
516 | 515 | ||
@@ -527,7 +526,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, | |||
527 | struct cifs_acl *ndacl_ptr = NULL; /* no need for SACL ptr */ | 526 | struct cifs_acl *ndacl_ptr = NULL; /* no need for SACL ptr */ |
528 | 527 | ||
529 | if ((inode == NULL) || (pntsd == NULL) || (pnntsd == NULL)) | 528 | if ((inode == NULL) || (pntsd == NULL) || (pnntsd == NULL)) |
530 | return (-EIO); | 529 | return -EIO; |
531 | 530 | ||
532 | owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + | 531 | owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + |
533 | le32_to_cpu(pntsd->osidoffset)); | 532 | le32_to_cpu(pntsd->osidoffset)); |
@@ -550,7 +549,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, | |||
550 | /* copy security descriptor control portion and owner and group sid */ | 549 | /* copy security descriptor control portion and owner and group sid */ |
551 | copy_sec_desc(pntsd, pnntsd, sidsoffset); | 550 | copy_sec_desc(pntsd, pnntsd, sidsoffset); |
552 | 551 | ||
553 | return (rc); | 552 | return rc; |
554 | } | 553 | } |
555 | 554 | ||
556 | 555 | ||
@@ -629,11 +628,11 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
629 | cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); | 628 | cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); |
630 | 629 | ||
631 | if (!inode) | 630 | if (!inode) |
632 | return (rc); | 631 | return rc; |
633 | 632 | ||
634 | sb = inode->i_sb; | 633 | sb = inode->i_sb; |
635 | if (sb == NULL) | 634 | if (sb == NULL) |
636 | return (rc); | 635 | return rc; |
637 | 636 | ||
638 | cifs_sb = CIFS_SB(sb); | 637 | cifs_sb = CIFS_SB(sb); |
639 | xid = GetXid(); | 638 | xid = GetXid(); |
@@ -652,7 +651,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
652 | if (rc != 0) { | 651 | if (rc != 0) { |
653 | cERROR(1, ("Unable to open file to set ACL")); | 652 | cERROR(1, ("Unable to open file to set ACL")); |
654 | FreeXid(xid); | 653 | FreeXid(xid); |
655 | return (rc); | 654 | return rc; |
656 | } | 655 | } |
657 | } | 656 | } |
658 | 657 | ||
@@ -665,7 +664,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
665 | 664 | ||
666 | FreeXid(xid); | 665 | FreeXid(xid); |
667 | 666 | ||
668 | return (rc); | 667 | return rc; |
669 | } | 668 | } |
670 | 669 | ||
671 | /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ | 670 | /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ |
@@ -715,7 +714,7 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) | |||
715 | if (!pnntsd) { | 714 | if (!pnntsd) { |
716 | cERROR(1, ("Unable to allocate security descriptor")); | 715 | cERROR(1, ("Unable to allocate security descriptor")); |
717 | kfree(pntsd); | 716 | kfree(pntsd); |
718 | return (-ENOMEM); | 717 | return -ENOMEM; |
719 | } | 718 | } |
720 | 719 | ||
721 | rc = build_sec_desc(pntsd, pnntsd, inode, nmode); | 720 | rc = build_sec_desc(pntsd, pnntsd, inode, nmode); |
@@ -732,6 +731,6 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) | |||
732 | kfree(pntsd); | 731 | kfree(pntsd); |
733 | } | 732 | } |
734 | 733 | ||
735 | return (rc); | 734 | return rc; |
736 | } | 735 | } |
737 | #endif /* CONFIG_CIFS_EXPERIMENTAL */ | 736 | #endif /* CONFIG_CIFS_EXPERIMENTAL */ |
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index 4ff8939c6cc7..83fd40dc1ef0 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
@@ -310,9 +310,8 @@ void calc_lanman_hash(struct cifsSesInfo *ses, char *lnm_session_key) | |||
310 | utf8 and other multibyte codepages each need their own strupper | 310 | utf8 and other multibyte codepages each need their own strupper |
311 | function since a byte at a time will ont work. */ | 311 | function since a byte at a time will ont work. */ |
312 | 312 | ||
313 | for (i = 0; i < CIFS_ENCPWD_SIZE; i++) { | 313 | for (i = 0; i < CIFS_ENCPWD_SIZE; i++) |
314 | password_with_pad[i] = toupper(password_with_pad[i]); | 314 | password_with_pad[i] = toupper(password_with_pad[i]); |
315 | } | ||
316 | 315 | ||
317 | SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key); | 316 | SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key); |
318 | /* clear password before we return/free memory */ | 317 | /* clear password before we return/free memory */ |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 9cfcf326ead3..7e1cf262effe 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -27,7 +27,7 @@ | |||
27 | #define MAX_SES_INFO 2 | 27 | #define MAX_SES_INFO 2 |
28 | #define MAX_TCON_INFO 4 | 28 | #define MAX_TCON_INFO 4 |
29 | 29 | ||
30 | #define MAX_TREE_SIZE 2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1 | 30 | #define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1) |
31 | #define MAX_SERVER_SIZE 15 | 31 | #define MAX_SERVER_SIZE 15 |
32 | #define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */ | 32 | #define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */ |
33 | #define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null | 33 | #define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null |
@@ -537,8 +537,8 @@ require use of the stronger protocol */ | |||
537 | #endif /* WEAK_PW_HASH */ | 537 | #endif /* WEAK_PW_HASH */ |
538 | #define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */ | 538 | #define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */ |
539 | 539 | ||
540 | #define CIFSSEC_DEF CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | 540 | #define CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2) |
541 | #define CIFSSEC_MAX CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2 | 541 | #define CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2) |
542 | #define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5) | 542 | #define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5) |
543 | /* | 543 | /* |
544 | ***************************************************************** | 544 | ***************************************************************** |
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h index 0f327c224da3..409abce12732 100644 --- a/fs/cifs/cifspdu.h +++ b/fs/cifs/cifspdu.h | |||
@@ -31,7 +31,7 @@ | |||
31 | #else | 31 | #else |
32 | #define CIFS_PROT 0 | 32 | #define CIFS_PROT 0 |
33 | #endif | 33 | #endif |
34 | #define POSIX_PROT CIFS_PROT+1 | 34 | #define POSIX_PROT (CIFS_PROT+1) |
35 | #define BAD_PROT 0xFFFF | 35 | #define BAD_PROT 0xFFFF |
36 | 36 | ||
37 | /* SMB command codes */ | 37 | /* SMB command codes */ |
@@ -341,7 +341,7 @@ | |||
341 | #define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */ | 341 | #define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */ |
342 | #define CREATE_NO_EA_KNOWLEDGE 0x00000200 | 342 | #define CREATE_NO_EA_KNOWLEDGE 0x00000200 |
343 | #define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete | 343 | #define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete |
344 | "open for recovery" flag - should | 344 | "open for recovery" flag should |
345 | be zero in any case */ | 345 | be zero in any case */ |
346 | #define CREATE_OPEN_FOR_RECOVERY 0x00000400 | 346 | #define CREATE_OPEN_FOR_RECOVERY 0x00000400 |
347 | #define CREATE_RANDOM_ACCESS 0x00000800 | 347 | #define CREATE_RANDOM_ACCESS 0x00000800 |
@@ -414,8 +414,8 @@ struct smb_hdr { | |||
414 | __u8 WordCount; | 414 | __u8 WordCount; |
415 | } __attribute__((packed)); | 415 | } __attribute__((packed)); |
416 | /* given a pointer to an smb_hdr retrieve the value of byte count */ | 416 | /* given a pointer to an smb_hdr retrieve the value of byte count */ |
417 | #define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) | 417 | #define BCC(smb_var) (*(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) |
418 | #define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) | 418 | #define BCC_LE(smb_var) (*(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) |
419 | /* given a pointer to an smb_hdr retrieve the pointer to the byte area */ | 419 | /* given a pointer to an smb_hdr retrieve the pointer to the byte area */ |
420 | #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2) | 420 | #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2) |
421 | 421 | ||
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 4511b708f0f3..c621ffa2ca90 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -686,11 +686,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) | |||
686 | SecurityBlob, | 686 | SecurityBlob, |
687 | count - 16, | 687 | count - 16, |
688 | &server->secType); | 688 | &server->secType); |
689 | if (rc == 1) { | 689 | if (rc == 1) |
690 | rc = 0; | 690 | rc = 0; |
691 | } else { | 691 | else |
692 | rc = -EINVAL; | 692 | rc = -EINVAL; |
693 | } | ||
694 | } | 693 | } |
695 | } else | 694 | } else |
696 | server->capabilities &= ~CAP_EXTENDED_SECURITY; | 695 | server->capabilities &= ~CAP_EXTENDED_SECURITY; |
@@ -3914,7 +3913,10 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr, | |||
3914 | bool is_unicode; | 3913 | bool is_unicode; |
3915 | struct dfs_referral_level_3 *ref; | 3914 | struct dfs_referral_level_3 *ref; |
3916 | 3915 | ||
3917 | is_unicode = pSMBr->hdr.Flags2 & SMBFLG2_UNICODE; | 3916 | if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) |
3917 | is_unicode = true; | ||
3918 | else | ||
3919 | is_unicode = false; | ||
3918 | *num_of_nodes = le16_to_cpu(pSMBr->NumberOfReferrals); | 3920 | *num_of_nodes = le16_to_cpu(pSMBr->NumberOfReferrals); |
3919 | 3921 | ||
3920 | if (*num_of_nodes < 1) { | 3922 | if (*num_of_nodes < 1) { |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index e8fa46c7cff2..b51d5777cde6 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -455,7 +455,7 @@ incomplete_rcv: | |||
455 | /* Note that FC 1001 length is big endian on the wire, | 455 | /* Note that FC 1001 length is big endian on the wire, |
456 | but we convert it here so it is always manipulated | 456 | but we convert it here so it is always manipulated |
457 | as host byte order */ | 457 | as host byte order */ |
458 | pdu_length = ntohl(smb_buffer->smb_buf_length); | 458 | pdu_length = be32_to_cpu((__force __be32)smb_buffer->smb_buf_length); |
459 | smb_buffer->smb_buf_length = pdu_length; | 459 | smb_buffer->smb_buf_length = pdu_length; |
460 | 460 | ||
461 | cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); | 461 | cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); |
@@ -1461,6 +1461,39 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path, | |||
1461 | return rc; | 1461 | return rc; |
1462 | } | 1462 | } |
1463 | 1463 | ||
1464 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
1465 | static struct lock_class_key cifs_key[2]; | ||
1466 | static struct lock_class_key cifs_slock_key[2]; | ||
1467 | |||
1468 | static inline void | ||
1469 | cifs_reclassify_socket4(struct socket *sock) | ||
1470 | { | ||
1471 | struct sock *sk = sock->sk; | ||
1472 | BUG_ON(sock_owned_by_user(sk)); | ||
1473 | sock_lock_init_class_and_name(sk, "slock-AF_INET-CIFS", | ||
1474 | &cifs_slock_key[0], "sk_lock-AF_INET-CIFS", &cifs_key[0]); | ||
1475 | } | ||
1476 | |||
1477 | static inline void | ||
1478 | cifs_reclassify_socket6(struct socket *sock) | ||
1479 | { | ||
1480 | struct sock *sk = sock->sk; | ||
1481 | BUG_ON(sock_owned_by_user(sk)); | ||
1482 | sock_lock_init_class_and_name(sk, "slock-AF_INET6-CIFS", | ||
1483 | &cifs_slock_key[1], "sk_lock-AF_INET6-CIFS", &cifs_key[1]); | ||
1484 | } | ||
1485 | #else | ||
1486 | static inline void | ||
1487 | cifs_reclassify_socket4(struct socket *sock) | ||
1488 | { | ||
1489 | } | ||
1490 | |||
1491 | static inline void | ||
1492 | cifs_reclassify_socket6(struct socket *sock) | ||
1493 | { | ||
1494 | } | ||
1495 | #endif | ||
1496 | |||
1464 | /* See RFC1001 section 14 on representation of Netbios names */ | 1497 | /* See RFC1001 section 14 on representation of Netbios names */ |
1465 | static void rfc1002mangle(char *target, char *source, unsigned int length) | 1498 | static void rfc1002mangle(char *target, char *source, unsigned int length) |
1466 | { | 1499 | { |
@@ -1495,6 +1528,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1495 | /* BB other socket options to set KEEPALIVE, NODELAY? */ | 1528 | /* BB other socket options to set KEEPALIVE, NODELAY? */ |
1496 | cFYI(1, ("Socket created")); | 1529 | cFYI(1, ("Socket created")); |
1497 | (*csocket)->sk->sk_allocation = GFP_NOFS; | 1530 | (*csocket)->sk->sk_allocation = GFP_NOFS; |
1531 | cifs_reclassify_socket4(*csocket); | ||
1498 | } | 1532 | } |
1499 | } | 1533 | } |
1500 | 1534 | ||
@@ -1627,6 +1661,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1627 | /* BB other socket options to set KEEPALIVE, NODELAY? */ | 1661 | /* BB other socket options to set KEEPALIVE, NODELAY? */ |
1628 | cFYI(1, ("ipv6 Socket created")); | 1662 | cFYI(1, ("ipv6 Socket created")); |
1629 | (*csocket)->sk->sk_allocation = GFP_NOFS; | 1663 | (*csocket)->sk->sk_allocation = GFP_NOFS; |
1664 | cifs_reclassify_socket6(*csocket); | ||
1630 | } | 1665 | } |
1631 | } | 1666 | } |
1632 | 1667 | ||
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 2e904bd111c8..46e54d39461d 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -1413,6 +1413,82 @@ out_busy: | |||
1413 | return -ETXTBSY; | 1413 | return -ETXTBSY; |
1414 | } | 1414 | } |
1415 | 1415 | ||
1416 | static int | ||
1417 | cifs_set_file_size(struct inode *inode, struct iattr *attrs, | ||
1418 | int xid, char *full_path) | ||
1419 | { | ||
1420 | int rc; | ||
1421 | struct cifsFileInfo *open_file; | ||
1422 | struct cifsInodeInfo *cifsInode = CIFS_I(inode); | ||
1423 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); | ||
1424 | struct cifsTconInfo *pTcon = cifs_sb->tcon; | ||
1425 | |||
1426 | /* | ||
1427 | * To avoid spurious oplock breaks from server, in the case of | ||
1428 | * inodes that we already have open, avoid doing path based | ||
1429 | * setting of file size if we can do it by handle. | ||
1430 | * This keeps our caching token (oplock) and avoids timeouts | ||
1431 | * when the local oplock break takes longer to flush | ||
1432 | * writebehind data than the SMB timeout for the SetPathInfo | ||
1433 | * request would allow | ||
1434 | */ | ||
1435 | open_file = find_writable_file(cifsInode); | ||
1436 | if (open_file) { | ||
1437 | __u16 nfid = open_file->netfid; | ||
1438 | __u32 npid = open_file->pid; | ||
1439 | rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, nfid, | ||
1440 | npid, false); | ||
1441 | atomic_dec(&open_file->wrtPending); | ||
1442 | cFYI(1, ("SetFSize for attrs rc = %d", rc)); | ||
1443 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | ||
1444 | unsigned int bytes_written; | ||
1445 | rc = CIFSSMBWrite(xid, pTcon, nfid, 0, attrs->ia_size, | ||
1446 | &bytes_written, NULL, NULL, 1); | ||
1447 | cFYI(1, ("Wrt seteof rc %d", rc)); | ||
1448 | } | ||
1449 | } else | ||
1450 | rc = -EINVAL; | ||
1451 | |||
1452 | if (rc != 0) { | ||
1453 | /* Set file size by pathname rather than by handle | ||
1454 | either because no valid, writeable file handle for | ||
1455 | it was found or because there was an error setting | ||
1456 | it by handle */ | ||
1457 | rc = CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, | ||
1458 | false, cifs_sb->local_nls, | ||
1459 | cifs_sb->mnt_cifs_flags & | ||
1460 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
1461 | cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); | ||
1462 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | ||
1463 | __u16 netfid; | ||
1464 | int oplock = 0; | ||
1465 | |||
1466 | rc = SMBLegacyOpen(xid, pTcon, full_path, | ||
1467 | FILE_OPEN, GENERIC_WRITE, | ||
1468 | CREATE_NOT_DIR, &netfid, &oplock, NULL, | ||
1469 | cifs_sb->local_nls, | ||
1470 | cifs_sb->mnt_cifs_flags & | ||
1471 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
1472 | if (rc == 0) { | ||
1473 | unsigned int bytes_written; | ||
1474 | rc = CIFSSMBWrite(xid, pTcon, netfid, 0, | ||
1475 | attrs->ia_size, | ||
1476 | &bytes_written, NULL, | ||
1477 | NULL, 1); | ||
1478 | cFYI(1, ("wrt seteof rc %d", rc)); | ||
1479 | CIFSSMBClose(xid, pTcon, netfid); | ||
1480 | } | ||
1481 | } | ||
1482 | } | ||
1483 | |||
1484 | if (rc == 0) { | ||
1485 | rc = cifs_vmtruncate(inode, attrs->ia_size); | ||
1486 | cifs_truncate_page(inode->i_mapping, inode->i_size); | ||
1487 | } | ||
1488 | |||
1489 | return rc; | ||
1490 | } | ||
1491 | |||
1416 | int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | 1492 | int cifs_setattr(struct dentry *direntry, struct iattr *attrs) |
1417 | { | 1493 | { |
1418 | int xid; | 1494 | int xid; |
@@ -1420,7 +1496,6 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1420 | struct cifsTconInfo *pTcon; | 1496 | struct cifsTconInfo *pTcon; |
1421 | char *full_path = NULL; | 1497 | char *full_path = NULL; |
1422 | int rc = -EACCES; | 1498 | int rc = -EACCES; |
1423 | struct cifsFileInfo *open_file = NULL; | ||
1424 | FILE_BASIC_INFO time_buf; | 1499 | FILE_BASIC_INFO time_buf; |
1425 | bool set_time = false; | 1500 | bool set_time = false; |
1426 | bool set_dosattr = false; | 1501 | bool set_dosattr = false; |
@@ -1472,78 +1547,8 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1472 | } | 1547 | } |
1473 | 1548 | ||
1474 | if (attrs->ia_valid & ATTR_SIZE) { | 1549 | if (attrs->ia_valid & ATTR_SIZE) { |
1475 | /* To avoid spurious oplock breaks from server, in the case of | 1550 | rc = cifs_set_file_size(inode, attrs, xid, full_path); |
1476 | inodes that we already have open, avoid doing path based | 1551 | if (rc != 0) |
1477 | setting of file size if we can do it by handle. | ||
1478 | This keeps our caching token (oplock) and avoids timeouts | ||
1479 | when the local oplock break takes longer to flush | ||
1480 | writebehind data than the SMB timeout for the SetPathInfo | ||
1481 | request would allow */ | ||
1482 | |||
1483 | open_file = find_writable_file(cifsInode); | ||
1484 | if (open_file) { | ||
1485 | __u16 nfid = open_file->netfid; | ||
1486 | __u32 npid = open_file->pid; | ||
1487 | rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, | ||
1488 | nfid, npid, false); | ||
1489 | atomic_dec(&open_file->wrtPending); | ||
1490 | cFYI(1, ("SetFSize for attrs rc = %d", rc)); | ||
1491 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | ||
1492 | unsigned int bytes_written; | ||
1493 | rc = CIFSSMBWrite(xid, pTcon, | ||
1494 | nfid, 0, attrs->ia_size, | ||
1495 | &bytes_written, NULL, NULL, | ||
1496 | 1 /* 45 seconds */); | ||
1497 | cFYI(1, ("Wrt seteof rc %d", rc)); | ||
1498 | } | ||
1499 | } else | ||
1500 | rc = -EINVAL; | ||
1501 | |||
1502 | if (rc != 0) { | ||
1503 | /* Set file size by pathname rather than by handle | ||
1504 | either because no valid, writeable file handle for | ||
1505 | it was found or because there was an error setting | ||
1506 | it by handle */ | ||
1507 | rc = CIFSSMBSetEOF(xid, pTcon, full_path, | ||
1508 | attrs->ia_size, false, | ||
1509 | cifs_sb->local_nls, | ||
1510 | cifs_sb->mnt_cifs_flags & | ||
1511 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
1512 | cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); | ||
1513 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | ||
1514 | __u16 netfid; | ||
1515 | int oplock = 0; | ||
1516 | |||
1517 | rc = SMBLegacyOpen(xid, pTcon, full_path, | ||
1518 | FILE_OPEN, GENERIC_WRITE, | ||
1519 | CREATE_NOT_DIR, &netfid, &oplock, | ||
1520 | NULL, cifs_sb->local_nls, | ||
1521 | cifs_sb->mnt_cifs_flags & | ||
1522 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
1523 | if (rc == 0) { | ||
1524 | unsigned int bytes_written; | ||
1525 | rc = CIFSSMBWrite(xid, pTcon, | ||
1526 | netfid, 0, | ||
1527 | attrs->ia_size, | ||
1528 | &bytes_written, NULL, | ||
1529 | NULL, 1 /* 45 sec */); | ||
1530 | cFYI(1, ("wrt seteof rc %d", rc)); | ||
1531 | CIFSSMBClose(xid, pTcon, netfid); | ||
1532 | } | ||
1533 | |||
1534 | } | ||
1535 | } | ||
1536 | |||
1537 | /* Server is ok setting allocation size implicitly - no need | ||
1538 | to call: | ||
1539 | CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, true, | ||
1540 | cifs_sb->local_nls); | ||
1541 | */ | ||
1542 | |||
1543 | if (rc == 0) { | ||
1544 | rc = cifs_vmtruncate(inode, attrs->ia_size); | ||
1545 | cifs_truncate_page(inode->i_mapping, inode->i_size); | ||
1546 | } else | ||
1547 | goto cifs_setattr_exit; | 1552 | goto cifs_setattr_exit; |
1548 | } | 1553 | } |
1549 | 1554 | ||
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 83f306954883..5f40ed3473f5 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c | |||
@@ -690,6 +690,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, | |||
690 | else | 690 | else |
691 | cifs_buf_release(cifsFile->srch_inf. | 691 | cifs_buf_release(cifsFile->srch_inf. |
692 | ntwrk_buf_start); | 692 | ntwrk_buf_start); |
693 | cifsFile->srch_inf.ntwrk_buf_start = NULL; | ||
693 | } | 694 | } |
694 | rc = initiate_cifs_search(xid, file); | 695 | rc = initiate_cifs_search(xid, file); |
695 | if (rc) { | 696 | if (rc) { |