Example #1
0
int
computeHostAddress(rsComm_t *rsComm, char *inStr, rodsHostAddr_t *addr)
{
  int status;
  dataObjInp_t dataObjInp;
  dataObjInfo_t *dataObjInfoHead = NULL;
  char *path;
  rescGrpInfo_t *rescGrpInfo = NULL;

  if (inStr[0] == '@')
    path = inStr + 1;
  else
    path = inStr;
  if (path[0] == '/') { /* objpath */
    memset (&dataObjInp, 0, sizeof (dataObjInp));
    rstrcpy (dataObjInp.objPath, path, MAX_NAME_LEN);
    status = getDataObjInfo (rsComm, &dataObjInp, &dataObjInfoHead,
			     ACCESS_READ_OBJECT, 0);
    if (status < 0) {
      rodsLog (LOG_ERROR,
	       "computeHostAddress: getDataObjInfo error for Path %s", path); 
      return (status);
    }

    status = sortObjInfoForOpen (rsComm, &dataObjInfoHead, NULL, 0);
    if (status < 0) {
      rodsLog (LOG_ERROR,
               "computeHostAddress: sortObjInfoForOpen error for Path %s", path);
      return status;
    }
    rstrcpy (addr->zoneName, dataObjInfoHead->rescInfo->zoneName, NAME_LEN);
    rstrcpy (addr->hostAddr, dataObjInfoHead->rescInfo->rescLoc, LONG_NAME_LEN);
    freeAllDataObjInfo (dataObjInfoHead);
  }
  else { /* it is a logical resource (or group) name */
    status = getRescInfo (rsComm, path, NULL, &rescGrpInfo);
    if (status < 0) {
      rodsLog (LOG_ERROR,
               "computeHostAddress: getRescInfo error for Path %s", path);
      return (status);
    }

    status = sortResc(rsComm, &rescGrpInfo, "random");
    if (status < 0) {
      rodsLog (LOG_ERROR,
               "computeHostAddress: sortResc error for Path %s", path);
      return status;
    }
    rstrcpy (addr->zoneName, rescGrpInfo->rescInfo->zoneName, NAME_LEN);
    rstrcpy (addr->hostAddr, rescGrpInfo->rescInfo->rescLoc, LONG_NAME_LEN);
    freeAllRescGrpInfo (rescGrpInfo);
  }
    return(0);
}
Example #2
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;
}
Example #3
0
int
getRescForGetInDataObj( rsComm_t *rsComm, dataObjInp_t *dataObjInp,
                        hostSearchStat_t *hostSearchStat ) {
    int status, i;
    dataObjInfo_t *dataObjInfoHead = NULL;

    if ( dataObjInp == NULL || hostSearchStat == NULL ) {
        return USER__NULL_INPUT_ERR;
    }

    status = getDataObjInfoIncSpecColl( rsComm, dataObjInp, &dataObjInfoHead );
    if ( status < 0 ) {
        return status;
    }

    sortObjInfoForOpen( &dataObjInfoHead, &dataObjInp->condInput, 0 );
    if ( dataObjInfoHead ) {
        if ( hostSearchStat->numHost >= MAX_HOST_TO_SEARCH ||
                hostSearchStat->totalCount >= MAX_HOST_TO_SEARCH ) {
            freeAllDataObjInfo( dataObjInfoHead );
            return 0;
        }
        for ( i = 0; i < hostSearchStat->numHost; i++ ) {
            if ( dataObjInfoHead->rescInfo == hostSearchStat->rescInfo[i] ) {
                hostSearchStat->count[i]++;
                hostSearchStat->totalCount++;
                freeAllDataObjInfo( dataObjInfoHead );
                return 0;
            }
        }
        /* no match. add one */
        hostSearchStat->rescInfo[hostSearchStat->numHost] =
            dataObjInfoHead->rescInfo;
        hostSearchStat->count[hostSearchStat->numHost] = 1;
        hostSearchStat->numHost++;
        hostSearchStat->totalCount++;
    }
    freeAllDataObjInfo( dataObjInfoHead );
    return 0;
}
Example #4
0
int
specCollSubStat( rsComm_t *rsComm, specColl_t *specColl,
                 char *subPath, specCollPerm_t specCollPerm, dataObjInfo_t **dataObjInfo ) {
    int status;
    int objType;
    rodsStat_t *rodsStat = NULL;
    dataObjInfo_t *myDataObjInfo = NULL;;

    if ( dataObjInfo == NULL ) {
        return USER__NULL_INPUT_ERR;
    }
    *dataObjInfo = NULL;

    if ( specColl->collClass == MOUNTED_COLL ) {
        /* a mount point */
        myDataObjInfo = *dataObjInfo = ( dataObjInfo_t * ) malloc( sizeof( dataObjInfo_t ) );

        memset( myDataObjInfo, 0, sizeof( dataObjInfo_t ) );

        /*status = resolveResc (specColl->resource, &myDataObjInfo->rescInfo);
        if (status < 0) {
            rodsLog( LOG_ERROR,"specCollSubStat: resolveResc error for %s, status = %d",
                     specColl->resource, status);
            freeDataObjInfo (myDataObjInfo);
            *dataObjInfo = NULL;
            return status;
        }*/

        rstrcpy( myDataObjInfo->objPath, subPath, MAX_NAME_LEN );
        rstrcpy( myDataObjInfo->subPath, subPath, MAX_NAME_LEN );
        rstrcpy( myDataObjInfo->rescName, specColl->resource, NAME_LEN );
        rstrcpy( myDataObjInfo->rescHier, specColl->rescHier, MAX_NAME_LEN );
        rstrcpy( myDataObjInfo->dataType, "generic", NAME_LEN );

        status = getMountedSubPhyPath( specColl->collection,
                                       specColl->phyPath, subPath, myDataObjInfo->filePath );
        if ( status < 0 ) {
            freeDataObjInfo( myDataObjInfo );
            *dataObjInfo = NULL;
            return status;
        }
        replSpecColl( specColl, &myDataObjInfo->specColl );
    }
    else if ( specColl->collClass == LINKED_COLL ) {

        /* a link point */
        specCollCache_t *specCollCache = NULL;
        char newPath[MAX_NAME_LEN];
        specColl_t *curSpecColl;
        char *accessStr;
        dataObjInp_t myDataObjInp;
        rodsObjStat_t *rodsObjStatOut = NULL;

        *dataObjInfo = NULL;
        curSpecColl = specColl;

        status = getMountedSubPhyPath( curSpecColl->collection,
                                       curSpecColl->phyPath, subPath, newPath );
        if ( status < 0 ) {
            return status;
        }

        status = resolveLinkedPath( rsComm, newPath, &specCollCache, NULL );
        if ( status < 0 ) {
            return status;
        }
        if ( specCollCache != NULL &&
                specCollCache->specColl.collClass != LINKED_COLL ) {

            status = specCollSubStat( rsComm, &specCollCache->specColl,
                                      newPath, specCollPerm, dataObjInfo );
            return status;
        }
        bzero( &myDataObjInp, sizeof( myDataObjInp ) );
        rstrcpy( myDataObjInp.objPath, newPath, MAX_NAME_LEN );

        status = collStat( rsComm, &myDataObjInp, &rodsObjStatOut );
        if ( status >= 0 && NULL != rodsObjStatOut ) {      /* a collection */ // JMC cppcheck - nullptr
            myDataObjInfo = *dataObjInfo =
                                ( dataObjInfo_t * ) malloc( sizeof( dataObjInfo_t ) );
            memset( myDataObjInfo, 0, sizeof( dataObjInfo_t ) );
            replSpecColl( curSpecColl, &myDataObjInfo->specColl );
            rstrcpy( myDataObjInfo->objPath, newPath, MAX_NAME_LEN );
            myDataObjInfo->dataId = strtoll( rodsObjStatOut->dataId, 0, 0 );
            rstrcpy( myDataObjInfo->dataOwnerName, rodsObjStatOut->ownerName, NAME_LEN );
            rstrcpy( myDataObjInfo->dataOwnerZone, rodsObjStatOut->ownerZone, NAME_LEN );
            rstrcpy( myDataObjInfo->dataCreate,    rodsObjStatOut->createTime, TIME_LEN );
            rstrcpy( myDataObjInfo->dataModify,    rodsObjStatOut->modifyTime, TIME_LEN );
            freeRodsObjStat( rodsObjStatOut );
            return COLL_OBJ_T;
        }
        freeRodsObjStat( rodsObjStatOut );

        /* data object */
        if ( specCollPerm == READ_COLL_PERM ) {
            accessStr = ACCESS_READ_OBJECT;
        }
        else if ( specCollPerm == WRITE_COLL_PERM ) {
            accessStr = ACCESS_DELETE_OBJECT;
        }
        else {
            accessStr = NULL;
        }

        status = getDataObjInfo( rsComm, &myDataObjInp, dataObjInfo,
                                 accessStr, 0 );
        if ( status < 0 ) {
            myDataObjInfo = *dataObjInfo =
                                ( dataObjInfo_t * ) malloc( sizeof( dataObjInfo_t ) );
            memset( myDataObjInfo, 0, sizeof( dataObjInfo_t ) );
            replSpecColl( curSpecColl, &myDataObjInfo->specColl );
            rstrcpy( myDataObjInfo->objPath, newPath, MAX_NAME_LEN );
            rodsLog( LOG_DEBUG,
                     "specCollSubStat: getDataObjInfo error for %s, status = %d",
                     newPath, status );
            return status;
        }
        else {
            replSpecColl( curSpecColl, &( *dataObjInfo )->specColl );
            return DATA_OBJ_T;
        }
    }
    else if ( getStructFileType( specColl ) >= 0 ) {

        /* bundle */
        dataObjInp_t myDataObjInp;
        dataObjInfo_t *tmpDataObjInfo;

        bzero( &myDataObjInp, sizeof( myDataObjInp ) );
        rstrcpy( myDataObjInp.objPath, specColl->objPath, MAX_NAME_LEN );
        // add the resource hierarchy to the condInput of the inp
        addKeyVal( &myDataObjInp.condInput, RESC_HIER_STR_KW, specColl->rescHier );
        status = getDataObjInfo( rsComm, &myDataObjInp, dataObjInfo, NULL, 1 );
        if ( status < 0 ) {
            rodsLog( LOG_ERROR,
                     "specCollSubStat: getDataObjInfo error for %s, status = %d",
                     myDataObjInp.objPath, status );
            *dataObjInfo = NULL;
            return status;
        }

        /* screen out any stale copies */
        status = sortObjInfoForOpen( dataObjInfo, &myDataObjInp.condInput, 0 );
        if ( status < 0 ) {
            rodsLog( LOG_ERROR,
                     "specCollSubStat: sortObjInfoForOpen error for %s. status = %d",
                     myDataObjInp.objPath, status );
            return status;
        }

        if ( strlen( specColl->resource ) > 0 ) {
            if ( requeDataObjInfoByResc( dataObjInfo, specColl->resource,
                                         0, 1 ) >= 0 ) {
                if ( strcmp( specColl->resource,
                             ( *dataObjInfo )->rescName ) != 0 ) {
                    rodsLog( LOG_ERROR,
                             "specCollSubStat: %s in %s does not match cache resc %s",
                             myDataObjInp.objPath, ( *dataObjInfo )->rescName,
                             specColl->resource );
                    freeAllDataObjInfo( *dataObjInfo );
                    *dataObjInfo = NULL;
                    return SYS_CACHE_STRUCT_FILE_RESC_ERR;
                }
            }
            else {
                rodsLog( LOG_ERROR,
                         "specCollSubStat: requeDataObjInfoByResc %s, resc %s error",
                         myDataObjInp.objPath, specColl->resource );
                freeAllDataObjInfo( *dataObjInfo );
                *dataObjInfo = NULL;
                return SYS_CACHE_STRUCT_FILE_RESC_ERR;
            }
        }

        /* free all the other dataObjInfo */
        if ( ( *dataObjInfo )->next != NULL ) {
            freeAllDataObjInfo( ( *dataObjInfo )->next );
            ( *dataObjInfo )->next = NULL;
        }

        /* fill in DataObjInfo */
        tmpDataObjInfo = *dataObjInfo;
        replSpecColl( specColl, &tmpDataObjInfo->specColl );
        rstrcpy( specColl->resource, tmpDataObjInfo->rescName, NAME_LEN );
        rstrcpy( specColl->rescHier, tmpDataObjInfo->rescHier, MAX_NAME_LEN );
        rstrcpy( specColl->phyPath, tmpDataObjInfo->filePath, MAX_NAME_LEN );
        rstrcpy( tmpDataObjInfo->subPath, subPath, MAX_NAME_LEN );
        specColl->replNum = tmpDataObjInfo->replNum;

        if ( strcmp( ( *dataObjInfo )->subPath, specColl->collection ) == 0 ) {
            /* no need to go down */
            return COLL_OBJ_T;
        }
    }
    else {
        rodsLog( LOG_ERROR,
                 "specCollSubStat: Unknown specColl collClass = %d",
                 specColl->collClass );
        return SYS_UNKNOWN_SPEC_COLL_CLASS;
    }
    status = l3Stat( rsComm, *dataObjInfo, &rodsStat );

    if ( status < 0 ) {
        return status;
    }

    if ( rodsStat->st_ctim != 0 ) {
        snprintf( ( *dataObjInfo )->dataCreate, TIME_LEN, "%d", rodsStat->st_ctim );
        snprintf( ( *dataObjInfo )->dataModify, TIME_LEN, "%d", rodsStat->st_mtim );
    }

    if ( rodsStat->st_mode & S_IFDIR ) {
        objType = COLL_OBJ_T;
    }
    else {
        objType = DATA_OBJ_T;
        ( *dataObjInfo )->dataSize = rodsStat->st_size;
    }
    free( rodsStat );

    return objType;
}
Example #5
0
int
_rsDataObjOpen( rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t *dataObjInfoHead ) {
    int status = 0;
    int phyOpenFlag = DO_PHYOPEN;
    if ( getValByKey( &dataObjInp->condInput, NO_OPEN_FLAG_KW ) != NULL ) {
        phyOpenFlag = DO_NOT_PHYOPEN;
    }
    else if ( getValByKey( &dataObjInp->condInput, PHYOPEN_BY_SIZE_KW )
              != NULL ) {
        phyOpenFlag = PHYOPEN_BY_SIZE;
    }
    // =-=-=-=-=-=-=-
    // JMC - backport 4604
    char * lockType = getValByKey( &dataObjInp->condInput, LOCK_TYPE_KW );
    int lockFd = -1; // JMC - backport 4604
    if ( lockType != NULL ) {
        lockFd = irods::server_api_call(
                     DATA_OBJ_LOCK_AN,
                     rsComm,
                     dataObjInp,
                     NULL,
                     ( void** ) NULL,
                     NULL );
        if ( lockFd > 0 ) {
            /* rm it so it won't be done again causing deadlock */
            rmKeyVal( &dataObjInp->condInput, LOCK_TYPE_KW );
        }
        else {
            rodsLogError( LOG_ERROR, lockFd,
                          "_rsDataObjOpen: lock error for %s. lockType = %s",
                          dataObjInp->objPath, lockType );
            return lockFd;
        }
    }

    int writeFlag = getWriteFlag( dataObjInp->openFlags );

    // check earlier attempt at resolving resource hierarchy
    if (!getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW)) {
        int l1descInx = 0;
        if ( dataObjInp->openFlags & O_CREAT && writeFlag > 0 ) {
            l1descInx = rsDataObjCreate( rsComm, dataObjInp );
            status = l1descInx; // JMC - backport 4604
        }
        // =-=-=-=-=-=-=-
        // JMC - backport 4604
        if ( lockFd >= 0 ) {
            if ( status > 0 ) {
                L1desc[l1descInx].lockFd = lockFd;
            }
            else {
                char fd_string[NAME_LEN];
                snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd );
                addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string );
                irods::server_api_call(
                    DATA_OBJ_UNLOCK_AN,
                    rsComm,
                    dataObjInp,
                    NULL,
                    ( void** ) NULL,
                    NULL );

            }
        }
        return status;
    }
    else {
//////
        /* screen out any stale copies */
        status = sortObjInfoForOpen( &dataObjInfoHead, &dataObjInp->condInput, writeFlag );
        if ( status < 0 ) { // JMC - backport 4604
            if ( lockFd > 0 ) {
                char fd_string[NAME_LEN];
                snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd );
                addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string );
                irods::server_api_call(
                    DATA_OBJ_UNLOCK_AN,
                    rsComm,
                    dataObjInp,
                    NULL,
                    ( void** ) NULL,
                    NULL );


            }
            std::stringstream msg;
            msg << __FUNCTION__;
            msg << " - Unable to select a data obj info matching the resource hierarchy from the keywords.";
            irods::log( ERROR( status, msg.str() ) );
            return status;
        }
//////
        status = applyPreprocRuleForOpen( rsComm, dataObjInp, &dataObjInfoHead );
        if ( status < 0 ) { // JMC - backport 4604
            if ( lockFd > 0 ) {
                char fd_string[NAME_LEN];
                snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd );
                addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string );
                irods::server_api_call(
                    DATA_OBJ_UNLOCK_AN,
                    rsComm,
                    dataObjInp,
                    NULL,
                    ( void** ) NULL,
                    NULL );

            }
            return status;
        }
    }

    dataObjInfo_t * compDataObjInfo = NULL;
    if ( getStructFileType( dataObjInfoHead->specColl ) >= 0 ) {
        /* special coll. Nothing to do */
    }
    else if ( writeFlag > 0 ) {
        // JMC :: had to reformat this code to find a missing {
        //     :: i seriously hope its in the right place...
        status = procDataObjOpenForWrite( rsComm, dataObjInp, &dataObjInfoHead, &compDataObjInfo );
    }

    if ( status < 0 ) {
        if ( lockFd > 0 ) {
            char fd_string[NAME_LEN];
            snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd );
            addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string );
            irods::server_api_call(
                DATA_OBJ_UNLOCK_AN,
                rsComm,
                dataObjInp,
                NULL,
                ( void** ) NULL,
                NULL );
        }
        freeAllDataObjInfo( dataObjInfoHead );
        return status;
    }

    std::string resc_class;
    irods::error prop_err = irods::get_resource_property<std::string>(
                                dataObjInfoHead->rescId, "class", resc_class );
    if ( prop_err.ok() ) {
        if ( resc_class == "bundle" ) {
            status = stageBundledData( rsComm, &dataObjInfoHead );
            if ( status < 0 ) {
                rodsLog( LOG_ERROR,
                         "_rsDataObjOpen: stageBundledData of %s failed stat=%d",
                         dataObjInfoHead->objPath, status );
                freeAllDataObjInfo( dataObjInfoHead );
                if ( lockFd >= 0 ) {
                    char fd_string[NAME_LEN];
                    snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd );
                    addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string );
                    irods::server_api_call(
                        DATA_OBJ_UNLOCK_AN,
                        rsComm,
                        dataObjInp,
                        NULL,
                        ( void** ) NULL,
                        NULL );
                }
                return status;
            }
        }
    }

    /* If compDataObjInfo != NULL, an existing COMPOUND_CL DataObjInfo exist.
     * Need to replicate to * this DataObjInfo in rsdataObjClose.
     * For read, compDataObjInfo should be NULL. */
    dataObjInfo_t * tmpDataObjInfo = dataObjInfoHead;

    while ( tmpDataObjInfo != NULL ) {
        dataObjInfo_t * nextDataObjInfo = tmpDataObjInfo->next;
        tmpDataObjInfo->next = NULL;

        int l1descInx = status = _rsDataObjOpenWithObjInfo( rsComm, dataObjInp, phyOpenFlag, tmpDataObjInfo );

        if ( l1descInx >= 0 ) {
            if ( compDataObjInfo != NULL ) {
                L1desc[l1descInx].replDataObjInfo = compDataObjInfo;
            }

            dataObjInfo_t *otherDataObjInfo = NULL;
            queDataObjInfo( &otherDataObjInfo, nextDataObjInfo, 0, 1 ); // JMC - backport 4542
            L1desc[l1descInx].otherDataObjInfo = otherDataObjInfo; // JMC - backport 4542

            if ( writeFlag > 0 ) {
                L1desc[l1descInx].openType = OPEN_FOR_WRITE_TYPE;
            }
            else {
                L1desc[l1descInx].openType = OPEN_FOR_READ_TYPE;
            }
            if ( lockFd >= 0 ) {
                L1desc[l1descInx].lockFd = lockFd;
            }
            return l1descInx;

        } // if l1descInx >= 0

        tmpDataObjInfo = nextDataObjInfo;
    } // while

    return status;
} // BAD
Example #6
0
int
rsExecCmd (rsComm_t *rsComm, execCmd_t *execCmdInp, execCmdOut_t **execCmdOut)
{
    int status;
    dataObjInfo_t *dataObjInfoHead = NULL;
    rodsServerHost_t *rodsServerHost;
    int remoteFlag;
    rodsHostAddr_t addr;

    /* some sanity check on the cmd path */
    if (strchr (execCmdInp->cmd, '/') != NULL) {
	rodsLog (LOG_ERROR,
	  "rsExecCmd: bad cmd path %s", execCmdInp->cmd);
	return (BAD_EXEC_CMD_PATH);
    }

    memset (&addr, 0, sizeof (addr));
    if (*execCmdInp->hintPath != '\0') {
	dataObjInp_t dataObjInp;
	memset (&dataObjInp, 0, sizeof (dataObjInp));
	rstrcpy (dataObjInp.objPath, execCmdInp->hintPath, MAX_NAME_LEN);
        status = getDataObjInfo (rsComm, &dataObjInp, &dataObjInfoHead,
          ACCESS_READ_OBJECT, 0);

        if (status < 0) {
	    rodsLog (LOG_ERROR,
              "rsExecCmd: getDataObjInfo error for hintPath %s", 
	      execCmdInp->hintPath);  
            return (status);
	}
        status = sortObjInfoForOpen (rsComm, &dataObjInfoHead, 
	  &execCmdInp->condInput, 0);
	if (status < 0) return status;

	if (execCmdInp->addPathToArgv > 0) {
	    char tmpArgv[LONG_NAME_LEN];
	    rstrcpy (tmpArgv, execCmdInp->cmdArgv, HUGE_NAME_LEN);
	    snprintf (execCmdInp->cmdArgv, HUGE_NAME_LEN, "%s %s",
	      dataObjInfoHead->filePath, tmpArgv);
	}
	rstrcpy (addr.zoneName, dataObjInfoHead->rescInfo->zoneName, 
	  NAME_LEN);
	rstrcpy (addr.hostAddr, dataObjInfoHead->rescInfo->rescLoc, 
	  LONG_NAME_LEN);
	/* just in case we have to do it remote */
	*execCmdInp->hintPath = '\0';	/* no need for hint */
        rstrcpy (execCmdInp->execAddr, dataObjInfoHead->rescInfo->rescLoc,
          LONG_NAME_LEN);
	freeAllDataObjInfo (dataObjInfoHead);
        remoteFlag = resolveHost (&addr, &rodsServerHost);
    } else if (*execCmdInp->execAddr  != '\0') {
	rstrcpy (addr.hostAddr, execCmdInp->execAddr, LONG_NAME_LEN);
        remoteFlag = resolveHost (&addr, &rodsServerHost);
    } else {
	rodsServerHost = LocalServerHost;
	remoteFlag = LOCAL_HOST;
    }
    
    if (remoteFlag == LOCAL_HOST) {
	status = _rsExecCmd (rsComm, execCmdInp, execCmdOut);
    } else if (remoteFlag == REMOTE_HOST) {
	status = remoteExecCmd (rsComm, execCmdInp, execCmdOut, 
	  rodsServerHost);
    } else {
       rodsLog (LOG_NOTICE,
         "rsFileOpenByHost: resolveHost of %s error, status = %d",
          addr.hostAddr, remoteFlag);
        status = SYS_UNRECOGNIZED_REMOTE_FLAG;
    }
     
    return (status);
}