Ejemplo n.º 1
0
void ini_ProcIter (
  pwr_tStatus	*status,
  ini_sContext	*cp,
  int		mask,
  void		(*func)(pwr_tStatus*, ini_sContext*, ini_sProc*)
)
{
  lst_sEntry	*pl;
  ini_sProc	*pp;

  pwr_dStatus(sts, status, INI__SUCCESS);

  for (pp = lst_Succ(NULL, &cp->proc_lh, &pl); pp != NULL; pp = lst_Succ(NULL, pl, &pl)) {
    if (pp->proc.flags.m & mask)
      func(sts, cp, pp);
  }
}
Ejemplo n.º 2
0
/*_*
  @aref cyclesup CycleSup
  */
lst_sEntry* csup_Init(pwr_tStatus* status, pwr_tObjid tid, float scanTime)
{
  lst_sEntry* lh;
  pwr_tObjid cid;
  pwr_tObjid pid;
  csup_sObject* cp;
  int tv_sec;
  pwr_tFloat32 max_delay;

  pwr_dStatus(sts, status, CSUP__SUCCESS);

  lh = calloc(1, sizeof(*lh));
  if (lh == NULL)
    pwr_Return(NULL, sts, CSUP__INSVIRMEM);

  lst_Init(NULL, lh, NULL);

  for (*sts = gdh_GetClassList(pwr_cClass_CycleSup, &cid); ODD(*sts);
       *sts = gdh_GetNextObject(cid, &cid)) {
    cp = calloc(1, sizeof(*cp));
    cp->aref.Objid = cid;
    *sts = gdh_DLRefObjectInfoAttrref(&cp->aref, (void**)&cp->o, &cp->dlid);
    if (EVEN(*sts))
      goto error;

    if (ODD(gdh_GetParent(cid, &pid)) && cdh_ObjidIsEqual(pid, tid))
      cp->is_owner = 1;

    lst_InsertSucc(NULL, lh, &cp->le, cp);
    max_delay = cp->o->MaxDelay;
    cp->o->DelayLimit.tv_sec = tv_sec = (int)max_delay;
    cp->o->DelayLimit.tv_nsec
        = (int)((max_delay - (float)tv_sec + FLT_EPSILON) * 1.0e9);
    // errh_Info("maxdelay: %f, tv_sec: %d, tv_nsec: %d", cp->o->MaxDelay,
    //  cp->o->DelayLimit.tv_sec, cp->o->DelayLimit.tv_nsec);
  }

  if (lst_IsEmpty(NULL, lh))
    goto error;

  return lh;

error:
  csup_Exit(NULL, lh);
  return NULL;
}
Ejemplo n.º 3
0
pwr_tDeltaTime *
time_ClockToD (
  pwr_tStatus *status,
  pwr_tDeltaTime *tp,
  time_tClock clock
)
{
  pwr_tDeltaTime time;
  pwr_dStatus(sts, status, TIME__SUCCESS);

  if (tp == NULL)
    tp = &time;

  tp->tv_sec = clock / 100;
  tp->tv_nsec = clock % 100 * 10000000;

  return tp;
}
Ejemplo n.º 4
0
void
csup_Exit (
    pwr_tStatus *status,
    lst_sEntry *lh
)
{
    csup_sObject	*cp;

    pwr_dStatus(sts, status, CSUP__SUCCESS);

    if (lh == NULL) return;

    while ((cp = lst_Succ(NULL, lh, NULL)) != NULL) {
        lst_Remove(NULL, &cp->le);
        free(cp);
    }
    free(lh);
}
Ejemplo n.º 5
0
void
ivol_CopyBody (
  pwr_tStatus		*status,
  void			*fp,
  void			*tp,
  gdb_sClass		*cp
)
{
  int			i;
  gdb_sAttribute	*ap;

  pwr_dStatus(sts, status, GDH__SUCCESS);

  for (i = 0, ap = cp->attr; i < cp->acount; i++, ap++) {
    if (ap->flags.b.state) 
      continue;
    memcpy((char *)tp + ap->offs, (char *)fp + ap->offs, ap->size);
  }
}
Ejemplo n.º 6
0
void *
que_Get (
  pwr_tStatus *status,
  que_sQue *qp,
  pwr_tDeltaTime *tp,
  void *tmo_item
)
{
  void *p = NULL;
  pwr_dStatus(sts, status, QUE__SUCCESS);

  thread_MutexLock(&qp->mutex);

    while((p = lst_RemoveSucc(NULL, &qp->lh, NULL)) == NULL && ODD(*sts) && *sts != THREAD__TIMEDOUT)
      *sts = thread_CondTimedWait(&qp->cond, &qp->mutex, tp);

  thread_MutexUnlock(&qp->mutex);

  return p == NULL ? tmo_item : p;
}
Ejemplo n.º 7
0
pwr_tStatus
qos_SignalQue (
  pwr_tStatus	*status,
  qdb_sQue	*qp
)
{
  pwr_dStatus	(sts, status, QCOM__SUCCESS);

  qdb_AssumeLocked;

  pthread_mutex_lock(&qp->lock.mutex);

  qp->lock.waiting = FALSE;

  pthread_cond_signal(&qp->lock.cond);
  
  pthread_mutex_unlock(&qp->lock.mutex);

  return TRUE;
}
Ejemplo n.º 8
0
static pwr_tDeltaTime *
vms_to_delta (
  pwr_tStatus *status,
  pwr_tDeltaTime *tp,
  time_tOs *vt
)
{
  time_tOs time;
  int divisor = -10000000;
  pwr_dStatus(sts, status, TIME__SUCCESS);

  if (tp == NULL)
    tp = (pwr_tDeltaTime *)&time;

  *sts = lib$ediv(&divisor, vt, &tp->tv_sec, &tp->tv_nsec);
  if (EVEN(*sts)) return NULL;
  tp->tv_nsec *= 100;

  return tp;
}
Ejemplo n.º 9
0
que_sQue *
que_Create (
  pwr_tStatus *status,
  que_sQue *qp
)
{
  que_sQue *lqp = NULL;
  pwr_dStatus(sts, status, QUE__SUCCESS);

  if (qp == NULL) {
    lqp = qp = (que_sQue *) calloc(1, sizeof(*qp));
    if (lqp == NULL)
      pwr_Return(lqp, sts, QUE__INSVIRMEM);
  }

  thread_CondInit(&qp->cond);
  thread_MutexInit(&qp->mutex);
  lst_Init(NULL, &qp->lh, NULL);

  return qp;
}
Ejemplo n.º 10
0
ivol_sBody *
ivol_GetBody (
  pwr_tStatus		*status,
  pwr_tObjid		oid,
  ivol_sBody		*lb
)
{
  static ivol_sBody	body;

  pwr_dStatus(sts, status, GDH__SUCCESS);

  if (lb == NULL) lb = &body;

  lb->op = hash_Search(sts, gdbroot->oid_ht, &oid);
  if ( !lb->op)
    return 0;
  lb->size = lb->op->g.size;
  lb->body = pool_Address(NULL, gdbroot->rtdb, lb->op->u.n.body);

  return lb;
}
Ejemplo n.º 11
0
pwr_tBoolean ini_ReadNodeFile (
  pwr_tStatus	*status,
  ini_sContext	*cp
)
{
  FILE *f;

  pwr_dStatus(sts, status, INI__SUCCESS);

  f = ini_OpenFile(sts, cp, &cp->nodefile);

  if (f == NULL)
    return NO;

  errh_LogInfo(&cp->log, "Reading Node file %s", cp->nodefile.name);

  qini_ParseFile(f, cp->nid_t, &cp->warnings, &cp->errors, &cp->fatals);
  fclose(f);

  return YES;
}
Ejemplo n.º 12
0
time_tOs *
time_DtoOs (
  pwr_tStatus *status,
  time_tOs *tp,
  pwr_tDeltaTime *dp
)
{
  time_tOs os_time;
  int multiplier = -10000000;
  int nsec = dp->tv_nsec/100;
  int sec = dp->tv_sec;

  pwr_dStatus(sts, status, TIME__SUCCESS);

  if (tp == NULL)
    tp = &os_time;

  *sts = lib$emul(&sec, &multiplier, &nsec, tp);
  if (EVEN(*sts)) return NULL;

  return tp;
}
Ejemplo n.º 13
0
time_tClock
time_Clock (
  pwr_tStatus *status,
  pwr_tDeltaTime *ap
)
{
  long		tics;
  struct tms	buff;
  static int    tics_per_sec = 0;
  pwr_dStatus(sts, status, TIME__SUCCESS);

  if ( !tics_per_sec)
    tics_per_sec = sysconf(_SC_CLK_TCK);

  tics = times(&buff);

  if (ap != NULL) {
    tics += (ap->tv_sec * tics_per_sec) + (ap->tv_nsec / (1000000000 / tics_per_sec));
  }

  return tics;
}
Ejemplo n.º 14
0
char *ini_LoadDirectory (
  pwr_tStatus	*status,
  ini_sContext *cp
)
{
  pwr_dStatus(sts, status, INI__SUCCESS);

  if (!cp->flags.b.nodename)
    syi_NodeName(sts, cp->nodename, sizeof(cp->nodename));
  if (!cp->flags.b.hostname)
    syi_HostName(sts, cp->hostname, sizeof(cp->hostname));

  syi_NodeSpec(sts, cp->nodespec, sizeof(cp->nodespec));
  syi_HostSpec(sts, cp->hostspec, sizeof(cp->hostspec));
  syi_BootDisk(sts, cp->bootdisk, sizeof(cp->bootdisk));

  {
    char *s;

    if ((s = getenv(dbs_cNameBaseDirectory)) != NULL)
      sprintf(cp->bdir, "%s/", s);
    else
      errh_LogError(&cp->log, "Environment variable '%s' is not defined", dbs_cNameBaseDirectory);

    if ((s = getenv(dbs_cNameDirectory)) != NULL)
      sprintf(cp->dir, "%s/", s);
    else
      errh_LogError(&cp->log, "Environment variable '%s' is not defined", dbs_cNameDirectory);

    if (!cp->flags.b.busid) {
      s = getenv(pwr_dEnvBusId);
      if (s != NULL)

	cp->busid = atoi(s);
    }
  }

  return cp->dir;
}
Ejemplo n.º 15
0
void  ini_ProcStart (
  pwr_tStatus	*status,
  ini_sContext	*cp,
  ini_sProc	*pp
)  
{

  pwr_dStatus(sts, status, INI__SUCCESS);

  if (pp->flags.b.running) 
    return;
  
  if (pp->flags.b.run) {
    errh_LogInfo(&cp->log, "Starting %s, file: %s, prio: %d", pp->id, pp->proc.file, pp->proc.p_prio);
  } else {
    errh_LogInfo(&cp->log, "%s, file: %s, prio: %d, will not be started.", pp->id, pp->proc.file, pp->proc.p_prio);
    return;
  }

  *sts = proc_Start(&pp->proc);
  if (EVEN(*sts))
    errh_LogError(&cp->log, "Error starting %s, %m", pp->id, *sts);
}
Ejemplo n.º 16
0
time_tClock
time_Clock (
  pwr_tStatus	  *status,
  pwr_tDeltaTime  *ap
)
{
  long		  tics;
  struct tms	  buff;
  void		  *argv[2];

  pwr_dStatus(sts, status, TIME__SUCCESS);

  argv[0] = (void *) 1;
  argv[1] = &tics;

  *sts = sys$cmexec(&uptime, argv);

  if (ap != NULL) {
    tics += ap->tv_sec * 100 + ap->tv_nsec / 10000000;
  }

  return tics;
}
Ejemplo n.º 17
0
void ini_ProcPrio (
  pwr_tStatus	*status,
  ini_sContext	*cp,
  ini_sProc	*pp
)  
{

  char    set[100];
  
  pwr_dStatus(sts, status, INI__SUCCESS);

  if (pp->flags.b.running) 
    return;
  
  if (pp->flags.b.run) {
#if defined(OS_LINUX)
    if (!(pp->flags.b.plc)) {
      sprintf(set, "rt_prio -rp %d %d", pp->proc.p_prio, pp->proc.pid);
      system(set);
    }
#endif 
  }
}
Ejemplo n.º 18
0
void sanc_SubscribeMountServers(pwr_tStatus* status, gdb_sNode* np)
{
  gdb_sMountServer* msp;
  pool_sQlink* msl;
  gdb_sObject* op;

  pwr_dStatus(sts, status, 1);

  gdb_AssumeLocked;

  for (msl = pool_Qsucc(NULL, gdbroot->pool, &np->nodms_lh);
       msl != &np->nodms_lh; msl = pool_Qsucc(NULL, gdbroot->pool, msl)) {
    msp = pool_Qitem(msl, gdb_sMountServer, nodms_ll);

    op = pool_Address(sts, gdbroot->pool, msp->msor);
    if (op == NULL)
      continue;

    sanc_Subscribe(sts, op);
  }

  *sts = 1;
}
Ejemplo n.º 19
0
FILE *ini_OpenFile (
  pwr_tStatus	*status,
  ini_sContext	*cp,
  ini_sFile	*fp

)
{
  FILE *f;

  pwr_dStatus(sts, status, INI__SUCCESS);

  f = fopen(fp->name, "r");
  if (f == NULL) {
    if (fp->errcount)
      (*fp->errcount)++;
    if (fp->logOpenFail)
      fp->logOpenFail(&cp->log, "Could not open file %s", fp->name);
    return NULL;
  }

  if (cp->flags.b.verbose) errh_LogInfo(&cp->log, "Opened file %s", fp->name);

  return f;
}
Ejemplo n.º 20
0
pwr_tDeltaTime *
time_Uptime (
  pwr_tStatus *status,
  pwr_tDeltaTime *tp,
  pwr_tDeltaTime *ap
)
{
  pwr_tDeltaTime time;
  unsigned long tics;
  static pwr_tUInt64 tics_64;
  struct tms buff;
  static int tics_per_sec = 0;
  static pwr_tTime boot_time = {0,0};
  static pwr_tDeltaTime max_diff = {0, 20000000};
  pwr_tDeltaTime uptime_tics;
  pwr_tTime current_time;
  pwr_tDeltaTime diff;
  static pwr_tUInt16 msb_flips = 0;
  static pwr_tBoolean old_high_bit = 0;
  pwr_tBoolean high_bit;
  lldiv_t uptime_s;
  pwr_dStatus(sts, status, TIME__SUCCESS);
 
  if ( !tics_per_sec)
    tics_per_sec = sysconf(_SC_CLK_TCK);

  if (tp == NULL)
    tp = &time;

  tics = times(&buff);

  high_bit = tics >> (32 - 1);
  if (!high_bit && old_high_bit)
    msb_flips++;
  old_high_bit = high_bit;

  tics_64  = ((pwr_tUInt64) msb_flips << 32) | tics;
  uptime_s = lldiv(tics_64, (pwr_tInt64) tics_per_sec);
  
  uptime_tics.tv_sec  = (pwr_tInt64) uptime_s.quot;
  uptime_tics.tv_nsec = ((pwr_tUInt64) uptime_s.rem) * (1000000000 / tics_per_sec);

  // pwr_Assert(tp->tv_sec >= 0 && tp->tv_nsec >= 0);

  time_GetTime( &current_time);
  if ( !boot_time.tv_sec) {
    time_Asub( &boot_time, &current_time, &uptime_tics);
    *tp = uptime_tics;
  }
  else {
    time_Adiff( tp, &current_time, &boot_time);
    time_Dsub( &diff, tp, &uptime_tics);
    time_Dabs(NULL, &diff);
    if ( time_Dcomp(&diff, &max_diff) > 0) {
      time_Asub( &boot_time, &current_time, &uptime_tics);
      *tp = uptime_tics;
      if (status != NULL) {
        *status = TIME__CLKCHANGE;
      }
    }
  }

  if (ap != NULL)
    return time_Dadd(tp, tp, ap);
  else
    return tp;
}
Ejemplo n.º 21
0
int csup_Exec(pwr_tStatus* status, lst_sEntry* lh, pwr_tDeltaTime* next_start,
    pwr_tDeltaTime* stop, pwr_tTime* now)
{
  int action = 0;
  csup_sObject* cp;
  pwr_tDeltaTime nextLimit;

  pwr_dStatus(sts, status, CSUP__SUCCESS);

  if (lh == NULL || next_start == NULL || now == NULL || stop == NULL)
    pwr_Return(NO, sts, CSUP__NULPOINT);

  while ((cp = lst_Succ(NULL, lh, &lh)) != NULL) {
    pwr_sClass_CycleSup* o = cp->o;

    if (cp->is_owner) {
      if (time_Dcomp(&o->NextLimit, NULL) > 0) {
        if (time_Dcomp(stop, &o->NextLimit) > 0) {
          if (!o->Delayed) {
            o->DelayedTime = *now;
            o->Delayed = TRUE;
            o->Timely = FALSE;
          }
          o->DelayCount++;
          o->LastDelay = *now;
          action = MAX(action, o->DelayAction);
        } else if (!o->Timely) {
          o->Timely = TRUE;
          o->TimelyTime = *now;
        }
      }
      if ((o->DelayLimit.tv_sec & 1 << 31)
          != (o->DelayLimit.tv_nsec & 1 << 31)) {
        // printf("DelayLimit.tv_sec: %d, DelayLimit.tv_nsec: %d\n",
        // o->DelayLimit.tv_sec, o->DelayLimit.tv_nsec);
        errh_Info("DelayLimit.tv_sec: %d, DelayLimit.tv_nsec: %d",
            o->DelayLimit.tv_sec, o->DelayLimit.tv_nsec);
      }
      if ((next_start->tv_sec & 1 << 31) != (next_start->tv_nsec & 1 << 31)) {
        // printf("next_start->tv_sec: %d, next_start->tv_nsec: %d\n",
        // next_start->tv_sec, next_start->tv_nsec);
        errh_Info("next_start->tv_sec: %d, next_start->tv_nsec: %d",
            next_start->tv_sec, next_start->tv_nsec);
      }
      time_Dadd(&nextLimit, next_start, &o->DelayLimit);

      /* If we update the tv_nsec field first it is
         possible that emon will detect a slip even if it is not. */

      o->NextLimit.tv_sec = nextLimit.tv_sec;
      o->NextLimit.tv_nsec = nextLimit.tv_nsec;

      o->CycleCount++;
    } else {
      /* Not owner, check stall delay */
      if (o->DelayAction == 2) {
        nextLimit.tv_nsec = o->NextLimit.tv_nsec;
        nextLimit.tv_sec = o->NextLimit.tv_sec;
        if (time_Dcomp(&nextLimit, NULL) > 0
            && time_Dcomp(stop, &nextLimit) > 0) {
          o->DelayCount++;
          o->LastDelay = *now;
          action = MAX(action, o->DelayAction);
        }
      }
    }
  }

  return action;
}
Ejemplo n.º 22
0
pwr_tBoolean
ivol_RebuildVolume (
  pwr_tStatus		*status,
  ivol_sVolume		*lv,
  const co_mFormat	*format
)
{
  gdb_sVolume		*vp = lv->vp;
  ivol_sObject		*iop;
  lst_sEntry		*iol;
  pool_sQlink		*ol;
  gdb_sObject		*op;

  pwr_dStatus(sts, status, GDH__SUCCESS);

  gdb_AssumeExcled;
  gdb_AssumeLocked;

#if 0
  // if (!vp->modified) continue;
#endif

  for (
    ol = pool_Qsucc(sts, gdbroot->pool, &vp->l.obj_lh);
    ol != &vp->l.obj_lh;
  ) {
    op = pool_Qitem(ol, gdb_sObject, l.obj_ll);
    ol = pool_Qsucc(sts, gdbroot->pool, ol);

    if (op->u.n.flags.b.swapDelete && !op->u.n.flags.b.systemCreated) {
      vol_SetAlarmLevel(sts, op, 0);/* !!! TODO Remeber to take care of move also in dvol delete and move */
      vol_SetBlockLevel(sts, op, 0);/* !!! TODO Remeber to take care of move also in dvol delete and move */
    }
  }

  /* Unlink all modified objects.  */
  for (iop = lst_Succ(NULL, &lv->upd_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    if (!(iop->flags.m & gdb_mChange_head)) continue;
    vol_UnlinkObject(sts, vp, iop->op, iop->unlink.m);
    updateObject(lv, iop);
  }
  for (iop = lst_Succ(NULL, &lv->upd_io_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    if (!(iop->flags.m & gdb_mChange_head)) continue;
    vol_UnlinkObject(sts, vp, iop->op, iop->unlink.m);
    updateObject(lv, iop);
  }

  for (iop = lst_Succ(NULL, &lv->cre_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    vol_LinkObject(sts, vp, iop->op, vol_mLink_loOidTab);
  }

  for (
    ol = pool_Qsucc(sts, gdbroot->pool, &vp->l.obj_lh);
    ol != &vp->l.obj_lh;
  ) {
    op = pool_Qitem(ol, gdb_sObject, l.obj_ll);
    ol = pool_Qsucc(sts, gdbroot->pool, ol);

    if (op->u.n.flags.b.swapDelete && !op->u.n.flags.b.systemCreated) {
      vol_UnlinkObject(sts, vp, op, vol_mLink_swapDelete);
    }
  }

  /* Relink all new and modified objects.  */

  for (iop = lst_Succ(NULL, &lv->upd_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    if (!(iop->flags.m & gdb_mChange_head)) continue;
    vol_LinkObject(sts, vp, iop->op, iop->link.m);
  }
  for (iop = lst_Succ(NULL, &lv->upd_io_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    if (!(iop->flags.m & gdb_mChange_head)) continue;
    vol_LinkObject(sts, vp, iop->op, iop->link.m);
  }

  convFctn = dvms_GetFctns(format);

  for (iop = lst_Succ(NULL, &lv->cre_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    vol_LinkObject(sts, vp, iop->op, vol_mLink_swapBuild);
    if (convFctn != NULL)
      decodeObject(NULL, iop->op, iop->cp, format->b.bo);
  }

  convFctn = NULL;
  

#if 0
  san_DeleteVolumeServers(sts, vp);
#endif

  return YES;
}
Ejemplo n.º 23
0
ini_sProc *ini_ProcInsert (
  pwr_tStatus	*status,
  ini_sContext	*cp,
  char		*id,
  char		*name,
  int		load,
  int		run,
  char		*file,
  int		prio,
  int		debug,
  char		*arg
)
{
  ini_sProc	*pp;
  char		buf[255];
  char          *s;
  int           ret;
  struct stat   f_stat;

  pwr_dStatus(sts, status, INI__SUCCESS);

  pp = tree_Insert(sts, cp->proc_t, id);
  if (pp == NULL) return NULL;

  if (name != NULL && name[0] != '\0' && strcmp(name, "\"\"")) {
    if (pp->proc.name != NULL) free(pp->proc.name);
    sprintf(buf, name, cp->busid);
    pp->proc.name = strsav(buf);
  }
  if (load != -1) pp->proc.flags.b.load = load != 0;
  if (run != -1) pp->flags.b.run = run != 0;
  if (file != NULL && file[0] != '\0' && strcmp(file, "\"\"")) {
    if (pp->proc.file != NULL) free(pp->proc.file);
      pp->proc.file = strsav(file);
#if defined(OS_LINUX)
      s = getenv("pwr_exe");
      sprintf(buf, "%s/%s", s, file);
      ret = stat(buf, &f_stat);
      if (ret == -1)
      {
        s = getenv("pwrp_exe");
	sprintf(buf, "%s/%s", s, file);
	ret = stat(buf, &f_stat);
	if (ret == -1)
	{
	  pp->flags.b.run  = 0;
	  pp->proc.flags.b.load = 0;
	}
      }
#endif
  }
  if (arg != NULL && arg[0] != '\0' && strcmp(arg, "\"\"")) {
    if (pp->proc.arg != NULL) free(pp->proc.arg);
    pp->proc.arg = strsav(arg);
  }
  if (prio != -1) pp->proc.p_prio = prio;
  if (debug != -1) pp->proc.flags.b.debug = debug != 0;
  if (!lst_IsLinked(NULL, &pp->proc_ll)) {
    lst_InsertPred(NULL, &cp->proc_lh, &pp->proc_ll, pp);
  }

  return pp;
}
Ejemplo n.º 24
0
void
ivol_BuildNode (
  pwr_tStatus		*status,
  ivol_sNode		*lnp,
  const co_mFormat      *formatp
)
{
  gdb_sVolume		*vp;
  pwr_sMountObject	*MountObject;
  cdh_uVolumeId		sys_vid;
  pwr_tObjid		sys_oid;
  pwr_tObjid		oid;
  gdb_sObject		*op;
  gdb_sObject		*vop;
  gdb_sObject		*mop;
  pool_sQlink		*vl;
  gdb_sClass		*cp;
  pool_sQlink		*cl;
  co_mFormat            fm;
  pwr_tTime		time;
  
  
  pwr_dStatus(sts, status, GDH__SUCCESS);

  /* Fill in remaining node information.  */

  gdbroot->db->nod_oid = lnp->nod_oid;

  gdbroot->my_node->nod_oid = gdbroot->db->nod_oid;
  gdbroot->my_node->vol_oid = gdbroot->db->vol_oid;

  /* Create the system volume and mount it in the root voulme.  */

  sys_vid.pwr	  = gdbroot->db->vid;
  sys_vid.v.vid_3 = cdh_eVid3_local;
  sys_oid.vid	  = sys_vid.pwr;
  sys_oid.oix	  = pwr_cNObjectIx;
  time_GetTime(&time);

  vp = gdb_LoadVolume(sts, sys_vid.pwr, "", pwr_eClass_SystemVolume, gdbroot->db->nid, 
                      time, gdb_mLoad_build, co_GetOwnFormat(&fm));
  if (vp == NULL) errh_Bugcheck(*sts, "");

  /* Create the volume object.  */

  vop = loadObject(sts, vp, vp->g.name.orig, sys_oid, pwr_eClass_SystemVolume,
    sizeof(pwr_sSystemVolume), pwr_cNObjid, net_mGo__, pwr_cNObjid); 
  if (vop == NULL) errh_Bugcheck(*sts, "");
  vop->u.n.flags.b.bodyDecoded = 1;

  /* Create the 'pwrNode' object.  */

  oid = vol_Oid(sts, vp, pwr_eClass_NodeHier);
  op = loadObject(sts, vp, "pwrNode", oid, pwr_eClass_NodeHier,
    sizeof(pwr_sNodeHier), sys_oid, net_mGo__, pwr_cNObjid); 
  if (op == NULL) errh_Bugcheck(*sts, "");
  op->u.n.flags.b.bodyDecoded = 1;

  errh_Info("Created pwrNode, oid: %s", cdh_ObjidToString(NULL, oid, 1));
  /* Create a mount object in the root volume, to mount the 'pwrNode' object.  */

  pwr_Assert(gdbroot->my_volume != NULL);

  oid = vol_Oid(sts, gdbroot->my_volume, pwr_eClass_MountObject);
  mop = loadObject(sts, gdbroot->my_volume, "pwrNode", oid, pwr_eClass_MountObject,
    sizeof(pwr_sMountObject), gdbroot->db->vol_oid, net_mGo_isMountClient, op->g.oid); 
  if (mop == NULL) errh_Bugcheck(*sts, "");
  mop->u.n.flags.b.bodyDecoded = 1;
  
  MountObject = pool_Address(NULL, gdbroot->rtdb, mop->u.n.body);
  strcpy(MountObject->Description, "Mounts the system volume object pwr_Node.");
  MountObject->Object = op->g.oid;

  /* Build all native volumes.  */

  for (
    vl = pool_Qsucc(sts, gdbroot->pool, &gdbroot->db->vol_lh);
    vl != &gdbroot->db->vol_lh;
    vl = pool_Qsucc(sts, gdbroot->pool, vl)
  ) {
    vp = pool_Qitem(vl, gdb_sVolume, l.vol_ll);

    if (vp->l.flags.b.isNative) ivol_BuildVolume(sts, vp);
  }

  /* Link class definitions.  */

  for (
    cl = pool_Qsucc(sts, gdbroot->pool, &gdbroot->db->class_lh);
    cl != &gdbroot->db->class_lh;
  ) {
    cp = pool_Qitem(cl, gdb_sClass, class_ll);
    /* NOTA BENE !! mvol_LinkClass will change the linkage.  */
    cl = pool_Qsucc(sts, gdbroot->pool, cl);

    mvol_LinkClass(sts, cp, gdb_mAdd__);
  }

  /* Link Sub classes to attributes.  */

  for (
    cl = pool_Qsucc(sts, gdbroot->pool, &gdbroot->db->class_lh);
    cl != &gdbroot->db->class_lh;
  ) {
    cp = pool_Qitem(cl, gdb_sClass, class_ll);
    cl = pool_Qsucc(sts, gdbroot->pool, cl);

    if (cp->hasSc)
      mvol_LinkSubClassToAttribute(sts, cp);
  }

  /* Build ScObjects for native volumes.  */

  for (
    vl = pool_Qsucc(sts, gdbroot->pool, &gdbroot->db->vol_lh);
    vl != &gdbroot->db->vol_lh;
    vl = pool_Qsucc(sts, gdbroot->pool, vl)
  ) {
    vp = pool_Qitem(vl, gdb_sVolume, l.vol_ll);

    if (vp->l.flags.b.isNative)
      buildScObjects(sts, vp);
  }


  /* Build class attribute tree */
  mvol_BuildCatt(sts);


  convFctn = dvms_GetFctns(formatp);
  if (convFctn != NULL)
    decodeObjects(formatp->b.bo);
  convFctn = NULL;

  mountClients(sts, gdbroot->my_volume);
}
Ejemplo n.º 25
0
void ini_ProcTable(pwr_tStatus* status, ini_sContext* cp)
{
  FILE* f;
  ini_sProc* pp;
  char* s;
  char buffer[256];
  char sev_server_args[20] = "-n";

  pwr_dStatus(sts, status, INI__SUCCESS);

  pp = ini_ProcInsert(sts, cp, "pwr_qmon", "pwr_qmon_%d", 0, 1, "rt_qmon",
      cPrio_qmon, 0, 0, "-n", 0);
  pp->flags.b.qmon = 1;
  pp->proc.flags.b.system = 1;

  if (cp->flags.b.rootvolume)
    strcpy(sev_server_args, "");
  pp = ini_ProcInsert(sts, cp, "pwr_sev_server", "pwr_sev_server_%d", 0, 1,
      "sev_server", cPrio_sev_server, 0, 0, sev_server_args, 0);
  pp->proc.flags.b.system = 1;

  f = ini_OpenFile(sts, cp, &cp->applfile);
  if (f != NULL) {
    if (cp->flags.b.verbose)
      errh_LogInfo(
          &cp->log, "Reading Application file %s\n", cp->applfile.name);
    for (;;) {
      char* nl;

      s = fgets(buffer, sizeof(buffer) - 1, f);
      if (s == NULL)
        break;
      nl = strchr(s, '\n');
      if (nl != NULL)
        *nl = '\0';

      if (cp->flags.b.verbose)
        errh_LogInfo(&cp->log, "   %s", buffer);
      if (buffer[0] == '#')
        continue;

      do {
        int i_load = -1;
        int i_run = -1;
        int i_debug = -1;
        int i_prio = -1;
        char* id = NULL;
        char* name = NULL;
        char* load = NULL;
        char* run = NULL;
        char* file = NULL;
        char* prio = NULL;
        char* debug = NULL;
        char* arg = NULL;

        id = strtok(s, ",");
        if (id == NULL)
          break;
        name = strtok(NULL, ",");
        if (name == NULL)
          break;
        load = strtok(NULL, ",");
        if (load == NULL)
          break;
        run = strtok(NULL, ",");
        if (run == NULL)
          break;
        file = strtok(NULL, ",");
        if (file == NULL)
          break;
        prio = strtok(NULL, ",");
        if (prio == NULL)
          break;
        debug = strtok(NULL, ",");
        if (debug == NULL)
          break;
        arg = strtok(NULL, ",");
        if (arg == NULL)
          break;

        while (isspace(*id))
          id++;
        while (isspace(*name))
          name++;
        while (isspace(*load))
          load++;
        while (isspace(*run))
          run++;
        while (isspace(*file))
          file++;
        while (isspace(*prio))
          prio++;
        while (isspace(*debug))
          debug++;
        while (isspace(*arg))
          arg++;

        if (id[0] == '\0')
          break;
        if (strstr(load, "no"))
          i_load = 0;
        else if (strstr(load, "load"))
          i_load = 1;

        if (strstr(run, "no"))
          i_run = 0;
        else if (strstr(run, "run"))
          i_run = 1;

        if (strstr(debug, "no"))
          i_debug = 0;
        else if (strstr(debug, "debug"))
          i_debug = 1;

        if (strcspn(prio, "0123456789") > 0)
          i_prio = -1;
        else
          i_prio = atoi(prio);

        pp = ini_ProcInsert(
            sts, cp, id, name, i_load, i_run, file, i_prio, i_debug, 0, arg, 0);
        if (!pp->proc.flags.b.system && !pp->proc.flags.b.base)
          pp->proc.flags.b.user = 1;
      } while (0);
    }
    fclose(f);
  }
}
Ejemplo n.º 26
0
pwr_tBoolean
qos_WaitQueOld (
  pwr_tStatus		*status,
  qdb_sQue		*qp,
  int			tmo
)
{
  pwr_tDeltaTime	dtime;
  struct timespec	dtime_ts;
  sigset_t		newset;
  siginfo_t		info;
  int			ok;
  pwr_tBoolean		signal = FALSE;
  pwr_dStatus		(sts, status, QCOM__SUCCESS);

  qdb_AssumeLocked;

  if (tmo == qcom_cTmoNone)
    return FALSE;

  qp->lock.waiting = TRUE;

  sigemptyset(&newset);
  sigaddset(&newset, qdb_cSigMsg);

//  qp->lock.pid = BUILDPID(getpid(), pthread_self());
// I think that each thread has it's own pid in Linux. ML
  qp->lock.pid = getpid();

  qdb_Unlock;

    if (tmo != qcom_cTmoEternal) {
      time_MsToD(&dtime, tmo);
      dtime_ts.tv_sec = dtime.tv_sec;
      dtime_ts.tv_nsec = dtime.tv_nsec;
     
      ok = sigtimedwait(&newset, &info, &dtime_ts);  
    } else {
      for (;;) {
        ok = sigwaitinfo(&newset, &info);
        if ( ok == -1 && errno == EINTR)
          continue;
        break;
      }
    }
    
    if (ok == -1 && errno != EAGAIN) {
      errh_Error("waitQue (%d) %s", errno, strerror(errno));
    }
    else if (!(ok == -1 || ok == qdb_cSigMsg)) {
      errh_Error("qos waitQue signr %d", ok);
    }

  qdb_Lock;

  if (qp->lock.waiting) {
    *sts = QCOM__TMO;
    qp->lock.waiting = FALSE;
  } else {
    signal = TRUE;
  }

  return signal;
}