diff options
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifsproto.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 64 |
2 files changed, 66 insertions, 0 deletions
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 88e2bc44ac58..bf2bff14c24f 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -142,6 +142,8 @@ extern int CIFSFindNext(const int xid, struct cifsTconInfo *tcon, | |||
142 | extern int CIFSFindClose(const int, struct cifsTconInfo *tcon, | 142 | extern int CIFSFindClose(const int, struct cifsTconInfo *tcon, |
143 | const __u16 search_handle); | 143 | const __u16 search_handle); |
144 | 144 | ||
145 | extern int CIFSSMBQFileInfo(const int xid, struct cifsTconInfo *tcon, | ||
146 | u16 netfid, FILE_ALL_INFO *pFindData); | ||
145 | extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, | 147 | extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, |
146 | const unsigned char *searchName, | 148 | const unsigned char *searchName, |
147 | FILE_ALL_INFO *findData, | 149 | FILE_ALL_INFO *findData, |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 9d17df3e0768..4ed97825db3d 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -3230,8 +3230,72 @@ QInfRetry: | |||
3230 | return rc; | 3230 | return rc; |
3231 | } | 3231 | } |
3232 | 3232 | ||
3233 | int | ||
3234 | CIFSSMBQFileInfo(const int xid, struct cifsTconInfo *tcon, | ||
3235 | u16 netfid, FILE_ALL_INFO *pFindData) | ||
3236 | { | ||
3237 | struct smb_t2_qfi_req *pSMB = NULL; | ||
3238 | struct smb_t2_qfi_rsp *pSMBr = NULL; | ||
3239 | int rc = 0; | ||
3240 | int bytes_returned; | ||
3241 | __u16 params, byte_count; | ||
3242 | |||
3243 | QFileInfoRetry: | ||
3244 | rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, | ||
3245 | (void **) &pSMBr); | ||
3246 | if (rc) | ||
3247 | return rc; | ||
3248 | |||
3249 | params = 2 /* level */ + 2 /* fid */; | ||
3250 | pSMB->t2.TotalDataCount = 0; | ||
3251 | pSMB->t2.MaxParameterCount = cpu_to_le16(4); | ||
3252 | /* BB find exact max data count below from sess structure BB */ | ||
3253 | pSMB->t2.MaxDataCount = cpu_to_le16(CIFSMaxBufSize); | ||
3254 | pSMB->t2.MaxSetupCount = 0; | ||
3255 | pSMB->t2.Reserved = 0; | ||
3256 | pSMB->t2.Flags = 0; | ||
3257 | pSMB->t2.Timeout = 0; | ||
3258 | pSMB->t2.Reserved2 = 0; | ||
3259 | pSMB->t2.ParameterOffset = cpu_to_le16(offsetof(struct smb_t2_qfi_req, | ||
3260 | Fid) - 4); | ||
3261 | pSMB->t2.DataCount = 0; | ||
3262 | pSMB->t2.DataOffset = 0; | ||
3263 | pSMB->t2.SetupCount = 1; | ||
3264 | pSMB->t2.Reserved3 = 0; | ||
3265 | pSMB->t2.SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION); | ||
3266 | byte_count = params + 1 /* pad */ ; | ||
3267 | pSMB->t2.TotalParameterCount = cpu_to_le16(params); | ||
3268 | pSMB->t2.ParameterCount = pSMB->t2.TotalParameterCount; | ||
3269 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO); | ||
3270 | pSMB->Pad = 0; | ||
3271 | pSMB->Fid = netfid; | ||
3272 | pSMB->hdr.smb_buf_length += byte_count; | ||
3273 | |||
3274 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | ||
3275 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | ||
3276 | if (rc) { | ||
3277 | cFYI(1, ("Send error in QPathInfo = %d", rc)); | ||
3278 | } else { /* decode response */ | ||
3279 | rc = validate_t2((struct smb_t2_rsp *)pSMBr); | ||
3233 | 3280 | ||
3281 | if (rc) /* BB add auto retry on EOPNOTSUPP? */ | ||
3282 | rc = -EIO; | ||
3283 | else if (pSMBr->ByteCount < 40) | ||
3284 | rc = -EIO; /* bad smb */ | ||
3285 | else if (pFindData) { | ||
3286 | __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); | ||
3287 | memcpy((char *) pFindData, | ||
3288 | (char *) &pSMBr->hdr.Protocol + | ||
3289 | data_offset, sizeof(FILE_ALL_INFO)); | ||
3290 | } else | ||
3291 | rc = -ENOMEM; | ||
3292 | } | ||
3293 | cifs_buf_release(pSMB); | ||
3294 | if (rc == -EAGAIN) | ||
3295 | goto QFileInfoRetry; | ||
3234 | 3296 | ||
3297 | return rc; | ||
3298 | } | ||
3235 | 3299 | ||
3236 | int | 3300 | int |
3237 | CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, | 3301 | CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, |