#include "afsincludes.h" /* Afs-based standard headers */
#include "afs/afs_stats.h" /* afs statistics */
#include "afs/afs_osi.h"
-#include "afs/afs_md5.h"
+#include "hcrypto/md5.h"
/* Local variables. */
afs_rwlock_t afs_xcell; /* Export for cmdebug peeking at locks */
if (cellnum == 0)
cellnum = afs_cellnum_next;
- cn = (struct cell_name *)afs_osi_Alloc(sizeof(*cn));
+ cn = afs_osi_Alloc(sizeof(*cn));
+ osi_Assert(cn != NULL);
cn->next = afs_cellname_head;
cn->cellnum = cellnum;
cn->cellname = afs_strdup(name);
}
UpgradeSToWLock(&afs_xcell, 682);
- tc = (struct cell_alias *)afs_osi_Alloc(sizeof(struct cell_alias));
+ tc = afs_osi_Alloc(sizeof(struct cell_alias));
+ osi_Assert(tc != NULL);
tc->alias = afs_strdup(alias);
tc->cell = afs_strdup(cell);
tc->next = afs_cellalias_head;
}
/*!
+ * Return number of the primary cell.
+ * \return
+ * Cell number, or 0 if primary cell not found
+ */
+afs_int32
+afs_GetPrimaryCellNum(void)
+{
+ struct cell *cell;
+ afs_int32 cellNum = 0;
+ cell = afs_GetPrimaryCell(READ_LOCK);
+ if (cell) {
+ cellNum = cell->cellNum;
+ afs_PutCell(cell, READ_LOCK);
+ }
+ return cellNum;
+}
+
+/*!
* Returns true if the given cell is the primary cell.
* \param cell
* \return
{
struct cell *tc, *tcl = 0;
afs_int32 i, newc = 0, code = 0;
+ struct md5 m;
AFS_STATCNT(afs_NewCell);
if (tc) {
aflags &= ~CNoSUID;
} else {
- tc = (struct cell *)afs_osi_Alloc(sizeof(struct cell));
+ tc = afs_osi_Alloc(sizeof(struct cell));
+ osi_Assert(tc != NULL);
memset(tc, 0, sizeof(*tc));
tc->cellName = afs_strdup(acellName);
tc->fsport = AFS_FSPORT;
tc->vlport = AFS_VLPORT;
- AFS_MD5_String(tc->cellHandle, tc->cellName, strlen(tc->cellName));
+ MD5_Init(&m);
+ MD5_Update(&m, tc->cellName, strlen(tc->cellName));
+ MD5_Final(tc->cellHandle, &m);
AFS_RWLOCK_INIT(&tc->lock, "cell lock");
newc = 1;
aflags |= CNoSUID;