Ejemplo n.º 1
0
/*!
 * Fill in stats for a newly created file/directory.
 *
 * \param adp The parent dir's vcache.
 * \param avc The created vnode.
 * \param afid The new fid.
 * \param attrs
 * \param areq
 * \param file_type Specify if file or directory.
 *
 * \note Call with avc write locked.
 */
void
afs_GenDisconStatus(struct vcache *adp, struct vcache *avc,
		    struct VenusFid *afid, struct vattr *attrs,
		    struct vrequest *areq, int file_type)
{
    memcpy(&avc->f.fid, afid, sizeof(struct VenusFid));
    avc->f.m.Mode = attrs->va_mode;
    /* Used to do this:
     * avc->f.m.Owner = attrs->va_uid;
     * But now we use the parent dir's ownership,
     * there's no other way to get a server owner id.
     * XXX: Does it really matter?
     */
    avc->f.m.Group = adp->f.m.Group;
    avc->f.m.Owner = adp->f.m.Owner;
    hset64(avc->f.m.DataVersion, 0, 0);
    avc->f.m.Length = attrs->va_size;
    avc->f.m.Date = osi_Time();
    switch(file_type) {
      case VREG:
	vSetType(avc, VREG);
        avc->f.m.Mode |= S_IFREG;
	avc->f.m.LinkCount = 1;
	avc->f.parent.vnode = adp->f.fid.Fid.Vnode;
	avc->f.parent.unique = adp->f.fid.Fid.Unique;
	break;
      case VDIR:
        vSetType(avc, VDIR);
        avc->f.m.Mode |= S_IFDIR;
	avc->f.m.LinkCount = 2;
	break;
      case VLNK:
	vSetType(avc, VLNK);
	avc->f.m.Mode |= S_IFLNK;
	if ((avc->f.m.Mode & 0111) == 0)
	    avc->mvstat = 1;
	avc->f.parent.vnode = adp->f.fid.Fid.Vnode;
	avc->f.parent.unique = adp->f.fid.Fid.Unique;
	break;
      default:
	break;
    }
    avc->f.anyAccess = adp->f.anyAccess;
    afs_AddAxs(avc->Access, areq->uid, adp->Access->axess);

    avc->callback = NULL;
    avc->f.states |= CStatd;
    avc->f.states &= ~CBulkFetching;
}
Ejemplo n.º 2
0
void
osi_PostPopulateVCache(struct vcache *avc) {
    memset(&(avc->vc_bhv_desc), 0, sizeof(avc->vc_bhv_desc));
    bhv_desc_init(&(avc->vc_bhv_desc), avc, avc, &Afs_vnodeops);

#if defined(AFS_SGI65_ENV)
    vn_bhv_head_init(&(avc->v.v_bh), "afsvp");
    vn_bhv_insert_initial(&(avc->v.v_bh), &(avc->vc_bhv_desc));
    avc->v.v_mreg = avc->v.v_mregb = (struct pregion *)avc;
# if defined(VNODE_TRACING)
    avc->v.v_trace = ktrace_alloc(VNODE_TRACE_SIZE, 0);
# endif
    init_bitlock(&avc->v.v_pcacheflag, VNODE_PCACHE_LOCKBIT, "afs_pcache",
		 avc->v.v_number);
    init_mutex(&avc->v.v_filocksem, MUTEX_DEFAULT, "afsvfl", (long)avc);
    init_mutex(&avc->v.v_buf_lock, MUTEX_DEFAULT, "afsvnbuf", (long)avc);
#else
    bhv_head_init(&(avc->v.v_bh));
    bhv_insert_initial(&(avc->v.v_bh), &(avc->vc_bhv_desc));
#endif

    vnode_pcache_init(&avc->v);

#if defined(DEBUG) && defined(VNODE_INIT_BITLOCK)
    /* Above define is never true execpt in SGI test kernels. */
    init_bitlock(&avc->v.v_flag, VLOCK, "vnode", avc->v.v_number);
#endif

#ifdef INTR_KTHREADS
    AFS_VN_INIT_BUF_LOCK(&(avc->v));
#endif

    vSetVfsp(avc, afs_globalVFS);
    vSetType(avc, VREG);

    VN_SET_DPAGES(&(avc->v), NULL);
    osi_Assert((avc->v.v_flag & VINACT) == 0);
    avc->v.v_flag = 0;
    osi_Assert(VN_GET_PGCNT(&(avc->v)) == 0);
    osi_Assert(avc->mapcnt == 0 && avc->vc_locktrips == 0);
    osi_Assert(avc->vc_rwlockid == OSI_NO_LOCKID);
    osi_Assert(avc->v.v_filocks == NULL);
# if !defined(AFS_SGI65_ENV)
    osi_Assert(avc->v.v_filocksem == NULL);
# endif
    osi_Assert(avc->cred == NULL);
# if defined(AFS_SGI64_ENV)
    vnode_pcache_reinit(&avc->v);
    avc->v.v_rdev = NODEV;
# endif
    vn_initlist((struct vnlist *)&avc->v);
    avc->lastr = 0;
}
Ejemplo n.º 3
0
void
osi_PostPopulateVCache(struct vcache *avc) {
    AFSTOV(avc)->v_op = afs_ops;
    AFSTOV(avc)->v_vfsp = afs_globalVFS;
    vSetType(avc, VREG);

#ifdef AFS_SUN58_ENV
    /* Normally we do this in osi_vnhold when we notice the ref count went from
     * 0 -> 1. But if we just setup or reused a vcache, we set the refcount to
     * 1 directly. So, we must explicitly VFS_HOLD here. */
    VFS_HOLD(afs_globalVFS);
#endif
}
Ejemplo n.º 4
0
void
osi_PostPopulateVCache(struct vcache *avc) {
    avc->v->v_mount = afs_globalVFS;
    vSetType(avc, VREG);
}