Example #1
0
int
renameLocalPath( PathCacheTable *pctable, char *from, char *to, char *toIrodsPath ) {

    /* do not check existing path here as path cache may be out of date */
    pathCache_t *fromPathCache = matchPathCache( pctable, from );
    if ( NULL == fromPathCache ) {
        return 0;
    }
    LOCK_STRUCT( *fromPathCache );

    if ( fromPathCache->fileCache != NULL ) {
        LOCK_STRUCT( *( fromPathCache->fileCache ) );
        free( fromPathCache->fileCache->localPath );
        fromPathCache->fileCache->localPath = strdup( to );
        free( fromPathCache->fileCache->objPath );
        fromPathCache->fileCache->objPath = strdup( toIrodsPath );
        UNLOCK_STRUCT( *( fromPathCache->fileCache ) );
    }

    pathCache_t *tmpPathCache = NULL;
    LOCK( *pctable -> PathCacheLock );
    pathReplace( pctable, ( char * ) to, fromPathCache->fileCache, &fromPathCache->stbuf, &tmpPathCache );

    pathNotExist( pctable, ( char * ) from );

    UNLOCK( *pctable -> PathCacheLock );
    UNLOCK_STRUCT( *fromPathCache );
    return 0;
}
Example #2
0
/* getIFuseConnByPath - try to use the same conn as opened desc of the
 * same path */
iFuseConn_t *getAndUseConnByPath( char *localPath, int *status ) {
    iFuseConn_t *iFuseConn;
    /* make sure iFuseConn is not released after getAndLockIFuseDescByPath finishes */
    pathCache_t *tmpPathCache = matchPathCache( pctable, localPath );
    if ( tmpPathCache ) {
        LOCK_STRUCT( *tmpPathCache );
        *status = _getAndUseConnForPathCache( &iFuseConn, tmpPathCache );
        UNLOCK_STRUCT( *tmpPathCache );
    }
    else {
        /* no match. just assign one */
        pathExist( pctable, localPath, NULL, NULL, NULL ); // need to find a way to clean up
        *status = getAndUseIFuseConn( &iFuseConn );

    }

    return iFuseConn;
}