diff options
author | Jeff Layton <jlayton@redhat.com> | 2009-04-30 07:17:56 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2009-04-30 11:45:00 -0400 |
commit | 460b96960d1946914e50316ffeefe7b41dddce91 (patch) | |
tree | 12d09d46a6410a90818cf41da0a77ecf2882f383 /fs/cifs/cifssmb.c | |
parent | 59140797c5817363087b0ffb46e6bb81a11fe0dc (diff) |
cifs: change CIFSSMBUnixQuerySymLink to use new helpers
Change CIFSSMBUnixQuerySymLink to use the new unicode helper functions.
Also change the calling conventions so that the allocation of the target
name buffer is done in CIFSSMBUnixQuerySymLink rather than by the caller.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Suresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/cifssmb.c')
-rw-r--r-- | fs/cifs/cifssmb.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index f15848374cfa..dfb8e391d538 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -2382,8 +2382,7 @@ winCreateHardLinkRetry: | |||
2382 | 2382 | ||
2383 | int | 2383 | int |
2384 | CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon, | 2384 | CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon, |
2385 | const unsigned char *searchName, | 2385 | const unsigned char *searchName, char **symlinkinfo, |
2386 | char *symlinkinfo, const int buflen, | ||
2387 | const struct nls_table *nls_codepage) | 2386 | const struct nls_table *nls_codepage) |
2388 | { | 2387 | { |
2389 | /* SMB_QUERY_FILE_UNIX_LINK */ | 2388 | /* SMB_QUERY_FILE_UNIX_LINK */ |
@@ -2393,6 +2392,7 @@ CIFSSMBUnixQuerySymLink(const int xid, struct cifsTconInfo *tcon, | |||
2393 | int bytes_returned; | 2392 | int bytes_returned; |
2394 | int name_len; | 2393 | int name_len; |
2395 | __u16 params, byte_count; | 2394 | __u16 params, byte_count; |
2395 | char *data_start; | ||
2396 | 2396 | ||
2397 | cFYI(1, ("In QPathSymLinkInfo (Unix) for path %s", searchName)); | 2397 | cFYI(1, ("In QPathSymLinkInfo (Unix) for path %s", searchName)); |
2398 | 2398 | ||
@@ -2447,30 +2447,22 @@ querySymLinkRetry: | |||
2447 | /* decode response */ | 2447 | /* decode response */ |
2448 | 2448 | ||
2449 | rc = validate_t2((struct smb_t2_rsp *)pSMBr); | 2449 | rc = validate_t2((struct smb_t2_rsp *)pSMBr); |
2450 | if (rc || (pSMBr->ByteCount < 2)) | ||
2451 | /* BB also check enough total bytes returned */ | 2450 | /* BB also check enough total bytes returned */ |
2452 | rc = -EIO; /* bad smb */ | 2451 | if (rc || (pSMBr->ByteCount < 2)) |
2452 | rc = -EIO; | ||
2453 | else { | 2453 | else { |
2454 | __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); | 2454 | u16 count = le16_to_cpu(pSMBr->t2.DataCount); |
2455 | __u16 count = le16_to_cpu(pSMBr->t2.DataCount); | 2455 | |
2456 | data_start = ((char *) &pSMBr->hdr.Protocol) + | ||
2457 | le16_to_cpu(pSMBr->t2.DataOffset); | ||
2456 | 2458 | ||
2457 | if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) { | ||
2458 | name_len = UniStrnlen((wchar_t *) ((char *) | ||
2459 | &pSMBr->hdr.Protocol + data_offset), | ||
2460 | min_t(const int, buflen, count) / 2); | ||
2461 | /* BB FIXME investigate remapping reserved chars here */ | 2459 | /* BB FIXME investigate remapping reserved chars here */ |
2462 | cifs_strfromUCS_le(symlinkinfo, | 2460 | *symlinkinfo = cifs_strndup(data_start, count, |
2463 | (__le16 *) ((char *)&pSMBr->hdr.Protocol | 2461 | pSMBr->hdr.Flags2 & |
2464 | + data_offset), | 2462 | SMBFLG2_UNICODE, |
2465 | name_len, nls_codepage); | 2463 | nls_codepage); |
2466 | } else { | 2464 | if (!symlinkinfo) |
2467 | strncpy(symlinkinfo, | 2465 | rc = -ENOMEM; |
2468 | (char *) &pSMBr->hdr.Protocol + | ||
2469 | data_offset, | ||
2470 | min_t(const int, buflen, count)); | ||
2471 | } | ||
2472 | symlinkinfo[buflen] = 0; | ||
2473 | /* just in case so calling code does not go off the end of buffer */ | ||
2474 | } | 2466 | } |
2475 | } | 2467 | } |
2476 | cifs_buf_release(pSMB); | 2468 | cifs_buf_release(pSMB); |