diff options
-rw-r--r-- | fs/cifs/connect.c | 398 | ||||
-rw-r--r-- | fs/cifs/dir.c | 8 | ||||
-rw-r--r-- | fs/cifs/export.c | 24 | ||||
-rw-r--r-- | fs/cifs/fcntl.c | 2 | ||||
-rw-r--r-- | fs/cifs/file.c | 245 | ||||
-rw-r--r-- | fs/cifs/inode.c | 259 | ||||
-rw-r--r-- | fs/cifs/ioctl.c | 4 | ||||
-rw-r--r-- | fs/cifs/link.c | 97 | ||||
-rw-r--r-- | fs/cifs/md4.c | 4 | ||||
-rw-r--r-- | fs/cifs/md5.c | 8 | ||||
-rw-r--r-- | fs/cifs/misc.c | 150 | ||||
-rw-r--r-- | fs/cifs/netmisc.c | 2 |
12 files changed, 610 insertions, 591 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 9b95d4637fcc..ef10c3717fb5 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -16,7 +16,7 @@ | |||
16 | * | 16 | * |
17 | * You should have received a copy of the GNU Lesser General Public License | 17 | * You should have received a copy of the GNU Lesser General Public License |
18 | * along with this library; if not, write to the Free Software | 18 | * along with this library; 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> |
22 | #include <linux/net.h> | 22 | #include <linux/net.h> |
@@ -93,20 +93,20 @@ struct smb_vol { | |||
93 | unsigned int wsize; | 93 | unsigned int wsize; |
94 | unsigned int sockopt; | 94 | unsigned int sockopt; |
95 | unsigned short int port; | 95 | unsigned short int port; |
96 | char * prepath; | 96 | char *prepath; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | static int ipv4_connect(struct sockaddr_in *psin_server, | 99 | static int ipv4_connect(struct sockaddr_in *psin_server, |
100 | struct socket **csocket, | 100 | struct socket **csocket, |
101 | char * netb_name, | 101 | char *netb_name, |
102 | char * server_netb_name); | 102 | char *server_netb_name); |
103 | static int ipv6_connect(struct sockaddr_in6 *psin_server, | 103 | static int ipv6_connect(struct sockaddr_in6 *psin_server, |
104 | struct socket **csocket); | 104 | struct socket **csocket); |
105 | 105 | ||
106 | 106 | ||
107 | /* | 107 | /* |
108 | * cifs tcp session reconnection | 108 | * cifs tcp session reconnection |
109 | * | 109 | * |
110 | * mark tcp session as reconnecting so temporarily locked | 110 | * mark tcp session as reconnecting so temporarily locked |
111 | * mark all smb sessions as reconnecting for tcp session | 111 | * mark all smb sessions as reconnecting for tcp session |
112 | * reconnect tcp session | 112 | * reconnect tcp session |
@@ -120,11 +120,11 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
120 | struct list_head *tmp; | 120 | struct list_head *tmp; |
121 | struct cifsSesInfo *ses; | 121 | struct cifsSesInfo *ses; |
122 | struct cifsTconInfo *tcon; | 122 | struct cifsTconInfo *tcon; |
123 | struct mid_q_entry * mid_entry; | 123 | struct mid_q_entry *mid_entry; |
124 | 124 | ||
125 | spin_lock(&GlobalMid_Lock); | 125 | spin_lock(&GlobalMid_Lock); |
126 | if( kthread_should_stop() ) { | 126 | if ( kthread_should_stop() ) { |
127 | /* the demux thread will exit normally | 127 | /* the demux thread will exit normally |
128 | next time through the loop */ | 128 | next time through the loop */ |
129 | spin_unlock(&GlobalMid_Lock); | 129 | spin_unlock(&GlobalMid_Lock); |
130 | return rc; | 130 | return rc; |
@@ -150,18 +150,18 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
150 | } | 150 | } |
151 | list_for_each(tmp, &GlobalTreeConnectionList) { | 151 | list_for_each(tmp, &GlobalTreeConnectionList) { |
152 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 152 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
153 | if((tcon) && (tcon->ses) && (tcon->ses->server == server)) { | 153 | if ((tcon) && (tcon->ses) && (tcon->ses->server == server)) { |
154 | tcon->tidStatus = CifsNeedReconnect; | 154 | tcon->tidStatus = CifsNeedReconnect; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | read_unlock(&GlobalSMBSeslock); | 157 | read_unlock(&GlobalSMBSeslock); |
158 | /* do not want to be sending data on a socket we are freeing */ | 158 | /* do not want to be sending data on a socket we are freeing */ |
159 | down(&server->tcpSem); | 159 | down(&server->tcpSem); |
160 | if(server->ssocket) { | 160 | if (server->ssocket) { |
161 | cFYI(1, ("State: 0x%x Flags: 0x%lx", server->ssocket->state, | 161 | cFYI(1, ("State: 0x%x Flags: 0x%lx", server->ssocket->state, |
162 | server->ssocket->flags)); | 162 | server->ssocket->flags)); |
163 | server->ssocket->ops->shutdown(server->ssocket,SEND_SHUTDOWN); | 163 | server->ssocket->ops->shutdown(server->ssocket, SEND_SHUTDOWN); |
164 | cFYI(1, ("Post shutdown state: 0x%x Flags: 0x%lx", | 164 | cFYI(1, ("Post shutdown state: 0x%x Flags: 0x%lx", |
165 | server->ssocket->state, | 165 | server->ssocket->state, |
166 | server->ssocket->flags)); | 166 | server->ssocket->flags)); |
167 | sock_release(server->ssocket); | 167 | sock_release(server->ssocket); |
@@ -173,8 +173,8 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
173 | mid_entry = list_entry(tmp, struct | 173 | mid_entry = list_entry(tmp, struct |
174 | mid_q_entry, | 174 | mid_q_entry, |
175 | qhead); | 175 | qhead); |
176 | if(mid_entry) { | 176 | if (mid_entry) { |
177 | if(mid_entry->midState == MID_REQUEST_SUBMITTED) { | 177 | if (mid_entry->midState == MID_REQUEST_SUBMITTED) { |
178 | /* Mark other intransit requests as needing | 178 | /* Mark other intransit requests as needing |
179 | retry so we do not immediately mark the | 179 | retry so we do not immediately mark the |
180 | session bad again (ie after we reconnect | 180 | session bad again (ie after we reconnect |
@@ -184,29 +184,29 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
184 | } | 184 | } |
185 | } | 185 | } |
186 | spin_unlock(&GlobalMid_Lock); | 186 | spin_unlock(&GlobalMid_Lock); |
187 | up(&server->tcpSem); | 187 | up(&server->tcpSem); |
188 | 188 | ||
189 | while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood)) | 189 | while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood)) { |
190 | { | ||
191 | try_to_freeze(); | 190 | try_to_freeze(); |
192 | if(server->protocolType == IPV6) { | 191 | if (server->protocolType == IPV6) { |
193 | rc = ipv6_connect(&server->addr.sockAddr6,&server->ssocket); | 192 | rc = ipv6_connect(&server->addr.sockAddr6, |
193 | &server->ssocket); | ||
194 | } else { | 194 | } else { |
195 | rc = ipv4_connect(&server->addr.sockAddr, | 195 | rc = ipv4_connect(&server->addr.sockAddr, |
196 | &server->ssocket, | 196 | &server->ssocket, |
197 | server->workstation_RFC1001_name, | 197 | server->workstation_RFC1001_name, |
198 | server->server_RFC1001_name); | 198 | server->server_RFC1001_name); |
199 | } | 199 | } |
200 | if(rc) { | 200 | if (rc) { |
201 | cFYI(1, ("reconnect error %d",rc)); | 201 | cFYI(1, ("reconnect error %d", rc)); |
202 | msleep(3000); | 202 | msleep(3000); |
203 | } else { | 203 | } else { |
204 | atomic_inc(&tcpSesReconnectCount); | 204 | atomic_inc(&tcpSesReconnectCount); |
205 | spin_lock(&GlobalMid_Lock); | 205 | spin_lock(&GlobalMid_Lock); |
206 | if( !kthread_should_stop() ) | 206 | if ( !kthread_should_stop() ) |
207 | server->tcpStatus = CifsGood; | 207 | server->tcpStatus = CifsGood; |
208 | server->sequence_number = 0; | 208 | server->sequence_number = 0; |
209 | spin_unlock(&GlobalMid_Lock); | 209 | spin_unlock(&GlobalMid_Lock); |
210 | /* atomic_set(&server->inFlight,0);*/ | 210 | /* atomic_set(&server->inFlight,0);*/ |
211 | wake_up(&server->response_q); | 211 | wake_up(&server->response_q); |
212 | } | 212 | } |
@@ -214,26 +214,26 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
214 | return rc; | 214 | return rc; |
215 | } | 215 | } |
216 | 216 | ||
217 | /* | 217 | /* |
218 | return codes: | 218 | return codes: |
219 | 0 not a transact2, or all data present | 219 | 0 not a transact2, or all data present |
220 | >0 transact2 with that much data missing | 220 | >0 transact2 with that much data missing |
221 | -EINVAL = invalid transact2 | 221 | -EINVAL = invalid transact2 |
222 | 222 | ||
223 | */ | 223 | */ |
224 | static int check2ndT2(struct smb_hdr * pSMB, unsigned int maxBufSize) | 224 | static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize) |
225 | { | 225 | { |
226 | struct smb_t2_rsp * pSMBt; | 226 | struct smb_t2_rsp *pSMBt; |
227 | int total_data_size; | 227 | int total_data_size; |
228 | int data_in_this_rsp; | 228 | int data_in_this_rsp; |
229 | int remaining; | 229 | int remaining; |
230 | 230 | ||
231 | if(pSMB->Command != SMB_COM_TRANSACTION2) | 231 | if (pSMB->Command != SMB_COM_TRANSACTION2) |
232 | return 0; | 232 | return 0; |
233 | 233 | ||
234 | /* check for plausible wct, bcc and t2 data and parm sizes */ | 234 | /* check for plausible wct, bcc and t2 data and parm sizes */ |
235 | /* check for parm and data offset going beyond end of smb */ | 235 | /* check for parm and data offset going beyond end of smb */ |
236 | if(pSMB->WordCount != 10) { /* coalesce_t2 depends on this */ | 236 | if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */ |
237 | cFYI(1, ("invalid transact2 word count")); | 237 | cFYI(1, ("invalid transact2 word count")); |
238 | return -EINVAL; | 238 | return -EINVAL; |
239 | } | 239 | } |
@@ -245,25 +245,25 @@ static int check2ndT2(struct smb_hdr * pSMB, unsigned int maxBufSize) | |||
245 | 245 | ||
246 | remaining = total_data_size - data_in_this_rsp; | 246 | remaining = total_data_size - data_in_this_rsp; |
247 | 247 | ||
248 | if(remaining == 0) | 248 | if (remaining == 0) |
249 | return 0; | 249 | return 0; |
250 | else if(remaining < 0) { | 250 | else if (remaining < 0) { |
251 | cFYI(1, ("total data %d smaller than data in frame %d", | 251 | cFYI(1, ("total data %d smaller than data in frame %d", |
252 | total_data_size, data_in_this_rsp)); | 252 | total_data_size, data_in_this_rsp)); |
253 | return -EINVAL; | 253 | return -EINVAL; |
254 | } else { | 254 | } else { |
255 | cFYI(1, ("missing %d bytes from transact2, check next response", | 255 | cFYI(1, ("missing %d bytes from transact2, check next response", |
256 | remaining)); | 256 | remaining)); |
257 | if(total_data_size > maxBufSize) { | 257 | if (total_data_size > maxBufSize) { |
258 | cERROR(1,("TotalDataSize %d is over maximum buffer %d", | 258 | cERROR(1, ("TotalDataSize %d is over maximum buffer %d", |
259 | total_data_size,maxBufSize)); | 259 | total_data_size, maxBufSize)); |
260 | return -EINVAL; | 260 | return -EINVAL; |
261 | } | 261 | } |
262 | return remaining; | 262 | return remaining; |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) | 266 | static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) |
267 | { | 267 | { |
268 | struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; | 268 | struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; |
269 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; | 269 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; |
@@ -271,43 +271,43 @@ static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) | |||
271 | int total_in_buf; | 271 | int total_in_buf; |
272 | int remaining; | 272 | int remaining; |
273 | int total_in_buf2; | 273 | int total_in_buf2; |
274 | char * data_area_of_target; | 274 | char *data_area_of_target; |
275 | char * data_area_of_buf2; | 275 | char *data_area_of_buf2; |
276 | __u16 byte_count; | 276 | __u16 byte_count; |
277 | 277 | ||
278 | total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); | 278 | total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); |
279 | 279 | ||
280 | if(total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) { | 280 | if (total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) { |
281 | cFYI(1,("total data sizes of primary and secondary t2 differ")); | 281 | cFYI(1, ("total data sizes of primary and secondary t2 differ")); |
282 | } | 282 | } |
283 | 283 | ||
284 | total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); | 284 | total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); |
285 | 285 | ||
286 | remaining = total_data_size - total_in_buf; | 286 | remaining = total_data_size - total_in_buf; |
287 | 287 | ||
288 | if(remaining < 0) | 288 | if (remaining < 0) |
289 | return -EINVAL; | 289 | return -EINVAL; |
290 | 290 | ||
291 | if(remaining == 0) /* nothing to do, ignore */ | 291 | if (remaining == 0) /* nothing to do, ignore */ |
292 | return 0; | 292 | return 0; |
293 | 293 | ||
294 | total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); | 294 | total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); |
295 | if(remaining < total_in_buf2) { | 295 | if (remaining < total_in_buf2) { |
296 | cFYI(1, ("transact2 2nd response contains too much data")); | 296 | cFYI(1, ("transact2 2nd response contains too much data")); |
297 | } | 297 | } |
298 | 298 | ||
299 | /* find end of first SMB data area */ | 299 | /* find end of first SMB data area */ |
300 | data_area_of_target = (char *)&pSMBt->hdr.Protocol + | 300 | data_area_of_target = (char *)&pSMBt->hdr.Protocol + |
301 | le16_to_cpu(pSMBt->t2_rsp.DataOffset); | 301 | le16_to_cpu(pSMBt->t2_rsp.DataOffset); |
302 | /* validate target area */ | 302 | /* validate target area */ |
303 | 303 | ||
304 | data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol + | 304 | data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol + |
305 | le16_to_cpu(pSMB2->t2_rsp.DataOffset); | 305 | le16_to_cpu(pSMB2->t2_rsp.DataOffset); |
306 | 306 | ||
307 | data_area_of_target += total_in_buf; | 307 | data_area_of_target += total_in_buf; |
308 | 308 | ||
309 | /* copy second buffer into end of first buffer */ | 309 | /* copy second buffer into end of first buffer */ |
310 | memcpy(data_area_of_target,data_area_of_buf2,total_in_buf2); | 310 | memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); |
311 | total_in_buf += total_in_buf2; | 311 | total_in_buf += total_in_buf2; |
312 | pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf); | 312 | pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf); |
313 | byte_count = le16_to_cpu(BCC_LE(pTargetSMB)); | 313 | byte_count = le16_to_cpu(BCC_LE(pTargetSMB)); |
@@ -321,7 +321,7 @@ static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB) | |||
321 | 321 | ||
322 | pTargetSMB->smb_buf_length = byte_count; | 322 | pTargetSMB->smb_buf_length = byte_count; |
323 | 323 | ||
324 | if(remaining == total_in_buf2) { | 324 | if (remaining == total_in_buf2) { |
325 | cFYI(1, ("found the last secondary response")); | 325 | cFYI(1, ("found the last secondary response")); |
326 | return 0; /* we are done */ | 326 | return 0; /* we are done */ |
327 | } else /* more responses to go */ | 327 | } else /* more responses to go */ |
@@ -352,12 +352,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
352 | current->flags |= PF_MEMALLOC; | 352 | current->flags |= PF_MEMALLOC; |
353 | server->tsk = current; /* save process info to wake at shutdown */ | 353 | server->tsk = current; /* save process info to wake at shutdown */ |
354 | cFYI(1, ("Demultiplex PID: %d", current->pid)); | 354 | cFYI(1, ("Demultiplex PID: %d", current->pid)); |
355 | write_lock(&GlobalSMBSeslock); | 355 | write_lock(&GlobalSMBSeslock); |
356 | atomic_inc(&tcpSesAllocCount); | 356 | atomic_inc(&tcpSesAllocCount); |
357 | length = tcpSesAllocCount.counter; | 357 | length = tcpSesAllocCount.counter; |
358 | write_unlock(&GlobalSMBSeslock); | 358 | write_unlock(&GlobalSMBSeslock); |
359 | complete(&cifsd_complete); | 359 | complete(&cifsd_complete); |
360 | if(length > 1) { | 360 | if (length > 1) { |
361 | mempool_resize(cifs_req_poolp, | 361 | mempool_resize(cifs_req_poolp, |
362 | length + cifs_min_rcv, | 362 | length + cifs_min_rcv, |
363 | GFP_KERNEL); | 363 | GFP_KERNEL); |
@@ -452,7 +452,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
452 | with the most common, zero, as regular data */ | 452 | with the most common, zero, as regular data */ |
453 | temp = *((char *) smb_buffer); | 453 | temp = *((char *) smb_buffer); |
454 | 454 | ||
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 = ntohl(smb_buffer->smb_buf_length); |
@@ -461,17 +461,17 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
461 | cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); | 461 | cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); |
462 | 462 | ||
463 | if (temp == (char) RFC1002_SESSION_KEEP_ALIVE) { | 463 | if (temp == (char) RFC1002_SESSION_KEEP_ALIVE) { |
464 | continue; | 464 | continue; |
465 | } else if (temp == (char)RFC1002_POSITIVE_SESSION_RESPONSE) { | 465 | } else if (temp == (char)RFC1002_POSITIVE_SESSION_RESPONSE) { |
466 | cFYI(1, ("Good RFC 1002 session rsp")); | 466 | cFYI(1, ("Good RFC 1002 session rsp")); |
467 | continue; | 467 | continue; |
468 | } else if (temp == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) { | 468 | } else if (temp == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) { |
469 | /* we get this from Windows 98 instead of | 469 | /* we get this from Windows 98 instead of |
470 | an error on SMB negprot response */ | 470 | an error on SMB negprot response */ |
471 | cFYI(1,("Negative RFC1002 Session Response Error 0x%x)", | 471 | cFYI(1, ("Negative RFC1002 Session Response Error 0x%x)", |
472 | pdu_length)); | 472 | pdu_length)); |
473 | if(server->tcpStatus == CifsNew) { | 473 | if (server->tcpStatus == CifsNew) { |
474 | /* if nack on negprot (rather than | 474 | /* if nack on negprot (rather than |
475 | ret of smb negprot error) reconnecting | 475 | ret of smb negprot error) reconnecting |
476 | not going to help, ret error to mount */ | 476 | not going to help, ret error to mount */ |
477 | break; | 477 | break; |
@@ -481,10 +481,10 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
481 | msleep(1000); | 481 | msleep(1000); |
482 | /* always try 445 first on reconnect | 482 | /* always try 445 first on reconnect |
483 | since we get NACK on some if we ever | 483 | since we get NACK on some if we ever |
484 | connected to port 139 (the NACK is | 484 | connected to port 139 (the NACK is |
485 | since we do not begin with RFC1001 | 485 | since we do not begin with RFC1001 |
486 | session initialize frame) */ | 486 | session initialize frame) */ |
487 | server->addr.sockAddr.sin_port = | 487 | server->addr.sockAddr.sin_port = |
488 | htons(CIFS_PORT); | 488 | htons(CIFS_PORT); |
489 | cifs_reconnect(server); | 489 | cifs_reconnect(server); |
490 | csocket = server->ssocket; | 490 | csocket = server->ssocket; |
@@ -492,7 +492,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
492 | continue; | 492 | continue; |
493 | } | 493 | } |
494 | } else if (temp != (char) 0) { | 494 | } else if (temp != (char) 0) { |
495 | cERROR(1,("Unknown RFC 1002 frame")); | 495 | cERROR(1, ("Unknown RFC 1002 frame")); |
496 | cifs_dump_mem(" Received Data: ", (char *)smb_buffer, | 496 | cifs_dump_mem(" Received Data: ", (char *)smb_buffer, |
497 | length); | 497 | length); |
498 | cifs_reconnect(server); | 498 | cifs_reconnect(server); |
@@ -501,7 +501,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
501 | } | 501 | } |
502 | 502 | ||
503 | /* else we have an SMB response */ | 503 | /* else we have an SMB response */ |
504 | if((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) || | 504 | if ((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) || |
505 | (pdu_length < sizeof (struct smb_hdr) - 1 - 4)) { | 505 | (pdu_length < sizeof (struct smb_hdr) - 1 - 4)) { |
506 | cERROR(1, ("Invalid size SMB length %d pdu_length %d", | 506 | cERROR(1, ("Invalid size SMB length %d pdu_length %d", |
507 | length, pdu_length+4)); | 507 | length, pdu_length+4)); |
@@ -509,12 +509,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
509 | csocket = server->ssocket; | 509 | csocket = server->ssocket; |
510 | wake_up(&server->response_q); | 510 | wake_up(&server->response_q); |
511 | continue; | 511 | continue; |
512 | } | 512 | } |
513 | 513 | ||
514 | /* else length ok */ | 514 | /* else length ok */ |
515 | reconnect = 0; | 515 | reconnect = 0; |
516 | 516 | ||
517 | if(pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { | 517 | if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { |
518 | isLargeBuf = TRUE; | 518 | isLargeBuf = TRUE; |
519 | memcpy(bigbuf, smallbuf, 4); | 519 | memcpy(bigbuf, smallbuf, 4); |
520 | smb_buffer = bigbuf; | 520 | smb_buffer = bigbuf; |
@@ -522,11 +522,11 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
522 | length = 0; | 522 | length = 0; |
523 | iov.iov_base = 4 + (char *)smb_buffer; | 523 | iov.iov_base = 4 + (char *)smb_buffer; |
524 | iov.iov_len = pdu_length; | 524 | iov.iov_len = pdu_length; |
525 | for (total_read = 0; total_read < pdu_length; | 525 | for (total_read = 0; total_read < pdu_length; |
526 | total_read += length) { | 526 | total_read += length) { |
527 | length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, | 527 | length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, |
528 | pdu_length - total_read, 0); | 528 | pdu_length - total_read, 0); |
529 | if( kthread_should_stop() || | 529 | if ( kthread_should_stop() || |
530 | (length == -EINTR)) { | 530 | (length == -EINTR)) { |
531 | /* then will exit */ | 531 | /* then will exit */ |
532 | reconnect = 2; | 532 | reconnect = 2; |
@@ -534,19 +534,19 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
534 | } else if (server->tcpStatus == CifsNeedReconnect) { | 534 | } else if (server->tcpStatus == CifsNeedReconnect) { |
535 | cifs_reconnect(server); | 535 | cifs_reconnect(server); |
536 | csocket = server->ssocket; | 536 | csocket = server->ssocket; |
537 | /* Reconnect wakes up rspns q */ | 537 | /* Reconnect wakes up rspns q */ |
538 | /* Now we will reread sock */ | 538 | /* Now we will reread sock */ |
539 | reconnect = 1; | 539 | reconnect = 1; |
540 | break; | 540 | break; |
541 | } else if ((length == -ERESTARTSYS) || | 541 | } else if ((length == -ERESTARTSYS) || |
542 | (length == -EAGAIN)) { | 542 | (length == -EAGAIN)) { |
543 | msleep(1); /* minimum sleep to prevent looping, | 543 | msleep(1); /* minimum sleep to prevent looping, |
544 | allowing socket to clear and app | 544 | allowing socket to clear and app |
545 | threads to set tcpStatus | 545 | threads to set tcpStatus |
546 | CifsNeedReconnect if server hung*/ | 546 | CifsNeedReconnect if server hung*/ |
547 | continue; | 547 | continue; |
548 | } else if (length <= 0) { | 548 | } else if (length <= 0) { |
549 | cERROR(1,("Received no data, expecting %d", | 549 | cERROR(1, ("Received no data, expecting %d", |
550 | pdu_length - total_read)); | 550 | pdu_length - total_read)); |
551 | cifs_reconnect(server); | 551 | cifs_reconnect(server); |
552 | csocket = server->ssocket; | 552 | csocket = server->ssocket; |
@@ -554,9 +554,9 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
554 | break; | 554 | break; |
555 | } | 555 | } |
556 | } | 556 | } |
557 | if(reconnect == 2) | 557 | if (reconnect == 2) |
558 | break; | 558 | break; |
559 | else if(reconnect == 1) | 559 | else if (reconnect == 1) |
560 | continue; | 560 | continue; |
561 | 561 | ||
562 | length += 4; /* account for rfc1002 hdr */ | 562 | length += 4; /* account for rfc1002 hdr */ |
@@ -577,12 +577,12 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
577 | if ((mid_entry->mid == smb_buffer->Mid) && | 577 | if ((mid_entry->mid == smb_buffer->Mid) && |
578 | (mid_entry->midState == MID_REQUEST_SUBMITTED) && | 578 | (mid_entry->midState == MID_REQUEST_SUBMITTED) && |
579 | (mid_entry->command == smb_buffer->Command)) { | 579 | (mid_entry->command == smb_buffer->Command)) { |
580 | if(check2ndT2(smb_buffer,server->maxBuf) > 0) { | 580 | if (check2ndT2(smb_buffer,server->maxBuf) > 0) { |
581 | /* We have a multipart transact2 resp */ | 581 | /* We have a multipart transact2 resp */ |
582 | isMultiRsp = TRUE; | 582 | isMultiRsp = TRUE; |
583 | if(mid_entry->resp_buf) { | 583 | if (mid_entry->resp_buf) { |
584 | /* merge response - fix up 1st*/ | 584 | /* merge response - fix up 1st*/ |
585 | if(coalesce_t2(smb_buffer, | 585 | if (coalesce_t2(smb_buffer, |
586 | mid_entry->resp_buf)) { | 586 | mid_entry->resp_buf)) { |
587 | mid_entry->multiRsp = 1; | 587 | mid_entry->multiRsp = 1; |
588 | break; | 588 | break; |
@@ -592,7 +592,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
592 | goto multi_t2_fnd; | 592 | goto multi_t2_fnd; |
593 | } | 593 | } |
594 | } else { | 594 | } else { |
595 | if(!isLargeBuf) { | 595 | if (!isLargeBuf) { |
596 | cERROR(1,("1st trans2 resp needs bigbuf")); | 596 | cERROR(1,("1st trans2 resp needs bigbuf")); |
597 | /* BB maybe we can fix this up, switch | 597 | /* BB maybe we can fix this up, switch |
598 | to already allocated large buffer? */ | 598 | to already allocated large buffer? */ |
@@ -607,7 +607,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
607 | break; | 607 | break; |
608 | } | 608 | } |
609 | mid_entry->resp_buf = smb_buffer; | 609 | mid_entry->resp_buf = smb_buffer; |
610 | if(isLargeBuf) | 610 | if (isLargeBuf) |
611 | mid_entry->largeBuf = 1; | 611 | mid_entry->largeBuf = 1; |
612 | else | 612 | else |
613 | mid_entry->largeBuf = 0; | 613 | mid_entry->largeBuf = 0; |
@@ -627,9 +627,9 @@ multi_t2_fnd: | |||
627 | spin_unlock(&GlobalMid_Lock); | 627 | spin_unlock(&GlobalMid_Lock); |
628 | if (task_to_wake) { | 628 | if (task_to_wake) { |
629 | /* Was previous buf put in mpx struct for multi-rsp? */ | 629 | /* Was previous buf put in mpx struct for multi-rsp? */ |
630 | if(!isMultiRsp) { | 630 | if (!isMultiRsp) { |
631 | /* smb buffer will be freed by user thread */ | 631 | /* smb buffer will be freed by user thread */ |
632 | if(isLargeBuf) { | 632 | if (isLargeBuf) { |
633 | bigbuf = NULL; | 633 | bigbuf = NULL; |
634 | } else | 634 | } else |
635 | smallbuf = NULL; | 635 | smallbuf = NULL; |
@@ -654,7 +654,7 @@ multi_t2_fnd: | |||
654 | /* check if we have blocked requests that need to free */ | 654 | /* check if we have blocked requests that need to free */ |
655 | /* Note that cifs_max_pending is normally 50, but | 655 | /* Note that cifs_max_pending is normally 50, but |
656 | can be set at module install time to as little as two */ | 656 | can be set at module install time to as little as two */ |
657 | if(atomic_read(&server->inFlight) >= cifs_max_pending) | 657 | if (atomic_read(&server->inFlight) >= cifs_max_pending) |
658 | atomic_set(&server->inFlight, cifs_max_pending - 1); | 658 | atomic_set(&server->inFlight, cifs_max_pending - 1); |
659 | /* We do not want to set the max_pending too low or we | 659 | /* We do not want to set the max_pending too low or we |
660 | could end up with the counter going negative */ | 660 | could end up with the counter going negative */ |
@@ -668,7 +668,7 @@ multi_t2_fnd: | |||
668 | /* give those requests time to exit */ | 668 | /* give those requests time to exit */ |
669 | msleep(125); | 669 | msleep(125); |
670 | 670 | ||
671 | if(server->ssocket) { | 671 | if (server->ssocket) { |
672 | sock_release(csocket); | 672 | sock_release(csocket); |
673 | server->ssocket = NULL; | 673 | server->ssocket = NULL; |
674 | } | 674 | } |
@@ -711,7 +711,7 @@ multi_t2_fnd: | |||
711 | cFYI(1, | 711 | cFYI(1, |
712 | ("Clearing Mid 0x%x - waking up ",mid_entry->mid)); | 712 | ("Clearing Mid 0x%x - waking up ",mid_entry->mid)); |
713 | task_to_wake = mid_entry->tsk; | 713 | task_to_wake = mid_entry->tsk; |
714 | if(task_to_wake) { | 714 | if (task_to_wake) { |
715 | wake_up_process(task_to_wake); | 715 | wake_up_process(task_to_wake); |
716 | } | 716 | } |
717 | } | 717 | } |
@@ -753,7 +753,7 @@ multi_t2_fnd: | |||
753 | write_unlock(&GlobalSMBSeslock); | 753 | write_unlock(&GlobalSMBSeslock); |
754 | 754 | ||
755 | kfree(server); | 755 | kfree(server); |
756 | if(length > 0) { | 756 | if (length > 0) { |
757 | mempool_resize(cifs_req_poolp, | 757 | mempool_resize(cifs_req_poolp, |
758 | length + cifs_min_rcv, | 758 | length + cifs_min_rcv, |
759 | GFP_KERNEL); | 759 | GFP_KERNEL); |
@@ -804,8 +804,8 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
804 | if (!options) | 804 | if (!options) |
805 | return 1; | 805 | return 1; |
806 | 806 | ||
807 | if(strncmp(options,"sep=",4) == 0) { | 807 | if (strncmp(options,"sep=",4) == 0) { |
808 | if(options[4] != 0) { | 808 | if (options[4] != 0) { |
809 | separator[0] = options[4]; | 809 | separator[0] = options[4]; |
810 | options += 5; | 810 | options += 5; |
811 | } else { | 811 | } else { |
@@ -828,7 +828,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
828 | printk(KERN_WARNING | 828 | printk(KERN_WARNING |
829 | "CIFS: invalid or missing username\n"); | 829 | "CIFS: invalid or missing username\n"); |
830 | return 1; /* needs_arg; */ | 830 | return 1; /* needs_arg; */ |
831 | } else if(!*value) { | 831 | } else if (!*value) { |
832 | /* null user, ie anonymous, authentication */ | 832 | /* null user, ie anonymous, authentication */ |
833 | vol->nullauth = 1; | 833 | vol->nullauth = 1; |
834 | } | 834 | } |
@@ -842,12 +842,12 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
842 | if (!value) { | 842 | if (!value) { |
843 | vol->password = NULL; | 843 | vol->password = NULL; |
844 | continue; | 844 | continue; |
845 | } else if(value[0] == 0) { | 845 | } else if (value[0] == 0) { |
846 | /* check if string begins with double comma | 846 | /* check if string begins with double comma |
847 | since that would mean the password really | 847 | since that would mean the password really |
848 | does start with a comma, and would not | 848 | does start with a comma, and would not |
849 | indicate an empty string */ | 849 | indicate an empty string */ |
850 | if(value[1] != separator[0]) { | 850 | if (value[1] != separator[0]) { |
851 | vol->password = NULL; | 851 | vol->password = NULL; |
852 | continue; | 852 | continue; |
853 | } | 853 | } |
@@ -885,7 +885,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
885 | } | 885 | } |
886 | temp_len++; | 886 | temp_len++; |
887 | } | 887 | } |
888 | if(value[temp_len] == 0) { | 888 | if (value[temp_len] == 0) { |
889 | options = NULL; | 889 | options = NULL; |
890 | } else { | 890 | } else { |
891 | value[temp_len] = 0; | 891 | value[temp_len] = 0; |
@@ -896,13 +896,13 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
896 | double commas to singles. Note that this ends up | 896 | double commas to singles. Note that this ends up |
897 | allocating a few bytes too many, which is ok */ | 897 | allocating a few bytes too many, which is ok */ |
898 | vol->password = kzalloc(temp_len, GFP_KERNEL); | 898 | vol->password = kzalloc(temp_len, GFP_KERNEL); |
899 | if(vol->password == NULL) { | 899 | if (vol->password == NULL) { |
900 | printk("CIFS: no memory for pass\n"); | 900 | printk("CIFS: no memory for pass\n"); |
901 | return 1; | 901 | return 1; |
902 | } | 902 | } |
903 | for(i=0,j=0;i<temp_len;i++,j++) { | 903 | for(i=0,j=0;i<temp_len;i++,j++) { |
904 | vol->password[j] = value[i]; | 904 | vol->password[j] = value[i]; |
905 | if(value[i] == separator[0] | 905 | if (value[i] == separator[0] |
906 | && value[i+1] == separator[0]) { | 906 | && value[i+1] == separator[0]) { |
907 | /* skip second comma */ | 907 | /* skip second comma */ |
908 | i++; | 908 | i++; |
@@ -911,7 +911,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
911 | vol->password[j] = 0; | 911 | vol->password[j] = 0; |
912 | } else { | 912 | } else { |
913 | vol->password = kzalloc(temp_len+1, GFP_KERNEL); | 913 | vol->password = kzalloc(temp_len+1, GFP_KERNEL); |
914 | if(vol->password == NULL) { | 914 | if (vol->password == NULL) { |
915 | printk("CIFS: no memory for pass\n"); | 915 | printk("CIFS: no memory for pass\n"); |
916 | return 1; | 916 | return 1; |
917 | } | 917 | } |
@@ -1089,7 +1089,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1089 | } | 1089 | } |
1090 | } else if (strnicmp(data, "netbiosname", 4) == 0) { | 1090 | } else if (strnicmp(data, "netbiosname", 4) == 0) { |
1091 | if (!value || !*value || (*value == ' ')) { | 1091 | if (!value || !*value || (*value == ' ')) { |
1092 | cFYI(1,("invalid (empty) netbiosname specified")); | 1092 | cFYI(1, ("invalid (empty) netbiosname specified")); |
1093 | } else { | 1093 | } else { |
1094 | memset(vol->source_rfc1001_name,0x20,15); | 1094 | memset(vol->source_rfc1001_name,0x20,15); |
1095 | for(i=0;i<15;i++) { | 1095 | for(i=0;i<15;i++) { |
@@ -1187,7 +1187,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1187 | /* turn off mandatory locking in mode | 1187 | /* turn off mandatory locking in mode |
1188 | if remote locking is turned off since the | 1188 | if remote locking is turned off since the |
1189 | local vfs will do advisory */ | 1189 | local vfs will do advisory */ |
1190 | if(vol->file_mode == (S_IALLUGO & ~(S_ISUID | S_IXGRP))) | 1190 | if (vol->file_mode == (S_IALLUGO & ~(S_ISUID | S_IXGRP))) |
1191 | vol->file_mode = S_IALLUGO; | 1191 | vol->file_mode = S_IALLUGO; |
1192 | } else if (strnicmp(data, "setuids", 7) == 0) { | 1192 | } else if (strnicmp(data, "setuids", 7) == 0) { |
1193 | vol->setuids = 1; | 1193 | vol->setuids = 1; |
@@ -1257,7 +1257,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1257 | return 1; | 1257 | return 1; |
1258 | } | 1258 | } |
1259 | } | 1259 | } |
1260 | if(vol->UNCip == NULL) | 1260 | if (vol->UNCip == NULL) |
1261 | vol->UNCip = &vol->UNC[2]; | 1261 | vol->UNCip = &vol->UNC[2]; |
1262 | 1262 | ||
1263 | return 0; | 1263 | return 0; |
@@ -1276,7 +1276,7 @@ cifs_find_tcp_session(struct in_addr * target_ip_addr, | |||
1276 | list_for_each(tmp, &GlobalSMBSessionList) { | 1276 | list_for_each(tmp, &GlobalSMBSessionList) { |
1277 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); | 1277 | ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); |
1278 | if (ses->server) { | 1278 | if (ses->server) { |
1279 | if((target_ip_addr && | 1279 | if ((target_ip_addr && |
1280 | (ses->server->addr.sockAddr.sin_addr.s_addr | 1280 | (ses->server->addr.sockAddr.sin_addr.s_addr |
1281 | == target_ip_addr->s_addr)) || (target_ip6_addr | 1281 | == target_ip_addr->s_addr)) || (target_ip6_addr |
1282 | && memcmp(&ses->server->addr.sockAddr6.sin6_addr, | 1282 | && memcmp(&ses->server->addr.sockAddr6.sin6_addr, |
@@ -1319,7 +1319,7 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName) | |||
1319 | /* BB lock tcon, server and tcp session and increment use count here? */ | 1319 | /* BB lock tcon, server and tcp session and increment use count here? */ |
1320 | /* found a match on the TCP session */ | 1320 | /* found a match on the TCP session */ |
1321 | /* BB check if reconnection needed */ | 1321 | /* BB check if reconnection needed */ |
1322 | cFYI(1,("IP match, old UNC: %s new: %s", | 1322 | cFYI(1, ("IP match, old UNC: %s new: %s", |
1323 | tcon->treeName, uncName)); | 1323 | tcon->treeName, uncName)); |
1324 | if (strncmp | 1324 | if (strncmp |
1325 | (tcon->treeName, uncName, | 1325 | (tcon->treeName, uncName, |
@@ -1423,7 +1423,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1423 | int connected = 0; | 1423 | int connected = 0; |
1424 | __be16 orig_port = 0; | 1424 | __be16 orig_port = 0; |
1425 | 1425 | ||
1426 | if(*csocket == NULL) { | 1426 | if (*csocket == NULL) { |
1427 | rc = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, csocket); | 1427 | rc = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, csocket); |
1428 | if (rc < 0) { | 1428 | if (rc < 0) { |
1429 | cERROR(1, ("Error %d creating socket",rc)); | 1429 | cERROR(1, ("Error %d creating socket",rc)); |
@@ -1437,7 +1437,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | psin_server->sin_family = AF_INET; | 1439 | psin_server->sin_family = AF_INET; |
1440 | if(psin_server->sin_port) { /* user overrode default port */ | 1440 | if (psin_server->sin_port) { /* user overrode default port */ |
1441 | rc = (*csocket)->ops->connect(*csocket, | 1441 | rc = (*csocket)->ops->connect(*csocket, |
1442 | (struct sockaddr *) psin_server, | 1442 | (struct sockaddr *) psin_server, |
1443 | sizeof (struct sockaddr_in),0); | 1443 | sizeof (struct sockaddr_in),0); |
@@ -1445,13 +1445,13 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1445 | connected = 1; | 1445 | connected = 1; |
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | if(!connected) { | 1448 | if (!connected) { |
1449 | /* save original port so we can retry user specified port | 1449 | /* save original port so we can retry user specified port |
1450 | later if fall back ports fail this time */ | 1450 | later if fall back ports fail this time */ |
1451 | orig_port = psin_server->sin_port; | 1451 | orig_port = psin_server->sin_port; |
1452 | 1452 | ||
1453 | /* do not retry on the same port we just failed on */ | 1453 | /* do not retry on the same port we just failed on */ |
1454 | if(psin_server->sin_port != htons(CIFS_PORT)) { | 1454 | if (psin_server->sin_port != htons(CIFS_PORT)) { |
1455 | psin_server->sin_port = htons(CIFS_PORT); | 1455 | psin_server->sin_port = htons(CIFS_PORT); |
1456 | 1456 | ||
1457 | rc = (*csocket)->ops->connect(*csocket, | 1457 | rc = (*csocket)->ops->connect(*csocket, |
@@ -1472,9 +1472,9 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1472 | /* give up here - unless we want to retry on different | 1472 | /* give up here - unless we want to retry on different |
1473 | protocol families some day */ | 1473 | protocol families some day */ |
1474 | if (!connected) { | 1474 | if (!connected) { |
1475 | if(orig_port) | 1475 | if (orig_port) |
1476 | psin_server->sin_port = orig_port; | 1476 | psin_server->sin_port = orig_port; |
1477 | cFYI(1,("Error %d connecting to server via ipv4",rc)); | 1477 | cFYI(1, ("Error %d connecting to server via ipv4",rc)); |
1478 | sock_release(*csocket); | 1478 | sock_release(*csocket); |
1479 | *csocket = NULL; | 1479 | *csocket = NULL; |
1480 | return rc; | 1480 | return rc; |
@@ -1482,26 +1482,26 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1482 | /* Eventually check for other socket options to change from | 1482 | /* Eventually check for other socket options to change from |
1483 | the default. sock_setsockopt not used because it expects | 1483 | the default. sock_setsockopt not used because it expects |
1484 | user space buffer */ | 1484 | user space buffer */ |
1485 | cFYI(1,("sndbuf %d rcvbuf %d rcvtimeo 0x%lx",(*csocket)->sk->sk_sndbuf, | 1485 | cFYI(1, ("sndbuf %d rcvbuf %d rcvtimeo 0x%lx",(*csocket)->sk->sk_sndbuf, |
1486 | (*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo)); | 1486 | (*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo)); |
1487 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; | 1487 | (*csocket)->sk->sk_rcvtimeo = 7 * HZ; |
1488 | /* make the bufsizes depend on wsize/rsize and max requests */ | 1488 | /* make the bufsizes depend on wsize/rsize and max requests */ |
1489 | if((*csocket)->sk->sk_sndbuf < (200 * 1024)) | 1489 | if ((*csocket)->sk->sk_sndbuf < (200 * 1024)) |
1490 | (*csocket)->sk->sk_sndbuf = 200 * 1024; | 1490 | (*csocket)->sk->sk_sndbuf = 200 * 1024; |
1491 | if((*csocket)->sk->sk_rcvbuf < (140 * 1024)) | 1491 | if ((*csocket)->sk->sk_rcvbuf < (140 * 1024)) |
1492 | (*csocket)->sk->sk_rcvbuf = 140 * 1024; | 1492 | (*csocket)->sk->sk_rcvbuf = 140 * 1024; |
1493 | 1493 | ||
1494 | /* send RFC1001 sessinit */ | 1494 | /* send RFC1001 sessinit */ |
1495 | if(psin_server->sin_port == htons(RFC1001_PORT)) { | 1495 | if (psin_server->sin_port == htons(RFC1001_PORT)) { |
1496 | /* some servers require RFC1001 sessinit before sending | 1496 | /* some servers require RFC1001 sessinit before sending |
1497 | negprot - BB check reconnection in case where second | 1497 | negprot - BB check reconnection in case where second |
1498 | sessinit is sent but no second negprot */ | 1498 | sessinit is sent but no second negprot */ |
1499 | struct rfc1002_session_packet * ses_init_buf; | 1499 | struct rfc1002_session_packet * ses_init_buf; |
1500 | struct smb_hdr * smb_buf; | 1500 | struct smb_hdr * smb_buf; |
1501 | ses_init_buf = kzalloc(sizeof(struct rfc1002_session_packet), GFP_KERNEL); | 1501 | ses_init_buf = kzalloc(sizeof(struct rfc1002_session_packet), GFP_KERNEL); |
1502 | if(ses_init_buf) { | 1502 | if (ses_init_buf) { |
1503 | ses_init_buf->trailer.session_req.called_len = 32; | 1503 | ses_init_buf->trailer.session_req.called_len = 32; |
1504 | if(target_name && (target_name[0] != 0)) { | 1504 | if (target_name && (target_name[0] != 0)) { |
1505 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, | 1505 | rfc1002mangle(ses_init_buf->trailer.session_req.called_name, |
1506 | target_name, 16); | 1506 | target_name, 16); |
1507 | } else { | 1507 | } else { |
@@ -1512,7 +1512,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, | |||
1512 | ses_init_buf->trailer.session_req.calling_len = 32; | 1512 | ses_init_buf->trailer.session_req.calling_len = 32; |
1513 | /* calling name ends in null (byte 16) from old smb | 1513 | /* calling name ends in null (byte 16) from old smb |
1514 | convention. */ | 1514 | convention. */ |
1515 | if(netbios_name && (netbios_name[0] !=0)) { | 1515 | if (netbios_name && (netbios_name[0] !=0)) { |
1516 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, | 1516 | rfc1002mangle(ses_init_buf->trailer.session_req.calling_name, |
1517 | netbios_name,16); | 1517 | netbios_name,16); |
1518 | } else { | 1518 | } else { |
@@ -1551,7 +1551,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1551 | int connected = 0; | 1551 | int connected = 0; |
1552 | __be16 orig_port = 0; | 1552 | __be16 orig_port = 0; |
1553 | 1553 | ||
1554 | if(*csocket == NULL) { | 1554 | if (*csocket == NULL) { |
1555 | rc = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket); | 1555 | rc = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket); |
1556 | if (rc < 0) { | 1556 | if (rc < 0) { |
1557 | cERROR(1, ("Error %d creating ipv6 socket",rc)); | 1557 | cERROR(1, ("Error %d creating ipv6 socket",rc)); |
@@ -1559,14 +1559,14 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1559 | return rc; | 1559 | return rc; |
1560 | } else { | 1560 | } else { |
1561 | /* BB other socket options to set KEEPALIVE, NODELAY? */ | 1561 | /* BB other socket options to set KEEPALIVE, NODELAY? */ |
1562 | cFYI(1,("ipv6 Socket created")); | 1562 | cFYI(1, ("ipv6 Socket created")); |
1563 | (*csocket)->sk->sk_allocation = GFP_NOFS; | 1563 | (*csocket)->sk->sk_allocation = GFP_NOFS; |
1564 | } | 1564 | } |
1565 | } | 1565 | } |
1566 | 1566 | ||
1567 | psin_server->sin6_family = AF_INET6; | 1567 | psin_server->sin6_family = AF_INET6; |
1568 | 1568 | ||
1569 | if(psin_server->sin6_port) { /* user overrode default port */ | 1569 | if (psin_server->sin6_port) { /* user overrode default port */ |
1570 | rc = (*csocket)->ops->connect(*csocket, | 1570 | rc = (*csocket)->ops->connect(*csocket, |
1571 | (struct sockaddr *) psin_server, | 1571 | (struct sockaddr *) psin_server, |
1572 | sizeof (struct sockaddr_in6),0); | 1572 | sizeof (struct sockaddr_in6),0); |
@@ -1574,13 +1574,13 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1574 | connected = 1; | 1574 | connected = 1; |
1575 | } | 1575 | } |
1576 | 1576 | ||
1577 | if(!connected) { | 1577 | if (!connected) { |
1578 | /* save original port so we can retry user specified port | 1578 | /* save original port so we can retry user specified port |
1579 | later if fall back ports fail this time */ | 1579 | later if fall back ports fail this time */ |
1580 | 1580 | ||
1581 | orig_port = psin_server->sin6_port; | 1581 | orig_port = psin_server->sin6_port; |
1582 | /* do not retry on the same port we just failed on */ | 1582 | /* do not retry on the same port we just failed on */ |
1583 | if(psin_server->sin6_port != htons(CIFS_PORT)) { | 1583 | if (psin_server->sin6_port != htons(CIFS_PORT)) { |
1584 | psin_server->sin6_port = htons(CIFS_PORT); | 1584 | psin_server->sin6_port = htons(CIFS_PORT); |
1585 | 1585 | ||
1586 | rc = (*csocket)->ops->connect(*csocket, | 1586 | rc = (*csocket)->ops->connect(*csocket, |
@@ -1601,9 +1601,9 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) | |||
1601 | /* give up here - unless we want to retry on different | 1601 | /* give up here - unless we want to retry on different |
1602 | protocol families some day */ | 1602 | protocol families some day */ |
1603 | if (!connected) { | 1603 | if (!connected) { |
1604 | if(orig_port) | 1604 | if (orig_port) |
1605 | psin_server->sin6_port = orig_port; | 1605 | psin_server->sin6_port = orig_port; |
1606 | cFYI(1,("Error %d connecting to server via ipv6",rc)); | 1606 | cFYI(1, ("Error %d connecting to server via ipv6",rc)); |
1607 | sock_release(*csocket); | 1607 | sock_release(*csocket); |
1608 | *csocket = NULL; | 1608 | *csocket = NULL; |
1609 | return rc; | 1609 | return rc; |
@@ -1631,12 +1631,12 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | |||
1631 | __u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); | 1631 | __u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability); |
1632 | 1632 | ||
1633 | 1633 | ||
1634 | if(!CIFSSMBQFSUnixInfo(xid, tcon)) { | 1634 | if (!CIFSSMBQFSUnixInfo(xid, tcon)) { |
1635 | __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability); | 1635 | __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability); |
1636 | 1636 | ||
1637 | /* check for reconnect case in which we do not | 1637 | /* check for reconnect case in which we do not |
1638 | want to change the mount behavior if we can avoid it */ | 1638 | want to change the mount behavior if we can avoid it */ |
1639 | if(vol_info == NULL) { | 1639 | if (vol_info == NULL) { |
1640 | /* turn off POSIX ACL and PATHNAMES if not set | 1640 | /* turn off POSIX ACL and PATHNAMES if not set |
1641 | originally at mount time */ | 1641 | originally at mount time */ |
1642 | if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0) | 1642 | if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0) |
@@ -1653,15 +1653,15 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | |||
1653 | if (vol_info && vol_info->no_psx_acl) | 1653 | if (vol_info && vol_info->no_psx_acl) |
1654 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; | 1654 | cap &= ~CIFS_UNIX_POSIX_ACL_CAP; |
1655 | else if (CIFS_UNIX_POSIX_ACL_CAP & cap) { | 1655 | else if (CIFS_UNIX_POSIX_ACL_CAP & cap) { |
1656 | cFYI(1,("negotiated posix acl support")); | 1656 | cFYI(1, ("negotiated posix acl support")); |
1657 | if(sb) | 1657 | if (sb) |
1658 | sb->s_flags |= MS_POSIXACL; | 1658 | sb->s_flags |= MS_POSIXACL; |
1659 | } | 1659 | } |
1660 | 1660 | ||
1661 | if (vol_info && vol_info->posix_paths == 0) | 1661 | if (vol_info && vol_info->posix_paths == 0) |
1662 | cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; | 1662 | cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; |
1663 | else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { | 1663 | else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { |
1664 | cFYI(1,("negotiate posix pathnames")); | 1664 | cFYI(1, ("negotiate posix pathnames")); |
1665 | if (sb) | 1665 | if (sb) |
1666 | CIFS_SB(sb)->mnt_cifs_flags |= | 1666 | CIFS_SB(sb)->mnt_cifs_flags |= |
1667 | CIFS_MOUNT_POSIX_PATHS; | 1667 | CIFS_MOUNT_POSIX_PATHS; |
@@ -1677,31 +1677,31 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon, | |||
1677 | if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) { | 1677 | if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) { |
1678 | CIFS_SB(sb)->rsize = 127 * 1024; | 1678 | CIFS_SB(sb)->rsize = 127 * 1024; |
1679 | #ifdef CONFIG_CIFS_DEBUG2 | 1679 | #ifdef CONFIG_CIFS_DEBUG2 |
1680 | cFYI(1,("larger reads not supported by srv")); | 1680 | cFYI(1, ("larger reads not supported by srv")); |
1681 | #endif | 1681 | #endif |
1682 | } | 1682 | } |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | 1685 | ||
1686 | cFYI(1,("Negotiate caps 0x%x",(int)cap)); | 1686 | cFYI(1, ("Negotiate caps 0x%x",(int)cap)); |
1687 | #ifdef CONFIG_CIFS_DEBUG2 | 1687 | #ifdef CONFIG_CIFS_DEBUG2 |
1688 | if (cap & CIFS_UNIX_FCNTL_CAP) | 1688 | if (cap & CIFS_UNIX_FCNTL_CAP) |
1689 | cFYI(1,("FCNTL cap")); | 1689 | cFYI(1, ("FCNTL cap")); |
1690 | if (cap & CIFS_UNIX_EXTATTR_CAP) | 1690 | if (cap & CIFS_UNIX_EXTATTR_CAP) |
1691 | cFYI(1,("EXTATTR cap")); | 1691 | cFYI(1, ("EXTATTR cap")); |
1692 | if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) | 1692 | if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) |
1693 | cFYI(1,("POSIX path cap")); | 1693 | cFYI(1, ("POSIX path cap")); |
1694 | if (cap & CIFS_UNIX_XATTR_CAP) | 1694 | if (cap & CIFS_UNIX_XATTR_CAP) |
1695 | cFYI(1,("XATTR cap")); | 1695 | cFYI(1, ("XATTR cap")); |
1696 | if (cap & CIFS_UNIX_POSIX_ACL_CAP) | 1696 | if (cap & CIFS_UNIX_POSIX_ACL_CAP) |
1697 | cFYI(1,("POSIX ACL cap")); | 1697 | cFYI(1, ("POSIX ACL cap")); |
1698 | if (cap & CIFS_UNIX_LARGE_READ_CAP) | 1698 | if (cap & CIFS_UNIX_LARGE_READ_CAP) |
1699 | cFYI(1,("very large read cap")); | 1699 | cFYI(1, ("very large read cap")); |
1700 | if (cap & CIFS_UNIX_LARGE_WRITE_CAP) | 1700 | if (cap & CIFS_UNIX_LARGE_WRITE_CAP) |
1701 | cFYI(1,("very large write cap")); | 1701 | cFYI(1, ("very large write cap")); |
1702 | #endif /* CIFS_DEBUG2 */ | 1702 | #endif /* CIFS_DEBUG2 */ |
1703 | if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) { | 1703 | if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) { |
1704 | cFYI(1,("setting capabilities failed")); | 1704 | cFYI(1, ("setting capabilities failed")); |
1705 | } | 1705 | } |
1706 | } | 1706 | } |
1707 | } | 1707 | } |
@@ -1736,7 +1736,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | if (volume_info.nullauth) { | 1738 | if (volume_info.nullauth) { |
1739 | cFYI(1,("null user")); | 1739 | cFYI(1, ("null user")); |
1740 | volume_info.username = NULL; | 1740 | volume_info.username = NULL; |
1741 | } else if (volume_info.username) { | 1741 | } else if (volume_info.username) { |
1742 | /* BB fixme parse for domain name here */ | 1742 | /* BB fixme parse for domain name here */ |
@@ -1755,16 +1755,16 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1755 | if (volume_info.UNCip && volume_info.UNC) { | 1755 | if (volume_info.UNCip && volume_info.UNC) { |
1756 | rc = cifs_inet_pton(AF_INET, volume_info.UNCip,&sin_server.sin_addr.s_addr); | 1756 | rc = cifs_inet_pton(AF_INET, volume_info.UNCip,&sin_server.sin_addr.s_addr); |
1757 | 1757 | ||
1758 | if(rc <= 0) { | 1758 | if (rc <= 0) { |
1759 | /* not ipv4 address, try ipv6 */ | 1759 | /* not ipv4 address, try ipv6 */ |
1760 | rc = cifs_inet_pton(AF_INET6,volume_info.UNCip,&sin_server6.sin6_addr.in6_u); | 1760 | rc = cifs_inet_pton(AF_INET6,volume_info.UNCip,&sin_server6.sin6_addr.in6_u); |
1761 | if(rc > 0) | 1761 | if (rc > 0) |
1762 | address_type = AF_INET6; | 1762 | address_type = AF_INET6; |
1763 | } else { | 1763 | } else { |
1764 | address_type = AF_INET; | 1764 | address_type = AF_INET; |
1765 | } | 1765 | } |
1766 | 1766 | ||
1767 | if(rc <= 0) { | 1767 | if (rc <= 0) { |
1768 | /* we failed translating address */ | 1768 | /* we failed translating address */ |
1769 | kfree(volume_info.UNC); | 1769 | kfree(volume_info.UNC); |
1770 | kfree(volume_info.password); | 1770 | kfree(volume_info.password); |
@@ -1795,12 +1795,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1795 | } | 1795 | } |
1796 | 1796 | ||
1797 | /* this is needed for ASCII cp to Unicode converts */ | 1797 | /* this is needed for ASCII cp to Unicode converts */ |
1798 | if(volume_info.iocharset == NULL) { | 1798 | if (volume_info.iocharset == NULL) { |
1799 | cifs_sb->local_nls = load_nls_default(); | 1799 | cifs_sb->local_nls = load_nls_default(); |
1800 | /* load_nls_default can not return null */ | 1800 | /* load_nls_default can not return null */ |
1801 | } else { | 1801 | } else { |
1802 | cifs_sb->local_nls = load_nls(volume_info.iocharset); | 1802 | cifs_sb->local_nls = load_nls(volume_info.iocharset); |
1803 | if(cifs_sb->local_nls == NULL) { | 1803 | if (cifs_sb->local_nls == NULL) { |
1804 | cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset)); | 1804 | cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset)); |
1805 | kfree(volume_info.UNC); | 1805 | kfree(volume_info.UNC); |
1806 | kfree(volume_info.password); | 1806 | kfree(volume_info.password); |
@@ -1810,12 +1810,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1810 | } | 1810 | } |
1811 | } | 1811 | } |
1812 | 1812 | ||
1813 | if(address_type == AF_INET) | 1813 | if (address_type == AF_INET) |
1814 | existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr, | 1814 | existingCifsSes = cifs_find_tcp_session(&sin_server.sin_addr, |
1815 | NULL /* no ipv6 addr */, | 1815 | NULL /* no ipv6 addr */, |
1816 | volume_info.username, &srvTcp); | 1816 | volume_info.username, &srvTcp); |
1817 | else if(address_type == AF_INET6) { | 1817 | else if (address_type == AF_INET6) { |
1818 | cFYI(1,("looking for ipv6 address")); | 1818 | cFYI(1, ("looking for ipv6 address")); |
1819 | existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */, | 1819 | existingCifsSes = cifs_find_tcp_session(NULL /* no ipv4 addr */, |
1820 | &sin_server6.sin6_addr, | 1820 | &sin_server6.sin6_addr, |
1821 | volume_info.username, &srvTcp); | 1821 | volume_info.username, &srvTcp); |
@@ -1836,7 +1836,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1836 | else | 1836 | else |
1837 | sin_server.sin_port = 0; | 1837 | sin_server.sin_port = 0; |
1838 | if (address_type == AF_INET6) { | 1838 | if (address_type == AF_INET6) { |
1839 | cFYI(1,("attempting ipv6 connect")); | 1839 | cFYI(1, ("attempting ipv6 connect")); |
1840 | /* BB should we allow ipv6 on port 139? */ | 1840 | /* BB should we allow ipv6 on port 139? */ |
1841 | /* other OS never observed in Wild doing 139 with v6 */ | 1841 | /* other OS never observed in Wild doing 139 with v6 */ |
1842 | rc = ipv6_connect(&sin_server6,&csocket); | 1842 | rc = ipv6_connect(&sin_server6,&csocket); |
@@ -2091,7 +2091,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2091 | send_sig call */ | 2091 | send_sig call */ |
2092 | force_sig(SIGKILL,srvTcp->tsk); | 2092 | force_sig(SIGKILL,srvTcp->tsk); |
2093 | tsk = srvTcp->tsk; | 2093 | tsk = srvTcp->tsk; |
2094 | if(tsk) | 2094 | if (tsk) |
2095 | kthread_stop(tsk); | 2095 | kthread_stop(tsk); |
2096 | } | 2096 | } |
2097 | } | 2097 | } |
@@ -2133,7 +2133,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2133 | /* tell server which Unix caps we support */ | 2133 | /* tell server which Unix caps we support */ |
2134 | if (tcon->ses->capabilities & CAP_UNIX) | 2134 | if (tcon->ses->capabilities & CAP_UNIX) |
2135 | reset_cifs_unix_caps(xid, tcon, sb, &volume_info); | 2135 | reset_cifs_unix_caps(xid, tcon, sb, &volume_info); |
2136 | else if(cifs_sb->rsize > (1024 * 127)) { | 2136 | else if (cifs_sb->rsize > (1024 * 127)) { |
2137 | cifs_sb->rsize = 1024 * 127; | 2137 | cifs_sb->rsize = 1024 * 127; |
2138 | #ifdef CONFIG_CIFS_DEBUG2 | 2138 | #ifdef CONFIG_CIFS_DEBUG2 |
2139 | cFYI(1, ("no very large read support, rsize 127K")); | 2139 | cFYI(1, ("no very large read support, rsize 127K")); |
@@ -2200,7 +2200,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2200 | pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); | 2200 | pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); |
2201 | pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq); | 2201 | pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq); |
2202 | 2202 | ||
2203 | if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 2203 | if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
2204 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 2204 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
2205 | 2205 | ||
2206 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | 2206 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
@@ -2330,10 +2330,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2330 | /* We look for obvious messed up bcc or strings in response so we do not go off | 2330 | /* We look for obvious messed up bcc or strings in response so we do not go off |
2331 | the end since (at least) WIN2K and Windows XP have a major bug in not null | 2331 | the end since (at least) WIN2K and Windows XP have a major bug in not null |
2332 | terminating last Unicode string in response */ | 2332 | terminating last Unicode string in response */ |
2333 | if(ses->serverOS) | 2333 | if (ses->serverOS) |
2334 | kfree(ses->serverOS); | 2334 | kfree(ses->serverOS); |
2335 | ses->serverOS = kzalloc(2 * (len + 1), GFP_KERNEL); | 2335 | ses->serverOS = kzalloc(2 * (len + 1), GFP_KERNEL); |
2336 | if(ses->serverOS == NULL) | 2336 | if (ses->serverOS == NULL) |
2337 | goto sesssetup_nomem; | 2337 | goto sesssetup_nomem; |
2338 | cifs_strfromUCS_le(ses->serverOS, | 2338 | cifs_strfromUCS_le(ses->serverOS, |
2339 | (__le16 *)bcc_ptr, len,nls_codepage); | 2339 | (__le16 *)bcc_ptr, len,nls_codepage); |
@@ -2346,14 +2346,14 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2346 | remaining_words-1); | 2346 | remaining_words-1); |
2347 | kfree(ses->serverNOS); | 2347 | kfree(ses->serverNOS); |
2348 | ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL); | 2348 | ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL); |
2349 | if(ses->serverNOS == NULL) | 2349 | if (ses->serverNOS == NULL) |
2350 | goto sesssetup_nomem; | 2350 | goto sesssetup_nomem; |
2351 | cifs_strfromUCS_le(ses->serverNOS, | 2351 | cifs_strfromUCS_le(ses->serverNOS, |
2352 | (__le16 *)bcc_ptr,len,nls_codepage); | 2352 | (__le16 *)bcc_ptr,len,nls_codepage); |
2353 | bcc_ptr += 2 * (len + 1); | 2353 | bcc_ptr += 2 * (len + 1); |
2354 | ses->serverNOS[2 * len] = 0; | 2354 | ses->serverNOS[2 * len] = 0; |
2355 | ses->serverNOS[1 + (2 * len)] = 0; | 2355 | ses->serverNOS[1 + (2 * len)] = 0; |
2356 | if(strncmp(ses->serverNOS, | 2356 | if (strncmp(ses->serverNOS, |
2357 | "NT LAN Manager 4",16) == 0) { | 2357 | "NT LAN Manager 4",16) == 0) { |
2358 | cFYI(1, ("NT4 server")); | 2358 | cFYI(1, ("NT4 server")); |
2359 | ses->flags |= CIFS_SES_NT4; | 2359 | ses->flags |= CIFS_SES_NT4; |
@@ -2362,11 +2362,11 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2362 | if (remaining_words > 0) { | 2362 | if (remaining_words > 0) { |
2363 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); | 2363 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); |
2364 | /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ | 2364 | /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ |
2365 | if(ses->serverDomain) | 2365 | if (ses->serverDomain) |
2366 | kfree(ses->serverDomain); | 2366 | kfree(ses->serverDomain); |
2367 | ses->serverDomain = | 2367 | ses->serverDomain = |
2368 | kzalloc(2*(len+1),GFP_KERNEL); | 2368 | kzalloc(2*(len+1),GFP_KERNEL); |
2369 | if(ses->serverDomain == NULL) | 2369 | if (ses->serverDomain == NULL) |
2370 | goto sesssetup_nomem; | 2370 | goto sesssetup_nomem; |
2371 | cifs_strfromUCS_le(ses->serverDomain, | 2371 | cifs_strfromUCS_le(ses->serverDomain, |
2372 | (__le16 *)bcc_ptr,len,nls_codepage); | 2372 | (__le16 *)bcc_ptr,len,nls_codepage); |
@@ -2375,7 +2375,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2375 | ses->serverDomain[1+(2*len)] = 0; | 2375 | ses->serverDomain[1+(2*len)] = 0; |
2376 | } /* else no more room so create dummy domain string */ | 2376 | } /* else no more room so create dummy domain string */ |
2377 | else { | 2377 | else { |
2378 | if(ses->serverDomain) | 2378 | if (ses->serverDomain) |
2379 | kfree(ses->serverDomain); | 2379 | kfree(ses->serverDomain); |
2380 | ses->serverDomain = | 2380 | ses->serverDomain = |
2381 | kzalloc(2, GFP_KERNEL); | 2381 | kzalloc(2, GFP_KERNEL); |
@@ -2398,7 +2398,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2398 | <= BCC(smb_buffer_response)) { | 2398 | <= BCC(smb_buffer_response)) { |
2399 | kfree(ses->serverOS); | 2399 | kfree(ses->serverOS); |
2400 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); | 2400 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); |
2401 | if(ses->serverOS == NULL) | 2401 | if (ses->serverOS == NULL) |
2402 | goto sesssetup_nomem; | 2402 | goto sesssetup_nomem; |
2403 | strncpy(ses->serverOS,bcc_ptr, len); | 2403 | strncpy(ses->serverOS,bcc_ptr, len); |
2404 | 2404 | ||
@@ -2409,7 +2409,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2409 | len = strnlen(bcc_ptr, 1024); | 2409 | len = strnlen(bcc_ptr, 1024); |
2410 | kfree(ses->serverNOS); | 2410 | kfree(ses->serverNOS); |
2411 | ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); | 2411 | ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); |
2412 | if(ses->serverNOS == NULL) | 2412 | if (ses->serverNOS == NULL) |
2413 | goto sesssetup_nomem; | 2413 | goto sesssetup_nomem; |
2414 | strncpy(ses->serverNOS, bcc_ptr, len); | 2414 | strncpy(ses->serverNOS, bcc_ptr, len); |
2415 | bcc_ptr += len; | 2415 | bcc_ptr += len; |
@@ -2417,10 +2417,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2417 | bcc_ptr++; | 2417 | bcc_ptr++; |
2418 | 2418 | ||
2419 | len = strnlen(bcc_ptr, 1024); | 2419 | len = strnlen(bcc_ptr, 1024); |
2420 | if(ses->serverDomain) | 2420 | if (ses->serverDomain) |
2421 | kfree(ses->serverDomain); | 2421 | kfree(ses->serverDomain); |
2422 | ses->serverDomain = kzalloc(len + 1,GFP_KERNEL); | 2422 | ses->serverDomain = kzalloc(len + 1,GFP_KERNEL); |
2423 | if(ses->serverDomain == NULL) | 2423 | if (ses->serverDomain == NULL) |
2424 | goto sesssetup_nomem; | 2424 | goto sesssetup_nomem; |
2425 | strncpy(ses->serverDomain, bcc_ptr, len); | 2425 | strncpy(ses->serverDomain, bcc_ptr, len); |
2426 | bcc_ptr += len; | 2426 | bcc_ptr += len; |
@@ -2472,7 +2472,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2472 | __u16 count; | 2472 | __u16 count; |
2473 | 2473 | ||
2474 | cFYI(1, ("In NTLMSSP sesssetup (negotiate)")); | 2474 | cFYI(1, ("In NTLMSSP sesssetup (negotiate)")); |
2475 | if(ses == NULL) | 2475 | if (ses == NULL) |
2476 | return -EINVAL; | 2476 | return -EINVAL; |
2477 | domain = ses->domainName; | 2477 | domain = ses->domainName; |
2478 | *pNTLMv2_flag = FALSE; | 2478 | *pNTLMv2_flag = FALSE; |
@@ -2496,7 +2496,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2496 | pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); | 2496 | pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); |
2497 | pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); | 2497 | pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); |
2498 | 2498 | ||
2499 | if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 2499 | if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
2500 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 2500 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
2501 | 2501 | ||
2502 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | 2502 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
@@ -2524,9 +2524,9 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2524 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | | 2524 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | |
2525 | NTLMSSP_NEGOTIATE_56 | | 2525 | NTLMSSP_NEGOTIATE_56 | |
2526 | /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; | 2526 | /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; |
2527 | if(sign_CIFS_PDUs) | 2527 | if (sign_CIFS_PDUs) |
2528 | negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN; | 2528 | negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN; |
2529 | /* if(ntlmv2_support) | 2529 | /* if (ntlmv2_support) |
2530 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;*/ | 2530 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;*/ |
2531 | /* setup pointers to domain name and workstation name */ | 2531 | /* setup pointers to domain name and workstation name */ |
2532 | bcc_ptr += SecurityBlobLength; | 2532 | bcc_ptr += SecurityBlobLength; |
@@ -2626,11 +2626,11 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2626 | memcpy(ses->server->cryptKey, | 2626 | memcpy(ses->server->cryptKey, |
2627 | SecurityBlob2->Challenge, | 2627 | SecurityBlob2->Challenge, |
2628 | CIFS_CRYPTO_KEY_SIZE); | 2628 | CIFS_CRYPTO_KEY_SIZE); |
2629 | if(SecurityBlob2->NegotiateFlags & | 2629 | if (SecurityBlob2->NegotiateFlags & |
2630 | cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) | 2630 | cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) |
2631 | *pNTLMv2_flag = TRUE; | 2631 | *pNTLMv2_flag = TRUE; |
2632 | 2632 | ||
2633 | if((SecurityBlob2->NegotiateFlags & | 2633 | if ((SecurityBlob2->NegotiateFlags & |
2634 | cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) | 2634 | cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) |
2635 | || (sign_CIFS_PDUs > 1)) | 2635 | || (sign_CIFS_PDUs > 1)) |
2636 | ses->server->secMode |= | 2636 | ses->server->secMode |= |
@@ -2657,7 +2657,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2657 | /* We look for obvious messed up bcc or strings in response so we do not go off | 2657 | /* We look for obvious messed up bcc or strings in response so we do not go off |
2658 | the end since (at least) WIN2K and Windows XP have a major bug in not null | 2658 | the end since (at least) WIN2K and Windows XP have a major bug in not null |
2659 | terminating last Unicode string in response */ | 2659 | terminating last Unicode string in response */ |
2660 | if(ses->serverOS) | 2660 | if (ses->serverOS) |
2661 | kfree(ses->serverOS); | 2661 | kfree(ses->serverOS); |
2662 | ses->serverOS = | 2662 | ses->serverOS = |
2663 | kzalloc(2 * (len + 1), GFP_KERNEL); | 2663 | kzalloc(2 * (len + 1), GFP_KERNEL); |
@@ -2729,7 +2729,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2729 | if (((long) bcc_ptr + len) - (long) | 2729 | if (((long) bcc_ptr + len) - (long) |
2730 | pByteArea(smb_buffer_response) | 2730 | pByteArea(smb_buffer_response) |
2731 | <= BCC(smb_buffer_response)) { | 2731 | <= BCC(smb_buffer_response)) { |
2732 | if(ses->serverOS) | 2732 | if (ses->serverOS) |
2733 | kfree(ses->serverOS); | 2733 | kfree(ses->serverOS); |
2734 | ses->serverOS = | 2734 | ses->serverOS = |
2735 | kzalloc(len + 1, | 2735 | kzalloc(len + 1, |
@@ -2806,7 +2806,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2806 | __u16 count; | 2806 | __u16 count; |
2807 | 2807 | ||
2808 | cFYI(1, ("In NTLMSSPSessSetup (Authenticate)")); | 2808 | cFYI(1, ("In NTLMSSPSessSetup (Authenticate)")); |
2809 | if(ses == NULL) | 2809 | if (ses == NULL) |
2810 | return -EINVAL; | 2810 | return -EINVAL; |
2811 | user = ses->userName; | 2811 | user = ses->userName; |
2812 | domain = ses->domainName; | 2812 | domain = ses->domainName; |
@@ -2831,7 +2831,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2831 | 2831 | ||
2832 | pSMB->req.hdr.Uid = ses->Suid; | 2832 | pSMB->req.hdr.Uid = ses->Suid; |
2833 | 2833 | ||
2834 | if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 2834 | if (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
2835 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 2835 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
2836 | 2836 | ||
2837 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | 2837 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
@@ -2859,9 +2859,9 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2859 | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET | | 2859 | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET | |
2860 | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO | | 2860 | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO | |
2861 | 0x80000000 | NTLMSSP_NEGOTIATE_128; | 2861 | 0x80000000 | NTLMSSP_NEGOTIATE_128; |
2862 | if(sign_CIFS_PDUs) | 2862 | if (sign_CIFS_PDUs) |
2863 | negotiate_flags |= /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN |*/ NTLMSSP_NEGOTIATE_SIGN; | 2863 | negotiate_flags |= /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN |*/ NTLMSSP_NEGOTIATE_SIGN; |
2864 | if(ntlmv2_flag) | 2864 | if (ntlmv2_flag) |
2865 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2; | 2865 | negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2; |
2866 | 2866 | ||
2867 | /* setup pointers to domain name and workstation name */ | 2867 | /* setup pointers to domain name and workstation name */ |
@@ -3018,7 +3018,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3018 | le16_to_cpu(pSMBr->resp.SecurityBlobLength); | 3018 | le16_to_cpu(pSMBr->resp.SecurityBlobLength); |
3019 | if (action & GUEST_LOGIN) | 3019 | if (action & GUEST_LOGIN) |
3020 | cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */ | 3020 | cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */ |
3021 | /* if(SecurityBlob2->MessageType != NtLm??){ | 3021 | /* if (SecurityBlob2->MessageType != NtLm??){ |
3022 | cFYI("Unexpected message type on auth response is %d ")); | 3022 | cFYI("Unexpected message type on auth response is %d ")); |
3023 | } */ | 3023 | } */ |
3024 | if (ses) { | 3024 | if (ses) { |
@@ -3057,7 +3057,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3057 | /* We look for obvious messed up bcc or strings in response so we do not go off | 3057 | /* We look for obvious messed up bcc or strings in response so we do not go off |
3058 | the end since (at least) WIN2K and Windows XP have a major bug in not null | 3058 | the end since (at least) WIN2K and Windows XP have a major bug in not null |
3059 | terminating last Unicode string in response */ | 3059 | terminating last Unicode string in response */ |
3060 | if(ses->serverOS) | 3060 | if (ses->serverOS) |
3061 | kfree(ses->serverOS); | 3061 | kfree(ses->serverOS); |
3062 | ses->serverOS = | 3062 | ses->serverOS = |
3063 | kzalloc(2 * (len + 1), GFP_KERNEL); | 3063 | kzalloc(2 * (len + 1), GFP_KERNEL); |
@@ -3091,7 +3091,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3091 | if (remaining_words > 0) { | 3091 | if (remaining_words > 0) { |
3092 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); | 3092 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); |
3093 | /* last string not always null terminated (e.g. for Windows XP & 2000) */ | 3093 | /* last string not always null terminated (e.g. for Windows XP & 2000) */ |
3094 | if(ses->serverDomain) | 3094 | if (ses->serverDomain) |
3095 | kfree(ses->serverDomain); | 3095 | kfree(ses->serverDomain); |
3096 | ses->serverDomain = | 3096 | ses->serverDomain = |
3097 | kzalloc(2 * | 3097 | kzalloc(2 * |
@@ -3119,12 +3119,12 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3119 | = 0; | 3119 | = 0; |
3120 | } /* else no more room so create dummy domain string */ | 3120 | } /* else no more room so create dummy domain string */ |
3121 | else { | 3121 | else { |
3122 | if(ses->serverDomain) | 3122 | if (ses->serverDomain) |
3123 | kfree(ses->serverDomain); | 3123 | kfree(ses->serverDomain); |
3124 | ses->serverDomain = kzalloc(2,GFP_KERNEL); | 3124 | ses->serverDomain = kzalloc(2,GFP_KERNEL); |
3125 | } | 3125 | } |
3126 | } else { /* no room so create dummy domain and NOS string */ | 3126 | } else { /* no room so create dummy domain and NOS string */ |
3127 | if(ses->serverDomain) | 3127 | if (ses->serverDomain) |
3128 | kfree(ses->serverDomain); | 3128 | kfree(ses->serverDomain); |
3129 | ses->serverDomain = kzalloc(2, GFP_KERNEL); | 3129 | ses->serverDomain = kzalloc(2, GFP_KERNEL); |
3130 | kfree(ses->serverNOS); | 3130 | kfree(ses->serverNOS); |
@@ -3135,7 +3135,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3135 | if (((long) bcc_ptr + len) - | 3135 | if (((long) bcc_ptr + len) - |
3136 | (long) pByteArea(smb_buffer_response) | 3136 | (long) pByteArea(smb_buffer_response) |
3137 | <= BCC(smb_buffer_response)) { | 3137 | <= BCC(smb_buffer_response)) { |
3138 | if(ses->serverOS) | 3138 | if (ses->serverOS) |
3139 | kfree(ses->serverOS); | 3139 | kfree(ses->serverOS); |
3140 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); | 3140 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); |
3141 | strncpy(ses->serverOS,bcc_ptr, len); | 3141 | strncpy(ses->serverOS,bcc_ptr, len); |
@@ -3153,7 +3153,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
3153 | bcc_ptr++; | 3153 | bcc_ptr++; |
3154 | 3154 | ||
3155 | len = strnlen(bcc_ptr, 1024); | 3155 | len = strnlen(bcc_ptr, 1024); |
3156 | if(ses->serverDomain) | 3156 | if (ses->serverDomain) |
3157 | kfree(ses->serverDomain); | 3157 | kfree(ses->serverDomain); |
3158 | ses->serverDomain = kzalloc(len+1,GFP_KERNEL); | 3158 | ses->serverDomain = kzalloc(len+1,GFP_KERNEL); |
3159 | strncpy(ses->serverDomain, bcc_ptr, len); | 3159 | strncpy(ses->serverDomain, bcc_ptr, len); |
@@ -3219,7 +3219,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3219 | pSMB->AndXCommand = 0xFF; | 3219 | pSMB->AndXCommand = 0xFF; |
3220 | pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); | 3220 | pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); |
3221 | bcc_ptr = &pSMB->Password[0]; | 3221 | bcc_ptr = &pSMB->Password[0]; |
3222 | if((ses->server->secMode) & SECMODE_USER) { | 3222 | if ((ses->server->secMode) & SECMODE_USER) { |
3223 | pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ | 3223 | pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ |
3224 | *bcc_ptr = 0; /* password is null byte */ | 3224 | *bcc_ptr = 0; /* password is null byte */ |
3225 | bcc_ptr++; /* skip password */ | 3225 | bcc_ptr++; /* skip password */ |
@@ -3233,7 +3233,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3233 | by Samba (not sure whether other servers allow | 3233 | by Samba (not sure whether other servers allow |
3234 | NTLMv2 password here) */ | 3234 | NTLMv2 password here) */ |
3235 | #ifdef CONFIG_CIFS_WEAK_PW_HASH | 3235 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
3236 | if((extended_security & CIFSSEC_MAY_LANMAN) && | 3236 | if ((extended_security & CIFSSEC_MAY_LANMAN) && |
3237 | (ses->server->secType == LANMAN)) | 3237 | (ses->server->secType == LANMAN)) |
3238 | calc_lanman_hash(ses, bcc_ptr); | 3238 | calc_lanman_hash(ses, bcc_ptr); |
3239 | else | 3239 | else |
@@ -3243,14 +3243,14 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3243 | bcc_ptr); | 3243 | bcc_ptr); |
3244 | 3244 | ||
3245 | bcc_ptr += CIFS_SESS_KEY_SIZE; | 3245 | bcc_ptr += CIFS_SESS_KEY_SIZE; |
3246 | if(ses->capabilities & CAP_UNICODE) { | 3246 | if (ses->capabilities & CAP_UNICODE) { |
3247 | /* must align unicode strings */ | 3247 | /* must align unicode strings */ |
3248 | *bcc_ptr = 0; /* null byte password */ | 3248 | *bcc_ptr = 0; /* null byte password */ |
3249 | bcc_ptr++; | 3249 | bcc_ptr++; |
3250 | } | 3250 | } |
3251 | } | 3251 | } |
3252 | 3252 | ||
3253 | if(ses->server->secMode & | 3253 | if (ses->server->secMode & |
3254 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 3254 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
3255 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 3255 | smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
3256 | 3256 | ||
@@ -3321,7 +3321,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3321 | } | 3321 | } |
3322 | /* else do not bother copying these informational fields */ | 3322 | /* else do not bother copying these informational fields */ |
3323 | } | 3323 | } |
3324 | if((smb_buffer_response->WordCount == 3) || | 3324 | if ((smb_buffer_response->WordCount == 3) || |
3325 | (smb_buffer_response->WordCount == 7)) | 3325 | (smb_buffer_response->WordCount == 7)) |
3326 | /* field is in same location */ | 3326 | /* field is in same location */ |
3327 | tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); | 3327 | tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport); |
@@ -3401,16 +3401,16 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3401 | int first_time = 0; | 3401 | int first_time = 0; |
3402 | 3402 | ||
3403 | /* what if server changes its buffer size after dropping the session? */ | 3403 | /* what if server changes its buffer size after dropping the session? */ |
3404 | if(pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ { | 3404 | if (pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ { |
3405 | rc = CIFSSMBNegotiate(xid, pSesInfo); | 3405 | rc = CIFSSMBNegotiate(xid, pSesInfo); |
3406 | if(rc == -EAGAIN) /* retry only once on 1st time connection */ { | 3406 | if (rc == -EAGAIN) /* retry only once on 1st time connection */ { |
3407 | rc = CIFSSMBNegotiate(xid, pSesInfo); | 3407 | rc = CIFSSMBNegotiate(xid, pSesInfo); |
3408 | if(rc == -EAGAIN) | 3408 | if (rc == -EAGAIN) |
3409 | rc = -EHOSTDOWN; | 3409 | rc = -EHOSTDOWN; |
3410 | } | 3410 | } |
3411 | if(rc == 0) { | 3411 | if (rc == 0) { |
3412 | spin_lock(&GlobalMid_Lock); | 3412 | spin_lock(&GlobalMid_Lock); |
3413 | if(pSesInfo->server->tcpStatus != CifsExiting) | 3413 | if (pSesInfo->server->tcpStatus != CifsExiting) |
3414 | pSesInfo->server->tcpStatus = CifsGood; | 3414 | pSesInfo->server->tcpStatus = CifsGood; |
3415 | else | 3415 | else |
3416 | rc = -EHOSTDOWN; | 3416 | rc = -EHOSTDOWN; |
@@ -3422,14 +3422,14 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3422 | if (!rc) { | 3422 | if (!rc) { |
3423 | pSesInfo->flags = 0; | 3423 | pSesInfo->flags = 0; |
3424 | pSesInfo->capabilities = pSesInfo->server->capabilities; | 3424 | pSesInfo->capabilities = pSesInfo->server->capabilities; |
3425 | if(linuxExtEnabled == 0) | 3425 | if (linuxExtEnabled == 0) |
3426 | pSesInfo->capabilities &= (~CAP_UNIX); | 3426 | pSesInfo->capabilities &= (~CAP_UNIX); |
3427 | /* pSesInfo->sequence_number = 0;*/ | 3427 | /* pSesInfo->sequence_number = 0;*/ |
3428 | cFYI(1,("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", | 3428 | cFYI(1, ("Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d", |
3429 | pSesInfo->server->secMode, | 3429 | pSesInfo->server->secMode, |
3430 | pSesInfo->server->capabilities, | 3430 | pSesInfo->server->capabilities, |
3431 | pSesInfo->server->timeAdj)); | 3431 | pSesInfo->server->timeAdj)); |
3432 | if(experimEnabled < 2) | 3432 | if (experimEnabled < 2) |
3433 | rc = CIFS_SessSetup(xid, pSesInfo, | 3433 | rc = CIFS_SessSetup(xid, pSesInfo, |
3434 | first_time, nls_info); | 3434 | first_time, nls_info); |
3435 | else if (extended_security | 3435 | else if (extended_security |
@@ -3446,18 +3446,18 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3446 | &ntlmv2_flag, | 3446 | &ntlmv2_flag, |
3447 | nls_info); | 3447 | nls_info); |
3448 | if (!rc) { | 3448 | if (!rc) { |
3449 | if(ntlmv2_flag) { | 3449 | if (ntlmv2_flag) { |
3450 | char * v2_response; | 3450 | char * v2_response; |
3451 | cFYI(1, ("more secure NTLM ver2 hash")); | 3451 | cFYI(1, ("more secure NTLM ver2 hash")); |
3452 | if(CalcNTLMv2_partial_mac_key(pSesInfo, | 3452 | if (CalcNTLMv2_partial_mac_key(pSesInfo, |
3453 | nls_info)) { | 3453 | nls_info)) { |
3454 | rc = -ENOMEM; | 3454 | rc = -ENOMEM; |
3455 | goto ss_err_exit; | 3455 | goto ss_err_exit; |
3456 | } else | 3456 | } else |
3457 | v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL); | 3457 | v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL); |
3458 | if(v2_response) { | 3458 | if (v2_response) { |
3459 | CalcNTLMv2_response(pSesInfo,v2_response); | 3459 | CalcNTLMv2_response(pSesInfo,v2_response); |
3460 | /* if(first_time) | 3460 | /* if (first_time) |
3461 | cifs_calculate_ntlmv2_mac_key( | 3461 | cifs_calculate_ntlmv2_mac_key( |
3462 | pSesInfo->server->mac_signing_key, | 3462 | pSesInfo->server->mac_signing_key, |
3463 | response, ntlm_session_key, */ | 3463 | response, ntlm_session_key, */ |
@@ -3473,7 +3473,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3473 | pSesInfo->server->cryptKey, | 3473 | pSesInfo->server->cryptKey, |
3474 | ntlm_session_key); | 3474 | ntlm_session_key); |
3475 | 3475 | ||
3476 | if(first_time) | 3476 | if (first_time) |
3477 | cifs_calculate_mac_key( | 3477 | cifs_calculate_mac_key( |
3478 | &pSesInfo->server->mac_signing_key, | 3478 | &pSesInfo->server->mac_signing_key, |
3479 | ntlm_session_key, | 3479 | ntlm_session_key, |
@@ -3493,7 +3493,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3493 | pSesInfo->server->cryptKey, | 3493 | pSesInfo->server->cryptKey, |
3494 | ntlm_session_key); | 3494 | ntlm_session_key); |
3495 | 3495 | ||
3496 | if(first_time) | 3496 | if (first_time) |
3497 | cifs_calculate_mac_key( | 3497 | cifs_calculate_mac_key( |
3498 | &pSesInfo->server->mac_signing_key, | 3498 | &pSesInfo->server->mac_signing_key, |
3499 | ntlm_session_key, pSesInfo->password); | 3499 | ntlm_session_key, pSesInfo->password); |
@@ -3502,7 +3502,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3502 | ntlm_session_key, nls_info); | 3502 | ntlm_session_key, nls_info); |
3503 | } | 3503 | } |
3504 | if (rc) { | 3504 | if (rc) { |
3505 | cERROR(1,("Send error in SessSetup = %d",rc)); | 3505 | cERROR(1, ("Send error in SessSetup = %d", rc)); |
3506 | } else { | 3506 | } else { |
3507 | cFYI(1, ("CIFS Session Established successfully")); | 3507 | cFYI(1, ("CIFS Session Established successfully")); |
3508 | pSesInfo->status = CifsGood; | 3508 | pSesInfo->status = CifsGood; |
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 8e86aaceb68a..38706e8496a3 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -135,10 +135,10 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, | |||
135 | struct cifs_sb_info *cifs_sb; | 135 | struct cifs_sb_info *cifs_sb; |
136 | struct cifsTconInfo *pTcon; | 136 | struct cifsTconInfo *pTcon; |
137 | char *full_path = NULL; | 137 | char *full_path = NULL; |
138 | FILE_ALL_INFO * buf = NULL; | 138 | FILE_ALL_INFO *buf = NULL; |
139 | struct inode *newinode = NULL; | 139 | struct inode *newinode = NULL; |
140 | struct cifsFileInfo * pCifsFile = NULL; | 140 | struct cifsFileInfo *pCifsFile = NULL; |
141 | struct cifsInodeInfo * pCifsInode; | 141 | struct cifsInodeInfo *pCifsInode; |
142 | int disposition = FILE_OVERWRITE_IF; | 142 | int disposition = FILE_OVERWRITE_IF; |
143 | int write_only = FALSE; | 143 | int write_only = FALSE; |
144 | 144 | ||
@@ -323,7 +323,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, | |||
323 | struct cifs_sb_info *cifs_sb; | 323 | struct cifs_sb_info *cifs_sb; |
324 | struct cifsTconInfo *pTcon; | 324 | struct cifsTconInfo *pTcon; |
325 | char *full_path = NULL; | 325 | char *full_path = NULL; |
326 | struct inode * newinode = NULL; | 326 | struct inode *newinode = NULL; |
327 | 327 | ||
328 | if (!old_valid_dev(device_number)) | 328 | if (!old_valid_dev(device_number)) |
329 | return -EINVAL; | 329 | return -EINVAL; |
diff --git a/fs/cifs/export.c b/fs/cifs/export.c index 1d716392c3aa..5a08effda0ae 100644 --- a/fs/cifs/export.c +++ b/fs/cifs/export.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Author(s): Steve French (sfrench@us.ibm.com) | 5 | * Author(s): Steve French (sfrench@us.ibm.com) |
6 | * | 6 | * |
7 | * Common Internet FileSystem (CIFS) client | 7 | * Common Internet FileSystem (CIFS) client |
8 | * | 8 | * |
9 | * Operations related to support for exporting files via NFSD | 9 | * Operations related to support for exporting files via NFSD |
10 | * | 10 | * |
11 | * This library is free software; you can redistribute it and/or modify | 11 | * This library is free software; you can redistribute it and/or modify |
@@ -23,7 +23,7 @@ | |||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 | */ | 24 | */ |
25 | 25 | ||
26 | /* | 26 | /* |
27 | * See Documentation/filesystems/Exporting | 27 | * See Documentation/filesystems/Exporting |
28 | * and examples in fs/exportfs | 28 | * and examples in fs/exportfs |
29 | */ | 29 | */ |
@@ -34,19 +34,19 @@ | |||
34 | 34 | ||
35 | static struct dentry *cifs_get_parent(struct dentry *dentry) | 35 | static struct dentry *cifs_get_parent(struct dentry *dentry) |
36 | { | 36 | { |
37 | /* BB need to add code here eventually to enable export via NFSD */ | 37 | /* BB need to add code here eventually to enable export via NFSD */ |
38 | return ERR_PTR(-EACCES); | 38 | return ERR_PTR(-EACCES); |
39 | } | 39 | } |
40 | 40 | ||
41 | struct export_operations cifs_export_ops = { | 41 | struct export_operations cifs_export_ops = { |
42 | .get_parent = cifs_get_parent, | 42 | .get_parent = cifs_get_parent, |
43 | /* Following five export operations are unneeded so far and can default */ | 43 | /* Following five export operations are unneeded so far and can default: |
44 | /* .get_dentry = | 44 | .get_dentry = |
45 | .get_name = | 45 | .get_name = |
46 | .find_exported_dentry = | 46 | .find_exported_dentry = |
47 | .decode_fh = | 47 | .decode_fh = |
48 | .encode_fs = */ | 48 | .encode_fs = */ |
49 | }; | 49 | }; |
50 | 50 | ||
51 | #endif /* EXPERIMENTAL */ | 51 | #endif /* EXPERIMENTAL */ |
52 | 52 | ||
diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c index 8e375bb4b379..995474c90885 100644 --- a/fs/cifs/fcntl.c +++ b/fs/cifs/fcntl.c | |||
@@ -66,7 +66,7 @@ static __u32 convert_to_cifs_notify_flags(unsigned long fcntl_notify_flags) | |||
66 | return cifs_ntfy_flags; | 66 | return cifs_ntfy_flags; |
67 | } | 67 | } |
68 | 68 | ||
69 | int cifs_dir_notify(struct file * file, unsigned long arg) | 69 | int cifs_dir_notify(struct file *file, unsigned long arg) |
70 | { | 70 | { |
71 | int xid; | 71 | int xid; |
72 | int rc = -EINVAL; | 72 | int rc = -EINVAL; |
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 5f1b707188f8..7d6fb6f3adeb 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -2,8 +2,8 @@ | |||
2 | * fs/cifs/file.c | 2 | * fs/cifs/file.c |
3 | * | 3 | * |
4 | * vfs operations that deal with files | 4 | * vfs operations that deal with files |
5 | * | 5 | * |
6 | * Copyright (C) International Business Machines Corp., 2002,2003 | 6 | * Copyright (C) International Business Machines Corp., 2002,2007 |
7 | * Author(s): Steve French (sfrench@us.ibm.com) | 7 | * Author(s): Steve French (sfrench@us.ibm.com) |
8 | * Jeremy Allison (jra@samba.org) | 8 | * Jeremy Allison (jra@samba.org) |
9 | * | 9 | * |
@@ -45,7 +45,7 @@ static inline struct cifsFileInfo *cifs_init_private( | |||
45 | { | 45 | { |
46 | memset(private_data, 0, sizeof(struct cifsFileInfo)); | 46 | memset(private_data, 0, sizeof(struct cifsFileInfo)); |
47 | private_data->netfid = netfid; | 47 | private_data->netfid = netfid; |
48 | private_data->pid = current->tgid; | 48 | private_data->pid = current->tgid; |
49 | init_MUTEX(&private_data->fh_sem); | 49 | init_MUTEX(&private_data->fh_sem); |
50 | mutex_init(&private_data->lock_mutex); | 50 | mutex_init(&private_data->lock_mutex); |
51 | INIT_LIST_HEAD(&private_data->llist); | 51 | INIT_LIST_HEAD(&private_data->llist); |
@@ -57,7 +57,7 @@ static inline struct cifsFileInfo *cifs_init_private( | |||
57 | does not tell us which handle the write is for so there can | 57 | does not tell us which handle the write is for so there can |
58 | be a close (overlapping with write) of the filehandle that | 58 | be a close (overlapping with write) of the filehandle that |
59 | cifs_writepages chose to use */ | 59 | cifs_writepages chose to use */ |
60 | atomic_set(&private_data->wrtPending,0); | 60 | atomic_set(&private_data->wrtPending, 0); |
61 | 61 | ||
62 | return private_data; | 62 | return private_data; |
63 | } | 63 | } |
@@ -105,7 +105,7 @@ static inline int cifs_open_inode_helper(struct inode *inode, struct file *file, | |||
105 | in the list so we do not have to walk the | 105 | in the list so we do not have to walk the |
106 | list to search for one in prepare_write */ | 106 | list to search for one in prepare_write */ |
107 | if ((file->f_flags & O_ACCMODE) == O_WRONLY) { | 107 | if ((file->f_flags & O_ACCMODE) == O_WRONLY) { |
108 | list_add_tail(&pCifsFile->flist, | 108 | list_add_tail(&pCifsFile->flist, |
109 | &pCifsInode->openFileList); | 109 | &pCifsInode->openFileList); |
110 | } else { | 110 | } else { |
111 | list_add(&pCifsFile->flist, | 111 | list_add(&pCifsFile->flist, |
@@ -218,9 +218,9 @@ int cifs_open(struct inode *inode, struct file *file) | |||
218 | 218 | ||
219 | /********************************************************************* | 219 | /********************************************************************* |
220 | * open flag mapping table: | 220 | * open flag mapping table: |
221 | * | 221 | * |
222 | * POSIX Flag CIFS Disposition | 222 | * POSIX Flag CIFS Disposition |
223 | * ---------- ---------------- | 223 | * ---------- ---------------- |
224 | * O_CREAT FILE_OPEN_IF | 224 | * O_CREAT FILE_OPEN_IF |
225 | * O_CREAT | O_EXCL FILE_CREATE | 225 | * O_CREAT | O_EXCL FILE_CREATE |
226 | * O_CREAT | O_TRUNC FILE_OVERWRITE_IF | 226 | * O_CREAT | O_TRUNC FILE_OVERWRITE_IF |
@@ -228,12 +228,12 @@ int cifs_open(struct inode *inode, struct file *file) | |||
228 | * none of the above FILE_OPEN | 228 | * none of the above FILE_OPEN |
229 | * | 229 | * |
230 | * Note that there is not a direct match between disposition | 230 | * Note that there is not a direct match between disposition |
231 | * FILE_SUPERSEDE (ie create whether or not file exists although | 231 | * FILE_SUPERSEDE (ie create whether or not file exists although |
232 | * O_CREAT | O_TRUNC is similar but truncates the existing | 232 | * O_CREAT | O_TRUNC is similar but truncates the existing |
233 | * file rather than creating a new file as FILE_SUPERSEDE does | 233 | * file rather than creating a new file as FILE_SUPERSEDE does |
234 | * (which uses the attributes / metadata passed in on open call) | 234 | * (which uses the attributes / metadata passed in on open call) |
235 | *? | 235 | *? |
236 | *? O_SYNC is a reasonable match to CIFS writethrough flag | 236 | *? O_SYNC is a reasonable match to CIFS writethrough flag |
237 | *? and the read write flags match reasonably. O_LARGEFILE | 237 | *? and the read write flags match reasonably. O_LARGEFILE |
238 | *? is irrelevant because largefile support is always used | 238 | *? is irrelevant because largefile support is always used |
239 | *? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, | 239 | *? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, |
@@ -253,8 +253,8 @@ int cifs_open(struct inode *inode, struct file *file) | |||
253 | and calling get_inode_info with returned buf (at least helps | 253 | and calling get_inode_info with returned buf (at least helps |
254 | non-Unix server case) */ | 254 | non-Unix server case) */ |
255 | 255 | ||
256 | /* BB we can not do this if this is the second open of a file | 256 | /* BB we can not do this if this is the second open of a file |
257 | and the first handle has writebehind data, we might be | 257 | and the first handle has writebehind data, we might be |
258 | able to simply do a filemap_fdatawrite/filemap_fdatawait first */ | 258 | able to simply do a filemap_fdatawrite/filemap_fdatawait first */ |
259 | buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); | 259 | buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); |
260 | if (!buf) { | 260 | if (!buf) { |
@@ -263,7 +263,7 @@ int cifs_open(struct inode *inode, struct file *file) | |||
263 | } | 263 | } |
264 | 264 | ||
265 | if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS) | 265 | if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS) |
266 | rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, | 266 | rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, |
267 | desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, | 267 | desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, |
268 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags | 268 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags |
269 | & CIFS_MOUNT_MAP_SPECIAL_CHR); | 269 | & CIFS_MOUNT_MAP_SPECIAL_CHR); |
@@ -300,7 +300,7 @@ int cifs_open(struct inode *inode, struct file *file) | |||
300 | write_unlock(&GlobalSMBSeslock); | 300 | write_unlock(&GlobalSMBSeslock); |
301 | } | 301 | } |
302 | 302 | ||
303 | if (oplock & CIFS_CREATE_ACTION) { | 303 | if (oplock & CIFS_CREATE_ACTION) { |
304 | /* time to set mode which we can not set earlier due to | 304 | /* time to set mode which we can not set earlier due to |
305 | problems creating new read-only files */ | 305 | problems creating new read-only files */ |
306 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { | 306 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { |
@@ -308,7 +308,7 @@ int cifs_open(struct inode *inode, struct file *file) | |||
308 | inode->i_mode, | 308 | inode->i_mode, |
309 | (__u64)-1, (__u64)-1, 0 /* dev */, | 309 | (__u64)-1, (__u64)-1, 0 /* dev */, |
310 | cifs_sb->local_nls, | 310 | cifs_sb->local_nls, |
311 | cifs_sb->mnt_cifs_flags & | 311 | cifs_sb->mnt_cifs_flags & |
312 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 312 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
313 | } else { | 313 | } else { |
314 | /* BB implement via Windows security descriptors eg | 314 | /* BB implement via Windows security descriptors eg |
@@ -345,7 +345,7 @@ static int cifs_reopen_file(struct file *file, int can_flush) | |||
345 | struct cifsTconInfo *pTcon; | 345 | struct cifsTconInfo *pTcon; |
346 | struct cifsFileInfo *pCifsFile; | 346 | struct cifsFileInfo *pCifsFile; |
347 | struct cifsInodeInfo *pCifsInode; | 347 | struct cifsInodeInfo *pCifsInode; |
348 | struct inode * inode; | 348 | struct inode *inode; |
349 | char *full_path = NULL; | 349 | char *full_path = NULL; |
350 | int desiredAccess; | 350 | int desiredAccess; |
351 | int disposition = FILE_OPEN; | 351 | int disposition = FILE_OPEN; |
@@ -372,7 +372,7 @@ static int cifs_reopen_file(struct file *file, int can_flush) | |||
372 | } | 372 | } |
373 | 373 | ||
374 | inode = file->f_path.dentry->d_inode; | 374 | inode = file->f_path.dentry->d_inode; |
375 | if(inode == NULL) { | 375 | if (inode == NULL) { |
376 | cERROR(1, ("inode not valid")); | 376 | cERROR(1, ("inode not valid")); |
377 | dump_stack(); | 377 | dump_stack(); |
378 | rc = -EBADF; | 378 | rc = -EBADF; |
@@ -396,7 +396,7 @@ reopen_error_exit: | |||
396 | } | 396 | } |
397 | 397 | ||
398 | cFYI(1, ("inode = 0x%p file flags 0x%x for %s", | 398 | cFYI(1, ("inode = 0x%p file flags 0x%x for %s", |
399 | inode, file->f_flags,full_path)); | 399 | inode, file->f_flags, full_path)); |
400 | desiredAccess = cifs_convert_flags(file->f_flags); | 400 | desiredAccess = cifs_convert_flags(file->f_flags); |
401 | 401 | ||
402 | if (oplockEnabled) | 402 | if (oplockEnabled) |
@@ -405,14 +405,14 @@ reopen_error_exit: | |||
405 | oplock = FALSE; | 405 | oplock = FALSE; |
406 | 406 | ||
407 | /* Can not refresh inode by passing in file_info buf to be returned | 407 | /* Can not refresh inode by passing in file_info buf to be returned |
408 | by SMBOpen and then calling get_inode_info with returned buf | 408 | by SMBOpen and then calling get_inode_info with returned buf |
409 | since file might have write behind data that needs to be flushed | 409 | since file might have write behind data that needs to be flushed |
410 | and server version of file size can be stale. If we knew for sure | 410 | and server version of file size can be stale. If we knew for sure |
411 | that inode was not dirty locally we could do this */ | 411 | that inode was not dirty locally we could do this */ |
412 | 412 | ||
413 | rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, | 413 | rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, |
414 | CREATE_NOT_DIR, &netfid, &oplock, NULL, | 414 | CREATE_NOT_DIR, &netfid, &oplock, NULL, |
415 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & | 415 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & |
416 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 416 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
417 | if (rc) { | 417 | if (rc) { |
418 | up(&pCifsFile->fh_sem); | 418 | up(&pCifsFile->fh_sem); |
@@ -486,22 +486,22 @@ int cifs_close(struct inode *inode, struct file *file) | |||
486 | already closed */ | 486 | already closed */ |
487 | if (pTcon->tidStatus != CifsNeedReconnect) { | 487 | if (pTcon->tidStatus != CifsNeedReconnect) { |
488 | int timeout = 2; | 488 | int timeout = 2; |
489 | while((atomic_read(&pSMBFile->wrtPending) != 0) | 489 | while ((atomic_read(&pSMBFile->wrtPending) != 0) |
490 | && (timeout < 1000) ) { | 490 | && (timeout < 1000) ) { |
491 | /* Give write a better chance to get to | 491 | /* Give write a better chance to get to |
492 | server ahead of the close. We do not | 492 | server ahead of the close. We do not |
493 | want to add a wait_q here as it would | 493 | want to add a wait_q here as it would |
494 | increase the memory utilization as | 494 | increase the memory utilization as |
495 | the struct would be in each open file, | 495 | the struct would be in each open file, |
496 | but this should give enough time to | 496 | but this should give enough time to |
497 | clear the socket */ | 497 | clear the socket */ |
498 | #ifdef CONFIG_CIFS_DEBUG2 | 498 | #ifdef CONFIG_CIFS_DEBUG2 |
499 | cFYI(1,("close delay, write pending")); | 499 | cFYI(1, ("close delay, write pending")); |
500 | #endif /* DEBUG2 */ | 500 | #endif /* DEBUG2 */ |
501 | msleep(timeout); | 501 | msleep(timeout); |
502 | timeout *= 4; | 502 | timeout *= 4; |
503 | } | 503 | } |
504 | if(atomic_read(&pSMBFile->wrtPending)) | 504 | if (atomic_read(&pSMBFile->wrtPending)) |
505 | cERROR(1,("close with pending writes")); | 505 | cERROR(1,("close with pending writes")); |
506 | rc = CIFSSMBClose(xid, pTcon, | 506 | rc = CIFSSMBClose(xid, pTcon, |
507 | pSMBFile->netfid); | 507 | pSMBFile->netfid); |
@@ -534,7 +534,7 @@ int cifs_close(struct inode *inode, struct file *file) | |||
534 | CIFS_I(inode)->clientCanCacheRead = FALSE; | 534 | CIFS_I(inode)->clientCanCacheRead = FALSE; |
535 | CIFS_I(inode)->clientCanCacheAll = FALSE; | 535 | CIFS_I(inode)->clientCanCacheAll = FALSE; |
536 | } | 536 | } |
537 | if ((rc ==0) && CIFS_I(inode)->write_behind_rc) | 537 | if ((rc == 0) && CIFS_I(inode)->write_behind_rc) |
538 | rc = CIFS_I(inode)->write_behind_rc; | 538 | rc = CIFS_I(inode)->write_behind_rc; |
539 | FreeXid(xid); | 539 | FreeXid(xid); |
540 | return rc; | 540 | return rc; |
@@ -554,7 +554,8 @@ int cifs_closedir(struct inode *inode, struct file *file) | |||
554 | 554 | ||
555 | if (pCFileStruct) { | 555 | if (pCFileStruct) { |
556 | struct cifsTconInfo *pTcon; | 556 | struct cifsTconInfo *pTcon; |
557 | struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); | 557 | struct cifs_sb_info *cifs_sb = |
558 | CIFS_SB(file->f_path.dentry->d_sb); | ||
558 | 559 | ||
559 | pTcon = cifs_sb->tcon; | 560 | pTcon = cifs_sb->tcon; |
560 | 561 | ||
@@ -572,7 +573,7 @@ int cifs_closedir(struct inode *inode, struct file *file) | |||
572 | if (ptmp) { | 573 | if (ptmp) { |
573 | cFYI(1, ("closedir free smb buf in srch struct")); | 574 | cFYI(1, ("closedir free smb buf in srch struct")); |
574 | pCFileStruct->srch_inf.ntwrk_buf_start = NULL; | 575 | pCFileStruct->srch_inf.ntwrk_buf_start = NULL; |
575 | if(pCFileStruct->srch_inf.smallBuf) | 576 | if (pCFileStruct->srch_inf.smallBuf) |
576 | cifs_small_buf_release(ptmp); | 577 | cifs_small_buf_release(ptmp); |
577 | else | 578 | else |
578 | cifs_buf_release(ptmp); | 579 | cifs_buf_release(ptmp); |
@@ -594,7 +595,8 @@ int cifs_closedir(struct inode *inode, struct file *file) | |||
594 | static int store_file_lock(struct cifsFileInfo *fid, __u64 len, | 595 | static int store_file_lock(struct cifsFileInfo *fid, __u64 len, |
595 | __u64 offset, __u8 lockType) | 596 | __u64 offset, __u8 lockType) |
596 | { | 597 | { |
597 | struct cifsLockInfo *li = kmalloc(sizeof(struct cifsLockInfo), GFP_KERNEL); | 598 | struct cifsLockInfo *li = |
599 | kmalloc(sizeof(struct cifsLockInfo), GFP_KERNEL); | ||
598 | if (li == NULL) | 600 | if (li == NULL) |
599 | return -ENOMEM; | 601 | return -ENOMEM; |
600 | li->offset = offset; | 602 | li->offset = offset; |
@@ -625,8 +627,8 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) | |||
625 | 627 | ||
626 | cFYI(1, ("Lock parm: 0x%x flockflags: " | 628 | cFYI(1, ("Lock parm: 0x%x flockflags: " |
627 | "0x%x flocktype: 0x%x start: %lld end: %lld", | 629 | "0x%x flocktype: 0x%x start: %lld end: %lld", |
628 | cmd, pfLock->fl_flags, pfLock->fl_type, pfLock->fl_start, | 630 | cmd, pfLock->fl_flags, pfLock->fl_type, pfLock->fl_start, |
629 | pfLock->fl_end)); | 631 | pfLock->fl_end)); |
630 | 632 | ||
631 | if (pfLock->fl_flags & FL_POSIX) | 633 | if (pfLock->fl_flags & FL_POSIX) |
632 | cFYI(1, ("Posix")); | 634 | cFYI(1, ("Posix")); |
@@ -641,7 +643,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) | |||
641 | "not implemented yet")); | 643 | "not implemented yet")); |
642 | if (pfLock->fl_flags & FL_LEASE) | 644 | if (pfLock->fl_flags & FL_LEASE) |
643 | cFYI(1, ("Lease on file - not implemented yet")); | 645 | cFYI(1, ("Lease on file - not implemented yet")); |
644 | if (pfLock->fl_flags & | 646 | if (pfLock->fl_flags & |
645 | (~(FL_POSIX | FL_FLOCK | FL_SLEEP | FL_ACCESS | FL_LEASE))) | 647 | (~(FL_POSIX | FL_FLOCK | FL_SLEEP | FL_ACCESS | FL_LEASE))) |
646 | cFYI(1, ("Unknown lock flags 0x%x", pfLock->fl_flags)); | 648 | cFYI(1, ("Unknown lock flags 0x%x", pfLock->fl_flags)); |
647 | 649 | ||
@@ -683,9 +685,9 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) | |||
683 | account for negative length which we can not accept over the | 685 | account for negative length which we can not accept over the |
684 | wire */ | 686 | wire */ |
685 | if (IS_GETLK(cmd)) { | 687 | if (IS_GETLK(cmd)) { |
686 | if(posix_locking) { | 688 | if (posix_locking) { |
687 | int posix_lock_type; | 689 | int posix_lock_type; |
688 | if(lockType & LOCKING_ANDX_SHARED_LOCK) | 690 | if (lockType & LOCKING_ANDX_SHARED_LOCK) |
689 | posix_lock_type = CIFS_RDLCK; | 691 | posix_lock_type = CIFS_RDLCK; |
690 | else | 692 | else |
691 | posix_lock_type = CIFS_WRLCK; | 693 | posix_lock_type = CIFS_WRLCK; |
@@ -700,7 +702,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) | |||
700 | rc = CIFSSMBLock(xid, pTcon, netfid, length, pfLock->fl_start, | 702 | rc = CIFSSMBLock(xid, pTcon, netfid, length, pfLock->fl_start, |
701 | 0, 1, lockType, 0 /* wait flag */ ); | 703 | 0, 1, lockType, 0 /* wait flag */ ); |
702 | if (rc == 0) { | 704 | if (rc == 0) { |
703 | rc = CIFSSMBLock(xid, pTcon, netfid, length, | 705 | rc = CIFSSMBLock(xid, pTcon, netfid, length, |
704 | pfLock->fl_start, 1 /* numUnlock */ , | 706 | pfLock->fl_start, 1 /* numUnlock */ , |
705 | 0 /* numLock */ , lockType, | 707 | 0 /* numLock */ , lockType, |
706 | 0 /* wait flag */ ); | 708 | 0 /* wait flag */ ); |
@@ -729,22 +731,24 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) | |||
729 | 731 | ||
730 | if (posix_locking) { | 732 | if (posix_locking) { |
731 | int posix_lock_type; | 733 | int posix_lock_type; |
732 | if(lockType & LOCKING_ANDX_SHARED_LOCK) | 734 | if (lockType & LOCKING_ANDX_SHARED_LOCK) |
733 | posix_lock_type = CIFS_RDLCK; | 735 | posix_lock_type = CIFS_RDLCK; |
734 | else | 736 | else |
735 | posix_lock_type = CIFS_WRLCK; | 737 | posix_lock_type = CIFS_WRLCK; |
736 | 738 | ||
737 | if(numUnlock == 1) | 739 | if (numUnlock == 1) |
738 | posix_lock_type = CIFS_UNLCK; | 740 | posix_lock_type = CIFS_UNLCK; |
739 | 741 | ||
740 | rc = CIFSSMBPosixLock(xid, pTcon, netfid, 0 /* set */, | 742 | rc = CIFSSMBPosixLock(xid, pTcon, netfid, 0 /* set */, |
741 | length, pfLock, | 743 | length, pfLock, |
742 | posix_lock_type, wait_flag); | 744 | posix_lock_type, wait_flag); |
743 | } else { | 745 | } else { |
744 | struct cifsFileInfo *fid = (struct cifsFileInfo *)file->private_data; | 746 | struct cifsFileInfo *fid = |
747 | (struct cifsFileInfo *)file->private_data; | ||
745 | 748 | ||
746 | if (numLock) { | 749 | if (numLock) { |
747 | rc = CIFSSMBLock(xid, pTcon, netfid, length, pfLock->fl_start, | 750 | rc = CIFSSMBLock(xid, pTcon, netfid, length, |
751 | pfLock->fl_start, | ||
748 | 0, numLock, lockType, wait_flag); | 752 | 0, numLock, lockType, wait_flag); |
749 | 753 | ||
750 | if (rc == 0) { | 754 | if (rc == 0) { |
@@ -763,7 +767,8 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) | |||
763 | list_for_each_entry_safe(li, tmp, &fid->llist, llist) { | 767 | list_for_each_entry_safe(li, tmp, &fid->llist, llist) { |
764 | if (pfLock->fl_start <= li->offset && | 768 | if (pfLock->fl_start <= li->offset && |
765 | length >= li->length) { | 769 | length >= li->length) { |
766 | stored_rc = CIFSSMBLock(xid, pTcon, netfid, | 770 | stored_rc = CIFSSMBLock(xid, pTcon, |
771 | netfid, | ||
767 | li->length, li->offset, | 772 | li->length, li->offset, |
768 | 1, 0, li->type, FALSE); | 773 | 1, 0, li->type, FALSE); |
769 | if (stored_rc) | 774 | if (stored_rc) |
@@ -824,7 +829,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, | |||
824 | and blocked, and the file has been freed on us while | 829 | and blocked, and the file has been freed on us while |
825 | we blocked so return what we managed to write */ | 830 | we blocked so return what we managed to write */ |
826 | return total_written; | 831 | return total_written; |
827 | } | 832 | } |
828 | if (open_file->closePend) { | 833 | if (open_file->closePend) { |
829 | FreeXid(xid); | 834 | FreeXid(xid); |
830 | if (total_written) | 835 | if (total_written) |
@@ -867,8 +872,8 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, | |||
867 | /* since the write may have blocked check these pointers again */ | 872 | /* since the write may have blocked check these pointers again */ |
868 | if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) { | 873 | if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) { |
869 | struct inode *inode = file->f_path.dentry->d_inode; | 874 | struct inode *inode = file->f_path.dentry->d_inode; |
870 | /* Do not update local mtime - server will set its actual value on write | 875 | /* Do not update local mtime - server will set its actual value on write |
871 | * inode->i_ctime = inode->i_mtime = | 876 | * inode->i_ctime = inode->i_mtime = |
872 | * current_fs_time(inode->i_sb);*/ | 877 | * current_fs_time(inode->i_sb);*/ |
873 | if (total_written > 0) { | 878 | if (total_written > 0) { |
874 | spin_lock(&inode->i_lock); | 879 | spin_lock(&inode->i_lock); |
@@ -877,7 +882,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, | |||
877 | *poffset); | 882 | *poffset); |
878 | spin_unlock(&inode->i_lock); | 883 | spin_unlock(&inode->i_lock); |
879 | } | 884 | } |
880 | mark_inode_dirty_sync(file->f_path.dentry->d_inode); | 885 | mark_inode_dirty_sync(file->f_path.dentry->d_inode); |
881 | } | 886 | } |
882 | FreeXid(xid); | 887 | FreeXid(xid); |
883 | return total_written; | 888 | return total_written; |
@@ -898,7 +903,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data, | |||
898 | 903 | ||
899 | pTcon = cifs_sb->tcon; | 904 | pTcon = cifs_sb->tcon; |
900 | 905 | ||
901 | cFYI(1,("write %zd bytes to offset %lld of %s", write_size, | 906 | cFYI(1, ("write %zd bytes to offset %lld of %s", write_size, |
902 | *poffset, file->f_path.dentry->d_name.name)); | 907 | *poffset, file->f_path.dentry->d_name.name)); |
903 | 908 | ||
904 | if (file->private_data == NULL) | 909 | if (file->private_data == NULL) |
@@ -921,10 +926,10 @@ static ssize_t cifs_write(struct file *file, const char *write_data, | |||
921 | FreeXid(xid); | 926 | FreeXid(xid); |
922 | /* if we have gotten here we have written some data | 927 | /* if we have gotten here we have written some data |
923 | and blocked, and the file has been freed on us | 928 | and blocked, and the file has been freed on us |
924 | while we blocked so return what we managed to | 929 | while we blocked so return what we managed to |
925 | write */ | 930 | write */ |
926 | return total_written; | 931 | return total_written; |
927 | } | 932 | } |
928 | if (open_file->closePend) { | 933 | if (open_file->closePend) { |
929 | FreeXid(xid); | 934 | FreeXid(xid); |
930 | if (total_written) | 935 | if (total_written) |
@@ -935,14 +940,14 @@ static ssize_t cifs_write(struct file *file, const char *write_data, | |||
935 | if (open_file->invalidHandle) { | 940 | if (open_file->invalidHandle) { |
936 | /* we could deadlock if we called | 941 | /* we could deadlock if we called |
937 | filemap_fdatawait from here so tell | 942 | filemap_fdatawait from here so tell |
938 | reopen_file not to flush data to | 943 | reopen_file not to flush data to |
939 | server now */ | 944 | server now */ |
940 | rc = cifs_reopen_file(file, FALSE); | 945 | rc = cifs_reopen_file(file, FALSE); |
941 | if (rc != 0) | 946 | if (rc != 0) |
942 | break; | 947 | break; |
943 | } | 948 | } |
944 | if(experimEnabled || (pTcon->ses->server && | 949 | if (experimEnabled || (pTcon->ses->server && |
945 | ((pTcon->ses->server->secMode & | 950 | ((pTcon->ses->server->secMode & |
946 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 951 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
947 | == 0))) { | 952 | == 0))) { |
948 | struct kvec iov[2]; | 953 | struct kvec iov[2]; |
@@ -976,7 +981,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data, | |||
976 | } | 981 | } |
977 | } else | 982 | } else |
978 | *poffset += bytes_written; | 983 | *poffset += bytes_written; |
979 | long_op = FALSE; /* subsequent writes fast - | 984 | long_op = FALSE; /* subsequent writes fast - |
980 | 15 seconds is plenty */ | 985 | 15 seconds is plenty */ |
981 | } | 986 | } |
982 | 987 | ||
@@ -1009,8 +1014,8 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode) | |||
1009 | the VFS or MM) should not happen but we had reports of on oops (due to | 1014 | the VFS or MM) should not happen but we had reports of on oops (due to |
1010 | it being zero) during stress testcases so we need to check for it */ | 1015 | it being zero) during stress testcases so we need to check for it */ |
1011 | 1016 | ||
1012 | if(cifs_inode == NULL) { | 1017 | if (cifs_inode == NULL) { |
1013 | cERROR(1,("Null inode passed to cifs_writeable_file")); | 1018 | cERROR(1, ("Null inode passed to cifs_writeable_file")); |
1014 | dump_stack(); | 1019 | dump_stack(); |
1015 | return NULL; | 1020 | return NULL; |
1016 | } | 1021 | } |
@@ -1024,13 +1029,13 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode) | |||
1024 | (open_file->pfile->f_flags & O_WRONLY))) { | 1029 | (open_file->pfile->f_flags & O_WRONLY))) { |
1025 | atomic_inc(&open_file->wrtPending); | 1030 | atomic_inc(&open_file->wrtPending); |
1026 | read_unlock(&GlobalSMBSeslock); | 1031 | read_unlock(&GlobalSMBSeslock); |
1027 | if((open_file->invalidHandle) && | 1032 | if ((open_file->invalidHandle) && |
1028 | (!open_file->closePend) /* BB fixme -since the second clause can not be true remove it BB */) { | 1033 | (!open_file->closePend) /* BB fixme -since the second clause can not be true remove it BB */) { |
1029 | rc = cifs_reopen_file(open_file->pfile, FALSE); | 1034 | rc = cifs_reopen_file(open_file->pfile, FALSE); |
1030 | /* if it fails, try another handle - might be */ | 1035 | /* if it fails, try another handle - might be */ |
1031 | /* dangerous to hold up writepages with retry */ | 1036 | /* dangerous to hold up writepages with retry */ |
1032 | if(rc) { | 1037 | if (rc) { |
1033 | cFYI(1,("failed on reopen file in wp")); | 1038 | cFYI(1, ("failed on reopen file in wp")); |
1034 | read_lock(&GlobalSMBSeslock); | 1039 | read_lock(&GlobalSMBSeslock); |
1035 | /* can not use this handle, no write | 1040 | /* can not use this handle, no write |
1036 | pending on this one after all */ | 1041 | pending on this one after all */ |
@@ -1082,7 +1087,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to) | |||
1082 | 1087 | ||
1083 | /* check to make sure that we are not extending the file */ | 1088 | /* check to make sure that we are not extending the file */ |
1084 | if (mapping->host->i_size - offset < (loff_t)to) | 1089 | if (mapping->host->i_size - offset < (loff_t)to) |
1085 | to = (unsigned)(mapping->host->i_size - offset); | 1090 | to = (unsigned)(mapping->host->i_size - offset); |
1086 | 1091 | ||
1087 | open_file = find_writable_file(CIFS_I(mapping->host)); | 1092 | open_file = find_writable_file(CIFS_I(mapping->host)); |
1088 | if (open_file) { | 1093 | if (open_file) { |
@@ -1116,8 +1121,8 @@ static int cifs_writepages(struct address_space *mapping, | |||
1116 | int done = 0; | 1121 | int done = 0; |
1117 | pgoff_t end; | 1122 | pgoff_t end; |
1118 | pgoff_t index; | 1123 | pgoff_t index; |
1119 | int range_whole = 0; | 1124 | int range_whole = 0; |
1120 | struct kvec * iov; | 1125 | struct kvec *iov; |
1121 | int len; | 1126 | int len; |
1122 | int n_iov = 0; | 1127 | int n_iov = 0; |
1123 | pgoff_t next; | 1128 | pgoff_t next; |
@@ -1139,14 +1144,14 @@ static int cifs_writepages(struct address_space *mapping, | |||
1139 | if (cifs_sb->wsize < PAGE_CACHE_SIZE) | 1144 | if (cifs_sb->wsize < PAGE_CACHE_SIZE) |
1140 | return generic_writepages(mapping, wbc); | 1145 | return generic_writepages(mapping, wbc); |
1141 | 1146 | ||
1142 | if((cifs_sb->tcon->ses) && (cifs_sb->tcon->ses->server)) | 1147 | if ((cifs_sb->tcon->ses) && (cifs_sb->tcon->ses->server)) |
1143 | if(cifs_sb->tcon->ses->server->secMode & | 1148 | if (cifs_sb->tcon->ses->server->secMode & |
1144 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 1149 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) |
1145 | if(!experimEnabled) | 1150 | if (!experimEnabled) |
1146 | return generic_writepages(mapping, wbc); | 1151 | return generic_writepages(mapping, wbc); |
1147 | 1152 | ||
1148 | iov = kmalloc(32 * sizeof(struct kvec), GFP_KERNEL); | 1153 | iov = kmalloc(32 * sizeof(struct kvec), GFP_KERNEL); |
1149 | if(iov == NULL) | 1154 | if (iov == NULL) |
1150 | return generic_writepages(mapping, wbc); | 1155 | return generic_writepages(mapping, wbc); |
1151 | 1156 | ||
1152 | 1157 | ||
@@ -1295,8 +1300,8 @@ retry: | |||
1295 | success rc but too little data written? */ | 1300 | success rc but too little data written? */ |
1296 | /* BB investigate retry logic on temporary | 1301 | /* BB investigate retry logic on temporary |
1297 | server crash cases and how recovery works | 1302 | server crash cases and how recovery works |
1298 | when page marked as error */ | 1303 | when page marked as error */ |
1299 | if(rc) | 1304 | if (rc) |
1300 | SetPageError(page); | 1305 | SetPageError(page); |
1301 | kunmap(page); | 1306 | kunmap(page); |
1302 | unlock_page(page); | 1307 | unlock_page(page); |
@@ -1326,7 +1331,7 @@ retry: | |||
1326 | return rc; | 1331 | return rc; |
1327 | } | 1332 | } |
1328 | 1333 | ||
1329 | static int cifs_writepage(struct page* page, struct writeback_control *wbc) | 1334 | static int cifs_writepage(struct page *page, struct writeback_control *wbc) |
1330 | { | 1335 | { |
1331 | int rc = -EFAULT; | 1336 | int rc = -EFAULT; |
1332 | int xid; | 1337 | int xid; |
@@ -1334,7 +1339,7 @@ static int cifs_writepage(struct page* page, struct writeback_control *wbc) | |||
1334 | xid = GetXid(); | 1339 | xid = GetXid(); |
1335 | /* BB add check for wbc flags */ | 1340 | /* BB add check for wbc flags */ |
1336 | page_cache_get(page); | 1341 | page_cache_get(page); |
1337 | if (!PageUptodate(page)) { | 1342 | if (!PageUptodate(page)) { |
1338 | cFYI(1, ("ppw - page not up to date")); | 1343 | cFYI(1, ("ppw - page not up to date")); |
1339 | } | 1344 | } |
1340 | 1345 | ||
@@ -1348,7 +1353,7 @@ static int cifs_writepage(struct page* page, struct writeback_control *wbc) | |||
1348 | * Just unlocking the page will cause the radix tree tag-bits | 1353 | * Just unlocking the page will cause the radix tree tag-bits |
1349 | * to fail to update with the state of the page correctly. | 1354 | * to fail to update with the state of the page correctly. |
1350 | */ | 1355 | */ |
1351 | set_page_writeback(page); | 1356 | set_page_writeback(page); |
1352 | rc = cifs_partialpagewrite(page, 0, PAGE_CACHE_SIZE); | 1357 | rc = cifs_partialpagewrite(page, 0, PAGE_CACHE_SIZE); |
1353 | SetPageUptodate(page); /* BB add check for error and Clearuptodate? */ | 1358 | SetPageUptodate(page); /* BB add check for error and Clearuptodate? */ |
1354 | unlock_page(page); | 1359 | unlock_page(page); |
@@ -1368,7 +1373,7 @@ static int cifs_commit_write(struct file *file, struct page *page, | |||
1368 | char *page_data; | 1373 | char *page_data; |
1369 | 1374 | ||
1370 | xid = GetXid(); | 1375 | xid = GetXid(); |
1371 | cFYI(1, ("commit write for page %p up to position %lld for %d", | 1376 | cFYI(1, ("commit write for page %p up to position %lld for %d", |
1372 | page, position, to)); | 1377 | page, position, to)); |
1373 | spin_lock(&inode->i_lock); | 1378 | spin_lock(&inode->i_lock); |
1374 | if (position > inode->i_size) { | 1379 | if (position > inode->i_size) { |
@@ -1396,7 +1401,7 @@ static int cifs_commit_write(struct file *file, struct page *page, | |||
1396 | rc = 0; | 1401 | rc = 0; |
1397 | /* else if (rc < 0) should we set writebehind rc? */ | 1402 | /* else if (rc < 0) should we set writebehind rc? */ |
1398 | kunmap(page); | 1403 | kunmap(page); |
1399 | } else { | 1404 | } else { |
1400 | set_page_dirty(page); | 1405 | set_page_dirty(page); |
1401 | } | 1406 | } |
1402 | 1407 | ||
@@ -1412,7 +1417,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync) | |||
1412 | 1417 | ||
1413 | xid = GetXid(); | 1418 | xid = GetXid(); |
1414 | 1419 | ||
1415 | cFYI(1, ("Sync file - name: %s datasync: 0x%x", | 1420 | cFYI(1, ("Sync file - name: %s datasync: 0x%x", |
1416 | dentry->d_name.name, datasync)); | 1421 | dentry->d_name.name, datasync)); |
1417 | 1422 | ||
1418 | rc = filemap_fdatawrite(inode->i_mapping); | 1423 | rc = filemap_fdatawrite(inode->i_mapping); |
@@ -1438,7 +1443,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync) | |||
1438 | if (!inode) | 1443 | if (!inode) |
1439 | return; */ | 1444 | return; */ |
1440 | 1445 | ||
1441 | /* fill in rpages then | 1446 | /* fill in rpages then |
1442 | result = cifs_pagein_inode(inode, index, rpages); */ /* BB finish */ | 1447 | result = cifs_pagein_inode(inode, index, rpages); */ /* BB finish */ |
1443 | 1448 | ||
1444 | /* cFYI(1, ("rpages is %d for sync page of Index %ld", rpages, index)); | 1449 | /* cFYI(1, ("rpages is %d for sync page of Index %ld", rpages, index)); |
@@ -1456,7 +1461,7 @@ int cifs_fsync(struct file *file, struct dentry *dentry, int datasync) | |||
1456 | */ | 1461 | */ |
1457 | int cifs_flush(struct file *file, fl_owner_t id) | 1462 | int cifs_flush(struct file *file, fl_owner_t id) |
1458 | { | 1463 | { |
1459 | struct inode * inode = file->f_path.dentry->d_inode; | 1464 | struct inode *inode = file->f_path.dentry->d_inode; |
1460 | int rc = 0; | 1465 | int rc = 0; |
1461 | 1466 | ||
1462 | /* Rather than do the steps manually: | 1467 | /* Rather than do the steps manually: |
@@ -1472,7 +1477,7 @@ int cifs_flush(struct file *file, fl_owner_t id) | |||
1472 | if (!rc) /* reset wb rc if we were able to write out dirty pages */ | 1477 | if (!rc) /* reset wb rc if we were able to write out dirty pages */ |
1473 | CIFS_I(inode)->write_behind_rc = 0; | 1478 | CIFS_I(inode)->write_behind_rc = 0; |
1474 | 1479 | ||
1475 | cFYI(1, ("Flush inode %p file %p rc %d",inode,file,rc)); | 1480 | cFYI(1, ("Flush inode %p file %p rc %d", inode, file, rc)); |
1476 | 1481 | ||
1477 | return rc; | 1482 | return rc; |
1478 | } | 1483 | } |
@@ -1508,13 +1513,13 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, | |||
1508 | for (total_read = 0, current_offset = read_data; | 1513 | for (total_read = 0, current_offset = read_data; |
1509 | read_size > total_read; | 1514 | read_size > total_read; |
1510 | total_read += bytes_read, current_offset += bytes_read) { | 1515 | total_read += bytes_read, current_offset += bytes_read) { |
1511 | current_read_size = min_t(const int, read_size - total_read, | 1516 | current_read_size = min_t(const int, read_size - total_read, |
1512 | cifs_sb->rsize); | 1517 | cifs_sb->rsize); |
1513 | rc = -EAGAIN; | 1518 | rc = -EAGAIN; |
1514 | smb_read_data = NULL; | 1519 | smb_read_data = NULL; |
1515 | while (rc == -EAGAIN) { | 1520 | while (rc == -EAGAIN) { |
1516 | int buf_type = CIFS_NO_BUFFER; | 1521 | int buf_type = CIFS_NO_BUFFER; |
1517 | if ((open_file->invalidHandle) && | 1522 | if ((open_file->invalidHandle) && |
1518 | (!open_file->closePend)) { | 1523 | (!open_file->closePend)) { |
1519 | rc = cifs_reopen_file(file, TRUE); | 1524 | rc = cifs_reopen_file(file, TRUE); |
1520 | if (rc != 0) | 1525 | if (rc != 0) |
@@ -1535,9 +1540,9 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, | |||
1535 | rc = -EFAULT; | 1540 | rc = -EFAULT; |
1536 | } | 1541 | } |
1537 | 1542 | ||
1538 | if(buf_type == CIFS_SMALL_BUFFER) | 1543 | if (buf_type == CIFS_SMALL_BUFFER) |
1539 | cifs_small_buf_release(smb_read_data); | 1544 | cifs_small_buf_release(smb_read_data); |
1540 | else if(buf_type == CIFS_LARGE_BUFFER) | 1545 | else if (buf_type == CIFS_LARGE_BUFFER) |
1541 | cifs_buf_release(smb_read_data); | 1546 | cifs_buf_release(smb_read_data); |
1542 | smb_read_data = NULL; | 1547 | smb_read_data = NULL; |
1543 | } | 1548 | } |
@@ -1586,21 +1591,21 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, | |||
1586 | if ((file->f_flags & O_ACCMODE) == O_WRONLY) | 1591 | if ((file->f_flags & O_ACCMODE) == O_WRONLY) |
1587 | cFYI(1, ("attempting read on write only file instance")); | 1592 | cFYI(1, ("attempting read on write only file instance")); |
1588 | 1593 | ||
1589 | for (total_read = 0, current_offset = read_data; | 1594 | for (total_read = 0, current_offset = read_data; |
1590 | read_size > total_read; | 1595 | read_size > total_read; |
1591 | total_read += bytes_read, current_offset += bytes_read) { | 1596 | total_read += bytes_read, current_offset += bytes_read) { |
1592 | current_read_size = min_t(const int, read_size - total_read, | 1597 | current_read_size = min_t(const int, read_size - total_read, |
1593 | cifs_sb->rsize); | 1598 | cifs_sb->rsize); |
1594 | /* For windows me and 9x we do not want to request more | 1599 | /* For windows me and 9x we do not want to request more |
1595 | than it negotiated since it will refuse the read then */ | 1600 | than it negotiated since it will refuse the read then */ |
1596 | if((pTcon->ses) && | 1601 | if ((pTcon->ses) && |
1597 | !(pTcon->ses->capabilities & CAP_LARGE_FILES)) { | 1602 | !(pTcon->ses->capabilities & CAP_LARGE_FILES)) { |
1598 | current_read_size = min_t(const int, current_read_size, | 1603 | current_read_size = min_t(const int, current_read_size, |
1599 | pTcon->ses->server->maxBuf - 128); | 1604 | pTcon->ses->server->maxBuf - 128); |
1600 | } | 1605 | } |
1601 | rc = -EAGAIN; | 1606 | rc = -EAGAIN; |
1602 | while (rc == -EAGAIN) { | 1607 | while (rc == -EAGAIN) { |
1603 | if ((open_file->invalidHandle) && | 1608 | if ((open_file->invalidHandle) && |
1604 | (!open_file->closePend)) { | 1609 | (!open_file->closePend)) { |
1605 | rc = cifs_reopen_file(file, TRUE); | 1610 | rc = cifs_reopen_file(file, TRUE); |
1606 | if (rc != 0) | 1611 | if (rc != 0) |
@@ -1646,7 +1651,7 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma) | |||
1646 | } | 1651 | } |
1647 | 1652 | ||
1648 | 1653 | ||
1649 | static void cifs_copy_cache_pages(struct address_space *mapping, | 1654 | static void cifs_copy_cache_pages(struct address_space *mapping, |
1650 | struct list_head *pages, int bytes_read, char *data, | 1655 | struct list_head *pages, int bytes_read, char *data, |
1651 | struct pagevec *plru_pvec) | 1656 | struct pagevec *plru_pvec) |
1652 | { | 1657 | { |
@@ -1669,12 +1674,12 @@ static void cifs_copy_cache_pages(struct address_space *mapping, | |||
1669 | continue; | 1674 | continue; |
1670 | } | 1675 | } |
1671 | 1676 | ||
1672 | target = kmap_atomic(page,KM_USER0); | 1677 | target = kmap_atomic(page, KM_USER0); |
1673 | 1678 | ||
1674 | if (PAGE_CACHE_SIZE > bytes_read) { | 1679 | if (PAGE_CACHE_SIZE > bytes_read) { |
1675 | memcpy(target, data, bytes_read); | 1680 | memcpy(target, data, bytes_read); |
1676 | /* zero the tail end of this partial page */ | 1681 | /* zero the tail end of this partial page */ |
1677 | memset(target + bytes_read, 0, | 1682 | memset(target + bytes_read, 0, |
1678 | PAGE_CACHE_SIZE - bytes_read); | 1683 | PAGE_CACHE_SIZE - bytes_read); |
1679 | bytes_read = 0; | 1684 | bytes_read = 0; |
1680 | } else { | 1685 | } else { |
@@ -1703,7 +1708,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, | |||
1703 | struct cifs_sb_info *cifs_sb; | 1708 | struct cifs_sb_info *cifs_sb; |
1704 | struct cifsTconInfo *pTcon; | 1709 | struct cifsTconInfo *pTcon; |
1705 | int bytes_read = 0; | 1710 | int bytes_read = 0; |
1706 | unsigned int read_size,i; | 1711 | unsigned int read_size, i; |
1707 | char *smb_read_data = NULL; | 1712 | char *smb_read_data = NULL; |
1708 | struct smb_com_read_rsp *pSMBr; | 1713 | struct smb_com_read_rsp *pSMBr; |
1709 | struct pagevec lru_pvec; | 1714 | struct pagevec lru_pvec; |
@@ -1721,8 +1726,8 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, | |||
1721 | 1726 | ||
1722 | pagevec_init(&lru_pvec, 0); | 1727 | pagevec_init(&lru_pvec, 0); |
1723 | #ifdef CONFIG_CIFS_DEBUG2 | 1728 | #ifdef CONFIG_CIFS_DEBUG2 |
1724 | cFYI(1,("rpages: num pages %d", num_pages)); | 1729 | cFYI(1, ("rpages: num pages %d", num_pages)); |
1725 | #endif | 1730 | #endif |
1726 | for (i = 0; i < num_pages; ) { | 1731 | for (i = 0; i < num_pages; ) { |
1727 | unsigned contig_pages; | 1732 | unsigned contig_pages; |
1728 | struct page *tmp_page; | 1733 | struct page *tmp_page; |
@@ -1736,14 +1741,14 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, | |||
1736 | 1741 | ||
1737 | /* count adjacent pages that we will read into */ | 1742 | /* count adjacent pages that we will read into */ |
1738 | contig_pages = 0; | 1743 | contig_pages = 0; |
1739 | expected_index = | 1744 | expected_index = |
1740 | list_entry(page_list->prev, struct page, lru)->index; | 1745 | list_entry(page_list->prev, struct page, lru)->index; |
1741 | list_for_each_entry_reverse(tmp_page,page_list,lru) { | 1746 | list_for_each_entry_reverse(tmp_page, page_list, lru) { |
1742 | if (tmp_page->index == expected_index) { | 1747 | if (tmp_page->index == expected_index) { |
1743 | contig_pages++; | 1748 | contig_pages++; |
1744 | expected_index++; | 1749 | expected_index++; |
1745 | } else | 1750 | } else |
1746 | break; | 1751 | break; |
1747 | } | 1752 | } |
1748 | if (contig_pages + i > num_pages) | 1753 | if (contig_pages + i > num_pages) |
1749 | contig_pages = num_pages - i; | 1754 | contig_pages = num_pages - i; |
@@ -1756,12 +1761,12 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, | |||
1756 | read_size = min_t(const unsigned int, read_size, | 1761 | read_size = min_t(const unsigned int, read_size, |
1757 | cifs_sb->rsize & PAGE_CACHE_MASK); | 1762 | cifs_sb->rsize & PAGE_CACHE_MASK); |
1758 | #ifdef CONFIG_CIFS_DEBUG2 | 1763 | #ifdef CONFIG_CIFS_DEBUG2 |
1759 | cFYI(1,("rpages: read size 0x%x contiguous pages %d", | 1764 | cFYI(1, ("rpages: read size 0x%x contiguous pages %d", |
1760 | read_size, contig_pages)); | 1765 | read_size, contig_pages)); |
1761 | #endif | 1766 | #endif |
1762 | rc = -EAGAIN; | 1767 | rc = -EAGAIN; |
1763 | while (rc == -EAGAIN) { | 1768 | while (rc == -EAGAIN) { |
1764 | if ((open_file->invalidHandle) && | 1769 | if ((open_file->invalidHandle) && |
1765 | (!open_file->closePend)) { | 1770 | (!open_file->closePend)) { |
1766 | rc = cifs_reopen_file(file, TRUE); | 1771 | rc = cifs_reopen_file(file, TRUE); |
1767 | if (rc != 0) | 1772 | if (rc != 0) |
@@ -1774,11 +1779,11 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, | |||
1774 | &bytes_read, &smb_read_data, | 1779 | &bytes_read, &smb_read_data, |
1775 | &buf_type); | 1780 | &buf_type); |
1776 | /* BB more RC checks ? */ | 1781 | /* BB more RC checks ? */ |
1777 | if (rc== -EAGAIN) { | 1782 | if (rc == -EAGAIN) { |
1778 | if (smb_read_data) { | 1783 | if (smb_read_data) { |
1779 | if(buf_type == CIFS_SMALL_BUFFER) | 1784 | if (buf_type == CIFS_SMALL_BUFFER) |
1780 | cifs_small_buf_release(smb_read_data); | 1785 | cifs_small_buf_release(smb_read_data); |
1781 | else if(buf_type == CIFS_LARGE_BUFFER) | 1786 | else if (buf_type == CIFS_LARGE_BUFFER) |
1782 | cifs_buf_release(smb_read_data); | 1787 | cifs_buf_release(smb_read_data); |
1783 | smb_read_data = NULL; | 1788 | smb_read_data = NULL; |
1784 | } | 1789 | } |
@@ -1799,10 +1804,10 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, | |||
1799 | if ((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) { | 1804 | if ((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) { |
1800 | i++; /* account for partial page */ | 1805 | i++; /* account for partial page */ |
1801 | 1806 | ||
1802 | /* server copy of file can have smaller size | 1807 | /* server copy of file can have smaller size |
1803 | than client */ | 1808 | than client */ |
1804 | /* BB do we need to verify this common case ? | 1809 | /* BB do we need to verify this common case ? |
1805 | this case is ok - if we are at server EOF | 1810 | this case is ok - if we are at server EOF |
1806 | we will hit it on next read */ | 1811 | we will hit it on next read */ |
1807 | 1812 | ||
1808 | /* break; */ | 1813 | /* break; */ |
@@ -1811,14 +1816,14 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, | |||
1811 | cFYI(1, ("No bytes read (%d) at offset %lld . " | 1816 | cFYI(1, ("No bytes read (%d) at offset %lld . " |
1812 | "Cleaning remaining pages from readahead list", | 1817 | "Cleaning remaining pages from readahead list", |
1813 | bytes_read, offset)); | 1818 | bytes_read, offset)); |
1814 | /* BB turn off caching and do new lookup on | 1819 | /* BB turn off caching and do new lookup on |
1815 | file size at server? */ | 1820 | file size at server? */ |
1816 | break; | 1821 | break; |
1817 | } | 1822 | } |
1818 | if (smb_read_data) { | 1823 | if (smb_read_data) { |
1819 | if(buf_type == CIFS_SMALL_BUFFER) | 1824 | if (buf_type == CIFS_SMALL_BUFFER) |
1820 | cifs_small_buf_release(smb_read_data); | 1825 | cifs_small_buf_release(smb_read_data); |
1821 | else if(buf_type == CIFS_LARGE_BUFFER) | 1826 | else if (buf_type == CIFS_LARGE_BUFFER) |
1822 | cifs_buf_release(smb_read_data); | 1827 | cifs_buf_release(smb_read_data); |
1823 | smb_read_data = NULL; | 1828 | smb_read_data = NULL; |
1824 | } | 1829 | } |
@@ -1829,12 +1834,12 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, | |||
1829 | 1834 | ||
1830 | /* need to free smb_read_data buf before exit */ | 1835 | /* need to free smb_read_data buf before exit */ |
1831 | if (smb_read_data) { | 1836 | if (smb_read_data) { |
1832 | if(buf_type == CIFS_SMALL_BUFFER) | 1837 | if (buf_type == CIFS_SMALL_BUFFER) |
1833 | cifs_small_buf_release(smb_read_data); | 1838 | cifs_small_buf_release(smb_read_data); |
1834 | else if(buf_type == CIFS_LARGE_BUFFER) | 1839 | else if (buf_type == CIFS_LARGE_BUFFER) |
1835 | cifs_buf_release(smb_read_data); | 1840 | cifs_buf_release(smb_read_data); |
1836 | smb_read_data = NULL; | 1841 | smb_read_data = NULL; |
1837 | } | 1842 | } |
1838 | 1843 | ||
1839 | FreeXid(xid); | 1844 | FreeXid(xid); |
1840 | return rc; | 1845 | return rc; |
@@ -1849,26 +1854,26 @@ static int cifs_readpage_worker(struct file *file, struct page *page, | |||
1849 | page_cache_get(page); | 1854 | page_cache_get(page); |
1850 | read_data = kmap(page); | 1855 | read_data = kmap(page); |
1851 | /* for reads over a certain size could initiate async read ahead */ | 1856 | /* for reads over a certain size could initiate async read ahead */ |
1852 | 1857 | ||
1853 | rc = cifs_read(file, read_data, PAGE_CACHE_SIZE, poffset); | 1858 | rc = cifs_read(file, read_data, PAGE_CACHE_SIZE, poffset); |
1854 | 1859 | ||
1855 | if (rc < 0) | 1860 | if (rc < 0) |
1856 | goto io_error; | 1861 | goto io_error; |
1857 | else | 1862 | else |
1858 | cFYI(1, ("Bytes read %d",rc)); | 1863 | cFYI(1, ("Bytes read %d", rc)); |
1859 | 1864 | ||
1860 | file->f_path.dentry->d_inode->i_atime = | 1865 | file->f_path.dentry->d_inode->i_atime = |
1861 | current_fs_time(file->f_path.dentry->d_inode->i_sb); | 1866 | current_fs_time(file->f_path.dentry->d_inode->i_sb); |
1862 | 1867 | ||
1863 | if (PAGE_CACHE_SIZE > rc) | 1868 | if (PAGE_CACHE_SIZE > rc) |
1864 | memset(read_data + rc, 0, PAGE_CACHE_SIZE - rc); | 1869 | memset(read_data + rc, 0, PAGE_CACHE_SIZE - rc); |
1865 | 1870 | ||
1866 | flush_dcache_page(page); | 1871 | flush_dcache_page(page); |
1867 | SetPageUptodate(page); | 1872 | SetPageUptodate(page); |
1868 | rc = 0; | 1873 | rc = 0; |
1869 | 1874 | ||
1870 | io_error: | 1875 | io_error: |
1871 | kunmap(page); | 1876 | kunmap(page); |
1872 | page_cache_release(page); | 1877 | page_cache_release(page); |
1873 | return rc; | 1878 | return rc; |
1874 | } | 1879 | } |
@@ -1886,7 +1891,7 @@ static int cifs_readpage(struct file *file, struct page *page) | |||
1886 | return -EBADF; | 1891 | return -EBADF; |
1887 | } | 1892 | } |
1888 | 1893 | ||
1889 | cFYI(1, ("readpage %p at offset %d 0x%x\n", | 1894 | cFYI(1, ("readpage %p at offset %d 0x%x\n", |
1890 | page, (int)offset, (int)offset)); | 1895 | page, (int)offset, (int)offset)); |
1891 | 1896 | ||
1892 | rc = cifs_readpage_worker(file, page, &offset); | 1897 | rc = cifs_readpage_worker(file, page, &offset); |
@@ -1900,7 +1905,7 @@ static int cifs_readpage(struct file *file, struct page *page) | |||
1900 | /* We do not want to update the file size from server for inodes | 1905 | /* We do not want to update the file size from server for inodes |
1901 | open for write - to avoid races with writepage extending | 1906 | open for write - to avoid races with writepage extending |
1902 | the file - in the future we could consider allowing | 1907 | the file - in the future we could consider allowing |
1903 | refreshing the inode only on increases in the file size | 1908 | refreshing the inode only on increases in the file size |
1904 | but this is tricky to do without racing with writebehind | 1909 | but this is tricky to do without racing with writebehind |
1905 | page caching in the current Linux kernel design */ | 1910 | page caching in the current Linux kernel design */ |
1906 | int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file) | 1911 | int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file) |
@@ -1910,7 +1915,7 @@ int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file) | |||
1910 | if (cifsInode) | 1915 | if (cifsInode) |
1911 | open_file = find_writable_file(cifsInode); | 1916 | open_file = find_writable_file(cifsInode); |
1912 | 1917 | ||
1913 | if(open_file) { | 1918 | if (open_file) { |
1914 | struct cifs_sb_info *cifs_sb; | 1919 | struct cifs_sb_info *cifs_sb; |
1915 | 1920 | ||
1916 | /* there is not actually a write pending so let | 1921 | /* there is not actually a write pending so let |
@@ -1920,12 +1925,12 @@ int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file) | |||
1920 | 1925 | ||
1921 | cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb); | 1926 | cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb); |
1922 | if ( cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO ) { | 1927 | if ( cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO ) { |
1923 | /* since no page cache to corrupt on directio | 1928 | /* since no page cache to corrupt on directio |
1924 | we can change size safely */ | 1929 | we can change size safely */ |
1925 | return 1; | 1930 | return 1; |
1926 | } | 1931 | } |
1927 | 1932 | ||
1928 | if(i_size_read(&cifsInode->vfs_inode) < end_of_file) | 1933 | if (i_size_read(&cifsInode->vfs_inode) < end_of_file) |
1929 | return 1; | 1934 | return 1; |
1930 | 1935 | ||
1931 | return 0; | 1936 | return 0; |
@@ -1940,7 +1945,7 @@ static int cifs_prepare_write(struct file *file, struct page *page, | |||
1940 | loff_t i_size; | 1945 | loff_t i_size; |
1941 | loff_t offset; | 1946 | loff_t offset; |
1942 | 1947 | ||
1943 | cFYI(1, ("prepare write for page %p from %d to %d",page,from,to)); | 1948 | cFYI(1, ("prepare write for page %p from %d to %d", page, from, to)); |
1944 | if (PageUptodate(page)) | 1949 | if (PageUptodate(page)) |
1945 | return 0; | 1950 | return 0; |
1946 | 1951 | ||
@@ -1979,8 +1984,8 @@ static int cifs_prepare_write(struct file *file, struct page *page, | |||
1979 | this will be written out by commit_write so is fine */ | 1984 | this will be written out by commit_write so is fine */ |
1980 | } | 1985 | } |
1981 | 1986 | ||
1982 | /* we do not need to pass errors back | 1987 | /* we do not need to pass errors back |
1983 | e.g. if we do not have read access to the file | 1988 | e.g. if we do not have read access to the file |
1984 | because cifs_commit_write will do the right thing. -- shaggy */ | 1989 | because cifs_commit_write will do the right thing. -- shaggy */ |
1985 | 1990 | ||
1986 | return 0; | 1991 | return 0; |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index f0ff12b3f398..d8ae20f1a47a 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -57,14 +57,14 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
57 | if (tmp_path == NULL) { | 57 | if (tmp_path == NULL) { |
58 | return -ENOMEM; | 58 | return -ENOMEM; |
59 | } | 59 | } |
60 | /* have to skip first of the double backslash of | 60 | /* have to skip first of the double backslash of |
61 | UNC name */ | 61 | UNC name */ |
62 | strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE); | 62 | strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE); |
63 | strncat(tmp_path, search_path, MAX_PATHCONF); | 63 | strncat(tmp_path, search_path, MAX_PATHCONF); |
64 | rc = connect_to_dfs_path(xid, pTcon->ses, | 64 | rc = connect_to_dfs_path(xid, pTcon->ses, |
65 | /* treename + */ tmp_path, | 65 | /* treename + */ tmp_path, |
66 | cifs_sb->local_nls, | 66 | cifs_sb->local_nls, |
67 | cifs_sb->mnt_cifs_flags & | 67 | cifs_sb->mnt_cifs_flags & |
68 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 68 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
69 | kfree(tmp_path); | 69 | kfree(tmp_path); |
70 | 70 | ||
@@ -81,7 +81,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
81 | /* get new inode */ | 81 | /* get new inode */ |
82 | if (*pinode == NULL) { | 82 | if (*pinode == NULL) { |
83 | *pinode = new_inode(sb); | 83 | *pinode = new_inode(sb); |
84 | if (*pinode == NULL) | 84 | if (*pinode == NULL) |
85 | return -ENOMEM; | 85 | return -ENOMEM; |
86 | /* Is an i_ino of zero legal? */ | 86 | /* Is an i_ino of zero legal? */ |
87 | /* Are there sanity checks we can use to ensure that | 87 | /* Are there sanity checks we can use to ensure that |
@@ -103,7 +103,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
103 | cifsInfo->time = jiffies; | 103 | cifsInfo->time = jiffies; |
104 | cFYI(1, ("New time %ld", cifsInfo->time)); | 104 | cFYI(1, ("New time %ld", cifsInfo->time)); |
105 | /* this is ok to set on every inode revalidate */ | 105 | /* this is ok to set on every inode revalidate */ |
106 | atomic_set(&cifsInfo->inUse,1); | 106 | atomic_set(&cifsInfo->inUse, 1); |
107 | 107 | ||
108 | inode->i_atime = | 108 | inode->i_atime = |
109 | cifs_NTtimeToUnix(le64_to_cpu(findData.LastAccessTime)); | 109 | cifs_NTtimeToUnix(le64_to_cpu(findData.LastAccessTime)); |
@@ -114,8 +114,8 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
114 | cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange)); | 114 | cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange)); |
115 | inode->i_mode = le64_to_cpu(findData.Permissions); | 115 | inode->i_mode = le64_to_cpu(findData.Permissions); |
116 | /* since we set the inode type below we need to mask off | 116 | /* since we set the inode type below we need to mask off |
117 | to avoid strange results if bits set above */ | 117 | to avoid strange results if bits set above */ |
118 | inode->i_mode &= ~S_IFMT; | 118 | inode->i_mode &= ~S_IFMT; |
119 | if (type == UNIX_FILE) { | 119 | if (type == UNIX_FILE) { |
120 | inode->i_mode |= S_IFREG; | 120 | inode->i_mode |= S_IFREG; |
121 | } else if (type == UNIX_SYMLINK) { | 121 | } else if (type == UNIX_SYMLINK) { |
@@ -137,7 +137,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
137 | } else { | 137 | } else { |
138 | /* safest to call it a file if we do not know */ | 138 | /* safest to call it a file if we do not know */ |
139 | inode->i_mode |= S_IFREG; | 139 | inode->i_mode |= S_IFREG; |
140 | cFYI(1,("unknown type %d",type)); | 140 | cFYI(1, ("unknown type %d", type)); |
141 | } | 141 | } |
142 | 142 | ||
143 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) | 143 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) |
@@ -183,17 +183,17 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
183 | inode->i_op = &cifs_file_inode_ops; | 183 | inode->i_op = &cifs_file_inode_ops; |
184 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { | 184 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { |
185 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 185 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
186 | inode->i_fop = | 186 | inode->i_fop = |
187 | &cifs_file_direct_nobrl_ops; | 187 | &cifs_file_direct_nobrl_ops; |
188 | else | 188 | else |
189 | inode->i_fop = &cifs_file_direct_ops; | 189 | inode->i_fop = &cifs_file_direct_ops; |
190 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 190 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
191 | inode->i_fop = &cifs_file_nobrl_ops; | 191 | inode->i_fop = &cifs_file_nobrl_ops; |
192 | else /* not direct, send byte range locks */ | 192 | else /* not direct, send byte range locks */ |
193 | inode->i_fop = &cifs_file_ops; | 193 | inode->i_fop = &cifs_file_ops; |
194 | 194 | ||
195 | /* check if server can support readpages */ | 195 | /* check if server can support readpages */ |
196 | if (pTcon->ses->server->maxBuf < | 196 | if (pTcon->ses->server->maxBuf < |
197 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) | 197 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) |
198 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | 198 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
199 | else | 199 | else |
@@ -215,7 +215,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
215 | return rc; | 215 | return rc; |
216 | } | 216 | } |
217 | 217 | ||
218 | static int decode_sfu_inode(struct inode * inode, __u64 size, | 218 | static int decode_sfu_inode(struct inode *inode, __u64 size, |
219 | const unsigned char *path, | 219 | const unsigned char *path, |
220 | struct cifs_sb_info *cifs_sb, int xid) | 220 | struct cifs_sb_info *cifs_sb, int xid) |
221 | { | 221 | { |
@@ -225,7 +225,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
225 | struct cifsTconInfo *pTcon = cifs_sb->tcon; | 225 | struct cifsTconInfo *pTcon = cifs_sb->tcon; |
226 | char buf[24]; | 226 | char buf[24]; |
227 | unsigned int bytes_read; | 227 | unsigned int bytes_read; |
228 | char * pbuf; | 228 | char *pbuf; |
229 | 229 | ||
230 | pbuf = buf; | 230 | pbuf = buf; |
231 | 231 | ||
@@ -241,16 +241,16 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
241 | cifs_sb->local_nls, | 241 | cifs_sb->local_nls, |
242 | cifs_sb->mnt_cifs_flags & | 242 | cifs_sb->mnt_cifs_flags & |
243 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 243 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
244 | if (rc==0) { | 244 | if (rc == 0) { |
245 | int buf_type = CIFS_NO_BUFFER; | 245 | int buf_type = CIFS_NO_BUFFER; |
246 | /* Read header */ | 246 | /* Read header */ |
247 | rc = CIFSSMBRead(xid, pTcon, | 247 | rc = CIFSSMBRead(xid, pTcon, |
248 | netfid, | 248 | netfid, |
249 | 24 /* length */, 0 /* offset */, | 249 | 24 /* length */, 0 /* offset */, |
250 | &bytes_read, &pbuf, &buf_type); | 250 | &bytes_read, &pbuf, &buf_type); |
251 | if ((rc == 0) && (bytes_read >= 8)) { | 251 | if ((rc == 0) && (bytes_read >= 8)) { |
252 | if (memcmp("IntxBLK", pbuf, 8) == 0) { | 252 | if (memcmp("IntxBLK", pbuf, 8) == 0) { |
253 | cFYI(1,("Block device")); | 253 | cFYI(1, ("Block device")); |
254 | inode->i_mode |= S_IFBLK; | 254 | inode->i_mode |= S_IFBLK; |
255 | if (bytes_read == 24) { | 255 | if (bytes_read == 24) { |
256 | /* we have enough to decode dev num */ | 256 | /* we have enough to decode dev num */ |
@@ -261,7 +261,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
261 | inode->i_rdev = MKDEV(mjr, mnr); | 261 | inode->i_rdev = MKDEV(mjr, mnr); |
262 | } | 262 | } |
263 | } else if (memcmp("IntxCHR", pbuf, 8) == 0) { | 263 | } else if (memcmp("IntxCHR", pbuf, 8) == 0) { |
264 | cFYI(1,("Char device")); | 264 | cFYI(1, ("Char device")); |
265 | inode->i_mode |= S_IFCHR; | 265 | inode->i_mode |= S_IFCHR; |
266 | if (bytes_read == 24) { | 266 | if (bytes_read == 24) { |
267 | /* we have enough to decode dev num */ | 267 | /* we have enough to decode dev num */ |
@@ -270,18 +270,18 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
270 | mjr = le64_to_cpu(*(__le64 *)(pbuf+8)); | 270 | mjr = le64_to_cpu(*(__le64 *)(pbuf+8)); |
271 | mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); | 271 | mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); |
272 | inode->i_rdev = MKDEV(mjr, mnr); | 272 | inode->i_rdev = MKDEV(mjr, mnr); |
273 | } | 273 | } |
274 | } else if (memcmp("IntxLNK", pbuf, 7) == 0) { | 274 | } else if (memcmp("IntxLNK", pbuf, 7) == 0) { |
275 | cFYI(1,("Symlink")); | 275 | cFYI(1, ("Symlink")); |
276 | inode->i_mode |= S_IFLNK; | 276 | inode->i_mode |= S_IFLNK; |
277 | } else { | 277 | } else { |
278 | inode->i_mode |= S_IFREG; /* file? */ | 278 | inode->i_mode |= S_IFREG; /* file? */ |
279 | rc = -EOPNOTSUPP; | 279 | rc = -EOPNOTSUPP; |
280 | } | 280 | } |
281 | } else { | 281 | } else { |
282 | inode->i_mode |= S_IFREG; /* then it is a file */ | 282 | inode->i_mode |= S_IFREG; /* then it is a file */ |
283 | rc = -EOPNOTSUPP; /* or some unknown SFU type */ | 283 | rc = -EOPNOTSUPP; /* or some unknown SFU type */ |
284 | } | 284 | } |
285 | CIFSSMBClose(xid, pTcon, netfid); | 285 | CIFSSMBClose(xid, pTcon, netfid); |
286 | } | 286 | } |
287 | return rc; | 287 | return rc; |
@@ -290,7 +290,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
290 | 290 | ||
291 | #define SFBITS_MASK (S_ISVTX | S_ISGID | S_ISUID) /* SETFILEBITS valid bits */ | 291 | #define SFBITS_MASK (S_ISVTX | S_ISGID | S_ISUID) /* SETFILEBITS valid bits */ |
292 | 292 | ||
293 | static int get_sfu_uid_mode(struct inode * inode, | 293 | static int get_sfu_uid_mode(struct inode *inode, |
294 | const unsigned char *path, | 294 | const unsigned char *path, |
295 | struct cifs_sb_info *cifs_sb, int xid) | 295 | struct cifs_sb_info *cifs_sb, int xid) |
296 | { | 296 | { |
@@ -301,15 +301,15 @@ static int get_sfu_uid_mode(struct inode * inode, | |||
301 | 301 | ||
302 | rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS", | 302 | rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS", |
303 | ea_value, 4 /* size of buf */, cifs_sb->local_nls, | 303 | ea_value, 4 /* size of buf */, cifs_sb->local_nls, |
304 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 304 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
305 | if (rc < 0) | 305 | if (rc < 0) |
306 | return (int)rc; | 306 | return (int)rc; |
307 | else if (rc > 3) { | 307 | else if (rc > 3) { |
308 | mode = le32_to_cpu(*((__le32 *)ea_value)); | 308 | mode = le32_to_cpu(*((__le32 *)ea_value)); |
309 | inode->i_mode &= ~SFBITS_MASK; | 309 | inode->i_mode &= ~SFBITS_MASK; |
310 | cFYI(1,("special bits 0%o org mode 0%o", mode, inode->i_mode)); | 310 | cFYI(1, ("special bits 0%o org mode 0%o", mode, inode->i_mode)); |
311 | inode->i_mode = (mode & SFBITS_MASK) | inode->i_mode; | 311 | inode->i_mode = (mode & SFBITS_MASK) | inode->i_mode; |
312 | cFYI(1,("special mode bits 0%o", mode)); | 312 | cFYI(1, ("special mode bits 0%o", mode)); |
313 | return 0; | 313 | return 0; |
314 | } else { | 314 | } else { |
315 | return 0; | 315 | return 0; |
@@ -334,11 +334,11 @@ int cifs_get_inode_info(struct inode **pinode, | |||
334 | int adjustTZ = FALSE; | 334 | int adjustTZ = FALSE; |
335 | 335 | ||
336 | pTcon = cifs_sb->tcon; | 336 | pTcon = cifs_sb->tcon; |
337 | cFYI(1,("Getting info on %s", search_path)); | 337 | cFYI(1, ("Getting info on %s", search_path)); |
338 | 338 | ||
339 | if ((pfindData == NULL) && (*pinode != NULL)) { | 339 | if ((pfindData == NULL) && (*pinode != NULL)) { |
340 | if (CIFS_I(*pinode)->clientCanCacheRead) { | 340 | if (CIFS_I(*pinode)->clientCanCacheRead) { |
341 | cFYI(1,("No need to revalidate cached inode sizes")); | 341 | cFYI(1, ("No need to revalidate cached inode sizes")); |
342 | return rc; | 342 | return rc; |
343 | } | 343 | } |
344 | } | 344 | } |
@@ -359,7 +359,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
359 | failed at least once - set flag in tcon or mount */ | 359 | failed at least once - set flag in tcon or mount */ |
360 | if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) { | 360 | if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) { |
361 | rc = SMBQueryInformation(xid, pTcon, search_path, | 361 | rc = SMBQueryInformation(xid, pTcon, search_path, |
362 | pfindData, cifs_sb->local_nls, | 362 | pfindData, cifs_sb->local_nls, |
363 | cifs_sb->mnt_cifs_flags & | 363 | cifs_sb->mnt_cifs_flags & |
364 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 364 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
365 | adjustTZ = TRUE; | 365 | adjustTZ = TRUE; |
@@ -384,8 +384,8 @@ int cifs_get_inode_info(struct inode **pinode, | |||
384 | strncat(tmp_path, search_path, MAX_PATHCONF); | 384 | strncat(tmp_path, search_path, MAX_PATHCONF); |
385 | rc = connect_to_dfs_path(xid, pTcon->ses, | 385 | rc = connect_to_dfs_path(xid, pTcon->ses, |
386 | /* treename + */ tmp_path, | 386 | /* treename + */ tmp_path, |
387 | cifs_sb->local_nls, | 387 | cifs_sb->local_nls, |
388 | cifs_sb->mnt_cifs_flags & | 388 | cifs_sb->mnt_cifs_flags & |
389 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 389 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
390 | kfree(tmp_path); | 390 | kfree(tmp_path); |
391 | /* BB fix up inode etc. */ | 391 | /* BB fix up inode etc. */ |
@@ -419,17 +419,17 @@ int cifs_get_inode_info(struct inode **pinode, | |||
419 | there Windows server or network appliances for which | 419 | there Windows server or network appliances for which |
420 | IndexNumber field is not guaranteed unique? */ | 420 | IndexNumber field is not guaranteed unique? */ |
421 | 421 | ||
422 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM){ | 422 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { |
423 | int rc1 = 0; | 423 | int rc1 = 0; |
424 | __u64 inode_num; | 424 | __u64 inode_num; |
425 | 425 | ||
426 | rc1 = CIFSGetSrvInodeNumber(xid, pTcon, | 426 | rc1 = CIFSGetSrvInodeNumber(xid, pTcon, |
427 | search_path, &inode_num, | 427 | search_path, &inode_num, |
428 | cifs_sb->local_nls, | 428 | cifs_sb->local_nls, |
429 | cifs_sb->mnt_cifs_flags & | 429 | cifs_sb->mnt_cifs_flags & |
430 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 430 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
431 | if (rc1) { | 431 | if (rc1) { |
432 | cFYI(1,("GetSrvInodeNum rc %d", rc1)); | 432 | cFYI(1, ("GetSrvInodeNum rc %d", rc1)); |
433 | /* BB EOPNOSUPP disable SERVER_INUM? */ | 433 | /* BB EOPNOSUPP disable SERVER_INUM? */ |
434 | } else /* do we need cast or hash to ino? */ | 434 | } else /* do we need cast or hash to ino? */ |
435 | (*pinode)->i_ino = inode_num; | 435 | (*pinode)->i_ino = inode_num; |
@@ -463,7 +463,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
463 | cFYI(0, ("Attributes came in as 0x%x", attr)); | 463 | cFYI(0, ("Attributes came in as 0x%x", attr)); |
464 | if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) { | 464 | if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) { |
465 | inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj; | 465 | inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj; |
466 | inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj; | 466 | inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj; |
467 | } | 467 | } |
468 | 468 | ||
469 | /* set default mode. will override for dirs below */ | 469 | /* set default mode. will override for dirs below */ |
@@ -471,8 +471,9 @@ int cifs_get_inode_info(struct inode **pinode, | |||
471 | /* new inode, can safely set these fields */ | 471 | /* new inode, can safely set these fields */ |
472 | inode->i_mode = cifs_sb->mnt_file_mode; | 472 | inode->i_mode = cifs_sb->mnt_file_mode; |
473 | else /* since we set the inode type below we need to mask off | 473 | else /* since we set the inode type below we need to mask off |
474 | to avoid strange results if type changes and both get orred in */ | 474 | to avoid strange results if type changes and both |
475 | inode->i_mode &= ~S_IFMT; | 475 | get orred in */ |
476 | inode->i_mode &= ~S_IFMT; | ||
476 | /* if (attr & ATTR_REPARSE) */ | 477 | /* if (attr & ATTR_REPARSE) */ |
477 | /* We no longer handle these as symlinks because we could not | 478 | /* We no longer handle these as symlinks because we could not |
478 | follow them due to the absolute path with drive letter */ | 479 | follow them due to the absolute path with drive letter */ |
@@ -490,13 +491,13 @@ int cifs_get_inode_info(struct inode **pinode, | |||
490 | /* BB Finish for SFU style symlinks and devices */ | 491 | /* BB Finish for SFU style symlinks and devices */ |
491 | } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && | 492 | } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && |
492 | (cifsInfo->cifsAttrs & ATTR_SYSTEM)) { | 493 | (cifsInfo->cifsAttrs & ATTR_SYSTEM)) { |
493 | if (decode_sfu_inode(inode, | 494 | if (decode_sfu_inode(inode, |
494 | le64_to_cpu(pfindData->EndOfFile), | 495 | le64_to_cpu(pfindData->EndOfFile), |
495 | search_path, | 496 | search_path, |
496 | cifs_sb, xid)) { | 497 | cifs_sb, xid)) { |
497 | cFYI(1,("Unrecognized sfu inode type")); | 498 | cFYI(1, ("Unrecognized sfu inode type")); |
498 | } | 499 | } |
499 | cFYI(1,("sfu mode 0%o",inode->i_mode)); | 500 | cFYI(1, ("sfu mode 0%o", inode->i_mode)); |
500 | } else { | 501 | } else { |
501 | inode->i_mode |= S_IFREG; | 502 | inode->i_mode |= S_IFREG; |
502 | /* treat the dos attribute of read-only as read-only | 503 | /* treat the dos attribute of read-only as read-only |
@@ -517,7 +518,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
517 | if (is_size_safe_to_change(cifsInfo, le64_to_cpu(pfindData->EndOfFile))) { | 518 | if (is_size_safe_to_change(cifsInfo, le64_to_cpu(pfindData->EndOfFile))) { |
518 | /* can not safely shrink the file size here if the | 519 | /* can not safely shrink the file size here if the |
519 | client is writing to it due to potential races */ | 520 | client is writing to it due to potential races */ |
520 | i_size_write(inode,le64_to_cpu(pfindData->EndOfFile)); | 521 | i_size_write(inode, le64_to_cpu(pfindData->EndOfFile)); |
521 | 522 | ||
522 | /* 512 bytes (2**9) is the fake blocksize that must be | 523 | /* 512 bytes (2**9) is the fake blocksize that must be |
523 | used for this calculation */ | 524 | used for this calculation */ |
@@ -528,7 +529,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
528 | 529 | ||
529 | inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks); | 530 | inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks); |
530 | 531 | ||
531 | /* BB fill in uid and gid here? with help from winbind? | 532 | /* BB fill in uid and gid here? with help from winbind? |
532 | or retrieve from NTFS stream extended attribute */ | 533 | or retrieve from NTFS stream extended attribute */ |
533 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { | 534 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { |
534 | /* fill in uid, gid, mode from server ACL */ | 535 | /* fill in uid, gid, mode from server ACL */ |
@@ -540,7 +541,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
540 | inode->i_gid = cifs_sb->mnt_gid; | 541 | inode->i_gid = cifs_sb->mnt_gid; |
541 | /* set so we do not keep refreshing these fields with | 542 | /* set so we do not keep refreshing these fields with |
542 | bad data after user has changed them in memory */ | 543 | bad data after user has changed them in memory */ |
543 | atomic_set(&cifsInfo->inUse,1); | 544 | atomic_set(&cifsInfo->inUse, 1); |
544 | } | 545 | } |
545 | 546 | ||
546 | if (S_ISREG(inode->i_mode)) { | 547 | if (S_ISREG(inode->i_mode)) { |
@@ -557,7 +558,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
557 | else /* not direct, send byte range locks */ | 558 | else /* not direct, send byte range locks */ |
558 | inode->i_fop = &cifs_file_ops; | 559 | inode->i_fop = &cifs_file_ops; |
559 | 560 | ||
560 | if (pTcon->ses->server->maxBuf < | 561 | if (pTcon->ses->server->maxBuf < |
561 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) | 562 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) |
562 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | 563 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
563 | else | 564 | else |
@@ -587,9 +588,9 @@ void cifs_read_inode(struct inode *inode) | |||
587 | cifs_sb = CIFS_SB(inode->i_sb); | 588 | cifs_sb = CIFS_SB(inode->i_sb); |
588 | xid = GetXid(); | 589 | xid = GetXid(); |
589 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) | 590 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) |
590 | cifs_get_inode_info_unix(&inode, "", inode->i_sb,xid); | 591 | cifs_get_inode_info_unix(&inode, "", inode->i_sb, xid); |
591 | else | 592 | else |
592 | cifs_get_inode_info(&inode, "", NULL, inode->i_sb,xid); | 593 | cifs_get_inode_info(&inode, "", NULL, inode->i_sb, xid); |
593 | /* can not call macro FreeXid here since in a void func */ | 594 | /* can not call macro FreeXid here since in a void func */ |
594 | _FreeXid(xid); | 595 | _FreeXid(xid); |
595 | } | 596 | } |
@@ -638,12 +639,12 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
638 | rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE, | 639 | rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE, |
639 | CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE, | 640 | CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE, |
640 | &netfid, &oplock, NULL, cifs_sb->local_nls, | 641 | &netfid, &oplock, NULL, cifs_sb->local_nls, |
641 | cifs_sb->mnt_cifs_flags & | 642 | cifs_sb->mnt_cifs_flags & |
642 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 643 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
643 | if (rc==0) { | 644 | if (rc == 0) { |
644 | CIFSSMBRenameOpenFile(xid, pTcon, netfid, NULL, | 645 | CIFSSMBRenameOpenFile(xid, pTcon, netfid, NULL, |
645 | cifs_sb->local_nls, | 646 | cifs_sb->local_nls, |
646 | cifs_sb->mnt_cifs_flags & | 647 | cifs_sb->mnt_cifs_flags & |
647 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 648 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
648 | CIFSSMBClose(xid, pTcon, netfid); | 649 | CIFSSMBClose(xid, pTcon, netfid); |
649 | if (direntry->d_inode) | 650 | if (direntry->d_inode) |
@@ -659,7 +660,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
659 | rc = CIFSSMBSetTimes(xid, pTcon, full_path, | 660 | rc = CIFSSMBSetTimes(xid, pTcon, full_path, |
660 | pinfo_buf, | 661 | pinfo_buf, |
661 | cifs_sb->local_nls, | 662 | cifs_sb->local_nls, |
662 | cifs_sb->mnt_cifs_flags & | 663 | cifs_sb->mnt_cifs_flags & |
663 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 664 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
664 | else | 665 | else |
665 | rc = -EOPNOTSUPP; | 666 | rc = -EOPNOTSUPP; |
@@ -670,7 +671,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
670 | /* rc = CIFSSMBSetAttrLegacy(xid, pTcon, | 671 | /* rc = CIFSSMBSetAttrLegacy(xid, pTcon, |
671 | full_path, | 672 | full_path, |
672 | (__u16)ATTR_NORMAL, | 673 | (__u16)ATTR_NORMAL, |
673 | cifs_sb->local_nls); | 674 | cifs_sb->local_nls); |
674 | For some strange reason it seems that NT4 eats the | 675 | For some strange reason it seems that NT4 eats the |
675 | old setattr call without actually setting the | 676 | old setattr call without actually setting the |
676 | attributes so on to the third attempted workaround | 677 | attributes so on to the third attempted workaround |
@@ -683,9 +684,9 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
683 | FILE_WRITE_ATTRIBUTES, 0, | 684 | FILE_WRITE_ATTRIBUTES, 0, |
684 | &netfid, &oplock, NULL, | 685 | &netfid, &oplock, NULL, |
685 | cifs_sb->local_nls, | 686 | cifs_sb->local_nls, |
686 | cifs_sb->mnt_cifs_flags & | 687 | cifs_sb->mnt_cifs_flags & |
687 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 688 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
688 | if (rc==0) { | 689 | if (rc == 0) { |
689 | rc = CIFSSMBSetFileTimes(xid, pTcon, | 690 | rc = CIFSSMBSetFileTimes(xid, pTcon, |
690 | pinfo_buf, | 691 | pinfo_buf, |
691 | netfid); | 692 | netfid); |
@@ -694,10 +695,10 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
694 | } | 695 | } |
695 | kfree(pinfo_buf); | 696 | kfree(pinfo_buf); |
696 | } | 697 | } |
697 | if (rc==0) { | 698 | if (rc == 0) { |
698 | rc = CIFSSMBDelFile(xid, pTcon, full_path, | 699 | rc = CIFSSMBDelFile(xid, pTcon, full_path, |
699 | cifs_sb->local_nls, | 700 | cifs_sb->local_nls, |
700 | cifs_sb->mnt_cifs_flags & | 701 | cifs_sb->mnt_cifs_flags & |
701 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 702 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
702 | if (!rc) { | 703 | if (!rc) { |
703 | if (direntry->d_inode) | 704 | if (direntry->d_inode) |
@@ -711,10 +712,10 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
711 | CREATE_NOT_DIR | | 712 | CREATE_NOT_DIR | |
712 | CREATE_DELETE_ON_CLOSE, | 713 | CREATE_DELETE_ON_CLOSE, |
713 | &netfid, &oplock, NULL, | 714 | &netfid, &oplock, NULL, |
714 | cifs_sb->local_nls, | 715 | cifs_sb->local_nls, |
715 | cifs_sb->mnt_cifs_flags & | 716 | cifs_sb->mnt_cifs_flags & |
716 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 717 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
717 | if (rc==0) { | 718 | if (rc == 0) { |
718 | CIFSSMBRenameOpenFile(xid, pTcon, | 719 | CIFSSMBRenameOpenFile(xid, pTcon, |
719 | netfid, NULL, | 720 | netfid, NULL, |
720 | cifs_sb->local_nls, | 721 | cifs_sb->local_nls, |
@@ -773,8 +774,8 @@ static void posix_fill_in_inode(struct inode *tmp_inode, | |||
773 | 774 | ||
774 | tmp_inode->i_mode = le64_to_cpu(pData->Permissions); | 775 | tmp_inode->i_mode = le64_to_cpu(pData->Permissions); |
775 | /* since we set the inode type below we need to mask off type | 776 | /* since we set the inode type below we need to mask off type |
776 | to avoid strange results if bits above were corrupt */ | 777 | to avoid strange results if bits above were corrupt */ |
777 | tmp_inode->i_mode &= ~S_IFMT; | 778 | tmp_inode->i_mode &= ~S_IFMT; |
778 | if (type == UNIX_FILE) { | 779 | if (type == UNIX_FILE) { |
779 | *pobject_type = DT_REG; | 780 | *pobject_type = DT_REG; |
780 | tmp_inode->i_mode |= S_IFREG; | 781 | tmp_inode->i_mode |= S_IFREG; |
@@ -804,11 +805,11 @@ static void posix_fill_in_inode(struct inode *tmp_inode, | |||
804 | /* safest to just call it a file */ | 805 | /* safest to just call it a file */ |
805 | *pobject_type = DT_REG; | 806 | *pobject_type = DT_REG; |
806 | tmp_inode->i_mode |= S_IFREG; | 807 | tmp_inode->i_mode |= S_IFREG; |
807 | cFYI(1,("unknown inode type %d",type)); | 808 | cFYI(1, ("unknown inode type %d", type)); |
808 | } | 809 | } |
809 | 810 | ||
810 | #ifdef CONFIG_CIFS_DEBUG2 | 811 | #ifdef CONFIG_CIFS_DEBUG2 |
811 | cFYI(1,("object type: %d", type)); | 812 | cFYI(1, ("object type: %d", type)); |
812 | #endif | 813 | #endif |
813 | tmp_inode->i_uid = le64_to_cpu(pData->Uid); | 814 | tmp_inode->i_uid = le64_to_cpu(pData->Uid); |
814 | tmp_inode->i_gid = le64_to_cpu(pData->Gid); | 815 | tmp_inode->i_gid = le64_to_cpu(pData->Gid); |
@@ -816,7 +817,7 @@ static void posix_fill_in_inode(struct inode *tmp_inode, | |||
816 | 817 | ||
817 | spin_lock(&tmp_inode->i_lock); | 818 | spin_lock(&tmp_inode->i_lock); |
818 | if (is_size_safe_to_change(cifsInfo, end_of_file)) { | 819 | if (is_size_safe_to_change(cifsInfo, end_of_file)) { |
819 | /* can not safely change the file size here if the | 820 | /* can not safely change the file size here if the |
820 | client is writing to it due to potential races */ | 821 | client is writing to it due to potential races */ |
821 | i_size_write(tmp_inode, end_of_file); | 822 | i_size_write(tmp_inode, end_of_file); |
822 | 823 | ||
@@ -830,27 +831,28 @@ static void posix_fill_in_inode(struct inode *tmp_inode, | |||
830 | cFYI(1, ("File inode")); | 831 | cFYI(1, ("File inode")); |
831 | tmp_inode->i_op = &cifs_file_inode_ops; | 832 | tmp_inode->i_op = &cifs_file_inode_ops; |
832 | 833 | ||
833 | if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { | 834 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { |
834 | if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 835 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
835 | tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; | 836 | tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; |
836 | else | 837 | else |
837 | tmp_inode->i_fop = &cifs_file_direct_ops; | 838 | tmp_inode->i_fop = &cifs_file_direct_ops; |
838 | 839 | ||
839 | } else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 840 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
840 | tmp_inode->i_fop = &cifs_file_nobrl_ops; | 841 | tmp_inode->i_fop = &cifs_file_nobrl_ops; |
841 | else | 842 | else |
842 | tmp_inode->i_fop = &cifs_file_ops; | 843 | tmp_inode->i_fop = &cifs_file_ops; |
843 | 844 | ||
844 | if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && | 845 | if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) && |
845 | (cifs_sb->tcon->ses->server->maxBuf < | 846 | (cifs_sb->tcon->ses->server->maxBuf < |
846 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) | 847 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) |
847 | tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | 848 | tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
848 | else | 849 | else |
849 | tmp_inode->i_data.a_ops = &cifs_addr_ops; | 850 | tmp_inode->i_data.a_ops = &cifs_addr_ops; |
850 | 851 | ||
851 | if(isNewInode) | 852 | if (isNewInode) |
852 | return; /* No sense invalidating pages for new inode since we | 853 | return; /* No sense invalidating pages for new inode |
853 | have not started caching readahead file data yet */ | 854 | since we we have not started caching |
855 | readahead file data yet */ | ||
854 | 856 | ||
855 | if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) && | 857 | if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) && |
856 | (local_size == tmp_inode->i_size)) { | 858 | (local_size == tmp_inode->i_size)) { |
@@ -869,10 +871,10 @@ static void posix_fill_in_inode(struct inode *tmp_inode, | |||
869 | tmp_inode->i_op = &cifs_symlink_inode_ops; | 871 | tmp_inode->i_op = &cifs_symlink_inode_ops; |
870 | /* tmp_inode->i_fop = *//* do not need to set to anything */ | 872 | /* tmp_inode->i_fop = *//* do not need to set to anything */ |
871 | } else { | 873 | } else { |
872 | cFYI(1, ("Special inode")); | 874 | cFYI(1, ("Special inode")); |
873 | init_special_inode(tmp_inode, tmp_inode->i_mode, | 875 | init_special_inode(tmp_inode, tmp_inode->i_mode, |
874 | tmp_inode->i_rdev); | 876 | tmp_inode->i_rdev); |
875 | } | 877 | } |
876 | } | 878 | } |
877 | 879 | ||
878 | int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | 880 | int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) |
@@ -897,21 +899,21 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
897 | return -ENOMEM; | 899 | return -ENOMEM; |
898 | } | 900 | } |
899 | 901 | ||
900 | if((pTcon->ses->capabilities & CAP_UNIX) && | 902 | if ((pTcon->ses->capabilities & CAP_UNIX) && |
901 | (CIFS_UNIX_POSIX_PATH_OPS_CAP & | 903 | (CIFS_UNIX_POSIX_PATH_OPS_CAP & |
902 | le64_to_cpu(pTcon->fsUnixInfo.Capability))) { | 904 | le64_to_cpu(pTcon->fsUnixInfo.Capability))) { |
903 | u32 oplock = 0; | 905 | u32 oplock = 0; |
904 | FILE_UNIX_BASIC_INFO * pInfo = | 906 | FILE_UNIX_BASIC_INFO * pInfo = |
905 | kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL); | 907 | kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL); |
906 | if(pInfo == NULL) { | 908 | if (pInfo == NULL) { |
907 | rc = -ENOMEM; | 909 | rc = -ENOMEM; |
908 | goto mkdir_out; | 910 | goto mkdir_out; |
909 | } | 911 | } |
910 | 912 | ||
911 | rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT, | 913 | rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT, |
912 | mode, NULL /* netfid */, pInfo, &oplock, | 914 | mode, NULL /* netfid */, pInfo, &oplock, |
913 | full_path, cifs_sb->local_nls, | 915 | full_path, cifs_sb->local_nls, |
914 | cifs_sb->mnt_cifs_flags & | 916 | cifs_sb->mnt_cifs_flags & |
915 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 917 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
916 | if (rc) { | 918 | if (rc) { |
917 | cFYI(1, ("posix mkdir returned 0x%x", rc)); | 919 | cFYI(1, ("posix mkdir returned 0x%x", rc)); |
@@ -919,8 +921,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
919 | } else { | 921 | } else { |
920 | int obj_type; | 922 | int obj_type; |
921 | if (pInfo->Type == -1) /* no return info - go query */ | 923 | if (pInfo->Type == -1) /* no return info - go query */ |
922 | goto mkdir_get_info; | 924 | goto mkdir_get_info; |
923 | /*BB check (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID ) to see if need to set uid/gid */ | 925 | /*BB check (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID ) to see if need |
926 | to set uid/gid */ | ||
924 | inc_nlink(inode); | 927 | inc_nlink(inode); |
925 | if (pTcon->nocase) | 928 | if (pTcon->nocase) |
926 | direntry->d_op = &cifs_ci_dentry_ops; | 929 | direntry->d_op = &cifs_ci_dentry_ops; |
@@ -937,7 +940,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
937 | newinode->i_ino = | 940 | newinode->i_ino = |
938 | (unsigned long)pInfo->UniqueId; | 941 | (unsigned long)pInfo->UniqueId; |
939 | } /* note ino incremented to unique num in new_inode */ | 942 | } /* note ino incremented to unique num in new_inode */ |
940 | if(inode->i_sb->s_flags & MS_NOATIME) | 943 | if (inode->i_sb->s_flags & MS_NOATIME) |
941 | newinode->i_flags |= S_NOATIME | S_NOCMTIME; | 944 | newinode->i_flags |= S_NOATIME | S_NOCMTIME; |
942 | newinode->i_nlink = 2; | 945 | newinode->i_nlink = 2; |
943 | 946 | ||
@@ -949,17 +952,17 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
949 | posix_fill_in_inode(direntry->d_inode, | 952 | posix_fill_in_inode(direntry->d_inode, |
950 | pInfo, &obj_type, 1 /* NewInode */); | 953 | pInfo, &obj_type, 1 /* NewInode */); |
951 | #ifdef CONFIG_CIFS_DEBUG2 | 954 | #ifdef CONFIG_CIFS_DEBUG2 |
952 | cFYI(1,("instantiated dentry %p %s to inode %p", | 955 | cFYI(1, ("instantiated dentry %p %s to inode %p", |
953 | direntry, direntry->d_name.name, newinode)); | 956 | direntry, direntry->d_name.name, newinode)); |
954 | 957 | ||
955 | if(newinode->i_nlink != 2) | 958 | if (newinode->i_nlink != 2) |
956 | cFYI(1,("unexpected number of links %d", | 959 | cFYI(1, ("unexpected number of links %d", |
957 | newinode->i_nlink)); | 960 | newinode->i_nlink)); |
958 | #endif | 961 | #endif |
959 | } | 962 | } |
960 | kfree(pInfo); | 963 | kfree(pInfo); |
961 | goto mkdir_out; | 964 | goto mkdir_out; |
962 | } | 965 | } |
963 | 966 | ||
964 | /* BB add setting the equivalent of mode via CreateX w/ACLs */ | 967 | /* BB add setting the equivalent of mode via CreateX w/ACLs */ |
965 | rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls, | 968 | rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls, |
@@ -968,14 +971,14 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
968 | cFYI(1, ("cifs_mkdir returned 0x%x", rc)); | 971 | cFYI(1, ("cifs_mkdir returned 0x%x", rc)); |
969 | d_drop(direntry); | 972 | d_drop(direntry); |
970 | } else { | 973 | } else { |
971 | mkdir_get_info: | 974 | mkdir_get_info: |
972 | inc_nlink(inode); | 975 | inc_nlink(inode); |
973 | if (pTcon->ses->capabilities & CAP_UNIX) | 976 | if (pTcon->ses->capabilities & CAP_UNIX) |
974 | rc = cifs_get_inode_info_unix(&newinode, full_path, | 977 | rc = cifs_get_inode_info_unix(&newinode, full_path, |
975 | inode->i_sb,xid); | 978 | inode->i_sb, xid); |
976 | else | 979 | else |
977 | rc = cifs_get_inode_info(&newinode, full_path, NULL, | 980 | rc = cifs_get_inode_info(&newinode, full_path, NULL, |
978 | inode->i_sb,xid); | 981 | inode->i_sb, xid); |
979 | 982 | ||
980 | if (pTcon->nocase) | 983 | if (pTcon->nocase) |
981 | direntry->d_op = &cifs_ci_dentry_ops; | 984 | direntry->d_op = &cifs_ci_dentry_ops; |
@@ -983,9 +986,9 @@ mkdir_get_info: | |||
983 | direntry->d_op = &cifs_dentry_ops; | 986 | direntry->d_op = &cifs_dentry_ops; |
984 | d_instantiate(direntry, newinode); | 987 | d_instantiate(direntry, newinode); |
985 | /* setting nlink not necessary except in cases where we | 988 | /* setting nlink not necessary except in cases where we |
986 | * failed to get it from the server or was set bogus */ | 989 | * failed to get it from the server or was set bogus */ |
987 | if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) | 990 | if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) |
988 | direntry->d_inode->i_nlink = 2; | 991 | direntry->d_inode->i_nlink = 2; |
989 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { | 992 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { |
990 | mode &= ~current->fs->umask; | 993 | mode &= ~current->fs->umask; |
991 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { | 994 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { |
@@ -1002,27 +1005,27 @@ mkdir_get_info: | |||
1002 | mode, (__u64)-1, | 1005 | mode, (__u64)-1, |
1003 | (__u64)-1, 0 /* dev_t */, | 1006 | (__u64)-1, 0 /* dev_t */, |
1004 | cifs_sb->local_nls, | 1007 | cifs_sb->local_nls, |
1005 | cifs_sb->mnt_cifs_flags & | 1008 | cifs_sb->mnt_cifs_flags & |
1006 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1009 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1007 | } | 1010 | } |
1008 | } else { | 1011 | } else { |
1009 | /* BB to be implemented via Windows secrty descriptors | 1012 | /* BB to be implemented via Windows secrty descriptors |
1010 | eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, | 1013 | eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, |
1011 | -1, -1, local_nls); */ | 1014 | -1, -1, local_nls); */ |
1012 | if(direntry->d_inode) { | 1015 | if (direntry->d_inode) { |
1013 | direntry->d_inode->i_mode = mode; | 1016 | direntry->d_inode->i_mode = mode; |
1014 | direntry->d_inode->i_mode |= S_IFDIR; | 1017 | direntry->d_inode->i_mode |= S_IFDIR; |
1015 | if(cifs_sb->mnt_cifs_flags & | 1018 | if (cifs_sb->mnt_cifs_flags & |
1016 | CIFS_MOUNT_SET_UID) { | 1019 | CIFS_MOUNT_SET_UID) { |
1017 | direntry->d_inode->i_uid = | 1020 | direntry->d_inode->i_uid = |
1018 | current->fsuid; | 1021 | current->fsuid; |
1019 | direntry->d_inode->i_gid = | 1022 | direntry->d_inode->i_gid = |
1020 | current->fsgid; | 1023 | current->fsgid; |
1021 | } | 1024 | } |
1022 | } | 1025 | } |
1023 | } | 1026 | } |
1024 | } | 1027 | } |
1025 | mkdir_out: | 1028 | mkdir_out: |
1026 | kfree(full_path); | 1029 | kfree(full_path); |
1027 | FreeXid(xid); | 1030 | FreeXid(xid); |
1028 | return rc; | 1031 | return rc; |
@@ -1056,7 +1059,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry) | |||
1056 | if (!rc) { | 1059 | if (!rc) { |
1057 | drop_nlink(inode); | 1060 | drop_nlink(inode); |
1058 | spin_lock(&direntry->d_inode->i_lock); | 1061 | spin_lock(&direntry->d_inode->i_lock); |
1059 | i_size_write(direntry->d_inode,0); | 1062 | i_size_write(direntry->d_inode, 0); |
1060 | clear_nlink(direntry->d_inode); | 1063 | clear_nlink(direntry->d_inode); |
1061 | spin_unlock(&direntry->d_inode->i_lock); | 1064 | spin_unlock(&direntry->d_inode->i_lock); |
1062 | } | 1065 | } |
@@ -1121,7 +1124,7 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry, | |||
1121 | info_buf_target = info_buf_source + 1; | 1124 | info_buf_target = info_buf_source + 1; |
1122 | if (pTcon->ses->capabilities & CAP_UNIX) | 1125 | if (pTcon->ses->capabilities & CAP_UNIX) |
1123 | rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName, | 1126 | rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName, |
1124 | info_buf_source, | 1127 | info_buf_source, |
1125 | cifs_sb_source->local_nls, | 1128 | cifs_sb_source->local_nls, |
1126 | cifs_sb_source->mnt_cifs_flags & | 1129 | cifs_sb_source->mnt_cifs_flags & |
1127 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1130 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
@@ -1171,12 +1174,12 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry, | |||
1171 | might not right be right access to request */ | 1174 | might not right be right access to request */ |
1172 | rc = CIFSSMBOpen(xid, pTcon, fromName, FILE_OPEN, GENERIC_READ, | 1175 | rc = CIFSSMBOpen(xid, pTcon, fromName, FILE_OPEN, GENERIC_READ, |
1173 | CREATE_NOT_DIR, &netfid, &oplock, NULL, | 1176 | CREATE_NOT_DIR, &netfid, &oplock, NULL, |
1174 | cifs_sb_source->local_nls, | 1177 | cifs_sb_source->local_nls, |
1175 | cifs_sb_source->mnt_cifs_flags & | 1178 | cifs_sb_source->mnt_cifs_flags & |
1176 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1179 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1177 | if (rc==0) { | 1180 | if (rc == 0) { |
1178 | rc = CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName, | 1181 | rc = CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName, |
1179 | cifs_sb_source->local_nls, | 1182 | cifs_sb_source->local_nls, |
1180 | cifs_sb_source->mnt_cifs_flags & | 1183 | cifs_sb_source->mnt_cifs_flags & |
1181 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1184 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1182 | CIFSSMBClose(xid, pTcon, netfid); | 1185 | CIFSSMBClose(xid, pTcon, netfid); |
@@ -1249,7 +1252,7 @@ int cifs_revalidate(struct dentry *direntry) | |||
1249 | 1252 | ||
1250 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { | 1253 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) { |
1251 | rc = cifs_get_inode_info_unix(&direntry->d_inode, full_path, | 1254 | rc = cifs_get_inode_info_unix(&direntry->d_inode, full_path, |
1252 | direntry->d_sb,xid); | 1255 | direntry->d_sb, xid); |
1253 | if (rc) { | 1256 | if (rc) { |
1254 | cFYI(1, ("error on getting revalidate info %d", rc)); | 1257 | cFYI(1, ("error on getting revalidate info %d", rc)); |
1255 | /* if (rc != -ENOENT) | 1258 | /* if (rc != -ENOENT) |
@@ -1258,7 +1261,7 @@ int cifs_revalidate(struct dentry *direntry) | |||
1258 | } | 1261 | } |
1259 | } else { | 1262 | } else { |
1260 | rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL, | 1263 | rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL, |
1261 | direntry->d_sb,xid); | 1264 | direntry->d_sb, xid); |
1262 | if (rc) { | 1265 | if (rc) { |
1263 | cFYI(1, ("error on getting revalidate info %d", rc)); | 1266 | cFYI(1, ("error on getting revalidate info %d", rc)); |
1264 | /* if (rc != -ENOENT) | 1267 | /* if (rc != -ENOENT) |
@@ -1271,7 +1274,7 @@ int cifs_revalidate(struct dentry *direntry) | |||
1271 | /* if not oplocked, we invalidate inode pages if mtime or file size | 1274 | /* if not oplocked, we invalidate inode pages if mtime or file size |
1272 | had changed on server */ | 1275 | had changed on server */ |
1273 | 1276 | ||
1274 | if (timespec_equal(&local_mtime,&direntry->d_inode->i_mtime) && | 1277 | if (timespec_equal(&local_mtime, &direntry->d_inode->i_mtime) && |
1275 | (local_size == direntry->d_inode->i_size)) { | 1278 | (local_size == direntry->d_inode->i_size)) { |
1276 | cFYI(1, ("cifs_revalidate - inode unchanged")); | 1279 | cFYI(1, ("cifs_revalidate - inode unchanged")); |
1277 | } else { | 1280 | } else { |
@@ -1298,7 +1301,7 @@ int cifs_revalidate(struct dentry *direntry) | |||
1298 | if (invalidate_inode) { | 1301 | if (invalidate_inode) { |
1299 | /* shrink_dcache not necessary now that cifs dentry ops | 1302 | /* shrink_dcache not necessary now that cifs dentry ops |
1300 | are exported for negative dentries */ | 1303 | are exported for negative dentries */ |
1301 | /* if(S_ISDIR(direntry->d_inode->i_mode)) | 1304 | /* if (S_ISDIR(direntry->d_inode->i_mode)) |
1302 | shrink_dcache_parent(direntry); */ | 1305 | shrink_dcache_parent(direntry); */ |
1303 | if (S_ISREG(direntry->d_inode->i_mode)) { | 1306 | if (S_ISREG(direntry->d_inode->i_mode)) { |
1304 | if (direntry->d_inode->i_mapping) | 1307 | if (direntry->d_inode->i_mapping) |
@@ -1351,7 +1354,7 @@ static int cifs_truncate_page(struct address_space *mapping, loff_t from) | |||
1351 | return rc; | 1354 | return rc; |
1352 | } | 1355 | } |
1353 | 1356 | ||
1354 | static int cifs_vmtruncate(struct inode * inode, loff_t offset) | 1357 | static int cifs_vmtruncate(struct inode *inode, loff_t offset) |
1355 | { | 1358 | { |
1356 | struct address_space *mapping = inode->i_mapping; | 1359 | struct address_space *mapping = inode->i_mapping; |
1357 | unsigned long limit; | 1360 | unsigned long limit; |
@@ -1424,7 +1427,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1424 | if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) { | 1427 | if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) { |
1425 | /* check if we have permission to change attrs */ | 1428 | /* check if we have permission to change attrs */ |
1426 | rc = inode_change_ok(direntry->d_inode, attrs); | 1429 | rc = inode_change_ok(direntry->d_inode, attrs); |
1427 | if(rc < 0) { | 1430 | if (rc < 0) { |
1428 | FreeXid(xid); | 1431 | FreeXid(xid); |
1429 | return rc; | 1432 | return rc; |
1430 | } else | 1433 | } else |
@@ -1459,16 +1462,16 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1459 | rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, | 1462 | rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, |
1460 | nfid, npid, FALSE); | 1463 | nfid, npid, FALSE); |
1461 | atomic_dec(&open_file->wrtPending); | 1464 | atomic_dec(&open_file->wrtPending); |
1462 | cFYI(1,("SetFSize for attrs rc = %d", rc)); | 1465 | cFYI(1, ("SetFSize for attrs rc = %d", rc)); |
1463 | if((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | 1466 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { |
1464 | int bytes_written; | 1467 | int bytes_written; |
1465 | rc = CIFSSMBWrite(xid, pTcon, | 1468 | rc = CIFSSMBWrite(xid, pTcon, |
1466 | nfid, 0, attrs->ia_size, | 1469 | nfid, 0, attrs->ia_size, |
1467 | &bytes_written, NULL, NULL, | 1470 | &bytes_written, NULL, NULL, |
1468 | 1 /* 45 seconds */); | 1471 | 1 /* 45 seconds */); |
1469 | cFYI(1,("Wrt seteof rc %d", rc)); | 1472 | cFYI(1, ("Wrt seteof rc %d", rc)); |
1470 | } | 1473 | } |
1471 | } else | 1474 | } else |
1472 | rc = -EINVAL; | 1475 | rc = -EINVAL; |
1473 | 1476 | ||
1474 | if (rc != 0) { | 1477 | if (rc != 0) { |
@@ -1478,11 +1481,11 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1478 | it by handle */ | 1481 | it by handle */ |
1479 | rc = CIFSSMBSetEOF(xid, pTcon, full_path, | 1482 | rc = CIFSSMBSetEOF(xid, pTcon, full_path, |
1480 | attrs->ia_size, FALSE, | 1483 | attrs->ia_size, FALSE, |
1481 | cifs_sb->local_nls, | 1484 | cifs_sb->local_nls, |
1482 | cifs_sb->mnt_cifs_flags & | 1485 | cifs_sb->mnt_cifs_flags & |
1483 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1486 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1484 | cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); | 1487 | cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); |
1485 | if((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { | 1488 | if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { |
1486 | __u16 netfid; | 1489 | __u16 netfid; |
1487 | int oplock = FALSE; | 1490 | int oplock = FALSE; |
1488 | 1491 | ||
@@ -1493,14 +1496,14 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1493 | NULL, cifs_sb->local_nls, | 1496 | NULL, cifs_sb->local_nls, |
1494 | cifs_sb->mnt_cifs_flags & | 1497 | cifs_sb->mnt_cifs_flags & |
1495 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1498 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1496 | if (rc==0) { | 1499 | if (rc == 0) { |
1497 | int bytes_written; | 1500 | int bytes_written; |
1498 | rc = CIFSSMBWrite(xid, pTcon, | 1501 | rc = CIFSSMBWrite(xid, pTcon, |
1499 | netfid, 0, | 1502 | netfid, 0, |
1500 | attrs->ia_size, | 1503 | attrs->ia_size, |
1501 | &bytes_written, NULL, | 1504 | &bytes_written, NULL, |
1502 | NULL, 1 /* 45 sec */); | 1505 | NULL, 1 /* 45 sec */); |
1503 | cFYI(1,("wrt seteof rc %d",rc)); | 1506 | cFYI(1, ("wrt seteof rc %d", rc)); |
1504 | CIFSSMBClose(xid, pTcon, netfid); | 1507 | CIFSSMBClose(xid, pTcon, netfid); |
1505 | } | 1508 | } |
1506 | 1509 | ||
@@ -1517,7 +1520,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1517 | rc = cifs_vmtruncate(direntry->d_inode, attrs->ia_size); | 1520 | rc = cifs_vmtruncate(direntry->d_inode, attrs->ia_size); |
1518 | cifs_truncate_page(direntry->d_inode->i_mapping, | 1521 | cifs_truncate_page(direntry->d_inode->i_mapping, |
1519 | direntry->d_inode->i_size); | 1522 | direntry->d_inode->i_size); |
1520 | } else | 1523 | } else |
1521 | goto cifs_setattr_exit; | 1524 | goto cifs_setattr_exit; |
1522 | } | 1525 | } |
1523 | if (attrs->ia_valid & ATTR_UID) { | 1526 | if (attrs->ia_valid & ATTR_UID) { |
@@ -1539,7 +1542,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1539 | && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID))) | 1542 | && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID))) |
1540 | rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid, | 1543 | rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid, |
1541 | 0 /* dev_t */, cifs_sb->local_nls, | 1544 | 0 /* dev_t */, cifs_sb->local_nls, |
1542 | cifs_sb->mnt_cifs_flags & | 1545 | cifs_sb->mnt_cifs_flags & |
1543 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1546 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1544 | else if (attrs->ia_valid & ATTR_MODE) { | 1547 | else if (attrs->ia_valid & ATTR_MODE) { |
1545 | rc = 0; | 1548 | rc = 0; |
@@ -1559,7 +1562,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1559 | time_buf.Attributes = cpu_to_le32(cifsInode->cifsAttrs & | 1562 | time_buf.Attributes = cpu_to_le32(cifsInode->cifsAttrs & |
1560 | (~ATTR_READONLY)); | 1563 | (~ATTR_READONLY)); |
1561 | /* Windows ignores set to zero */ | 1564 | /* Windows ignores set to zero */ |
1562 | if(time_buf.Attributes == 0) | 1565 | if (time_buf.Attributes == 0) |
1563 | time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL); | 1566 | time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL); |
1564 | } | 1567 | } |
1565 | /* BB to be implemented - | 1568 | /* BB to be implemented - |
@@ -1624,7 +1627,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1624 | NULL, cifs_sb->local_nls, | 1627 | NULL, cifs_sb->local_nls, |
1625 | cifs_sb->mnt_cifs_flags & | 1628 | cifs_sb->mnt_cifs_flags & |
1626 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1629 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1627 | if (rc==0) { | 1630 | if (rc == 0) { |
1628 | rc = CIFSSMBSetFileTimes(xid, pTcon, &time_buf, | 1631 | rc = CIFSSMBSetFileTimes(xid, pTcon, &time_buf, |
1629 | netfid); | 1632 | netfid); |
1630 | CIFSSMBClose(xid, pTcon, netfid); | 1633 | CIFSSMBClose(xid, pTcon, netfid); |
@@ -1634,7 +1637,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1634 | granularity */ | 1637 | granularity */ |
1635 | 1638 | ||
1636 | /* rc = CIFSSMBSetTimesLegacy(xid, pTcon, full_path, | 1639 | /* rc = CIFSSMBSetTimesLegacy(xid, pTcon, full_path, |
1637 | &time_buf, cifs_sb->local_nls); */ | 1640 | &time_buf, cifs_sb->local_nls); */ |
1638 | } | 1641 | } |
1639 | } | 1642 | } |
1640 | /* Even if error on time set, no sense failing the call if | 1643 | /* Even if error on time set, no sense failing the call if |
@@ -1642,7 +1645,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) | |||
1642 | and this check ensures that we are not being called from | 1645 | and this check ensures that we are not being called from |
1643 | sys_utimes in which case we ought to fail the call back to | 1646 | sys_utimes in which case we ought to fail the call back to |
1644 | the user when the server rejects the call */ | 1647 | the user when the server rejects the call */ |
1645 | if((rc) && (attrs->ia_valid & | 1648 | if ((rc) && (attrs->ia_valid & |
1646 | (ATTR_MODE | ATTR_GID | ATTR_UID | ATTR_SIZE))) | 1649 | (ATTR_MODE | ATTR_GID | ATTR_UID | ATTR_SIZE))) |
1647 | rc = 0; | 1650 | rc = 0; |
1648 | } | 1651 | } |
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c index a414f1775ae0..d24fe6880a04 100644 --- a/fs/cifs/ioctl.c +++ b/fs/cifs/ioctl.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * vfs operations that deal with io control | 4 | * vfs operations that deal with io control |
5 | * | 5 | * |
6 | * Copyright (C) International Business Machines Corp., 2005 | 6 | * Copyright (C) International Business Machines Corp., 2005,2007 |
7 | * Author(s): Steve French (sfrench@us.ibm.com) | 7 | * Author(s): Steve French (sfrench@us.ibm.com) |
8 | * | 8 | * |
9 | * This library is free software; you can redistribute it and/or modify | 9 | * This library is free software; you can redistribute it and/or modify |
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | #define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2) | 31 | #define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2) |
32 | 32 | ||
33 | int cifs_ioctl (struct inode * inode, struct file * filep, | 33 | int 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 */ |
diff --git a/fs/cifs/link.c b/fs/cifs/link.c index 6baea85d726e..41f657ced7ec 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c | |||
@@ -50,32 +50,32 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, | |||
50 | 50 | ||
51 | fromName = build_path_from_dentry(old_file); | 51 | fromName = build_path_from_dentry(old_file); |
52 | toName = build_path_from_dentry(direntry); | 52 | toName = build_path_from_dentry(direntry); |
53 | if((fromName == NULL) || (toName == NULL)) { | 53 | if ((fromName == NULL) || (toName == NULL)) { |
54 | rc = -ENOMEM; | 54 | rc = -ENOMEM; |
55 | goto cifs_hl_exit; | 55 | goto cifs_hl_exit; |
56 | } | 56 | } |
57 | 57 | ||
58 | if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX) | 58 | if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX) |
59 | rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName, | 59 | rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName, |
60 | cifs_sb_target->local_nls, | 60 | cifs_sb_target->local_nls, |
61 | cifs_sb_target->mnt_cifs_flags & | 61 | cifs_sb_target->mnt_cifs_flags & |
62 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 62 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
63 | else { | 63 | else { |
64 | rc = CIFSCreateHardLink(xid, pTcon, fromName, toName, | 64 | rc = CIFSCreateHardLink(xid, pTcon, fromName, toName, |
65 | cifs_sb_target->local_nls, | 65 | cifs_sb_target->local_nls, |
66 | cifs_sb_target->mnt_cifs_flags & | 66 | cifs_sb_target->mnt_cifs_flags & |
67 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 67 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
68 | if((rc == -EIO) || (rc == -EINVAL)) | 68 | if ((rc == -EIO) || (rc == -EINVAL)) |
69 | rc = -EOPNOTSUPP; | 69 | rc = -EOPNOTSUPP; |
70 | } | 70 | } |
71 | 71 | ||
72 | d_drop(direntry); /* force new lookup from server of target */ | 72 | d_drop(direntry); /* force new lookup from server of target */ |
73 | 73 | ||
74 | /* if source file is cached (oplocked) revalidate will not go to server | 74 | /* if source file is cached (oplocked) revalidate will not go to server |
75 | until the file is closed or oplock broken so update nlinks locally */ | 75 | until the file is closed or oplock broken so update nlinks locally */ |
76 | if(old_file->d_inode) { | 76 | if (old_file->d_inode) { |
77 | cifsInode = CIFS_I(old_file->d_inode); | 77 | cifsInode = CIFS_I(old_file->d_inode); |
78 | if(rc == 0) { | 78 | if (rc == 0) { |
79 | old_file->d_inode->i_nlink++; | 79 | old_file->d_inode->i_nlink++; |
80 | /* BB should we make this contingent on superblock flag NOATIME? */ | 80 | /* BB should we make this contingent on superblock flag NOATIME? */ |
81 | /* old_file->d_inode->i_ctime = CURRENT_TIME;*/ | 81 | /* old_file->d_inode->i_ctime = CURRENT_TIME;*/ |
@@ -84,14 +84,14 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, | |||
84 | to set the parent dir cifs inode time to zero | 84 | to set the parent dir cifs inode time to zero |
85 | to force revalidate (faster) for it too? */ | 85 | to force revalidate (faster) for it too? */ |
86 | } | 86 | } |
87 | /* if not oplocked will force revalidate to get info | 87 | /* if not oplocked will force revalidate to get info |
88 | on source file from srv */ | 88 | on source file from srv */ |
89 | cifsInode->time = 0; | 89 | cifsInode->time = 0; |
90 | 90 | ||
91 | /* Will update parent dir timestamps from srv within a second. | 91 | /* Will update parent dir timestamps from srv within a second. |
92 | Would it really be worth it to set the parent dir (cifs | 92 | Would it really be worth it to set the parent dir (cifs |
93 | inode) time field to zero to force revalidate on parent | 93 | inode) time field to zero to force revalidate on parent |
94 | directory faster ie | 94 | directory faster ie |
95 | CIFS_I(inode)->time = 0; */ | 95 | CIFS_I(inode)->time = 0; */ |
96 | } | 96 | } |
97 | 97 | ||
@@ -109,7 +109,7 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) | |||
109 | int rc = -EACCES; | 109 | int rc = -EACCES; |
110 | int xid; | 110 | int xid; |
111 | char *full_path = NULL; | 111 | char *full_path = NULL; |
112 | char * target_path = ERR_PTR(-ENOMEM); | 112 | char *target_path = ERR_PTR(-ENOMEM); |
113 | struct cifs_sb_info *cifs_sb; | 113 | struct cifs_sb_info *cifs_sb; |
114 | struct cifsTconInfo *pTcon; | 114 | struct cifsTconInfo *pTcon; |
115 | 115 | ||
@@ -129,7 +129,8 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) | |||
129 | goto out; | 129 | goto out; |
130 | } | 130 | } |
131 | 131 | ||
132 | /* BB add read reparse point symlink code and Unix extensions symlink code here BB */ | 132 | /* BB add read reparse point symlink code and Unix extensions |
133 | symlink code here BB */ | ||
133 | if (pTcon->ses->capabilities & CAP_UNIX) | 134 | if (pTcon->ses->capabilities & CAP_UNIX) |
134 | rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, | 135 | rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, |
135 | target_path, | 136 | target_path, |
@@ -176,7 +177,7 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname) | |||
176 | 177 | ||
177 | full_path = build_path_from_dentry(direntry); | 178 | full_path = build_path_from_dentry(direntry); |
178 | 179 | ||
179 | if(full_path == NULL) { | 180 | if (full_path == NULL) { |
180 | FreeXid(xid); | 181 | FreeXid(xid); |
181 | return -ENOMEM; | 182 | return -ENOMEM; |
182 | } | 183 | } |
@@ -189,15 +190,16 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname) | |||
189 | rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname, | 190 | rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname, |
190 | cifs_sb->local_nls); | 191 | cifs_sb->local_nls); |
191 | /* else | 192 | /* else |
192 | rc = CIFSCreateReparseSymLink(xid, pTcon, fromName, toName,cifs_sb_target->local_nls); */ | 193 | rc = CIFSCreateReparseSymLink(xid, pTcon, fromName, toName, |
194 | cifs_sb_target->local_nls); */ | ||
193 | 195 | ||
194 | if (rc == 0) { | 196 | if (rc == 0) { |
195 | if (pTcon->ses->capabilities & CAP_UNIX) | 197 | if (pTcon->ses->capabilities & CAP_UNIX) |
196 | rc = cifs_get_inode_info_unix(&newinode, full_path, | 198 | rc = cifs_get_inode_info_unix(&newinode, full_path, |
197 | inode->i_sb,xid); | 199 | inode->i_sb, xid); |
198 | else | 200 | else |
199 | rc = cifs_get_inode_info(&newinode, full_path, NULL, | 201 | rc = cifs_get_inode_info(&newinode, full_path, NULL, |
200 | inode->i_sb,xid); | 202 | inode->i_sb, xid); |
201 | 203 | ||
202 | if (rc != 0) { | 204 | if (rc != 0) { |
203 | cFYI(1, ("Create symlink ok, getinodeinfo fail rc = %d", | 205 | cFYI(1, ("Create symlink ok, getinodeinfo fail rc = %d", |
@@ -226,9 +228,9 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) | |||
226 | struct cifs_sb_info *cifs_sb; | 228 | struct cifs_sb_info *cifs_sb; |
227 | struct cifsTconInfo *pTcon; | 229 | struct cifsTconInfo *pTcon; |
228 | char *full_path = NULL; | 230 | char *full_path = NULL; |
229 | char *tmp_path = NULL; | 231 | char *tmp_path = NULL; |
230 | char * tmpbuffer; | 232 | char *tmpbuffer; |
231 | unsigned char * referrals = NULL; | 233 | unsigned char *referrals = NULL; |
232 | int num_referrals = 0; | 234 | int num_referrals = 0; |
233 | int len; | 235 | int len; |
234 | __u16 fid; | 236 | __u16 fid; |
@@ -237,13 +239,13 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) | |||
237 | cifs_sb = CIFS_SB(inode->i_sb); | 239 | cifs_sb = CIFS_SB(inode->i_sb); |
238 | pTcon = cifs_sb->tcon; | 240 | pTcon = cifs_sb->tcon; |
239 | 241 | ||
240 | /* BB would it be safe against deadlock to grab this sem | 242 | /* BB would it be safe against deadlock to grab this sem |
241 | even though rename itself grabs the sem and calls lookup? */ | 243 | even though rename itself grabs the sem and calls lookup? */ |
242 | /* mutex_lock(&inode->i_sb->s_vfs_rename_mutex);*/ | 244 | /* mutex_lock(&inode->i_sb->s_vfs_rename_mutex);*/ |
243 | full_path = build_path_from_dentry(direntry); | 245 | full_path = build_path_from_dentry(direntry); |
244 | /* mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);*/ | 246 | /* mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);*/ |
245 | 247 | ||
246 | if(full_path == NULL) { | 248 | if (full_path == NULL) { |
247 | FreeXid(xid); | 249 | FreeXid(xid); |
248 | return -ENOMEM; | 250 | return -ENOMEM; |
249 | } | 251 | } |
@@ -251,70 +253,77 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) | |||
251 | cFYI(1, | 253 | cFYI(1, |
252 | ("Full path: %s inode = 0x%p pBuffer = 0x%p buflen = %d", | 254 | ("Full path: %s inode = 0x%p pBuffer = 0x%p buflen = %d", |
253 | full_path, inode, pBuffer, buflen)); | 255 | full_path, inode, pBuffer, buflen)); |
254 | if(buflen > PATH_MAX) | 256 | if (buflen > PATH_MAX) |
255 | len = PATH_MAX; | 257 | len = PATH_MAX; |
256 | else | 258 | else |
257 | len = buflen; | 259 | len = buflen; |
258 | tmpbuffer = kmalloc(len,GFP_KERNEL); | 260 | tmpbuffer = kmalloc(len, GFP_KERNEL); |
259 | if(tmpbuffer == NULL) { | 261 | if (tmpbuffer == NULL) { |
260 | kfree(full_path); | 262 | kfree(full_path); |
261 | FreeXid(xid); | 263 | FreeXid(xid); |
262 | return -ENOMEM; | 264 | return -ENOMEM; |
263 | } | 265 | } |
264 | 266 | ||
265 | /* BB add read reparse point symlink code and Unix extensions symlink code here BB */ | 267 | /* BB add read reparse point symlink code and |
268 | Unix extensions symlink code here BB */ | ||
266 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) | 269 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) |
267 | rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, | 270 | rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, |
268 | tmpbuffer, | 271 | tmpbuffer, |
269 | len - 1, | 272 | len - 1, |
270 | cifs_sb->local_nls); | 273 | cifs_sb->local_nls); |
271 | else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { | 274 | else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { |
272 | cERROR(1,("SFU style symlinks not implemented yet")); | 275 | cERROR(1, ("SFU style symlinks not implemented yet")); |
273 | /* add open and read as in fs/cifs/inode.c */ | 276 | /* add open and read as in fs/cifs/inode.c */ |
274 | 277 | ||
275 | } else { | 278 | } else { |
276 | rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ, | 279 | rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ, |
277 | OPEN_REPARSE_POINT,&fid, &oplock, NULL, | 280 | OPEN_REPARSE_POINT, &fid, &oplock, NULL, |
278 | cifs_sb->local_nls, | 281 | cifs_sb->local_nls, |
279 | cifs_sb->mnt_cifs_flags & | 282 | cifs_sb->mnt_cifs_flags & |
280 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 283 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
281 | if(!rc) { | 284 | if (!rc) { |
282 | rc = CIFSSMBQueryReparseLinkInfo(xid, pTcon, full_path, | 285 | rc = CIFSSMBQueryReparseLinkInfo(xid, pTcon, full_path, |
283 | tmpbuffer, | 286 | tmpbuffer, |
284 | len - 1, | 287 | len - 1, |
285 | fid, | 288 | fid, |
286 | cifs_sb->local_nls); | 289 | cifs_sb->local_nls); |
287 | if(CIFSSMBClose(xid, pTcon, fid)) { | 290 | if (CIFSSMBClose(xid, pTcon, fid)) { |
288 | cFYI(1,("Error closing junction point (open for ioctl)")); | 291 | cFYI(1,("Error closing junction point (open for ioctl)")); |
289 | } | 292 | } |
290 | if(rc == -EIO) { | 293 | if (rc == -EIO) { |
291 | /* Query if DFS Junction */ | 294 | /* Query if DFS Junction */ |
292 | tmp_path = | 295 | tmp_path = |
293 | kmalloc(MAX_TREE_SIZE + MAX_PATHCONF + 1, | 296 | kmalloc(MAX_TREE_SIZE + MAX_PATHCONF + 1, |
294 | GFP_KERNEL); | 297 | GFP_KERNEL); |
295 | if (tmp_path) { | 298 | if (tmp_path) { |
296 | strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE); | 299 | strncpy(tmp_path, pTcon->treeName, |
297 | strncat(tmp_path, full_path, MAX_PATHCONF); | 300 | MAX_TREE_SIZE); |
298 | rc = get_dfs_path(xid, pTcon->ses, tmp_path, | 301 | strncat(tmp_path, full_path, |
302 | MAX_PATHCONF); | ||
303 | rc = get_dfs_path(xid, pTcon->ses, | ||
304 | tmp_path, | ||
299 | cifs_sb->local_nls, | 305 | cifs_sb->local_nls, |
300 | &num_referrals, &referrals, | 306 | &num_referrals, &referrals, |
301 | cifs_sb->mnt_cifs_flags & | 307 | cifs_sb->mnt_cifs_flags & |
302 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 308 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
303 | cFYI(1,("Get DFS for %s rc = %d ",tmp_path, rc)); | 309 | cFYI(1, ("Get DFS for %s rc = %d ", |
304 | if((num_referrals == 0) && (rc == 0)) | 310 | tmp_path, rc)); |
311 | if ((num_referrals == 0) && (rc == 0)) | ||
305 | rc = -EACCES; | 312 | rc = -EACCES; |
306 | else { | 313 | else { |
307 | cFYI(1,("num referral: %d",num_referrals)); | 314 | cFYI(1, ("num referral: %d", |
308 | if(referrals) { | 315 | num_referrals)); |
309 | cFYI(1,("referral string: %s",referrals)); | 316 | if (referrals) { |
310 | strncpy(tmpbuffer, referrals, len-1); | 317 | cFYI(1,("referral string: %s", referrals)); |
318 | strncpy(tmpbuffer, referrals, len-1); | ||
311 | } | 319 | } |
312 | } | 320 | } |
313 | kfree(referrals); | 321 | kfree(referrals); |
314 | kfree(tmp_path); | 322 | kfree(tmp_path); |
315 | } | 323 | } |
316 | /* BB add code like else decode referrals then memcpy to | 324 | /* BB add code like else decode referrals |
317 | tmpbuffer and free referrals string array BB */ | 325 | then memcpy to tmpbuffer and free referrals |
326 | string array BB */ | ||
318 | } | 327 | } |
319 | } | 328 | } |
320 | } | 329 | } |
diff --git a/fs/cifs/md4.c b/fs/cifs/md4.c index 46d62c9dda0f..b828a2e7d667 100644 --- a/fs/cifs/md4.c +++ b/fs/cifs/md4.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | Unix SMB/Netbios implementation. | 2 | Unix SMB/Netbios implementation. |
3 | Version 1.9. | 3 | Version 1.9. |
4 | a implementation of MD4 designed for use in the SMB authentication protocol | 4 | a implementation of MD4 designed for use in the SMB authentication protocol |
@@ -170,7 +170,7 @@ mdfour(unsigned char *out, unsigned char *in, int n) | |||
170 | 170 | ||
171 | while (n > 64) { | 171 | while (n > 64) { |
172 | copy64(M, in); | 172 | copy64(M, in); |
173 | mdfour64(M,&A,&B, &C, &D); | 173 | mdfour64(M, &A, &B, &C, &D); |
174 | in += 64; | 174 | in += 64; |
175 | n -= 64; | 175 | n -= 64; |
176 | } | 176 | } |
diff --git a/fs/cifs/md5.c b/fs/cifs/md5.c index ccebf9b7eb86..e5c3e1212697 100644 --- a/fs/cifs/md5.c +++ b/fs/cifs/md5.c | |||
@@ -15,9 +15,9 @@ | |||
15 | * will fill a supplied 16-byte array with the digest. | 15 | * will fill a supplied 16-byte array with the digest. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | /* This code slightly modified to fit into Samba by | 18 | /* This code slightly modified to fit into Samba by |
19 | abartlet@samba.org Jun 2001 | 19 | abartlet@samba.org Jun 2001 |
20 | and to fit the cifs vfs by | 20 | and to fit the cifs vfs by |
21 | Steve French sfrench@us.ibm.com */ | 21 | Steve French sfrench@us.ibm.com */ |
22 | 22 | ||
23 | #include <linux/string.h> | 23 | #include <linux/string.h> |
@@ -106,7 +106,7 @@ MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) | |||
106 | } | 106 | } |
107 | 107 | ||
108 | /* | 108 | /* |
109 | * Final wrapup - pad to 64-byte boundary with the bit pattern | 109 | * Final wrapup - pad to 64-byte boundary with the bit pattern |
110 | * 1 0* (64-bit count of bits processed, MSB-first) | 110 | * 1 0* (64-bit count of bits processed, MSB-first) |
111 | */ | 111 | */ |
112 | void | 112 | void |
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 0211e0651b50..7590fd3d958c 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -16,7 +16,7 @@ | |||
16 | * | 16 | * |
17 | * You should have received a copy of the GNU Lesser General Public License | 17 | * You should have received a copy of the GNU Lesser General Public License |
18 | * along with this library; if not, write to the Free Software | 18 | * along with this library; 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 | 21 | ||
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
@@ -32,12 +32,12 @@ | |||
32 | 32 | ||
33 | extern mempool_t *cifs_sm_req_poolp; | 33 | extern mempool_t *cifs_sm_req_poolp; |
34 | extern mempool_t *cifs_req_poolp; | 34 | extern mempool_t *cifs_req_poolp; |
35 | extern struct task_struct * oplockThread; | 35 | extern struct task_struct *oplockThread; |
36 | 36 | ||
37 | /* The xid serves as a useful identifier for each incoming vfs request, | 37 | /* The xid serves as a useful identifier for each incoming vfs request, |
38 | in a similar way to the mid which is useful to track each sent smb, | 38 | in a similar way to the mid which is useful to track each sent smb, |
39 | and CurrentXid can also provide a running counter (although it | 39 | and CurrentXid can also provide a running counter (although it |
40 | will eventually wrap past zero) of the total vfs operations handled | 40 | will eventually wrap past zero) of the total vfs operations handled |
41 | since the cifs fs was mounted */ | 41 | since the cifs fs was mounted */ |
42 | 42 | ||
43 | unsigned int | 43 | unsigned int |
@@ -50,7 +50,7 @@ _GetXid(void) | |||
50 | if (GlobalTotalActiveXid > GlobalMaxActiveXid) | 50 | if (GlobalTotalActiveXid > GlobalMaxActiveXid) |
51 | GlobalMaxActiveXid = GlobalTotalActiveXid; /* keep high water mark for number of simultaneous vfs ops in our filesystem */ | 51 | GlobalMaxActiveXid = GlobalTotalActiveXid; /* keep high water mark for number of simultaneous vfs ops in our filesystem */ |
52 | if (GlobalTotalActiveXid > 65000) | 52 | if (GlobalTotalActiveXid > 65000) |
53 | cFYI(1,("warning: more than 65000 requests active")); | 53 | cFYI(1, ("warning: more than 65000 requests active")); |
54 | xid = GlobalCurrentXid++; | 54 | xid = GlobalCurrentXid++; |
55 | spin_unlock(&GlobalMid_Lock); | 55 | spin_unlock(&GlobalMid_Lock); |
56 | return xid; | 56 | return xid; |
@@ -144,9 +144,9 @@ cifs_buf_get(void) | |||
144 | { | 144 | { |
145 | struct smb_hdr *ret_buf = NULL; | 145 | struct smb_hdr *ret_buf = NULL; |
146 | 146 | ||
147 | /* We could use negotiated size instead of max_msgsize - | 147 | /* We could use negotiated size instead of max_msgsize - |
148 | but it may be more efficient to always alloc same size | 148 | but it may be more efficient to always alloc same size |
149 | albeit slightly larger than necessary and maxbuffersize | 149 | albeit slightly larger than necessary and maxbuffersize |
150 | defaults to this and can not be bigger */ | 150 | defaults to this and can not be bigger */ |
151 | ret_buf = | 151 | ret_buf = |
152 | (struct smb_hdr *) mempool_alloc(cifs_req_poolp, GFP_KERNEL | GFP_NOFS); | 152 | (struct smb_hdr *) mempool_alloc(cifs_req_poolp, GFP_KERNEL | GFP_NOFS); |
@@ -172,7 +172,7 @@ cifs_buf_release(void *buf_to_free) | |||
172 | /* cFYI(1, ("Null buffer passed to cifs_buf_release"));*/ | 172 | /* cFYI(1, ("Null buffer passed to cifs_buf_release"));*/ |
173 | return; | 173 | return; |
174 | } | 174 | } |
175 | mempool_free(buf_to_free,cifs_req_poolp); | 175 | mempool_free(buf_to_free, cifs_req_poolp); |
176 | 176 | ||
177 | atomic_dec(&bufAllocCount); | 177 | atomic_dec(&bufAllocCount); |
178 | return; | 178 | return; |
@@ -183,9 +183,9 @@ cifs_small_buf_get(void) | |||
183 | { | 183 | { |
184 | struct smb_hdr *ret_buf = NULL; | 184 | struct smb_hdr *ret_buf = NULL; |
185 | 185 | ||
186 | /* We could use negotiated size instead of max_msgsize - | 186 | /* We could use negotiated size instead of max_msgsize - |
187 | but it may be more efficient to always alloc same size | 187 | but it may be more efficient to always alloc same size |
188 | albeit slightly larger than necessary and maxbuffersize | 188 | albeit slightly larger than necessary and maxbuffersize |
189 | defaults to this and can not be bigger */ | 189 | defaults to this and can not be bigger */ |
190 | ret_buf = | 190 | ret_buf = |
191 | (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, GFP_KERNEL | GFP_NOFS); | 191 | (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, GFP_KERNEL | GFP_NOFS); |
@@ -209,30 +209,30 @@ cifs_small_buf_release(void *buf_to_free) | |||
209 | cFYI(1, ("Null buffer passed to cifs_small_buf_release")); | 209 | cFYI(1, ("Null buffer passed to cifs_small_buf_release")); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | mempool_free(buf_to_free,cifs_sm_req_poolp); | 212 | mempool_free(buf_to_free, cifs_sm_req_poolp); |
213 | 213 | ||
214 | atomic_dec(&smBufAllocCount); | 214 | atomic_dec(&smBufAllocCount); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | 217 | ||
218 | /* | 218 | /* |
219 | Find a free multiplex id (SMB mid). Otherwise there could be | 219 | Find a free multiplex id (SMB mid). Otherwise there could be |
220 | mid collisions which might cause problems, demultiplexing the | 220 | mid collisions which might cause problems, demultiplexing the |
221 | wrong response to this request. Multiplex ids could collide if | 221 | wrong response to this request. Multiplex ids could collide if |
222 | one of a series requests takes much longer than the others, or | 222 | one of a series requests takes much longer than the others, or |
223 | if a very large number of long lived requests (byte range | 223 | if a very large number of long lived requests (byte range |
224 | locks or FindNotify requests) are pending. No more than | 224 | locks or FindNotify requests) are pending. No more than |
225 | 64K-1 requests can be outstanding at one time. If no | 225 | 64K-1 requests can be outstanding at one time. If no |
226 | mids are available, return zero. A future optimization | 226 | mids are available, return zero. A future optimization |
227 | could make the combination of mids and uid the key we use | 227 | could make the combination of mids and uid the key we use |
228 | to demultiplex on (rather than mid alone). | 228 | to demultiplex on (rather than mid alone). |
229 | In addition to the above check, the cifs demultiplex | 229 | In addition to the above check, the cifs demultiplex |
230 | code already used the command code as a secondary | 230 | code already used the command code as a secondary |
231 | check of the frame and if signing is negotiated the | 231 | check of the frame and if signing is negotiated the |
232 | response would be discarded if the mid were the same | 232 | response would be discarded if the mid were the same |
233 | but the signature was wrong. Since the mid is not put in the | 233 | but the signature was wrong. Since the mid is not put in the |
234 | pending queue until later (when it is about to be dispatched) | 234 | pending queue until later (when it is about to be dispatched) |
235 | we do have to limit the number of outstanding requests | 235 | we do have to limit the number of outstanding requests |
236 | to somewhat less than 64K-1 although it is hard to imagine | 236 | to somewhat less than 64K-1 although it is hard to imagine |
237 | so many threads being in the vfs at one time. | 237 | so many threads being in the vfs at one time. |
238 | */ | 238 | */ |
@@ -240,7 +240,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server) | |||
240 | { | 240 | { |
241 | __u16 mid = 0; | 241 | __u16 mid = 0; |
242 | __u16 last_mid; | 242 | __u16 last_mid; |
243 | int collision; | 243 | int collision; |
244 | 244 | ||
245 | if (server == NULL) | 245 | if (server == NULL) |
246 | return mid; | 246 | return mid; |
@@ -249,13 +249,13 @@ __u16 GetNextMid(struct TCP_Server_Info *server) | |||
249 | last_mid = server->CurrentMid; /* we do not want to loop forever */ | 249 | last_mid = server->CurrentMid; /* we do not want to loop forever */ |
250 | server->CurrentMid++; | 250 | server->CurrentMid++; |
251 | /* This nested loop looks more expensive than it is. | 251 | /* This nested loop looks more expensive than it is. |
252 | In practice the list of pending requests is short, | 252 | In practice the list of pending requests is short, |
253 | fewer than 50, and the mids are likely to be unique | 253 | fewer than 50, and the mids are likely to be unique |
254 | on the first pass through the loop unless some request | 254 | on the first pass through the loop unless some request |
255 | takes longer than the 64 thousand requests before it | 255 | takes longer than the 64 thousand requests before it |
256 | (and it would also have to have been a request that | 256 | (and it would also have to have been a request that |
257 | did not time out) */ | 257 | did not time out) */ |
258 | while(server->CurrentMid != last_mid) { | 258 | while (server->CurrentMid != last_mid) { |
259 | struct list_head *tmp; | 259 | struct list_head *tmp; |
260 | struct mid_q_entry *mid_entry; | 260 | struct mid_q_entry *mid_entry; |
261 | 261 | ||
@@ -290,11 +290,11 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
290 | const struct cifsTconInfo *treeCon, int word_count | 290 | const struct cifsTconInfo *treeCon, int word_count |
291 | /* length of fixed section (word count) in two byte units */) | 291 | /* length of fixed section (word count) in two byte units */) |
292 | { | 292 | { |
293 | struct list_head* temp_item; | 293 | struct list_head *temp_item; |
294 | struct cifsSesInfo * ses; | 294 | struct cifsSesInfo *ses; |
295 | char *temp = (char *) buffer; | 295 | char *temp = (char *) buffer; |
296 | 296 | ||
297 | memset(temp,0,256); /* bigger than MAX_CIFS_HDR_SIZE */ | 297 | memset(temp, 0, 256); /* bigger than MAX_CIFS_HDR_SIZE */ |
298 | 298 | ||
299 | buffer->smb_buf_length = | 299 | buffer->smb_buf_length = |
300 | (2 * word_count) + sizeof (struct smb_hdr) - | 300 | (2 * word_count) + sizeof (struct smb_hdr) - |
@@ -348,7 +348,7 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
348 | /* flag were disabled. */ | 348 | /* flag were disabled. */ |
349 | 349 | ||
350 | /* BB Add support for establishing new tCon and SMB Session */ | 350 | /* BB Add support for establishing new tCon and SMB Session */ |
351 | /* with userid/password pairs found on the smb session */ | 351 | /* with userid/password pairs found on the smb session */ |
352 | /* for other target tcp/ip addresses BB */ | 352 | /* for other target tcp/ip addresses BB */ |
353 | if (current->fsuid != treeCon->ses->linux_uid) { | 353 | if (current->fsuid != treeCon->ses->linux_uid) { |
354 | cFYI(1,("Multiuser mode and UID did not match tcon uid")); | 354 | cFYI(1,("Multiuser mode and UID did not match tcon uid")); |
@@ -357,12 +357,12 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
357 | ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList); | 357 | ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList); |
358 | if (ses->linux_uid == current->fsuid) { | 358 | if (ses->linux_uid == current->fsuid) { |
359 | if (ses->server == treeCon->ses->server) { | 359 | if (ses->server == treeCon->ses->server) { |
360 | cFYI(1,("found matching uid substitute right smb_uid")); | 360 | cFYI(1, ("found matching uid substitute right smb_uid")); |
361 | buffer->Uid = ses->Suid; | 361 | buffer->Uid = ses->Suid; |
362 | break; | 362 | break; |
363 | } else { | 363 | } else { |
364 | /* BB eventually call cifs_setup_session here */ | 364 | /* BB eventually call cifs_setup_session here */ |
365 | cFYI(1,("local UID found but smb sess with this server does not exist")); | 365 | cFYI(1, ("local UID found but no smb sess with this server exists")); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | } | 368 | } |
@@ -388,18 +388,18 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
388 | static int | 388 | static int |
389 | checkSMBhdr(struct smb_hdr *smb, __u16 mid) | 389 | checkSMBhdr(struct smb_hdr *smb, __u16 mid) |
390 | { | 390 | { |
391 | /* Make sure that this really is an SMB, that it is a response, | 391 | /* Make sure that this really is an SMB, that it is a response, |
392 | and that the message ids match */ | 392 | and that the message ids match */ |
393 | if ((*(__le32 *) smb->Protocol == cpu_to_le32(0x424d53ff)) && | 393 | if ((*(__le32 *) smb->Protocol == cpu_to_le32(0x424d53ff)) && |
394 | (mid == smb->Mid)) { | 394 | (mid == smb->Mid)) { |
395 | if (smb->Flags & SMBFLG_RESPONSE) | 395 | if (smb->Flags & SMBFLG_RESPONSE) |
396 | return 0; | 396 | return 0; |
397 | else { | 397 | else { |
398 | /* only one valid case where server sends us request */ | 398 | /* only one valid case where server sends us request */ |
399 | if (smb->Command == SMB_COM_LOCKING_ANDX) | 399 | if (smb->Command == SMB_COM_LOCKING_ANDX) |
400 | return 0; | 400 | return 0; |
401 | else | 401 | else |
402 | cERROR(1, ("Rcvd Request not response")); | 402 | cERROR(1, ("Received Request not response")); |
403 | } | 403 | } |
404 | } else { /* bad signature or mid */ | 404 | } else { /* bad signature or mid */ |
405 | if (*(__le32 *) smb->Protocol != cpu_to_le32(0x424d53ff)) | 405 | if (*(__le32 *) smb->Protocol != cpu_to_le32(0x424d53ff)) |
@@ -426,9 +426,9 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) | |||
426 | smb->WordCount = 0; | 426 | smb->WordCount = 0; |
427 | /* some error cases do not return wct and bcc */ | 427 | /* some error cases do not return wct and bcc */ |
428 | return 0; | 428 | return 0; |
429 | } else if ((length == sizeof(struct smb_hdr) + 1) && | 429 | } else if ((length == sizeof(struct smb_hdr) + 1) && |
430 | (smb->WordCount == 0)) { | 430 | (smb->WordCount == 0)) { |
431 | char * tmp = (char *)smb; | 431 | char *tmp = (char *)smb; |
432 | /* Need to work around a bug in two servers here */ | 432 | /* Need to work around a bug in two servers here */ |
433 | /* First, check if the part of bcc they sent was zero */ | 433 | /* First, check if the part of bcc they sent was zero */ |
434 | if (tmp[sizeof(struct smb_hdr)] == 0) { | 434 | if (tmp[sizeof(struct smb_hdr)] == 0) { |
@@ -442,7 +442,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) | |||
442 | tmp[sizeof(struct smb_hdr)+1] = 0; | 442 | tmp[sizeof(struct smb_hdr)+1] = 0; |
443 | return 0; | 443 | return 0; |
444 | } | 444 | } |
445 | cERROR(1,("rcvd invalid byte count (bcc)")); | 445 | cERROR(1, ("rcvd invalid byte count (bcc)")); |
446 | } else { | 446 | } else { |
447 | cERROR(1, ("Length less than smb header size")); | 447 | cERROR(1, ("Length less than smb header size")); |
448 | } | 448 | } |
@@ -468,15 +468,15 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) | |||
468 | if ((len > 64 * 1024) && (len > clc_len)) { | 468 | if ((len > 64 * 1024) && (len > clc_len)) { |
469 | /* check if lengths match mod 64K */ | 469 | /* check if lengths match mod 64K */ |
470 | if (((4 + len) & 0xFFFF) == (clc_len & 0xFFFF)) | 470 | if (((4 + len) & 0xFFFF) == (clc_len & 0xFFFF)) |
471 | return 0; /* bcc wrapped */ | 471 | return 0; /* bcc wrapped */ |
472 | } | 472 | } |
473 | cFYI(1, ("Calculated size %d vs length %d mismatch for mid %d", | 473 | cFYI(1, ("Calculated size %d vs length %d mismatch for mid %d", |
474 | clc_len, 4 + len, smb->Mid)); | 474 | clc_len, 4 + len, smb->Mid)); |
475 | /* Windows XP can return a few bytes too much, presumably | 475 | /* Windows XP can return a few bytes too much, presumably |
476 | an illegal pad, at the end of byte range lock responses | 476 | an illegal pad, at the end of byte range lock responses |
477 | so we allow for that three byte pad, as long as actual | 477 | so we allow for that three byte pad, as long as actual |
478 | received length is as long or longer than calculated length */ | 478 | received length is as long or longer than calculated length */ |
479 | /* We have now had to extend this more, since there is a | 479 | /* We have now had to extend this more, since there is a |
480 | case in which it needs to be bigger still to handle a | 480 | case in which it needs to be bigger still to handle a |
481 | malformed response to transact2 findfirst from WinXP when | 481 | malformed response to transact2 findfirst from WinXP when |
482 | access denied is returned and thus bcc and wct are zero | 482 | access denied is returned and thus bcc and wct are zero |
@@ -495,37 +495,38 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) | |||
495 | } | 495 | } |
496 | int | 496 | int |
497 | is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | 497 | is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) |
498 | { | 498 | { |
499 | struct smb_com_lock_req * pSMB = (struct smb_com_lock_req *)buf; | 499 | struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf; |
500 | struct list_head *tmp; | 500 | struct list_head *tmp; |
501 | struct list_head *tmp1; | 501 | struct list_head *tmp1; |
502 | struct cifsTconInfo *tcon; | 502 | struct cifsTconInfo *tcon; |
503 | struct cifsFileInfo *netfile; | 503 | struct cifsFileInfo *netfile; |
504 | 504 | ||
505 | cFYI(1,("Checking for oplock break or dnotify response")); | 505 | cFYI(1, ("Checking for oplock break or dnotify response")); |
506 | if ((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) && | 506 | if ((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) && |
507 | (pSMB->hdr.Flags & SMBFLG_RESPONSE)) { | 507 | (pSMB->hdr.Flags & SMBFLG_RESPONSE)) { |
508 | struct smb_com_transaction_change_notify_rsp * pSMBr = | 508 | struct smb_com_transaction_change_notify_rsp *pSMBr = |
509 | (struct smb_com_transaction_change_notify_rsp *)buf; | 509 | (struct smb_com_transaction_change_notify_rsp *)buf; |
510 | struct file_notify_information * pnotify; | 510 | struct file_notify_information *pnotify; |
511 | __u32 data_offset = 0; | 511 | __u32 data_offset = 0; |
512 | if (pSMBr->ByteCount > sizeof(struct file_notify_information)) { | 512 | if (pSMBr->ByteCount > sizeof(struct file_notify_information)) { |
513 | data_offset = le32_to_cpu(pSMBr->DataOffset); | 513 | data_offset = le32_to_cpu(pSMBr->DataOffset); |
514 | 514 | ||
515 | pnotify = (struct file_notify_information *) | 515 | pnotify = (struct file_notify_information *) |
516 | ((char *)&pSMBr->hdr.Protocol + data_offset); | 516 | ((char *)&pSMBr->hdr.Protocol + data_offset); |
517 | cFYI(1,("dnotify on %s Action: 0x%x",pnotify->FileName, | 517 | cFYI(1,("dnotify on %s Action: 0x%x", pnotify->FileName, |
518 | pnotify->Action)); /* BB removeme BB */ | 518 | pnotify->Action)); /* BB removeme BB */ |
519 | /* cifs_dump_mem("Rcvd notify Data: ",buf, | 519 | /* cifs_dump_mem("Rcvd notify Data: ",buf, |
520 | sizeof(struct smb_hdr)+60); */ | 520 | sizeof(struct smb_hdr)+60); */ |
521 | return TRUE; | 521 | return TRUE; |
522 | } | 522 | } |
523 | if (pSMBr->hdr.Status.CifsError) { | 523 | if (pSMBr->hdr.Status.CifsError) { |
524 | cFYI(1,("notify err 0x%d",pSMBr->hdr.Status.CifsError)); | 524 | cFYI(1, ("notify err 0x%d", |
525 | pSMBr->hdr.Status.CifsError)); | ||
525 | return TRUE; | 526 | return TRUE; |
526 | } | 527 | } |
527 | return FALSE; | 528 | return FALSE; |
528 | } | 529 | } |
529 | if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX) | 530 | if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX) |
530 | return FALSE; | 531 | return FALSE; |
531 | if (pSMB->hdr.Flags & SMBFLG_RESPONSE) { | 532 | if (pSMB->hdr.Flags & SMBFLG_RESPONSE) { |
@@ -533,13 +534,13 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | |||
533 | break - harmless race between close request and oplock | 534 | break - harmless race between close request and oplock |
534 | break response is expected from time to time writing out | 535 | break response is expected from time to time writing out |
535 | large dirty files cached on the client */ | 536 | large dirty files cached on the client */ |
536 | if ((NT_STATUS_INVALID_HANDLE) == | 537 | if ((NT_STATUS_INVALID_HANDLE) == |
537 | le32_to_cpu(pSMB->hdr.Status.CifsError)) { | 538 | le32_to_cpu(pSMB->hdr.Status.CifsError)) { |
538 | cFYI(1,("invalid handle on oplock break")); | 539 | cFYI(1, ("invalid handle on oplock break")); |
539 | return TRUE; | 540 | return TRUE; |
540 | } else if (ERRbadfid == | 541 | } else if (ERRbadfid == |
541 | le16_to_cpu(pSMB->hdr.Status.DosError.Error)) { | 542 | le16_to_cpu(pSMB->hdr.Status.DosError.Error)) { |
542 | return TRUE; | 543 | return TRUE; |
543 | } else { | 544 | } else { |
544 | return FALSE; /* on valid oplock brk we get "request" */ | 545 | return FALSE; /* on valid oplock brk we get "request" */ |
545 | } | 546 | } |
@@ -547,9 +548,10 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | |||
547 | if (pSMB->hdr.WordCount != 8) | 548 | if (pSMB->hdr.WordCount != 8) |
548 | return FALSE; | 549 | return FALSE; |
549 | 550 | ||
550 | cFYI(1,(" oplock type 0x%d level 0x%d",pSMB->LockType,pSMB->OplockLevel)); | 551 | cFYI(1, ("oplock type 0x%d level 0x%d", |
552 | pSMB->LockType, pSMB->OplockLevel)); | ||
551 | if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)) | 553 | if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)) |
552 | return FALSE; | 554 | return FALSE; |
553 | 555 | ||
554 | /* look up tcon based on tid & uid */ | 556 | /* look up tcon based on tid & uid */ |
555 | read_lock(&GlobalSMBSeslock); | 557 | read_lock(&GlobalSMBSeslock); |
@@ -557,14 +559,14 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | |||
557 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 559 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
558 | if ((tcon->tid == buf->Tid) && (srv == tcon->ses->server)) { | 560 | if ((tcon->tid == buf->Tid) && (srv == tcon->ses->server)) { |
559 | cifs_stats_inc(&tcon->num_oplock_brks); | 561 | cifs_stats_inc(&tcon->num_oplock_brks); |
560 | list_for_each(tmp1,&tcon->openFileList){ | 562 | list_for_each(tmp1, &tcon->openFileList) { |
561 | netfile = list_entry(tmp1,struct cifsFileInfo, | 563 | netfile = list_entry(tmp1, struct cifsFileInfo, |
562 | tlist); | 564 | tlist); |
563 | if (pSMB->Fid == netfile->netfid) { | 565 | if (pSMB->Fid == netfile->netfid) { |
564 | struct cifsInodeInfo *pCifsInode; | 566 | struct cifsInodeInfo *pCifsInode; |
565 | read_unlock(&GlobalSMBSeslock); | 567 | read_unlock(&GlobalSMBSeslock); |
566 | cFYI(1,("file id match, oplock break")); | 568 | cFYI(1,("file id match, oplock break")); |
567 | pCifsInode = | 569 | pCifsInode = |
568 | CIFS_I(netfile->pInode); | 570 | CIFS_I(netfile->pInode); |
569 | pCifsInode->clientCanCacheAll = FALSE; | 571 | pCifsInode->clientCanCacheAll = FALSE; |
570 | if (pSMB->OplockLevel == 0) | 572 | if (pSMB->OplockLevel == 0) |
@@ -581,12 +583,12 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | |||
581 | } | 583 | } |
582 | } | 584 | } |
583 | read_unlock(&GlobalSMBSeslock); | 585 | read_unlock(&GlobalSMBSeslock); |
584 | cFYI(1,("No matching file for oplock break")); | 586 | cFYI(1, ("No matching file for oplock break")); |
585 | return TRUE; | 587 | return TRUE; |
586 | } | 588 | } |
587 | } | 589 | } |
588 | read_unlock(&GlobalSMBSeslock); | 590 | read_unlock(&GlobalSMBSeslock); |
589 | cFYI(1,("Can not process oplock break for non-existent connection")); | 591 | cFYI(1, ("Can not process oplock break for non-existent connection")); |
590 | return TRUE; | 592 | return TRUE; |
591 | } | 593 | } |
592 | 594 | ||
@@ -643,13 +645,13 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length) | |||
643 | only legal in POSIX-like OS (if they are present in the string). Path | 645 | only legal in POSIX-like OS (if they are present in the string). Path |
644 | names are little endian 16 bit Unicode on the wire */ | 646 | names are little endian 16 bit Unicode on the wire */ |
645 | int | 647 | int |
646 | cifs_convertUCSpath(char *target, const __le16 * source, int maxlen, | 648 | cifs_convertUCSpath(char *target, const __le16 *source, int maxlen, |
647 | const struct nls_table * cp) | 649 | const struct nls_table *cp) |
648 | { | 650 | { |
649 | int i,j,len; | 651 | int i, j, len; |
650 | __u16 src_char; | 652 | __u16 src_char; |
651 | 653 | ||
652 | for(i = 0, j = 0; i < maxlen; i++) { | 654 | for (i = 0, j = 0; i < maxlen; i++) { |
653 | src_char = le16_to_cpu(source[i]); | 655 | src_char = le16_to_cpu(source[i]); |
654 | switch (src_char) { | 656 | switch (src_char) { |
655 | case 0: | 657 | case 0: |
@@ -678,8 +680,8 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen, | |||
678 | case UNI_LESSTHAN: | 680 | case UNI_LESSTHAN: |
679 | target[j] = '<'; | 681 | target[j] = '<'; |
680 | break; | 682 | break; |
681 | default: | 683 | default: |
682 | len = cp->uni2char(src_char, &target[j], | 684 | len = cp->uni2char(src_char, &target[j], |
683 | NLS_MAX_CHARSET_SIZE); | 685 | NLS_MAX_CHARSET_SIZE); |
684 | if (len > 0) { | 686 | if (len > 0) { |
685 | j += len; | 687 | j += len; |
@@ -703,10 +705,10 @@ cUCS_out: | |||
703 | only legal in POSIX-like OS (if they are present in the string). Path | 705 | only legal in POSIX-like OS (if they are present in the string). Path |
704 | names are little endian 16 bit Unicode on the wire */ | 706 | names are little endian 16 bit Unicode on the wire */ |
705 | int | 707 | int |
706 | cifsConvertToUCS(__le16 * target, const char *source, int maxlen, | 708 | cifsConvertToUCS(__le16 *target, const char *source, int maxlen, |
707 | const struct nls_table * cp, int mapChars) | 709 | const struct nls_table *cp, int mapChars) |
708 | { | 710 | { |
709 | int i,j,charlen; | 711 | int i, j, charlen; |
710 | int len_remaining = maxlen; | 712 | int len_remaining = maxlen; |
711 | char src_char; | 713 | char src_char; |
712 | __u16 temp; | 714 | __u16 temp; |
@@ -714,7 +716,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen, | |||
714 | if (!mapChars) | 716 | if (!mapChars) |
715 | return cifs_strtoUCS(target, source, PATH_MAX, cp); | 717 | return cifs_strtoUCS(target, source, PATH_MAX, cp); |
716 | 718 | ||
717 | for(i = 0, j = 0; i < maxlen; j++) { | 719 | for (i = 0, j = 0; i < maxlen; j++) { |
718 | src_char = source[i]; | 720 | src_char = source[i]; |
719 | switch (src_char) { | 721 | switch (src_char) { |
720 | case 0: | 722 | case 0: |
@@ -737,7 +739,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen, | |||
737 | break; | 739 | break; |
738 | case '|': | 740 | case '|': |
739 | target[j] = cpu_to_le16(UNI_PIPE); | 741 | target[j] = cpu_to_le16(UNI_PIPE); |
740 | break; | 742 | break; |
741 | /* BB We can not handle remapping slash until | 743 | /* BB We can not handle remapping slash until |
742 | all the calls to build_path_from_dentry | 744 | all the calls to build_path_from_dentry |
743 | are modified, as they use slash as separator BB */ | 745 | are modified, as they use slash as separator BB */ |
@@ -758,7 +760,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen, | |||
758 | /* character may take more than one byte in the | 760 | /* character may take more than one byte in the |
759 | the source string, but will take exactly two | 761 | the source string, but will take exactly two |
760 | bytes in the target string */ | 762 | bytes in the target string */ |
761 | i+= charlen; | 763 | i += charlen; |
762 | continue; | 764 | continue; |
763 | } | 765 | } |
764 | i++; /* move to next char in source string */ | 766 | i++; /* move to next char in source string */ |
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index 96c343247ea6..40ed5c9caad3 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c | |||
@@ -145,7 +145,7 @@ cifs_inet_pton(int address_family, char *cp, void *dst) | |||
145 | ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL); | 145 | ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL); |
146 | } | 146 | } |
147 | #ifdef CONFIG_CIFS_DEBUG2 | 147 | #ifdef CONFIG_CIFS_DEBUG2 |
148 | cFYI(1,("address conversion returned %d for %s", ret, cp)); | 148 | cFYI(1, ("address conversion returned %d for %s", ret, cp)); |
149 | #endif | 149 | #endif |
150 | if (ret > 0) | 150 | if (ret > 0) |
151 | ret = 1; | 151 | ret = 1; |