code = cm_MapVLRPCError(code, reqp);
if (afsd_logp->enabled) {
- char uuidstr[128];
- afsUUID_to_string(Uuid, uuidstr, sizeof(uuidstr));
+ struct uuid_fmtbuf uuidstr;
+ afsUUID_to_string(Uuid, &uuidstr);
if (code)
osi_Log2(afsd_logp,
"CALL VL_GetAddrsU serverNumber %s FAILURE, code 0x%x",
- osi_LogSaveString(afsd_logp, uuidstr),
+ osi_LogSaveString(afsd_logp, uuidstr.buffer),
code);
else
osi_Log1(afsd_logp, "CALL VL_GetAddrsU serverNumber %s SUCCESS",
- osi_LogSaveString(afsd_logp, uuidstr));
+ osi_LogSaveString(afsd_logp, uuidstr.buffer));
}
if (code)
int zilch;
cm_server_t *tsp;
char output[1024];
- char uuidstr[128];
+ struct uuid_fmtbuf uuidstr;
char hoststr[16];
if (lock)
default:
type = "unknown";
}
-
- afsUUID_to_string(&tsp->uuid, uuidstr, sizeof(uuidstr));
+ afsUUID_to_string(&tsp->uuid, &uuidstr);
afs_inet_ntoa_r(tsp->addr.sin_addr.s_addr, hoststr);
down = ctime(&tsp->downTime);
down[strlen(down)-1] = '\0';
"flags=0x%x waitCount=%u pingCount=%d rank=%u downTime=\"%s\" "
"refCount=%u\r\n",
cookie, tsp, tsp->cellp ? tsp->cellp->name : "", hoststr,
- ntohs(tsp->addr.sin_port), uuidstr, type,
+ ntohs(tsp->addr.sin_port), uuidstr.buffer, type,
tsp->capabilities, tsp->flags, tsp->waitCount, tsp->pingCount,
tsp->activeRank,
(tsp->flags & CM_SERVERFLAG_DOWN) ? "down" : "up",
* vlserver. If not, ...?
*/
if (!afs_uuid_equal(&serverUUID[i], &tsp->uuid)) {
- char uuid1[128], uuid2[128];
+ struct uuid_fmtbuf uuid1, uuid2;
char hoststr[16];
-
- afsUUID_to_string(&serverUUID[i], uuid1, sizeof(uuid1));
- afsUUID_to_string(&tsp->uuid, uuid2, sizeof(uuid2));
+ afsUUID_to_string(&serverUUID[i], &uuid1);
+ afsUUID_to_string(&tsp->uuid, &uuid2);
afs_inet_ntoa_r(serverNumber[i], hoststr);
osi_Log3(afsd_logp, "cm_UpdateVolumeLocation UUIDs do not match! %s != %s (%s)",
- osi_LogSaveString(afsd_logp, uuid1),
- osi_LogSaveString(afsd_logp, uuid2),
+ osi_LogSaveString(afsd_logp, uuid1.buffer),
+ osi_LogSaveString(afsd_logp, uuid2.buffer),
osi_LogSaveString(afsd_logp, hoststr));
}
}
bulkaddrs addrs;
struct ListAddrByAttributes attrs;
afs_int32 nentries, uniq;
- char s[512];
- afsUUID_to_string(u, s, 511);
- afs_dprintf(("GetServerByID %s\n", s));
+ struct uuid_fmtbuf s;
+ afsUUID_to_string(u, &s);
+ afs_dprintf(("GetServerByID %s\n", s.buffer));
for (i = 0; i < thecell->nservers; i++) {
if (afs_uuid_equal(&thecell->fsservers[i]->id, u)) {
1, thecell->security,
thecell->scindex);
} else {
- char s[512];
+ struct uuid_fmtbuf s;
- afsUUID_to_string(&uuid, s, 511);
- afs_dprintf(("GetServerByAddr 0x%x -> uuid %s\n", addr, s));
+ afsUUID_to_string(&uuid, &s);
+ afs_dprintf(("GetServerByAddr 0x%x -> uuid %s\n", addr, s.buffer));
if (nentries > AFS_MAXHOSTS) {
nentries = AFS_MAXHOSTS;
extern u_short afs_uuid_hash(afsUUID * uuid);
#if !defined(KERNEL) && !defined(UKERNEL)
extern int afsUUID_from_string(const char *str, afsUUID * uuid);
-extern int afsUUID_to_string(const afsUUID * uuid, char *str, size_t strsz);
+
+struct uuid_fmtbuf {
+ char buffer[38];
+};
+extern char *afsUUID_to_string(const afsUUID * uuid, struct uuid_fmtbuf *buf);
#endif
/* volparse.c */
return 0;
}
-/*
+/**
* Converts a UUID from binary representation to a string representation.
+ *
+ * @param[in] uuid pointer to a afsUUID
+ * @param[out] buf format work buffer
+ *
+ * @returns pointer to buffer containing string representation of "uuid"
*/
-int
-afsUUID_to_string(const afsUUID * uuid, char *str, size_t strsz)
+char *
+afsUUID_to_string(const afsUUID * uuid, struct uuid_fmtbuf *buf)
{
- snprintf(str, strsz, "%08x-%04x-%04x-%02x-%02x-%02x%02x%02x%02x%02x%02x",
+ memset(buf, 0, sizeof(*buf));
+ snprintf(buf->buffer, sizeof(buf->buffer),
+ "%08x-%04x-%04x-%02x-%02x-%02x%02x%02x%02x%02x%02x",
uuid->time_low, uuid->time_mid, uuid->time_hi_and_version,
(unsigned char)uuid->clock_seq_hi_and_reserved,
(unsigned char)uuid->clock_seq_low, (unsigned char)uuid->node[0],
(unsigned char)uuid->node[3], (unsigned char)uuid->node[4],
(unsigned char)uuid->node[5]);
- return 0;
+ return buf->buffer;
}
#endif
#ifdef AFS_NT40_ENV
char * p;
#else
- char uuidstr[128];
+ struct uuid_fmtbuf uuidstr;
#endif
int i, code;
char hoststr[16];
printf("UUID: %s\n",p);
RpcStringFree(&p);
#else
- afsUUID_to_string(&addr.uuid, uuidstr, sizeof(uuidstr));
- printf("UUID: %s\n",uuidstr);
+ afsUUID_to_string(&addr.uuid, &uuidstr);
+ printf("UUID: %s\n", uuidstr.buffer);
#endif
printf("Host interfaces:\n");
{
int index;
struct h_UuidHashChain *chain;
- char uuid1[128], uuid2[128];
+ struct uuid_fmtbuf uuid1, uuid2;
char hoststr[16];
/* hash into proper bucket */
if (chain->hostPtr->z.interface &&
afs_uuid_equal(&chain->hostPtr->z.interface->uuid, uuid)) {
if (GetLogLevel() >= 125) {
- afsUUID_to_string(&chain->hostPtr->z.interface->uuid, uuid1,
- 127);
- afsUUID_to_string(uuid, uuid2, 127);
+ afsUUID_to_string(&chain->hostPtr->z.interface->uuid, &uuid1);
+ afsUUID_to_string(uuid, &uuid2);
ViceLog(125, ("h_AddHostToUuidHashTable_r: host %p (uuid %s) exists as %s:%d (uuid %s)\n",
- host, uuid1,
+ host, uuid1.buffer,
afs_inet_ntoa_r(chain->hostPtr->z.host, hoststr),
- ntohs(chain->hostPtr->z.port), uuid2));
+ ntohs(chain->hostPtr->z.port), uuid2.buffer));
}
return;
}
hostUuidHashTable[index] = chain;
if (GetLogLevel() < 125)
return;
- afsUUID_to_string(uuid, uuid2, 127);
+ afsUUID_to_string(uuid, &uuid2);
ViceLog(125,
("h_AddHostToUuidHashTable_r: host %p (%s:%d) added as uuid %s\n",
host, afs_inet_ntoa_r(chain->hostPtr->z.host, hoststr),
- ntohs(chain->hostPtr->z.port), uuid2));
+ ntohs(chain->hostPtr->z.port), uuid2.buffer));
}
/* deletes a HashChain structure corresponding to this host */
{
int index;
struct h_UuidHashChain **uhp, *uth;
- char uuid1[128];
+ struct uuid_fmtbuf uuid1;
char hoststr[16];
if (!host->z.interface)
index = h_UuidHashIndex(&host->z.interface->uuid);
if (GetLogLevel() >= 125)
- afsUUID_to_string(&host->z.interface->uuid, uuid1, 127);
+ afsUUID_to_string(&host->z.interface->uuid, &uuid1);
for (uhp = &hostUuidHashTable[index]; (uth = *uhp); uhp = &uth->next) {
opr_Assert(uth->hostPtr);
if (uth->hostPtr == host) {
ViceLog(125,
("h_DeleteHostFromUuidHashTable_r: host %p (uuid %s %s:%d)\n",
- host, uuid1, afs_inet_ntoa_r(host->z.host, hoststr),
+ host, uuid1.buffer, afs_inet_ntoa_r(host->z.host, hoststr),
ntohs(host->z.port)));
*uhp = uth->next;
free(uth);
}
ViceLog(125,
("h_DeleteHostFromUuidHashTable_r: host %p (uuid %s %s:%d) not found\n",
- host, uuid1, afs_inet_ntoa_r(host->z.host, hoststr),
+ host, uuid1.buffer, afs_inet_ntoa_r(host->z.host, hoststr),
ntohs(host->z.port)));
return 0;
}
|| (identP->valid
&& !afs_uuid_equal(&identP->uuid,
&host->z.interface->uuid)))) {
- char uuid1[128], uuid2[128];
+
+ struct uuid_fmtbuf uuid1, uuid2;
+
if (identP->valid)
- afsUUID_to_string(&identP->uuid, uuid1, 127);
+ afsUUID_to_string(&identP->uuid, &uuid1);
if (host->z.interface)
- afsUUID_to_string(&host->z.interface->uuid, uuid2, 127);
+ afsUUID_to_string(&host->z.interface->uuid, &uuid2);
ViceLog(0,
("CB: new identity for host %p (%s:%d), "
"deleting(%x %p %s %s)\n",
host, afs_inet_ntoa_r(host->z.host, hoststr), ntohs(host->z.port),
identP->valid, host->z.interface,
- identP->valid ? uuid1 : "no_uuid",
- host->z.interface ? uuid2 : "no_uuid"));
+ identP->valid ? uuid1.buffer : "no_uuid",
+ host->z.interface ? uuid2.buffer : "no_uuid"));
/* The host in the cache is not the host for this connection */
h_Lock_r(host);
struct h_UuidHashChain *chain;
afsUUID * uuidp = &h->z.interface->uuid;
int index = h_UuidHashIndex(uuidp);
- char tmp[40];
+ struct uuid_fmtbuf tmp;
int chain_len = 0;
for (chain = hostUuidHashTable[index]; chain; chain = chain->next) {
host = chain->hostPtr;
if (host == NULL) {
- afsUUID_to_string(uuidp, tmp, sizeof(tmp));
- ViceLog(0, ("h_stateVerifyUuidHash: error: uuid hash chain has NULL host ptr (lookup uuid %s)\n", tmp));
+ afsUUID_to_string(uuidp, &tmp);
+ ViceLog(0, ("h_stateVerifyUuidHash: error: uuid hash chain has NULL host ptr (lookup uuid %s)\n",
+ tmp.buffer));
ret = 1;
goto done;
}
/* Fall through, so host not found */
- afsUUID_to_string(uuidp, tmp, sizeof(tmp));
+ afsUUID_to_string(uuidp, &tmp);
if (state->mode == FS_STATE_LOAD_MODE) {
- ViceLog(0, ("h_stateVerifyUuidHash: error: uuid %s not found in hash\n", tmp));
+ ViceLog(0, ("h_stateVerifyUuidHash: error: uuid %s not found in hash\n",
+ tmp.buffer));
ret = 1;
goto done;
} else {
- ViceLog(0, ("h_stateVerifyUuidHash: warning: uuid %s not found in hash\n", tmp));
+ ViceLog(0, ("h_stateVerifyUuidHash: warning: uuid %s not found in hash\n",
+ tmp.buffer));
state->flags.warnings_generated = 1;
}
int found;
struct Interface *interface;
char hoststr[16];
- char uuidstr[128];
+ struct uuid_fmtbuf uuidstr;
afs_uint16 port7001 = htons(7001);
opr_Assert(host);
h_AddHostToUuidHashTable_r(&interface->uuid, host);
if (GetLogLevel() >= 125) {
- afsUUID_to_string(&interface->uuid, uuidstr, 127);
+ afsUUID_to_string(&interface->uuid, &uuidstr);
- ViceLog(125, ("--- uuid %s\n", uuidstr));
+ ViceLog(125, ("--- uuid %s\n", uuidstr.buffer));
for (i = 0; i < host->z.interface->numberOfInterfaces; i++) {
ViceLog(125, ("--- alt address %s:%d\n",
afs_inet_ntoa_r(host->z.interface->interface[i].addr, hoststr),
static void
dump_hdr(void)
{
- char uuid_str[40];
+ struct uuid_fmtbuf uuid_str;
afs_uint32 hi, lo;
if (get_hdr())
DPFT1("timestamp", hdrs.hdr.timestamp);
DPFV1("sys_name", "u", hdrs.hdr.sys_name);
- afsUUID_to_string(&hdrs.hdr.server_uuid, uuid_str, sizeof(uuid_str));
- DPFS1("server_uuid", uuid_str);
+ afsUUID_to_string(&hdrs.hdr.server_uuid, &uuid_str);
+ DPFS1("server_uuid", uuid_str.buffer);
DPFV1("valid", "d", hdrs.hdr.valid);
DPFV1("endianness", "d", hdrs.hdr.endianness);
DPFV1("stats_detailed", "d", hdrs.hdr.stats_detailed);
dump_he_interfaces(void)
{
char temp_str[40];
+ struct uuid_fmtbuf uuidstr;
struct Interface * ifp;
int len, i;
char hoststr[16];
DPFSO0("Interface");
DPFV1("numberOfInterfaces", "u", ifp->numberOfInterfaces);
- afsUUID_to_string(&ifp->uuid, temp_str, sizeof(temp_str));
- DPFS1("uuid", temp_str);
+ afsUUID_to_string(&ifp->uuid, &uuidstr);
+ DPFS1("uuid", uuidstr.buffer);
for (i = 0; i < he_cursor.hdr.interfaces; i++) {
snprintf(temp_str, sizeof(temp_str), "interface[%d]", i);
DPFSO1(temp_str);
afs_int32 m_uniq = 0;
afsUUID m_uuid;
ListAddrByAttributes m_attrs;
- char buffer[128];
+ struct uuid_fmtbuf buffer;
memset(&m_attrs, 0, sizeof(m_attrs));
memset(&m_uuid, 0, sizeof(m_uuid));
memset(&m_addrs, 0, sizeof(m_addrs));
- memset(buffer, 0, sizeof(buffer));
m_attrs.Mask = VLADDR_IPADDR;
m_attrs.ipaddr = ntohl(ip1); /* -oldaddr */
xdr_free((xdrproc_t) xdr_bulkaddrs, &m_addrs);
switch (vcode) {
case 0: /* mh entry detected */
- afsUUID_to_string(&m_uuid, buffer, sizeof(buffer) - 1);
+ afsUUID_to_string(&m_uuid, &buffer);
fprintf(STDERR, "vos: Refusing to change address in multi-homed server entry.\n");
- fprintf(STDERR, " -oldaddr address is registered to file server UUID %s\n", buffer);
+ fprintf(STDERR, " -oldaddr address is registered to file server UUID %s\n",
+ buffer.buffer);
fprintf(STDERR, " Please restart the file server or use vos setaddrs.\n");
return EINVAL;
case VL_NOENT:
{
int i;
afs_uint32 addr;
- char buf[1024];
+ struct uuid_fmtbuf buf;
if (print) {
- afsUUID_to_string(m_uuid, buf, sizeof(buf));
- printf("UUID: %s\n", buf);
+ afsUUID_to_string(m_uuid, &buf);
+ printf("UUID: %s\n", buf.buffer);
}
/* print out the list of all the server */