diff options
author | Jeff Layton <jlayton@redhat.com> | 2010-02-12 07:44:17 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2010-03-05 23:38:25 -0500 |
commit | c8634fd3115497ac311f57be9c12f993437745cf (patch) | |
tree | 67f309df555e2d9af25ce3d141d6bc92a5895107 | |
parent | bcd5357f430363376565d07ca542127d6d36602c (diff) |
cifs: add a CIFSSMBUnixQFileInfo function
...to allow us to get unix attrs via filehandle.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
-rw-r--r-- | fs/cifs/cifsproto.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 69 |
2 files changed, 71 insertions, 0 deletions
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index bf2bff14c24f..ce9199f0af9d 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -154,6 +154,8 @@ extern int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon, | |||
154 | FILE_ALL_INFO *findData, | 154 | FILE_ALL_INFO *findData, |
155 | const struct nls_table *nls_codepage, int remap); | 155 | const struct nls_table *nls_codepage, int remap); |
156 | 156 | ||
157 | extern int CIFSSMBUnixQFileInfo(const int xid, struct cifsTconInfo *tcon, | ||
158 | u16 netfid, FILE_UNIX_BASIC_INFO *pFindData); | ||
157 | extern int CIFSSMBUnixQPathInfo(const int xid, | 159 | extern int CIFSSMBUnixQPathInfo(const int xid, |
158 | struct cifsTconInfo *tcon, | 160 | struct cifsTconInfo *tcon, |
159 | const unsigned char *searchName, | 161 | const unsigned char *searchName, |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 4ed97825db3d..903d53871da7 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -3399,6 +3399,75 @@ QPathInfoRetry: | |||
3399 | } | 3399 | } |
3400 | 3400 | ||
3401 | int | 3401 | int |
3402 | CIFSSMBUnixQFileInfo(const int xid, struct cifsTconInfo *tcon, | ||
3403 | u16 netfid, FILE_UNIX_BASIC_INFO *pFindData) | ||
3404 | { | ||
3405 | struct smb_t2_qfi_req *pSMB = NULL; | ||
3406 | struct smb_t2_qfi_rsp *pSMBr = NULL; | ||
3407 | int rc = 0; | ||
3408 | int bytes_returned; | ||
3409 | __u16 params, byte_count; | ||
3410 | |||
3411 | UnixQFileInfoRetry: | ||
3412 | rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, | ||
3413 | (void **) &pSMBr); | ||
3414 | if (rc) | ||
3415 | return rc; | ||
3416 | |||
3417 | params = 2 /* level */ + 2 /* fid */; | ||
3418 | pSMB->t2.TotalDataCount = 0; | ||
3419 | pSMB->t2.MaxParameterCount = cpu_to_le16(4); | ||
3420 | /* BB find exact max data count below from sess structure BB */ | ||
3421 | pSMB->t2.MaxDataCount = cpu_to_le16(CIFSMaxBufSize); | ||
3422 | pSMB->t2.MaxSetupCount = 0; | ||
3423 | pSMB->t2.Reserved = 0; | ||
3424 | pSMB->t2.Flags = 0; | ||
3425 | pSMB->t2.Timeout = 0; | ||
3426 | pSMB->t2.Reserved2 = 0; | ||
3427 | pSMB->t2.ParameterOffset = cpu_to_le16(offsetof(struct smb_t2_qfi_req, | ||
3428 | Fid) - 4); | ||
3429 | pSMB->t2.DataCount = 0; | ||
3430 | pSMB->t2.DataOffset = 0; | ||
3431 | pSMB->t2.SetupCount = 1; | ||
3432 | pSMB->t2.Reserved3 = 0; | ||
3433 | pSMB->t2.SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION); | ||
3434 | byte_count = params + 1 /* pad */ ; | ||
3435 | pSMB->t2.TotalParameterCount = cpu_to_le16(params); | ||
3436 | pSMB->t2.ParameterCount = pSMB->t2.TotalParameterCount; | ||
3437 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC); | ||
3438 | pSMB->Pad = 0; | ||
3439 | pSMB->Fid = netfid; | ||
3440 | pSMB->hdr.smb_buf_length += byte_count; | ||
3441 | |||
3442 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | ||
3443 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | ||
3444 | if (rc) { | ||
3445 | cFYI(1, ("Send error in QPathInfo = %d", rc)); | ||
3446 | } else { /* decode response */ | ||
3447 | rc = validate_t2((struct smb_t2_rsp *)pSMBr); | ||
3448 | |||
3449 | if (rc || (pSMBr->ByteCount < sizeof(FILE_UNIX_BASIC_INFO))) { | ||
3450 | cERROR(1, ("Malformed FILE_UNIX_BASIC_INFO response.\n" | ||
3451 | "Unix Extensions can be disabled on mount " | ||
3452 | "by specifying the nosfu mount option.")); | ||
3453 | rc = -EIO; /* bad smb */ | ||
3454 | } else { | ||
3455 | __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); | ||
3456 | memcpy((char *) pFindData, | ||
3457 | (char *) &pSMBr->hdr.Protocol + | ||
3458 | data_offset, | ||
3459 | sizeof(FILE_UNIX_BASIC_INFO)); | ||
3460 | } | ||
3461 | } | ||
3462 | |||
3463 | cifs_buf_release(pSMB); | ||
3464 | if (rc == -EAGAIN) | ||
3465 | goto UnixQFileInfoRetry; | ||
3466 | |||
3467 | return rc; | ||
3468 | } | ||
3469 | |||
3470 | int | ||
3402 | CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, | 3471 | CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, |
3403 | const unsigned char *searchName, | 3472 | const unsigned char *searchName, |
3404 | FILE_UNIX_BASIC_INFO *pFindData, | 3473 | FILE_UNIX_BASIC_INFO *pFindData, |