예제 #1
0
void *
afs_osi_Alloc(size_t size)
{
    AFS_STATCNT(osi_Alloc);
    /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
     * things so that NULL returned iff an error occurred */
    if (size == 0)
	return &memZero;

    AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
    AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += size);
#ifdef AFS_LINUX20_ENV
    return osi_linux_alloc(size, 1);
#elif defined(AFS_FBSD_ENV)
    return osi_fbsd_alloc(size, 1);
#else
    return AFS_KALLOC(size);
#endif
}
예제 #2
0
afs_fid(OSI_VC_DECL(avc), struct fid **fidpp)
#endif				/* AFS_AIX41_ENV */
{
    struct SmallFid Sfid;
    long addr[2];
    register struct cell *tcell;
    extern struct vcache *afs_globalVp;
    int SizeOfSmallFid = SIZEOF_SMALLFID;
    int rootvp = 0;
    OSI_VC_CONVERT(avc);

    AFS_STATCNT(afs_fid);

    if (afs_shuttingdown)
	return EIO;

    if (afs_NFSRootOnly && (avc == afs_globalVp))
	rootvp = 1;
    if (!afs_NFSRootOnly || rootvp
#ifdef AFS_AIX41_ENV
	|| USE_SMALLFID(credp)
#endif
	) {
	tcell = afs_GetCell(avc->f.fid.Cell, READ_LOCK);
	Sfid.Volume = avc->f.fid.Fid.Volume;
	Sfid.Vnode = avc->f.fid.Fid.Vnode;
	Sfid.CellAndUnique =
	    ((tcell->cellIndex << 24) + (avc->f.fid.Fid.Unique & 0xffffff));
	afs_PutCell(tcell, READ_LOCK);
	if (avc->f.fid.Fid.Vnode > 0xffff)
	    afs_fid_vnodeoverflow++;
	if (avc->f.fid.Fid.Unique > 0xffffff)
	    afs_fid_uniqueoverflow++;
    } else {
#if defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64))
	addr[1] = (long)AFS_XLATOR_MAGIC << 48;
#else /* defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64) */
	addr[1] = AFS_XLATOR_MAGIC;
	SizeOfSmallFid = sizeof(addr);
#endif /* defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64) */
	addr[0] = (long)avc;
#ifndef AFS_AIX41_ENV
	/* No post processing, so don't hold ref count. */
	AFS_FAST_HOLD(avc);
#endif
    }
#if	defined(AFS_AIX_ENV) || defined(AFS_SUN54_ENV)
    /* Use the fid pointer passed to us. */
    fidpp->fid_len = SizeOfSmallFid;

    if (afs_NFSRootOnly) {
	if (rootvp
#ifdef AFS_AIX41_ENV
	    || USE_SMALLFID(credp)
#endif
	    ) {
	    memcpy(fidpp->fid_data, (caddr_t) & Sfid, SizeOfSmallFid);
	} else {
	    memcpy(fidpp->fid_data, (caddr_t) addr, SizeOfSmallFid);
	}
    } else {
	memcpy(fidpp->fid_data, (caddr_t) & Sfid, SizeOfSmallFid);
    }
#else
    /* malloc a fid pointer ourselves. */
    *fidpp = (struct fid *)AFS_KALLOC(SizeOfSmallFid + 2);
    (*fidpp)->fid_len = SizeOfSmallFid;
    if (afs_NFSRootOnly) {
	if (rootvp) {
	    memcpy((*fidpp)->fid_data, (char *)&Sfid, SizeOfSmallFid);
	} else {
	    memcpy((*fidpp)->fid_data, (char *)addr, SizeOfSmallFid);
	}
    } else {
	memcpy((*fidpp)->fid_data, (char *)&Sfid, SizeOfSmallFid);
    }
#endif
    return (0);
}