Example #1
0
gdb_sObject *
ivol_LoadObject (
  pwr_tStatus		*status,
  ivol_sVolume		*lv,
  dbs_sObject		*o,
  pwr_tBitMask		ilink
)
{
  gdb_sObject		*op;
  net_mGo		flags;
  pwr_tObjid		soid = pwr_cNObjid;

  pwr_dStatus(sts, status, GDH__SUCCESS);

  flags.m = 0;

  if (o->flags.m & dbs_mFlags_isClient) {
    soid = o->soid;
    flags.b.isAliasClient = o->flags.b.isAliasClient;
    flags.b.isMountClient = o->flags.b.isMountClient;
  }

  op = gdb_AddObject(sts, o->name, o->oid, o->cid, o->rbody.size, o->poid, flags.m, soid);
  if (op == NULL) return NULL;
  if (vol_LinkObject(sts, lv->vp, op, ilink) == NULL)
    return NULL;
  op->u.n.flags.b.isMountClean = o->flags.b.isMountClean;
  /*  op->u.n.rbTime = o->rbody.time; */
  op->u.n.time = o->time;
  op->u.n.lflags.m = o->flags.m;
  return op;
}
Example #2
0
static gdb_sObject *
loadObject (
  pwr_tStatus		*sts,
  gdb_sVolume		*vp,
  char			*name,
  pwr_tObjid		oid,
  pwr_tClassId		cid,
  int			size,
  pwr_tObjid		poid,
  pwr_tBitMask		flags,
  pwr_tObjid		soid
)
{
  gdb_sObject		*op;

  pwr_Assert(hash_Search(NULL, gdbroot->oid_ht, &oid) == NULL);

  op = gdb_AddObject(sts, name, oid, cid, size, poid, flags, soid);
  if (op == NULL) return NULL;
  op->u.n.flags.b.systemCreated = 1;
  return vol_LinkObject(sts, vp, op, vol_mLink_load);
} 
Example #3
0
gdb_sObject *
dvol_CreateObject (
  pwr_tStatus		*sts,
  cdh_sParseName	*pn,
  pwr_tClassId		cid,
  pwr_tUInt32		size,
  pwr_tObjid		oid		/* Requested objid, */
)
{
  static cvol_sNotify	cm;		/* Cannot be on the stack for VAXELN */
  pwr_tObjid		poid;		/* Objid of parent (or pwr_cNObjid) */
  pwr_tInt32		size2;		/* Size of the new object */
  gdb_sClass		*cp;
  gdb_sObject		*tmp_op;
  gdb_sObject		*op;
  gdb_sObject		*pop;
  gdb_sVolume		*vp;
  pwr_sClassDef         *cdef;
  
  gdb_AssumeLocked;

  if (pn->flags.b.idString) pwr_Return(NULL, sts, GDH__NOSUCHOBJ);

  /* Verify class.  */

  cp = hash_Search(sts, gdbroot->cid_ht, &cid);
  if (cp == NULL) return NULL;

  size2 = MAX(size, cp->size);

  /* Check parent.  */

  pop = vol_NameToParentObject(sts, pn, gdb_mLo_dynamic, vol_mTrans_all);
  if (pop == NULL) {
    if (pn->nObject > 1)
      pwr_Return(NULL, sts , GDH__BADPARENT);

    poid = pwr_cNObjid;

    if (cdh_ObjidIsNull(oid))
      poid.vid = gdbroot->db->vid;
    else
      poid.vid = oid.vid;

    pop = vol_OidToObject(sts, poid, gdb_mLo_dynamic, vol_mTrans_all, cvol_eHint_none);
    if (pop == NULL) return NULL;
  } else {
    poid = pop->g.oid;
    if (cdh_ObjidIsNotNull(oid) && oid.vid != pop->g.oid.vid)
      pwr_Return(NULL, sts, GDH__BADPARENT);
  }

  vp = pool_Address(sts, gdbroot->pool, pop->l.vr);
  if (vp == NULL)
    pwr_Return(NULL, sts, GDH__BADPARENT);

  if (!vp->l.flags.b.dynamic)
    pwr_Return(NULL, sts, GDH__STATICVOL);

  /* Make sure that the name is unique.  */

  pn->object[pn->nObject-1].poid = poid;
  if (hash_Search(sts, gdbroot->family_ht, &pn->object[pn->nObject-1]) != NULL)
    pwr_Return(NULL, sts, GDH__DUPLNAME);

  if (cdh_ObjidIsNull(oid))
    oid = vol_Oid(sts, vp, cid);

  if (hash_Search(sts, gdbroot->oid_ht, &oid) != NULL)
    return NULL;

  tmp_op = op = gdb_AddObject(sts, pn->object[pn->nObject-1].name.orig, oid, cid, size2, poid, net_mGo__, pwr_cNObjid);
  if (op == NULL) return NULL;

  do {
    /* We have alloced an object header.
       Free it if something happens.  */

    op = vol_LinkObject(sts, vp, op, vol_mLink_create);
    if (op == NULL) break;

    cvols_InitNotify(op, &cm, net_eMsg_createObject);

    op = adoptObject(sts, op, pop, &cm);
    if (op == NULL) break;

    cdef  = pool_Address(NULL, gdbroot->rtdb, cp->cbr);

    if ( cdef->Flags.b.RtReadOnly)
      op->u.n.lflags.b.readOnly = 1;

    cvols_Notify(&cm);

    return op;
  } while (0);

  vol_UnlinkObject(sts, vp, op, vol_mLink_delete);
  return NULL;  
}