mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 13:38:01 +00:00
afs: Save size of sysname_info->name
In preparation for a future commit, save the size of sysname_info->name by adding a new field (name_size) into the sysname_info struct. Also, remove the sysname_info->allocked field, since now we can find out if memory has been allocated by checking if sysname_info->name_size is different than zero. No functional change should be incurred by this commit. Change-Id: Id0f5a646b2d82fda5344d53c9fc8b3407f2ea805 Reviewed-on: https://gerrit.openafs.org/14912 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
parent
29a89c82ad
commit
c40c0bd00b
@ -522,13 +522,13 @@ Check_AtSys(struct vcache *avc, const char *aname,
|
||||
|
||||
if (AFS_EQ_ATSYS(aname)) {
|
||||
state->offset = 0;
|
||||
state->name = osi_AllocLargeSpace(MAXSYSNAME);
|
||||
state->allocked = 1;
|
||||
state->name_size = MAXSYSNAME;
|
||||
state->name = osi_AllocLargeSpace(state->name_size);
|
||||
state->index =
|
||||
afs_getsysname(areq, avc, state->name, &num, sysnamelist);
|
||||
} else {
|
||||
state->offset = -1;
|
||||
state->allocked = 0;
|
||||
state->name_size = 0;
|
||||
state->index = 0;
|
||||
state->name = (char *)aname;
|
||||
}
|
||||
@ -545,7 +545,7 @@ Next_AtSys(struct vcache *avc, struct vrequest *areq,
|
||||
return 0; /* No list */
|
||||
|
||||
/* Check for the initial state of aname != "@sys" in Check_AtSys */
|
||||
if (state->offset == -1 && state->allocked == 0) {
|
||||
if (state->offset == -1 && state->name_size == 0) {
|
||||
char *tname;
|
||||
|
||||
/* Check for .*@sys */
|
||||
@ -557,7 +557,7 @@ Next_AtSys(struct vcache *avc, struct vrequest *areq,
|
||||
tname = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
|
||||
strncpy(tname, state->name, state->offset);
|
||||
state->name = tname;
|
||||
state->allocked = 1;
|
||||
state->name_size = AFS_LRALLOCSIZ;
|
||||
num = 0;
|
||||
state->index =
|
||||
afs_getsysname(areq, avc, state->name + state->offset, &num,
|
||||
|
@ -127,8 +127,13 @@ extern afs_int32 afs_rx_idledead_rep;
|
||||
|
||||
struct sysname_info {
|
||||
char *name;
|
||||
/*
|
||||
* 'name_size' represents the number of bytes allocated in 'name'. If 0,
|
||||
* 'name' points to existing memory, and shouldn't be freed.
|
||||
*/
|
||||
size_t name_size;
|
||||
short offset;
|
||||
signed char index, allocked;
|
||||
signed char index;
|
||||
};
|
||||
|
||||
/* flags to use with AFSOP_CACHEINIT */
|
||||
|
@ -2194,7 +2194,7 @@ DECL_PIOCTL(PFlush)
|
||||
*
|
||||
* \return 0 on success; non-zero otherwise.
|
||||
*
|
||||
* \notes The caller must free asys->name (checking if asys->allocked == 1).
|
||||
* \notes The caller must free asys->name if asys->name_size != 0.
|
||||
*/
|
||||
static int
|
||||
afs_LookupName(struct vcache *avc, struct vrequest *areq, char *aname,
|
||||
@ -2324,7 +2324,7 @@ DECL_PIOCTL(PNewStatMount)
|
||||
ReleaseWriteLock(&tvc->lock);
|
||||
afs_PutVCache(tvc);
|
||||
out:
|
||||
if (sysState.allocked)
|
||||
if (sysState.name_size != 0)
|
||||
osi_FreeLargeSpace(sysState.name);
|
||||
return code;
|
||||
}
|
||||
@ -3428,7 +3428,7 @@ DECL_PIOCTL(PRemoveMount)
|
||||
ReleaseWriteLock(&avc->lock);
|
||||
code = 0;
|
||||
out:
|
||||
if (sysState.allocked)
|
||||
if (sysState.name_size != 0)
|
||||
osi_FreeLargeSpace(bufp);
|
||||
return code;
|
||||
}
|
||||
@ -4917,7 +4917,7 @@ DECL_PIOCTL(PFlushMount)
|
||||
ReleaseWriteLock(&tvc->lock);
|
||||
afs_PutVCache(tvc);
|
||||
out:
|
||||
if (sysState.allocked)
|
||||
if (sysState.name_size != 0)
|
||||
osi_FreeLargeSpace(sysState.name);
|
||||
return code;
|
||||
}
|
||||
@ -5688,7 +5688,7 @@ DECL_PIOCTL(PGetLiteralFID)
|
||||
tfid.Fid.Volume = avc->f.fid.Fid.Volume;
|
||||
code = afs_pd_putBytes(aout, &tfid, sizeof(tfid));
|
||||
out:
|
||||
if (sysState.allocked) {
|
||||
if (sysState.name_size != 0) {
|
||||
osi_FreeLargeSpace(sysState.name);
|
||||
}
|
||||
return code;
|
||||
|
Loading…
x
Reference in New Issue
Block a user