Exemplo n.º 1
0
int Ge::get_ldhses_cb( void *ctx, ldh_tSesContext *ldhses, int load)
{
#if LDH
    Ge *gectx = (Ge *) ctx;
    ldh_tWBContext wbctx;
    int	sts;
    pwr_tVolumeId	volid = 0;
    pwr_tClassId	classid;
    ldh_tVolContext 	volctx;

    if ( gectx->ldhses) {
        *ldhses = gectx->ldhses;
        return 1;
    }
    else if ( !load)
        return 0;
    else {
        // Open workbench and attatch some volume
        sts = ldh_OpenWB( &wbctx, 0, 0);
        if ( EVEN(sts)) return sts;

        // Attach first rootvolume, or if no rootvolume exist some other volume
        sts = ldh_GetVolumeList( wbctx, &volid);
        while ( ODD(sts)) {
            sts = ldh_GetVolumeClass( wbctx, volid, &classid);
            if ( EVEN(sts)) return sts;

            if ( classid == pwr_eClass_RootVolume)
                break;
            sts = ldh_GetNextVolume( wbctx, volid, &volid);
        }
        if ( volid == 0) return sts;

        // Open ldh session
        sts = ldh_AttachVolume( wbctx, volid, &volctx);
        if ( EVEN(sts)) return sts;

        sts = ldh_OpenSession( ldhses, volctx, ldh_eAccess_ReadWrite,
                               ldh_eUtility_Pwr);
        if ( EVEN(sts)) return sts;
    }
    return 1;
#else
    return 0;
#endif
}
Exemplo n.º 2
0
int Cmd::attach_volume_cb( void *ctx,
			 pwr_tVolumeId	volid,
			 int pop)
{
  Cmd *cmd = (Cmd *) ctx;
  int	sts;
  pwr_tVolumeId	vid;
  pwr_tClassId	classid;

  if ( cmd->ldhses)
  {
//    cmd->wnav->message( 'E', "Other volume is already attached");
    return WNAV__VOLATTACHED;
  }

  if ( !cmd->wbctx)
  {
    sts = get_wbctx( (void *)cmd, &cmd->wbctx);
    if ( EVEN(sts)) return sts;
  }

  if ( volid == 0)
  {
    if ( cmd_volume_p != 0) {
      // Attach argument volume
      sts = ldh_VolumeNameToId( cmd->wbctx, cmd_volume_p, &volid);
    }
    if ( cmd_volume_p == 0 || EVEN(sts)) {
      // Attach first rootvolume, or if no rootvolume exist some other volume
      sts = ldh_GetVolumeList( cmd->wbctx, &vid);
      while ( ODD(sts)) {
	volid = vid;
	sts = ldh_GetVolumeClass( cmd->wbctx, vid, &classid);
	if ( EVEN(sts)) return sts;

	if ( classid == pwr_eClass_RootVolume)
	  break;
	sts = ldh_GetNextVolume( cmd->wbctx, vid, &vid);
      }
      if ( volid == 0) return sts;
    }
  }

  cmd->volid = volid;

  // Open ldh session
  sts = ldh_AttachVolume( cmd->wbctx, cmd->volid, &cmd->volctx);
  if ( EVEN(sts)) return sts;

  sts = ldh_OpenSession( &cmd->ldhses,
    cmd->volctx,
    ldh_eAccess_ReadWrite,
    ldh_eUtility_Pwr);
  if ( EVEN(sts)) {
    // Try read access
    sts = ldh_OpenSession( &cmd->ldhses,
			   cmd->volctx,
			   ldh_eAccess_ReadOnly,
			   ldh_eUtility_Pwr);
    if ( EVEN(sts)) return sts;
  }

  cmd->wnav->volume_attached( cmd->wbctx, cmd->ldhses, pop);

  return 1;
}