Skip to content

Commit 296ecba

Browse files
Ronnie SahlbergSteve French
authored andcommitted
cifs: add SMB2_query_info_[init|free]()
Signed-off-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]> Reviewed-by: Paulo Alcantara <[email protected]>
1 parent 8eb4ecf commit 296ecba

File tree

2 files changed

+51
-22
lines changed

2 files changed

+51
-22
lines changed

fs/cifs/smb2pdu.c

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,36 +2580,22 @@ validate_and_copy_iov(unsigned int offset, unsigned int buffer_length,
25802580
return 0;
25812581
}
25822582

2583-
static int
2584-
query_info(const unsigned int xid, struct cifs_tcon *tcon,
2585-
u64 persistent_fid, u64 volatile_fid, u8 info_class, u8 info_type,
2586-
u32 additional_info, size_t output_len, size_t min_len, void **data,
2587-
u32 *dlen)
2583+
int
2584+
SMB2_query_info_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,
2585+
u64 persistent_fid, u64 volatile_fid,
2586+
u8 info_class, u8 info_type, u32 additional_info,
2587+
size_t output_len)
25882588
{
2589-
struct smb_rqst rqst;
25902589
struct smb2_query_info_req *req;
2591-
struct smb2_query_info_rsp *rsp = NULL;
2592-
struct kvec iov[2];
2593-
struct kvec rsp_iov;
2594-
int rc = 0;
2595-
int resp_buftype;
2596-
struct cifs_ses *ses = tcon->ses;
2597-
int flags = 0;
2590+
struct kvec *iov = rqst->rq_iov;
25982591
unsigned int total_len;
2599-
2600-
cifs_dbg(FYI, "Query Info\n");
2601-
2602-
if (!ses || !(ses->server))
2603-
return -EIO;
2592+
int rc;
26042593

26052594
rc = smb2_plain_req_init(SMB2_QUERY_INFO, tcon, (void **) &req,
26062595
&total_len);
26072596
if (rc)
26082597
return rc;
26092598

2610-
if (smb3_encryption_required(tcon))
2611-
flags |= CIFS_TRANSFORM_REQ;
2612-
26132599
req->InfoType = info_type;
26142600
req->FileInfoClass = info_class;
26152601
req->PersistentFileId = persistent_fid;
@@ -2626,13 +2612,50 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
26262612
iov[0].iov_base = (char *)req;
26272613
/* 1 for Buffer */
26282614
iov[0].iov_len = total_len - 1;
2615+
return 0;
2616+
}
2617+
2618+
void
2619+
SMB2_query_info_free(struct smb_rqst *rqst)
2620+
{
2621+
cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */
2622+
}
2623+
2624+
static int
2625+
query_info(const unsigned int xid, struct cifs_tcon *tcon,
2626+
u64 persistent_fid, u64 volatile_fid, u8 info_class, u8 info_type,
2627+
u32 additional_info, size_t output_len, size_t min_len, void **data,
2628+
u32 *dlen)
2629+
{
2630+
struct smb_rqst rqst;
2631+
struct smb2_query_info_rsp *rsp = NULL;
2632+
struct kvec iov[1];
2633+
struct kvec rsp_iov;
2634+
int rc = 0;
2635+
int resp_buftype;
2636+
struct cifs_ses *ses = tcon->ses;
2637+
int flags = 0;
2638+
2639+
cifs_dbg(FYI, "Query Info\n");
2640+
2641+
if (!ses || !(ses->server))
2642+
return -EIO;
2643+
2644+
if (smb3_encryption_required(tcon))
2645+
flags |= CIFS_TRANSFORM_REQ;
26292646

26302647
memset(&rqst, 0, sizeof(struct smb_rqst));
2648+
memset(&iov, 0, sizeof(iov));
26312649
rqst.rq_iov = iov;
26322650
rqst.rq_nvec = 1;
26332651

2652+
rc = SMB2_query_info_init(tcon, &rqst, persistent_fid, volatile_fid,
2653+
info_class, info_type, additional_info,
2654+
output_len);
2655+
if (rc)
2656+
goto qinf_exit;
2657+
26342658
rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
2635-
cifs_small_buf_release(req);
26362659
rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base;
26372660

26382661
if (rc) {
@@ -2661,6 +2684,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
26612684
&rsp_iov, min_len, *data);
26622685

26632686
qinf_exit:
2687+
SMB2_query_info_free(&rqst);
26642688
free_rsp_buf(resp_buftype, rsp);
26652689
return rc;
26662690
}

fs/cifs/smb2proto.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
153153
extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
154154
u64 persistent_file_id, u64 volatile_file_id,
155155
struct smb2_file_all_info *data);
156+
extern int SMB2_query_info_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,
157+
u64 persistent_fid, u64 volatile_fid,
158+
u8 info_class, u8 info_type,
159+
u32 additional_info, size_t output_len);
160+
extern void SMB2_query_info_free(struct smb_rqst *rqst);
156161
extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
157162
u64 persistent_file_id, u64 volatile_file_id,
158163
void **data, unsigned int *plen);

0 commit comments

Comments
 (0)