Beispiel #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;
}
Beispiel #2
0
int
irodsUnlink (const char *path)
{
    dataObjInp_t dataObjInp;
    int status;
    iFuseConn_t *iFuseConn = NULL;

    rodsLog (LOG_DEBUG, "irodsUnlink: %s", path);

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

    status = parseRodsPathStr ((char *) (path + 1) , &MyRodsEnv,
                               dataObjInp.objPath);
    if (status < 0) {
        rodsLogError (LOG_ERROR, status,
                      "irodsUnlink: parseRodsPathStr of %s error", path);
        /* use ENOTDIR for this type of error */
        return -ENOTDIR;
    }

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

    getAndUseIFuseConn (&iFuseConn, &MyRodsEnv);
    status = rcDataObjUnlink (iFuseConn->conn, &dataObjInp);
    if (status >= 0) {
#ifdef CACHE_FUSE_PATH
        pathNotExist ((char *) path);
#endif
        status = 0;
    } else {
        if (isReadMsgError (status)) {
            ifuseReconnect (iFuseConn);
            status = rcDataObjUnlink (iFuseConn->conn, &dataObjInp);
        }
        if (status < 0) {
            rodsLogError (LOG_ERROR, status,
                          "irodsUnlink: rcDataObjUnlink of %s error", path);
            status = -ENOENT;
        }
    }
    unuseIFuseConn (iFuseConn);

    clearKeyVal (&dataObjInp.condInput);

    return (status);
}
Beispiel #3
0
int
irodsRmdir (const char *path)
{
    collInp_t collInp;
    int status;
    iFuseConn_t *iFuseConn = NULL;

    rodsLog (LOG_DEBUG, "irodsRmdir: %s", path);

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

    status = parseRodsPathStr ((char *) (path + 1) , &MyRodsEnv,
                               collInp.collName);
    if (status < 0) {
        rodsLogError (LOG_ERROR, status,
                      "irodsRmdir: parseRodsPathStr of %s error", path);
        /* use ENOTDIR for this type of error */
        return -ENOTDIR;
    }

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

    getAndUseIFuseConn (&iFuseConn, &MyRodsEnv);
    RECONNECT_IF_NECESSARY(status, iFuseConn, rcRmColl (iFuseConn->conn, &collInp, 0));
    if (status >= 0) {
#ifdef CACHE_FUSE_PATH
        pathNotExist ((char *) path);
#endif
        status = 0;
    } else {
        rodsLogError (LOG_ERROR, status,
                      "irodsRmdir: rcRmColl of %s error", path);
        status = -ENOENT;
    }

    unuseIFuseConn (iFuseConn);

    clearKeyVal (&collInp.condInput);

    return (status);
}
Beispiel #4
0
int
_irodsGetattr (iFuseConn_t *iFuseConn, const char *path, struct stat *stbuf)
{
    int status;
    dataObjInp_t dataObjInp;
    rodsObjStat_t *rodsObjStatOut = NULL;
#ifdef CACHE_FUSE_PATH
    pathCache_t *tmpPathCache;
#endif

    rodsLog (LOG_DEBUG, "_irodsGetattr: %s", path);

#ifdef CACHE_FUSE_PATH

    /*if (lookupPathNotExist( (char *) path) == 1) {
        rodsLog (LOG_DEBUG, "irodsGetattr: a match for non existing path %s", path);
        return -ENOENT;
    }*/

    if (matchAndLockPathCache ((char *) path, &tmpPathCache) == 1) {
        rodsLog (LOG_DEBUG, "irodsGetattr: a match for path %s", path);
        if (tmpPathCache->fileCache != NULL) {
            LOCK_STRUCT(*(tmpPathCache->fileCache));
            if(tmpPathCache->fileCache->state == HAVE_NEWLY_CREATED_CACHE) {
                status = _updatePathCacheStatFromFileCache (tmpPathCache);
                UNLOCK_STRUCT(*(tmpPathCache->fileCache));
                UNLOCK_STRUCT(*tmpPathCache);
                if (status < 0) {
                    clearPathFromCache ((char *) path);
                } else {
                    *stbuf = tmpPathCache->stbuf;
                    return (0);
                }
            } else {
                UNLOCK_STRUCT(*(tmpPathCache->fileCache));
                UNLOCK_STRUCT(*tmpPathCache);
            }
        } else {
            UNLOCK_STRUCT(*tmpPathCache);
        }
    }
#endif

    memset (stbuf, 0, sizeof (struct stat));
    memset (&dataObjInp, 0, sizeof (dataObjInp));
    status = parseRodsPathStr ((char *) (path + 1) , &MyRodsEnv, dataObjInp.objPath);
    if (status < 0) {
        rodsLogError (LOG_ERROR, status,
                      "irodsGetattr: parseRodsPathStr of %s error", path);
        /* use ENOTDIR for this type of error */
        return -ENOTDIR;
    }
    status = rcObjStat (iFuseConn->conn, &dataObjInp, &rodsObjStatOut);
    if (status < 0) {
        if (isReadMsgError (status)) {
            ifuseReconnect (iFuseConn);
            status = rcObjStat (iFuseConn->conn, &dataObjInp, &rodsObjStatOut);
        }
        if (status < 0) {
            if (status != USER_FILE_DOES_NOT_EXIST) {
                rodsLogError (LOG_ERROR, status,
                              "irodsGetattr: rcObjStat of %s error", path);
            }
#ifdef CACHE_FUSE_PATH
            pathNotExist ((char *) path);
#endif
            return -ENOENT;
        }
    }

    if (rodsObjStatOut->objType == COLL_OBJ_T) {
        fillDirStat (stbuf,
                     atoi (rodsObjStatOut->createTime), atoi (rodsObjStatOut->modifyTime),
                     atoi (rodsObjStatOut->modifyTime));
    } else if (rodsObjStatOut->objType == UNKNOWN_OBJ_T) {
        pathNotExist ((char *) path);
        if (rodsObjStatOut != NULL) freeRodsObjStat (rodsObjStatOut);
        return -ENOENT;
    } else {
        fillFileStat (stbuf, rodsObjStatOut->dataMode, rodsObjStatOut->objSize,
                      atoi (rodsObjStatOut->createTime), atoi (rodsObjStatOut->modifyTime),
                      atoi (rodsObjStatOut->modifyTime));
    }

    if (rodsObjStatOut != NULL)
        freeRodsObjStat (rodsObjStatOut);

    /* don't set file cache */
    pathExist ((char *) path, NULL, stbuf, &tmpPathCache);
    return 0;
}