Beispiel #1
0
int
l3Unlink (rsComm_t *rsComm, dataObjInfo_t *dataObjInfo)
{
    int rescTypeInx;
    fileUnlinkInp_t fileUnlinkInp;
    int status;

    if (getRescClass (dataObjInfo->rescInfo) == BUNDLE_CL) return 0;

     if (dataObjInfo->rescInfo->rescStatus == INT_RESC_STATUS_DOWN) 
	return SYS_RESC_IS_DOWN;

    if (getStructFileType (dataObjInfo->specColl) >= 0) {
        subFile_t subFile;
        memset (&subFile, 0, sizeof (subFile));
        rstrcpy (subFile.subFilePath, dataObjInfo->subPath,
          MAX_NAME_LEN);
        rstrcpy (subFile.addr.hostAddr, dataObjInfo->rescInfo->rescLoc,
          NAME_LEN);
        subFile.specColl = dataObjInfo->specColl;
        status = rsSubStructFileUnlink (rsComm, &subFile);
    } else {
        rescTypeInx = dataObjInfo->rescInfo->rescTypeInx;


        switch (RescTypeDef[rescTypeInx].rescCat) {
          case FILE_CAT:
            memset (&fileUnlinkInp, 0, sizeof (fileUnlinkInp));
            fileUnlinkInp.fileType = (fileDriverType_t)RescTypeDef[rescTypeInx].driverType;
            rstrcpy (fileUnlinkInp.fileName, dataObjInfo->filePath, 
	      MAX_NAME_LEN);
            rstrcpy (fileUnlinkInp.addr.hostAddr, 
	      dataObjInfo->rescInfo->rescLoc, NAME_LEN);
            status = rsFileUnlink (rsComm, &fileUnlinkInp);
            break;

          default:
            rodsLog (LOG_NOTICE,
              "l3Unlink: rescCat type %d is not recognized",
              RescTypeDef[rescTypeInx].rescCat);
            status = SYS_INVALID_RESC_TYPE;
            break;
	}
    }
    return (status);
}
Beispiel #2
0
int
l3Unlink( rsComm_t *rsComm, dataObjInfo_t *dataObjInfo ) {
    fileUnlinkInp_t fileUnlinkInp;
    int status;

    // =-=-=-=-=-=-=-
    // JMC - legacy resource  if (getRescClass (dataObjInfo->rescInfo) == BUNDLE_CL) return 0;
    std::string resc_class;
    irods::error prop_err = irods::get_resource_property<std::string>(
                                dataObjInfo->rescName,
                                irods::RESOURCE_CLASS,
                                resc_class );
    if ( prop_err.ok() ) {
        if ( resc_class == irods::RESOURCE_CLASS_BUNDLE ) { //BUNDLE_CL ) {
            return 0;
        }
    }
    else {
        std::stringstream msg;
        msg << "failed to get property [class] for resource [";
        msg << dataObjInfo->rescName;
        msg << "]";
        irods::log( PASSMSG( msg.str(), prop_err ) );
        return -1;
    }
    // =-=-=-=-=-=-=-

    // =-=-=-=-=-=-=-
    // extract the host location from the resource hierarchy
    std::string location;
    irods::error ret = irods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
    if ( !ret.ok() ) {
        irods::log( PASSMSG( "l3Unlink - failed in get_loc_for_hier_string", ret ) );
        return -1;
    }


//    irods::error resc_err = irods::is_resc_live( dataObjInfo->rescName );
    irods::error resc_err = irods::is_hier_live( dataObjInfo->rescHier );
    if ( !resc_err.ok() ) {
        return resc_err.code();
    }


    if ( getStructFileType( dataObjInfo->specColl ) >= 0 ) {
        subFile_t subFile;
        memset( &subFile, 0, sizeof( subFile ) );
        rstrcpy( subFile.subFilePath, dataObjInfo->subPath, MAX_NAME_LEN );
        rstrcpy( subFile.addr.hostAddr, location.c_str(), NAME_LEN );
        subFile.specColl = dataObjInfo->specColl;
        status = rsSubStructFileUnlink( rsComm, &subFile );
    }
    else {
        memset( &fileUnlinkInp, 0, sizeof( fileUnlinkInp ) );
        rstrcpy( fileUnlinkInp.fileName, dataObjInfo->filePath, MAX_NAME_LEN );
        rstrcpy( fileUnlinkInp.rescHier, dataObjInfo->rescHier, MAX_NAME_LEN );
        rstrcpy( fileUnlinkInp.addr.hostAddr, location.c_str(), NAME_LEN );
        rstrcpy( fileUnlinkInp.objPath, dataObjInfo->objPath, MAX_NAME_LEN );
        rstrcpy( fileUnlinkInp.in_pdmo, dataObjInfo->in_pdmo, MAX_NAME_LEN );
        status = rsFileUnlink( rsComm, &fileUnlinkInp );
    }
    return status;
}