Пример #1
0
int testDelFileTrash(rsComm_t *rsComm, char *name, char *dataId) {
   dataObjInfo_t dataObjInfo;
   keyValPair_t condInput;

   char *replica=0;

   rsComm->clientUser.authInfo.authFlag = LOCAL_PRIV_USER_AUTH;
   memset (&condInput, 0, sizeof (condInput));
   addKeyVal(&condInput, IRODS_ADMIN_RMTRASH_KW, " ");

   memset(&dataObjInfo, 0, sizeof(dataObjInfo));

   if (dataId != NULL && *dataId != 0) {
      rodsLong_t idataId;
      idataId = strtoll(dataId, NULL, 0); 
      if (idataId >= 0) {
	 dataObjInfo.dataId = idataId;
      }
   }
   dataObjInfo.replNum = -1;
   if (replica != NULL && *replica != 0) {
      int ireplica;
      ireplica = atoi(replica); 
      if (ireplica >= 0) {
	 dataObjInfo.replNum = ireplica;
      }
   }
   strncpy(dataObjInfo.objPath, name, sizeof dataObjInfo.objPath);

   return(chlUnregDataObj(rsComm, &dataObjInfo, &condInput));
}
Пример #2
0
int irods_reli_getfile ( const char *host, const char *path, const char *local_path )
{
	dataObjInp_t request;
	int result;

	struct irods_server *server = connect_to_host(host);
	if(!server) return -1;

	memset(&request,0,sizeof(request));
	strcpy(request.objPath,path);

	request.numThreads = 0; // server chooses threads
	request.openFlags = O_RDONLY;

	addKeyVal (&request.condInput, FORCE_FLAG_KW, "");

	debug(D_IRODS,"rcDataObjGet %s %s %s",host,path,local_path);
	result = rcDataObjGet(server->conn,&request,(char*) local_path);
	debug(D_IRODS,"= %d",result);

	clearKeyVal(&request.condInput);

	if(result<0) {
		errno = irods_reli_errno(result);
		return -1;
	}

	return 0;
}
Пример #3
0
int
modDelayedRule( char *ruleId, char *fieldName, char *fieldValue ) {
    int status;

    ruleExecModInp_t ruleExecModInp;
    memset( &ruleExecModInp, 0, sizeof( ruleExecModInp ) );

    /* for the time fields, convert from YYYY-MM-DD.hh:mm:ss in sec of unix time
      if necessary */
    if ( strcmp( fieldName, "exeTime" ) == 0 || strcmp( fieldName, "estimateExeTime" ) == 0 ||
            strcmp( fieldName, "lastExeTime" ) == 0 ) {
        status = checkDateFormat( fieldValue );
        if ( status == DATE_FORMAT_ERR ) {
            printf( "Time format error: it should be sec in unix time or YYYY-MM-DD.hh:mm:ss.\n" );
            return status;
        }
    }

    strncpy( ruleExecModInp.ruleId, ruleId, NAME_LEN );
    addKeyVal( &ruleExecModInp.condInput, fieldName, fieldValue );

    status = rcRuleExecMod( Conn, &ruleExecModInp );

    if ( status == CAT_SUCCESS_BUT_WITH_NO_INFO ) {
        printf( "No rule found with id %s\n", ruleId );
        return status;
    }
    if ( status < 0 ) {
        printError( Conn, status, "rcRuleExecMod" );
    }
    return status;
}
Пример #4
0
/* rsDataCopy - Do the copy data transfer.
 * Input -
 *   dataCopyInp_t dataCopyInp:
 *      dataOprInp:  - mostly setup by initDataOprInp()
 *         int oprType - SAME_HOST_COPY_OPR, COPY_TO_REM_OPR, COPY_TO_LOCAL_OPR
 *         int numThreads
 *         int srcL3descInx - the source L3descInx
 *         int destL3descInx - the target L3descInx
 *         int srcRescTypeInx;
 *         int destRescTypeInx;
 *         rodsLong_t offset
 *         rodsLong_t dataSize
 *         keyValPair_t condInput - valid input -
 *            EXEC_LOCALLY_KW - all operations except remote-remote copy
 *               have the keyword set.
 *
 *   portalOprOut_t portalOprOut - the resource server portal info.
 */
int
rsDataCopy( rsComm_t *rsComm, dataCopyInp_t *dataCopyInp ) {
    int status;
    int l3descInx;
    rodsServerHost_t *rodsServerHost;
    dataOprInp_t *dataOprInp;

    dataOprInp = &dataCopyInp->dataOprInp;


    if ( getValByKey( &dataOprInp->condInput, EXEC_LOCALLY_KW ) != NULL ||
            dataCopyInp->portalOprOut.numThreads == 0 ) {
        /* XXXXX do it locally if numThreads == 0 */
        status = _rsDataCopy( rsComm, dataCopyInp );
    }
    else {
        if ( dataOprInp->destL3descInx > 0 ) {
            l3descInx = dataOprInp->destL3descInx;
        }
        else {
            l3descInx = dataOprInp->srcL3descInx;
        }
        rodsServerHost = FileDesc[l3descInx].rodsServerHost;
        if ( rodsServerHost != NULL && rodsServerHost->localFlag != LOCAL_HOST ) {
            addKeyVal( &dataOprInp->condInput, EXEC_LOCALLY_KW, "" );
            status = remoteDataCopy( rsComm, dataCopyInp, rodsServerHost );
            clearKeyVal( &dataOprInp->condInput );
        }
        else {
            status = _rsDataCopy( rsComm, dataCopyInp );
        }
    }
    return status;
}
Пример #5
0
/* preProcParaGet - preprocessing for parallel get. Basically it calls
 * rsDataGet to setup portalOprOut with the resource server.
 */
int
preProcParaGet( rsComm_t *rsComm, int l1descInx, portalOprOut_t **portalOprOut ) {
    int status;
    dataOprInp_t dataOprInp;

    initDataOprInp( &dataOprInp, l1descInx, GET_OPR );
    /* add RESC_HIER_STR_KW for getNumThreads */
    if ( L1desc[l1descInx].dataObjInfo != NULL ) {
        //addKeyVal (&dataOprInp.condInput, RESC_NAME_KW,
        //           L1desc[l1descInx].dataObjInfo->rescInfo->rescName);
        addKeyVal( &dataOprInp.condInput, RESC_HIER_STR_KW,
                   L1desc[l1descInx].dataObjInfo->rescHier );
    }
    if ( L1desc[l1descInx].remoteZoneHost != NULL ) {
        status =  remoteDataGet( rsComm, &dataOprInp, portalOprOut,
                                 L1desc[l1descInx].remoteZoneHost );
    }
    else {
        status =  rsDataGet( rsComm, &dataOprInp, portalOprOut );
    }

    if ( status >= 0 ) {
        ( *portalOprOut )->l1descInx = l1descInx;
    }
    clearKeyVal( &dataOprInp.condInput );
    return status;
}
Пример #6
0
int
rcChksumLocFile( char *fileName, char *chksumFlag, keyValPair_t *condInput, const char* _scheme ) {
    char chksumStr[NAME_LEN];
    int status;

    if ( condInput == NULL || chksumFlag == NULL || fileName == NULL ) {
        rodsLog( LOG_NOTICE,
                 "rcChksumLocFile: NULL input" );
        return USER__NULL_INPUT_ERR;
    }

    if ( strcmp( chksumFlag, VERIFY_CHKSUM_KW ) != 0 &&
            strcmp( chksumFlag, REG_CHKSUM_KW ) != 0 &&
            strcmp( chksumFlag, RSYNC_CHKSUM_KW ) != 0 ) {
        rodsLog( LOG_NOTICE,
                 "rcChksumLocFile: bad input chksumFlag %s", chksumFlag );
        return USER_BAD_KEYWORD_ERR;
    }

    status = chksumLocFile( fileName, chksumStr, _scheme );
    if ( status < 0 ) {
        return status;
    }

    addKeyVal( condInput, chksumFlag, chksumStr );

    return 0;
}
Пример #7
0
int
getAllSessionVarValue( char *action, ruleExecInfo_t *rei,
                       keyValPair_t *varKeyVal ) {
    int i, status;
    char *varValue;
    char *lastVar = NULL; 	/* last var that has data */

    if ( varKeyVal == NULL || rei == NULL ) {
        rodsLog( LOG_ERROR,
                 "getAllSessionVarValue: input rei or varKeyVal is NULL" );
        return SYS_INTERNAL_NULL_INPUT_ERR;
    }

    for ( i = 0; i < coreRuleVarDef.MaxNumOfDVars; i++ ) {
        if ( lastVar == NULL || strcmp( lastVar, coreRuleVarDef.varName[i] ) != 0 ) {
            status = getSessionVarValue( "", coreRuleVarDef.varName[i], rei,
                                         &varValue );
            if ( status >= 0 && varValue != NULL ) {
                lastVar = coreRuleVarDef.varName[i];
                addKeyVal( varKeyVal, lastVar, varValue );
                free( varValue );
            }
        }
    }
    return 0;
}
Пример #8
0
// =-=-=-=-=-=-=-
// public - serialize object to kvp
    error pam_auth_object::get_re_vars(
        keyValPair_t& _kvp ) {
        // =-=-=-=-=-=-=-
        // all we have in this object is the auth results
        addKeyVal(
            &_kvp,
            "zone_name",
            zone_name_.c_str() );
        addKeyVal(
            &_kvp,
            "user_name",
            user_name_.c_str() );

        return SUCCESS();

    } // get_re_vars
Пример #9
0
int
rsDataGet( rsComm_t *rsComm, dataOprInp_t *dataOprInp,
           portalOprOut_t **portalOprOut ) {
    int status;
    int remoteFlag;
    int l3descInx;
    rodsServerHost_t *rodsServerHost;

    l3descInx = dataOprInp->srcL3descInx;

    if ( getValByKey( &dataOprInp->condInput, EXEC_LOCALLY_KW ) != NULL ) {
        remoteFlag = LOCAL_HOST;
    }
    else {
        rodsServerHost = FileDesc[l3descInx].rodsServerHost;
        if ( rodsServerHost == NULL ) {
            rodsLog( LOG_NOTICE, "rsDataGet: NULL rodsServerHost" );
            return SYS_INTERNAL_NULL_INPUT_ERR;
        }
        remoteFlag = rodsServerHost->localFlag;
    }

    if ( remoteFlag == LOCAL_HOST ) {
        status = _rsDataGet( rsComm, dataOprInp, portalOprOut );
    }
    else {
        addKeyVal( &dataOprInp->condInput, EXEC_LOCALLY_KW, "" );
        status = remoteDataGet( rsComm, dataOprInp, portalOprOut,
                                rodsServerHost );
        clearKeyVal( &dataOprInp->condInput );
    }


    return status;
}
Пример #10
0
int
modCollInfo2( rsComm_t *rsComm, specColl_t *specColl, int clearFlag ) {

    int status;
    char collInfo2[MAX_NAME_LEN];
    collInp_t modCollInp;

    memset( &modCollInp, 0, sizeof( modCollInp ) );
    rstrcpy( modCollInp.collName, specColl->collection, MAX_NAME_LEN );
    //addKeyVal( &modCollInp.condInput, COLLECTION_TYPE_KW,
    //           TAR_STRUCT_FILE_STR ); /* need this or rsModColl fail */
    if ( clearFlag > 0 ) {
        rstrcpy( collInfo2, "NULL_SPECIAL_VALUE", MAX_NAME_LEN );
    }
    else {
        makeCachedStructFileStr( collInfo2, specColl );
    }
    addKeyVal( &modCollInp.condInput, COLLECTION_INFO2_KW, collInfo2 );
    status = rsModColl( rsComm, &modCollInp );
    if ( status < 0 ) {
        rodsLog( LOG_NOTICE,
                 "tarSubStructFileWrite:rsModColl error for Coll %s,stat=%d",
                 modCollInp.collName, status );
    }
    return status;
}
Пример #11
0
int
_rcDataObjGet( rcComm_t *conn, dataObjInp_t *dataObjInp,
               portalOprOut_t **portalOprOut, bytesBuf_t *dataObjOutBBuf ) {
    int status;

    *portalOprOut = NULL;

    memset( &conn->transStat, 0, sizeof( transStat_t ) );

    memset( dataObjOutBBuf, 0, sizeof( bytesBuf_t ) );

    dataObjInp->oprType = GET_OPR;

#ifndef PARA_OPR
    addKeyVal( &dataObjInp->condInput, NO_PARA_OP_KW, "" );
#endif

    status = procApiRequest( conn, DATA_OBJ_GET_AN,  dataObjInp, NULL,
                             ( void ** ) portalOprOut, dataObjOutBBuf );

    if ( *portalOprOut != NULL && ( *portalOprOut )->l1descInx < 0 ) {
        status = ( *portalOprOut )->l1descInx;
    }

    return ( status );
}
Пример #12
0
int
_rsProcStat (rsComm_t *rsComm, procStatInp_t *procStatInp,
             genQueryOut_t **procStatOut)
{
    int status;
    rodsServerHost_t *rodsServerHost;
    int remoteFlag;
    rodsHostAddr_t addr;
    procStatInp_t myProcStatInp;
    char *tmpStr;

    if (getValByKey (&procStatInp->condInput, ALL_KW) != NULL) {
        status = _rsProcStatAll (rsComm, procStatInp, procStatOut);
        return status;
    }
    if (getValByKey (&procStatInp->condInput, EXEC_LOCALLY_KW) != NULL) {
        status = localProcStat (rsComm, procStatInp, procStatOut);
        return status;
    }

    bzero (&addr, sizeof (addr));
    bzero (&myProcStatInp, sizeof (myProcStatInp));
    if (*procStatInp->addr != '\0') {	/* given input addr */
        rstrcpy (addr.hostAddr, procStatInp->addr, LONG_NAME_LEN);
        remoteFlag = resolveHost (&addr, &rodsServerHost);
    } else if ((tmpStr = getValByKey (&procStatInp->condInput, RESC_NAME_KW))
               != NULL) {
        rescGrpInfo_t *rescGrpInfo = NULL;
        status = _getRescInfo (rsComm, tmpStr, &rescGrpInfo);
        if (status < 0) {
            rodsLog (LOG_ERROR,
                     "_rsProcStat: _getRescInfo of %s error. stat = %d",
                     tmpStr, status);
            return status;
        }
        rstrcpy (procStatInp->addr, rescGrpInfo->rescInfo->rescLoc, NAME_LEN);
        rodsServerHost = (rodsServerHost_t*)rescGrpInfo->rescInfo->rodsServerHost;
        if (rodsServerHost == NULL) {
            remoteFlag = SYS_INVALID_SERVER_HOST;
        } else {
            remoteFlag = rodsServerHost->localFlag;
        }
    } else {
        /* do the IES server */
        remoteFlag = getRcatHost (MASTER_RCAT, NULL, &rodsServerHost);
    }
    if (remoteFlag < 0) {
        rodsLog (LOG_ERROR,
                 "_rsProcStat: getRcatHost() failed. erro=%d", remoteFlag);
        return (remoteFlag);
    } else if (remoteFlag == REMOTE_HOST) {
        addKeyVal (&myProcStatInp.condInput, EXEC_LOCALLY_KW, "");
        status = remoteProcStat (rsComm, &myProcStatInp, procStatOut,
                                 rodsServerHost);
        rmKeyVal (&myProcStatInp.condInput, EXEC_LOCALLY_KW);
    } else {
        status = localProcStat (rsComm, procStatInp, procStatOut);
    }
    return status;
}
Пример #13
0
int
rsRuleExecSubmit (rsComm_t *rsComm, ruleExecSubmitInp_t *ruleExecSubmitInp,
char **ruleExecId)
{
    rodsServerHost_t *rodsServerHost;
    int status;

    *ruleExecId = NULL;

    if (ruleExecSubmitInp == NULL || 
      ruleExecSubmitInp->packedReiAndArgBBuf == NULL ||
      ruleExecSubmitInp->packedReiAndArgBBuf->len <= 0 ||
      ruleExecSubmitInp->packedReiAndArgBBuf->buf == NULL) {
       rodsLog(LOG_NOTICE,
        "rsRuleExecSubmit error. NULL input");
       return (SYS_INTERNAL_NULL_INPUT_ERR);
    }

#if 0
    status = getAndConnRcatHost(rsComm, MASTER_RCAT, NULL,
                                &rodsServerHost);
#else
    status = getAndConnReHost (rsComm, &rodsServerHost);
#endif
    if (status < 0) {
       return(status);
    }

    if (rodsServerHost->localFlag == LOCAL_HOST) {
#ifdef RODS_CAT
       status = _rsRuleExecSubmit (rsComm, ruleExecSubmitInp);
        if (status >= 0) {
            *ruleExecId = strdup (ruleExecSubmitInp->ruleExecId);
        }
#else
       rodsLog(LOG_NOTICE,
               "rsRuleExecSubmit error. ICAT is not configured on this host");
       return (SYS_NO_ICAT_SERVER_ERR);
#endif
    } else {
	if (getValByKey (&ruleExecSubmitInp->condInput, EXEC_LOCALLY_KW) != 
	  NULL) {
            rodsLog (LOG_ERROR,
              "rsRuleExecSubmit: reHost config error. reServer not running locally");
	    return SYS_CONFIG_FILE_ERR;
	} else {
	    addKeyVal (&ruleExecSubmitInp->condInput, EXEC_LOCALLY_KW, "");
	}
        status = rcRuleExecSubmit(rodsServerHost->conn, ruleExecSubmitInp,
	  ruleExecId);
    }
    if (status < 0) {
        rodsLog (LOG_ERROR,
          "rsRuleExecSubmit: rcRuleExecSubmit failed, status = %d", 
	  status);
    }
    return (status);
}
Пример #14
0
int
rsRsyncFileToData( rsComm_t *rsComm, dataObjInp_t *dataObjInp ) {

    char * fileChksumStr = getValByKey( &dataObjInp->condInput, RSYNC_CHKSUM_KW );

    if ( fileChksumStr == NULL ) {
        rodsLog( LOG_ERROR,
                 "rsRsyncFileToData: RSYNC_CHKSUM_KW input is missing" );
        return CHKSUM_EMPTY_IN_STRUCT_ERR;
    }

    // =-=-=-=-=-=-=-
    // determine the resource hierarchy if one is not provided
    if ( getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ) == NULL ) {
        std::string       hier;
        irods::error ret = irods::resolve_resource_hierarchy( irods::OPEN_OPERATION,
                           rsComm, dataObjInp, hier );
        if ( !ret.ok() ) {
            std::stringstream msg;
            msg << __FUNCTION__;
            msg << " :: failed in irods::resolve_resource_hierarchy for [";
            msg << dataObjInp->objPath << "]";
            irods::log( PASSMSG( msg.str(), ret ) );
            return ret.code();
        }

        // =-=-=-=-=-=-=-
        // we resolved the redirect and have a host, set the hier str for subsequent
        // api calls, etc.
        addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() );

    } // if keyword

    char *dataObjChksumStr = NULL;
    dataObjInfo_t *dataObjInfoHead = NULL;
    int status = _rsDataObjChksum( rsComm, dataObjInp, &dataObjChksumStr,
                                   &dataObjInfoHead );

    if ( status < 0 && status != CAT_NO_ACCESS_PERMISSION &&
            status != CAT_NO_ROWS_FOUND ) {
        /* XXXXX CAT_NO_ACCESS_PERMISSION mean the chksum was calculated but
         * cannot be registered. But the chksum value is OK.
         */
        rodsLog( LOG_ERROR,
                 "rsRsyncFileToData: _rsDataObjChksum of %s error. status = %d",
                 dataObjInp->objPath, status );
    }

    freeAllDataObjInfo( dataObjInfoHead );

    if ( dataObjChksumStr != NULL &&
            strcmp( dataObjChksumStr, fileChksumStr ) == 0 ) {
        free( dataObjChksumStr );
        return 0;
    }
    free( dataObjChksumStr );
    return SYS_SVR_TO_CLI_PUT_ACTION;
}
Пример #15
0
/// =-=-=-=-=-=-=-
/// @brief local function to replicate a new copy for
///        proc_results_for_rebalance
    static
    error repl_for_rebalance(
        rsComm_t*          _comm,
        const std::string& _obj_path,
        const std::string& _current_resc,
        const std::string& _src_hier,
        const std::string& _dst_hier,
        const std::string& _src_resc,
        const std::string& _dst_resc,
        int                _mode ) {
        // =-=-=-=-=-=-=-
        // generate a resource hierachy that ends at this resource for pdmo
        hierarchy_parser parser;
        parser.set_string( _src_hier );
        std::string sub_hier;
        parser.str( sub_hier, _current_resc );

        // =-=-=-=-=-=-=-
        // create a data obj input struct to call rsDataObjRepl which given
        // the _stage_sync_kw will either stage or sync the data object
        dataObjInp_t data_obj_inp;
        bzero( &data_obj_inp, sizeof( data_obj_inp ) );
        rstrcpy( data_obj_inp.objPath, _obj_path.c_str(), MAX_NAME_LEN );
        data_obj_inp.createMode = _mode;
        addKeyVal( &data_obj_inp.condInput, RESC_HIER_STR_KW,      _src_hier.c_str() );
        addKeyVal( &data_obj_inp.condInput, DEST_RESC_HIER_STR_KW, _dst_hier.c_str() );
        addKeyVal( &data_obj_inp.condInput, RESC_NAME_KW,          _src_resc.c_str() );
        addKeyVal( &data_obj_inp.condInput, DEST_RESC_NAME_KW,     _dst_resc.c_str() );
        addKeyVal( &data_obj_inp.condInput, IN_PDMO_KW,             sub_hier.c_str() );

        // =-=-=-=-=-=-=-
        // process the actual call for replication
        transferStat_t* trans_stat = NULL;
        int repl_stat = rsDataObjRepl( _comm, &data_obj_inp, &trans_stat );
        if ( repl_stat < 0 ) {
            std::stringstream msg;
            msg << "Failed to replicate the data object ["
                << _obj_path
                << "]";
            return ERROR( repl_stat, msg.str() );
        }

        return SUCCESS();

    } // repl_for_rebalance
Пример #16
0
int RodsConnection::putFile(const std::string &localPath, const std::string &objPath, const std::string &rodsResc,
                            unsigned int numThreads)
{
    dataObjInp_t putParam;
    char filePath[MAX_NAME_LEN];
    rodsLong_t size = 0;
    int status = 0;

    // get file size
    std::ifstream fileStream(localPath.c_str(), std::ifstream::binary);
    fileStream.seekg(0, fileStream.end);
    size = fileStream.tellg();
    fileStream.close();

    this->mutexLock();

    // zero rods api input params structure
    memset(&putParam, 0, sizeof(dataObjInp_t));

    // initialize rods api input params struct
    putParam.dataSize = size;
    putParam.oprType = PUT_OPR;
    putParam.numThreads = numThreads;

    // set remote object path
    rstrcpy(putParam.objPath, objPath.c_str(), MAX_NAME_LEN);

    // for now, we use the generic data type
    addKeyVal(&putParam.condInput, DATA_TYPE_KW, "generic");

    // target storage resource, if defined
    if (rodsResc.length())
        addKeyVal(&putParam.condInput, DEST_RESC_NAME_KW, rodsResc.c_str());

    // take copy of the local file path for the rods api
    strcpy(filePath, localPath.c_str());

    // call rods api
    status = rcDataObjPut(this->rodsCommPtr, &putParam, filePath);

    this->mutexUnlock();

    // return rods api status
    return (status);
}
Пример #17
0
/*
Do a query on AVUs for users and show the results
 */
int queryUser(char *attribute, char *op, char *value) {
   genQueryInp_t genQueryInp;
   genQueryOut_t *genQueryOut;
   int i1a[10];
   int i1b[10];
   int i2a[10];
   char *condVal[10];
   char v1[BIG_STR];
   char v2[BIG_STR];
   int status;
   char *columnNames[]={"user", "zone"};

   printCount=0;
   memset (&genQueryInp, 0, sizeof (genQueryInp_t));

   i1a[0]=COL_USER_NAME;
   i1b[0]=0;  /* (unused) */
   i1a[1]=COL_USER_ZONE;
   i1b[1]=0;  /* (unused) */
   genQueryInp.selectInp.inx = i1a;
   genQueryInp.selectInp.value = i1b;
   genQueryInp.selectInp.len = 2;

   i2a[0]=COL_META_USER_ATTR_NAME;
   sprintf(v1,"='%s'",attribute);
   condVal[0]=v1;

   i2a[1]=COL_META_USER_ATTR_VALUE;
   sprintf(v2, "%s '%s'", op, value);
   condVal[1]=v2;

   genQueryInp.sqlCondInp.inx = i2a;
   genQueryInp.sqlCondInp.value = condVal;
   genQueryInp.sqlCondInp.len=2;

   genQueryInp.maxRows=10;
   genQueryInp.continueInx=0;
   genQueryInp.condInput.len=0;

   if (zoneArgument[0]!='\0') {
      addKeyVal (&genQueryInp.condInput, ZONE_KW, zoneArgument);
   }

   status = rcGenQuery(Conn, &genQueryInp, &genQueryOut);

   printGenQueryResults(Conn, status, genQueryOut, columnNames);

   while (status==0 && genQueryOut->continueInx > 0) {
      genQueryInp.continueInx=genQueryOut->continueInx;
      status = rcGenQuery(Conn, &genQueryInp, &genQueryOut);
      if (genQueryOut->rowCnt>0) printf("----\n");
      printGenQueryResults(Conn, status, genQueryOut, 
					columnNames);
   }

   return (0);
}
Пример #18
0
/**
 * adapted from reHelpers2.c
 * input
 *     typ: collection type
 *     inPtr: collection value
 *     inx: index of the element
 * output
 *     value: element value (new on heap)
 *     inx: index of the next element
 *     outtyp: the type of the element (new on heap)
 * return
 *     0
 * 	   NO_VALUES_FOUND
 *     USER_PARAM_TYPE_ERR
 */
Res* getValueFromCollection( char *typ, void *inPtr, int inx, Region *r ) {
    Res *res;
    int i, j;

    if ( !strcmp( typ, StrArray_MS_T ) ) {
        strArray_t *strA;
        /* ->size size of an element */
        /* ->len  length of the array */
        strA = ( strArray_t  * ) inPtr;
        if ( inx >= strA->len ) {
            return NULL;
        }
        res = newStringRes( r, strA->value + inx * strA->size );
        return res;
    }
    else if ( !strcmp( typ, IntArray_MS_T ) ) {
        res = newRes( r );
        res->exprType = newSimpType( T_INT, r );
        intArray_t *intA;
        intA = ( intArray_t * ) inPtr;
        if ( inx >= intA->len ) {
            return NULL;
        }
        RES_INT_VAL_LVAL( res ) = intA->value[inx];
        return res;
    }
    else if ( !strcmp( typ, GenQueryOut_MS_T ) ) {
        keyValPair_t *k; /* element value */
        genQueryOut_t *g = ( genQueryOut_t * ) inPtr; /* the result set */
        char *cname, *aval; /* key and value */
        sqlResult_t *v; /* a result row */
        if ( g->rowCnt == 0 || inx >= g->rowCnt ) {
            return NULL;
        }
        k = ( keyValPair_t * )malloc( sizeof( keyValPair_t ) );
        k->len = 0;
        k->keyWord = NULL;
        k->value = NULL;
        for ( i = 0; i < g->attriCnt; i++ ) {
            v = g->sqlResult + i;
            cname = ( char * ) getAttrNameFromAttrId( v->attriInx );
            aval = v->value + v->len * inx;
            j  = addKeyVal( k, cname, aval ); /* addKeyVal duplicates the strings */
            if ( j < 0 ) {
                return NULL;
            }
        }
        res = newUninterpretedRes( r, KeyValPair_MS_T, k, NULL );
        return res;
    }
    else if ( strcmp( typ, KeyValPair_MS_T ) == 0 ) {
        return newStringRes( r, ( ( keyValPair_t * ) inPtr )->keyWord[inx] );
    }
    else {
        return NULL;
    }
}
Пример #19
0
// =-=-=-=-=-=-=-
// public - get rule engine kvp
    error network_object::get_re_vars(
        keyValPair_t& _kvp ) {

        std::stringstream ss;
        ss << socket_handle_;
        addKeyVal( &_kvp, SOCKET_HANDLE_KW, ss.str().c_str() );

        return SUCCESS();
    } // get_re_vars
Пример #20
0
int
filePathRegRepl (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp, char *filePath,
rescInfo_t *rescInfo)
{
    dataObjInfo_t destDataObjInfo, *dataObjInfoHead = NULL;
    regReplica_t regReplicaInp;
    char *rescGroupName = NULL;
    int status;

    status = getDataObjInfo (rsComm, phyPathRegInp, &dataObjInfoHead,
      ACCESS_READ_OBJECT, 0);

    if (status < 0) {
        rodsLog (LOG_ERROR,
          "filePathRegRepl: getDataObjInfo for %s", phyPathRegInp->objPath);
        return (status);
    }
    status = sortObjInfoForOpen (rsComm, &dataObjInfoHead, NULL, 0);
    if (status < 0) return status;

    destDataObjInfo = *dataObjInfoHead;
    rstrcpy (destDataObjInfo.filePath, filePath, MAX_NAME_LEN);
    destDataObjInfo.rescInfo = rescInfo;
    rstrcpy (destDataObjInfo.rescName, rescInfo->rescName, NAME_LEN);
    if ((rescGroupName = getValByKey (&phyPathRegInp->condInput,
      RESC_GROUP_NAME_KW)) != NULL) {
        rstrcpy (destDataObjInfo.rescGroupName, rescGroupName, NAME_LEN);
    }
    memset (&regReplicaInp, 0, sizeof (regReplicaInp));
    regReplicaInp.srcDataObjInfo = dataObjInfoHead;
    regReplicaInp.destDataObjInfo = &destDataObjInfo;
    if (getValByKey (&phyPathRegInp->condInput, SU_CLIENT_USER_KW) != NULL) {
        addKeyVal (&regReplicaInp.condInput, SU_CLIENT_USER_KW, "");
        addKeyVal (&regReplicaInp.condInput, IRODS_ADMIN_KW, "");
    } else if (getValByKey (&phyPathRegInp->condInput,
      IRODS_ADMIN_KW) != NULL) {
        addKeyVal (&regReplicaInp.condInput, IRODS_ADMIN_KW, "");
    }
    status = rsRegReplica (rsComm, &regReplicaInp);
    clearKeyVal (&regReplicaInp.condInput);
    freeAllDataObjInfo (dataObjInfoHead);

    return status;
}
Пример #21
0
int
doTest11( char *userName, char *rodsZone, char *accessPerm, char *collection,
          char *dataObj ) {
    genQueryInp_t genQueryInp;
    genQueryOut_t genQueryOut;
    char condStr[MAX_NAME_LEN];
    int status;
    char accStr[LONG_NAME_LEN];

    printf( "dotest11\n" );
    rodsLogSqlReq( 1 );

    memset( &genQueryInp, 0, sizeof( genQueryInp ) );

    snprintf( accStr, LONG_NAME_LEN, "%s", userName );
    addKeyVal( &genQueryInp.condInput, USER_NAME_CLIENT_KW, accStr );

    snprintf( accStr, LONG_NAME_LEN, "%s", rodsZone );
    addKeyVal( &genQueryInp.condInput, RODS_ZONE_CLIENT_KW, accStr );

    snprintf( accStr, LONG_NAME_LEN, "%s", accessPerm );
    addKeyVal( &genQueryInp.condInput, ACCESS_PERMISSION_KW, accStr );

    snprintf( condStr, MAX_NAME_LEN, "='%s'", collection );
    addInxVal( &genQueryInp.sqlCondInp, COL_COLL_NAME, condStr );

    snprintf( condStr, MAX_NAME_LEN, "='%s'", dataObj );
    addInxVal( &genQueryInp.sqlCondInp, COL_DATA_NAME, condStr );

    addInxIval( &genQueryInp.selectInp,  COL_D_DATA_ID, 1 );

    genQueryInp.maxRows = 10;

    status  = chlGenQuery( genQueryInp, &genQueryOut );
    printf( "chlGenQuery status=%d\n", status );

    printf( "genQueryOut->totalRowCount=%d\n", genQueryOut.totalRowCount );

    if ( status == 0 ) {
        printGenQOut( &genQueryOut );
    }

    return 0;
}
Пример #22
0
/* resolveDataObjReplStatus - a dirty copy may be deleted leaving no
 * dirty copy. In that case, pick the newest copy and mark it dirty
 */
int
resolveDataObjReplStatus( rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp ) {
    int status;
    dataObjInfo_t *dataObjInfoHead = NULL;
    dataObjInfo_t *newestDataObjInfo = NULL;
    dataObjInfo_t *tmpDataObjInfo;

    if ( getValByKey( &dataObjUnlinkInp->condInput, RESC_NAME_KW ) == NULL &&
            getValByKey( &dataObjUnlinkInp->condInput, REPL_NUM_KW ) == NULL ) {
        return 0;
    }
    status = getDataObjInfo( rsComm, dataObjUnlinkInp,
                             &dataObjInfoHead, ACCESS_DELETE_OBJECT, 1 );

    if ( status < 0 ) {
        return status;
    }

    tmpDataObjInfo = dataObjInfoHead;
    while ( tmpDataObjInfo != NULL ) {
        if ( tmpDataObjInfo->replStatus == 0 ) {
            if ( newestDataObjInfo == NULL ) {
                newestDataObjInfo = tmpDataObjInfo;
            }
            else if ( atoi( tmpDataObjInfo->dataModify ) >
                      atoi( newestDataObjInfo->dataModify ) ) {
                newestDataObjInfo = tmpDataObjInfo;
            }
        }
        else {
            newestDataObjInfo = NULL;
            break;
        }
        tmpDataObjInfo = tmpDataObjInfo->next;
    }

    /* modify the repl status */
    if ( newestDataObjInfo != NULL ) {
        keyValPair_t regParam;
        char tmpStr[MAX_NAME_LEN];
        modDataObjMeta_t modDataObjMetaInp;

        memset( &regParam, 0, sizeof( regParam ) );
        memset( &modDataObjMetaInp, 0, sizeof( modDataObjMetaInp ) );
        snprintf( tmpStr, MAX_NAME_LEN, "%d", NEWLY_CREATED_COPY );
        addKeyVal( &regParam, REPL_STATUS_KW, tmpStr );
        modDataObjMetaInp.dataObjInfo = newestDataObjInfo;
        modDataObjMetaInp.regParam = &regParam;

        status = rsModDataObjMeta( rsComm, &modDataObjMetaInp );

        clearKeyVal( &regParam );
    }
    freeAllDataObjInfo( dataObjInfoHead );
    return status;
}
Пример #23
0
/* phyPathRegNoChkPerm - Wrapper internal function to allow phyPathReg with 
 * no checking for path Perm.
 */
int
phyPathRegNoChkPerm (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp)
{
    int status;

    addKeyVal (&phyPathRegInp->condInput, NO_CHK_FILE_PERM_KW, "");

    status = irsPhyPathReg (rsComm, phyPathRegInp);
    return (status);
}
Пример #24
0
int testModDataObjMeta(rsComm_t *rsComm, char *name, 
		       char *dataType, char *filePath) {
   dataObjInfo_t dataObjInfo;
   int status;
   keyValPair_t regParam;
   char tmpStr[LONG_NAME_LEN], tmpStr2[LONG_NAME_LEN];
   /*   int replStatus; */

   memset(&dataObjInfo,0,sizeof(dataObjInfo_t));

   memset (&regParam, 0, sizeof (regParam));

   /*
   replStatus=1;
   snprintf (tmpStr, LONG_NAME_LEN, "%d", replStatus);
   addKeyVal (&regParam, "replStatus", tmpStr);
   */
   snprintf (tmpStr, sizeof tmpStr, "'now'");
   addKeyVal (&regParam, "dataCreate", tmpStr);

   snprintf (tmpStr2, sizeof tmpStr2, "'test comment'");
   addKeyVal (&regParam, "dataComments", tmpStr2);

   strcpy(dataObjInfo.objPath, name);
   /*   dataObjInfo.replNum=1; */
   dataObjInfo.replNum=0;

   strcpy(dataObjInfo.version, "12");
   strcpy(dataObjInfo.dataType, dataType);
   dataObjInfo.dataSize=42;

   strcpy(dataObjInfo.rescName, "resc A");

   strcpy(dataObjInfo.filePath, filePath);

   dataObjInfo.replStatus=5;

   status = chlModDataObjMeta(rsComm, &dataObjInfo, &regParam);


   return(status);
}
Пример #25
0
int
unmountFileDir (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp)
{
    int status;
    collInp_t modCollInp;
    rodsObjStat_t *rodsObjStatOut = NULL;

    status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
    if (status < 0) {
        return status;
    } else if (rodsObjStatOut->specColl == NULL) {
        freeRodsObjStat (rodsObjStatOut);
        rodsLog (LOG_ERROR,
          "unmountFileDir: %s not mounted", phyPathRegInp->objPath);
        return (SYS_COLL_NOT_MOUNTED_ERR);
    }

    if (getStructFileType (rodsObjStatOut->specColl) >= 0) {    
	/* a struct file */
        status = _rsSyncMountedColl (rsComm, rodsObjStatOut->specColl,
          PURGE_STRUCT_FILE_CACHE);
#if 0
	if (status < 0) {
	    freeRodsObjStat (rodsObjStatOut);
	    return (status);
	}
#endif
    }

    freeRodsObjStat (rodsObjStatOut);

    memset (&modCollInp, 0, sizeof (modCollInp));
    rstrcpy (modCollInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN);
    addKeyVal (&modCollInp.condInput, COLLECTION_TYPE_KW, 
      "NULL_SPECIAL_VALUE");
    addKeyVal (&modCollInp.condInput, COLLECTION_INFO1_KW, "NULL_SPECIAL_VALUE");
    addKeyVal (&modCollInp.condInput, COLLECTION_INFO2_KW, "NULL_SPECIAL_VALUE");

    status = rsModColl (rsComm, &modCollInp);

    return (status);
}
Пример #26
0
/**
 * \cond oldruleengine
 * \fn remoteExec(msParam_t *mPD, msParam_t *mPA, msParam_t *mPB, msParam_t *mPC, ruleExecInfo_t *rei)
 *
 * \brief  A set of statements to be remotely executed
 *
 * \module core
 *
 * \since pre-2.1
 *
 * \author  Arcot Rajasekar
 * \date    2008
 *
 * \note This micoservice takes a set of microservices that need to be executed at a
 *    remote iRODS server. The execution is done immediately and synchronously with
 *    the result returning back from the call.
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[in] mPD - a msParam of type STR_MS_T which is a host name of the server where the body need to be executed.
 * \param[in] mPA - a msParam of type STR_MS_T which is a delayCondition about when to execute the body.
 * \param[in] mPB - a msParam of type STR_MS_T which is a body. A statement list - micro-services and ruleNames separated by ##
 * \param[in] mPC - a msParam of type STR_MS_T which is arecoverBody. A statement list - micro-services and ruleNames separated by ##
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa  none
 * \endcond
**/
int remoteExec( msParam_t *mPD, msParam_t *mPA, msParam_t *mPB, msParam_t *mPC, ruleExecInfo_t *rei ) {
    int i;
    execMyRuleInp_t execMyRuleInp;
    msParamArray_t *tmpParamArray, *aParamArray;
    msParamArray_t *outParamArray = NULL;
    char tmpStr[LONG_NAME_LEN];
    char tmpStr1[LONG_NAME_LEN];
    /*
    char actionCall[MAX_ACTION_SIZE];
    char recoveryActionCall[MAX_ACTION_SIZE];
    char delayCondition[MAX_ACTION_SIZE];
    char hostName[MAX_ACTION_SIZE];
    rstrcpy(hostName, (char *) mPD->inOutStruct,MAX_ACTION_SIZE);
    rstrcpy(delayCondition, (char *) mPA->inOutStruct,MAX_ACTION_SIZE);
    rstrcpy(actionCall, (char *) mPB->inOutStruct,MAX_ACTION_SIZE);
    rstrcpy(recoveryActionCall, (char *) mPC->inOutStruct,MAX_ACTION_SIZE);
    i = _remoteExec(actionCall, recoveryActionCall, delayCondition, hostName, rei);
    */
    memset( &execMyRuleInp, 0, sizeof( execMyRuleInp ) );
    execMyRuleInp.condInput.len = 0;
    rstrcpy( execMyRuleInp.outParamDesc, ALL_MS_PARAM_KW, LONG_NAME_LEN );
    /*  rstrcpy (execMyRuleInp.addr.hostAddr, mPD->inOutStruct, LONG_NAME_LEN);*/
    rstrcpy( tmpStr, ( char * ) mPD->inOutStruct, LONG_NAME_LEN );
    i = evaluateExpression( tmpStr, tmpStr1, rei );
    if ( i < 0 ) {
        return( i );
    }
    parseHostAddrStr( tmpStr1, &execMyRuleInp.addr );

    if ( strlen( ( char* )mPC->inOutStruct ) != 0 ) {
        snprintf( execMyRuleInp.myRule, META_STR_LEN, "remExec||%s|%s", ( char* )mPB->inOutStruct, ( char* )mPC->inOutStruct );
    }
    else {
        snprintf( execMyRuleInp.myRule, META_STR_LEN, "remExec{%s}", ( char* )mPB->inOutStruct );
    }
    addKeyVal( &execMyRuleInp.condInput, "execCondition", ( char * ) mPA->inOutStruct );

    tmpParamArray = ( msParamArray_t * ) malloc( sizeof( msParamArray_t ) );
    memset( tmpParamArray, 0, sizeof( msParamArray_t ) );
    i = replMsParamArray( rei->msParamArray, tmpParamArray );
    if ( i < 0 ) {
        free( tmpParamArray );
        return( i );
    }
    aParamArray = rei->msParamArray;
    rei->msParamArray = tmpParamArray;
    execMyRuleInp.inpParamArray = rei->msParamArray;
    i = rsExecMyRule( rei->rsComm, &execMyRuleInp,  &outParamArray );
    carryOverMsParam( outParamArray, aParamArray );
    rei->msParamArray = aParamArray;
    clearMsParamArray( tmpParamArray, 0 );
    free( tmpParamArray );
    return( i );
}
Пример #27
0
/**
 * \fn msiAddKeyVal(msParam_t *inKeyValPair, msParam_t *key, msParam_t *value, ruleExecInfo_t *rei)
 *
 * \brief  Adds a new key and value to a keyValPair_t
 *
 * \module core
 *
 *
 * \note A new keyValPair_t is created if inKeyValPair is NULL.
 *
 * \usage See clients/icommands/test/rules/
 *
 * \param[in,out] inKeyValPair - Optional - a KeyValPair_MS_T
 * \param[in] key - Required - A STR_MS_T containing the key
 * \param[in] value - Optional - A STR_MS_T containing the value
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
**/
int msiAddKeyVal( msParam_t *inKeyValPair, msParam_t *key, msParam_t *value, ruleExecInfo_t *rei ) {
    char *key_str, *value_str;
    keyValPair_t *newKVP;

    /*************************************  INIT **********************************/

    /* For testing mode when used with irule --test */
    RE_TEST_MACRO( "    Calling msiAddKeyVal" )

    /* Sanity checks */
    if ( rei == NULL || rei->rsComm == NULL ) {
        rodsLog( LOG_ERROR, "msiAddKeyVal: input rei or rsComm is NULL." );
        return SYS_INTERNAL_NULL_INPUT_ERR;
    }


    /********************************** PARAM PARSING  *********************************/

    /* Parse key */
    if ( ( key_str = parseMspForStr( key ) ) == NULL ) {
        rodsLog( LOG_ERROR, "msiAddKeyVal: input key is NULL." );
        return USER__NULL_INPUT_ERR;
    }

    /* Parse value */
    value_str = parseMspForStr( value );

    /* Check for wrong parameter type */
    if ( inKeyValPair->type && strcmp( inKeyValPair->type, KeyValPair_MS_T ) ) {
        rodsLog( LOG_ERROR, "msiAddKeyVal: inKeyValPair is not of type KeyValPair_MS_T." );
        return USER_PARAM_TYPE_ERR;
    }

    /* Parse inKeyValPair. Create new one if empty. */
    if ( !inKeyValPair->inOutStruct ) {
        /* Set content */
        newKVP = ( keyValPair_t* )malloc( sizeof( keyValPair_t ) );
        memset( newKVP, 0, sizeof( keyValPair_t ) );
        inKeyValPair->inOutStruct = ( void* )newKVP;

        /* Set type */
        if ( !inKeyValPair->type ) {
            inKeyValPair->type = strdup( KeyValPair_MS_T );
        }
    }


    /******************************* ADD NEW PAIR AND DONE ******************************/

    rei->status = addKeyVal( ( keyValPair_t* )inKeyValPair->inOutStruct, key_str, value_str );

    /* Done */
    return rei->status;
}
Пример #28
0
int
ifusePut( rcComm_t *conn, char *objPath, char *cachePath, int mode,
          rodsLong_t srcSize ) {
    dataObjInp_t dataObjInp;
    int status;

    memset( &dataObjInp, 0, sizeof( dataObjInp ) );
    rstrcpy( dataObjInp.objPath, objPath, MAX_NAME_LEN );
    dataObjInp.dataSize = srcSize;
    dataObjInp.createMode = mode;
    dataObjInp.openFlags = O_RDWR;
    addKeyVal( &dataObjInp.condInput, FORCE_FLAG_KW, "" );
    addKeyVal( &dataObjInp.condInput, DATA_TYPE_KW, "generic" );
    if ( strlen( MyRodsEnv.rodsDefResource ) > 0 ) {
        addKeyVal( &dataObjInp.condInput, DEST_RESC_NAME_KW,
                   MyRodsEnv.rodsDefResource );
    }

    status = rcDataObjPut( conn, &dataObjInp, cachePath );
    return ( status );
}
Пример #29
0
int
initCondForPhymv (rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, 
dataObjInp_t *dataObjInp)
{
    char *myResc = NULL;

    if (dataObjInp == NULL) {
       rodsLog (LOG_ERROR,
          "initCondForPhymv: NULL dataObjInp input");
        return (USER__NULL_INPUT_ERR);
    }

    memset (dataObjInp, 0, sizeof (dataObjInp_t));

    if (rodsArgs == NULL) {
	return (0);
    }

    if (rodsArgs->admin == True) {
        addKeyVal (&dataObjInp->condInput, IRODS_ADMIN_KW, "");
    }

    if (rodsArgs->replNum == True) {
        addKeyVal (&dataObjInp->condInput, REPL_NUM_KW, 
	  rodsArgs->replNumValue);
    }

    if (rodsArgs->srcResc == True) {
        addKeyVal (&dataObjInp->condInput, RESC_NAME_KW,
          rodsArgs->srcRescString);
    }

    if (rodsArgs->resource == True) {
        if (rodsArgs->resourceString == NULL) {
            rodsLog (LOG_ERROR,
              "initCondForPhymv: NULL resourceString error");
            return (USER__NULL_INPUT_ERR);
        } else {
	    myResc = rodsArgs->resourceString;
            addKeyVal (&dataObjInp->condInput, DEST_RESC_NAME_KW,
              rodsArgs->resourceString);
        }
    } else if (myRodsEnv != NULL && strlen (myRodsEnv->rodsDefResource) > 0) {
	myResc = myRodsEnv->rodsDefResource;
        addKeyVal (&dataObjInp->condInput, DEST_RESC_NAME_KW,
          myRodsEnv->rodsDefResource);
    }
    if (rodsArgs->rescGroup == True) {
        if (rodsArgs->rescGroupString == NULL) {
            rodsLog (LOG_ERROR,
              "initCondForReg: NULL rescGroupString error");
            return (USER__NULL_INPUT_ERR);
        } else {
            addKeyVal (&dataObjInp->condInput, RESC_GROUP_NAME_KW,
              rodsArgs->rescGroupString);
        }
    }

    return (0);
}
Пример #30
0
int
checkCollAccessPerm( rsComm_t *rsComm, char *collection, char *accessPerm ) {
    char accStr[LONG_NAME_LEN];
    char condStr[MAX_NAME_LEN];
    genQueryInp_t genQueryInp;
    genQueryOut_t *genQueryOut = NULL;
    int status;

    if ( collection == NULL || accessPerm == NULL ) {
        return SYS_INTERNAL_NULL_INPUT_ERR;
    }

    memset( &genQueryInp, 0, sizeof( genQueryInp ) );

    snprintf( accStr, LONG_NAME_LEN, "%s", rsComm->clientUser.userName );
    addKeyVal( &genQueryInp.condInput, USER_NAME_CLIENT_KW, accStr );

    snprintf( accStr, LONG_NAME_LEN, "%s", rsComm->clientUser.rodsZone );
    addKeyVal( &genQueryInp.condInput, RODS_ZONE_CLIENT_KW, accStr );

    snprintf( accStr, LONG_NAME_LEN, "%s", accessPerm );
    addKeyVal( &genQueryInp.condInput, ACCESS_PERMISSION_KW, accStr );

    snprintf( condStr, MAX_NAME_LEN, "='%s'", collection );
    addInxVal( &genQueryInp.sqlCondInp, COL_COLL_NAME, condStr );

    addInxIval( &genQueryInp.selectInp, COL_COLL_ID, 1 );

    genQueryInp.maxRows = MAX_SQL_ROWS;

    status =  rsGenQuery( rsComm, &genQueryInp, &genQueryOut );

    clearGenQueryInp( &genQueryInp );
    if ( status >= 0 ) {
        freeGenQueryOut( &genQueryOut );
    }

    return status;
}