Windows: Return bytes_read count from cm_GetData

The existing interface for cm_GetData takes an input buffer and
a buffer size and no method by which the number of bytes read into
the buffer can be returned.  Add an output parameter to permit it.

Change-Id: I777d2fba850fb39d4323b006e3c79afa5ff4c2ff
Reviewed-on: http://gerrit.openafs.org/9930
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
This commit is contained in:
Jeffrey Altman 2013-05-23 16:57:21 -04:00
parent 7cca447e23
commit 25a0cf6fbc
3 changed files with 11 additions and 4 deletions

View File

@ -2222,7 +2222,7 @@ long cm_GetBuffer(cm_scache_t *scp, cm_buf_t *bufp, int *cpffp, cm_user_t *userp
* a provided buffer. Called with scp locked. The scp is locked on return.
*/
long cm_GetData(cm_scache_t *scp, osi_hyper_t *offsetp, char *datap, int data_length,
cm_user_t *userp, cm_req_t *reqp)
int * bytes_readp, cm_user_t *userp, cm_req_t *reqp)
{
long code=0, code1=0;
afs_uint32 nbytes; /* bytes in transfer */
@ -2247,6 +2247,9 @@ long cm_GetData(cm_scache_t *scp, osi_hyper_t *offsetp, char *datap, int data_le
int first_read = 1;
int scp_locked = 1;
if (bytes_readp)
*bytes_readp = 0;
memset(&afsStatus, 0, sizeof(afsStatus));
memset(&callback, 0, sizeof(callback));
memset(&volSync, 0, sizeof(volSync));
@ -2571,6 +2574,8 @@ long cm_GetData(cm_scache_t *scp, osi_hyper_t *offsetp, char *datap, int data_le
else
InterlockedDecrement(&scp->activeRPCs);
*bytes_readp = (long) (bufferp - datap);
return code;
}

View File

@ -37,7 +37,7 @@ extern long cm_GetBuffer(struct cm_scache *, struct cm_buf *, int *,
struct cm_user *, struct cm_req *);
extern long cm_GetData(cm_scache_t *scp, osi_hyper_t *offsetp, char *datap, int data_length,
cm_user_t *userp, cm_req_t *reqp);
int * bytes_readp, cm_user_t *userp, cm_req_t *reqp);
extern afs_int32 cm_CheckFetchRange(cm_scache_t *scp, osi_hyper_t *startBasep,
osi_hyper_t *length, cm_user_t *up,

View File

@ -860,10 +860,11 @@ long cm_ReadMountPoint(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
{
char temp[MOUNTPOINTLEN];
osi_hyper_t offset;
afs_uint32 bytesRead = 0;
/* otherwise, we have to read it in */
offset.LowPart = offset.HighPart = 0;
code = cm_GetData(scp, &offset, temp, MOUNTPOINTLEN, userp, reqp);
code = cm_GetData(scp, &offset, temp, MOUNTPOINTLEN, &bytesRead, userp, reqp);
if (code)
goto done;
@ -1789,10 +1790,11 @@ long cm_HandleLink(cm_scache_t *linkScp, cm_user_t *userp, cm_req_t *reqp)
{
char temp[MOUNTPOINTLEN];
osi_hyper_t offset;
afs_uint32 bytesRead = 0;
/* read the link data from the file server */
offset.LowPart = offset.HighPart = 0;
code = cm_GetData(linkScp, &offset, temp, MOUNTPOINTLEN, userp, reqp);
code = cm_GetData(linkScp, &offset, temp, MOUNTPOINTLEN, &bytesRead, userp, reqp);
if (code)
return code;