Search in sources :

Example 1 with FileNotFoundChimeraFsException

use of org.dcache.chimera.FileNotFoundChimeraFsException in project dcache by dCache.

the class ChimeraVfs method lookup.

@Override
public Inode lookup(Inode parent, String path) throws IOException {
    try {
        FsInode parentFsInode = toFsInode(parent);
        FsInode fsInode = parentFsInode.inodeOf(path, NO_STAT);
        return toInode(fsInode);
    } catch (FileNotFoundChimeraFsException e) {
        throw new NoEntException("Path Do not exist.");
    }
}
Also used : FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) FsInode(org.dcache.chimera.FsInode) NoEntException(org.dcache.nfs.status.NoEntException)

Example 2 with FileNotFoundChimeraFsException

use of org.dcache.chimera.FileNotFoundChimeraFsException in project dcache by dCache.

the class ChimeraVfs method setattr.

@Override
public void setattr(Inode inode, Stat stat) throws IOException {
    FsInode fsInode = toFsInode(inode);
    try {
        if (shouldRejectAttributeUpdates(fsInode, _fs)) {
            throw new PermException("setStat not allowed.");
        }
        // OperationSETATTR have already checked for a valid open stateid
        if (stat.isDefined(Stat.StatAttribute.SIZE)) {
            var chimeraStat = fsInode.stat();
            int type = chimeraStat.getMode() & UnixPermission.F_TYPE;
            switch(type) {
                case UnixPermission.S_IFREG:
                    // ok
                    break;
                case UnixPermission.S_IFDIR:
                    throw new IsDirException("Can't update size of a directory");
                default:
                    throw new InvalException("Can't update size of a non file object");
            }
            // allow set size only for newly created files
            if (fsInode.type() == FsInodeType.INODE && chimeraStat.getState() != FileState.CREATED) {
                throw new PermException("Can't change size of existing file");
            }
        }
        org.dcache.chimera.posix.Stat chimeraStat = toChimeraStat(stat);
        // convert empty setattr to noop
        if (!chimeraStat.getDefinedAttributeses().isEmpty()) {
            fsInode.setStat(chimeraStat);
        }
    } catch (InvalidArgumentChimeraException e) {
        throw new InvalException(e.getMessage());
    } catch (IsDirChimeraException e) {
        throw new IsDirException(e.getMessage());
    } catch (FileNotFoundChimeraFsException e) {
        throw new StaleException(e.getMessage());
    } catch (PermissionDeniedChimeraFsException e) {
        throw new PermException(e.getMessage());
    }
}
Also used : IsDirException(org.dcache.nfs.status.IsDirException) InvalException(org.dcache.nfs.status.InvalException) IsDirChimeraException(org.dcache.chimera.IsDirChimeraException) InvalidArgumentChimeraException(org.dcache.chimera.InvalidArgumentChimeraException) FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) PermissionDeniedChimeraFsException(org.dcache.chimera.PermissionDeniedChimeraFsException) FsInode(org.dcache.chimera.FsInode) PermException(org.dcache.nfs.status.PermException) StaleException(org.dcache.nfs.status.StaleException)

Example 3 with FileNotFoundChimeraFsException

use of org.dcache.chimera.FileNotFoundChimeraFsException in project dcache by dCache.

the class ChimeraNameSpaceProvider method deleteEntry.

@Override
public FileAttributes deleteEntry(Subject subject, Set<FileType> allowed, String path, Set<FileAttribute> attr) throws CacheException {
    try {
        File filePath = new File(path);
        String parentPath = filePath.getParent();
        if (parentPath == null) {
            throw new CacheException("Cannot delete file system root.");
        }
        ExtendedInode parent = pathToInode(subject, parentPath);
        String name = filePath.getName();
        ExtendedInode inode = parent.inodeOf(name, STAT);
        checkAllowed(allowed, inode);
        if (!Subjects.isExemptFromNamespaceChecks(subject) && !canDelete(subject, parent, inode)) {
            throw new PermissionDeniedCacheException("Access denied: " + path);
        }
        _fs.remove(parent, name, inode);
        return getFileAttributes(inode, attr);
    } catch (FileNotFoundChimeraFsException fnf) {
        throw new FileNotFoundCacheException("No such file or directory: " + path);
    } catch (DirNotEmptyChimeraFsException e) {
        throw new CacheException("Directory is not empty: " + path);
    } catch (IOException e) {
        throw new CacheException(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e.getMessage());
    }
}
Also used : FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) LockedCacheException(diskCacheV111.util.LockedCacheException) AttributeExistsCacheException(diskCacheV111.util.AttributeExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFileCacheException(diskCacheV111.util.NotFileCacheException) CacheException(diskCacheV111.util.CacheException) NoAttributeCacheException(diskCacheV111.util.NoAttributeCacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) DirNotEmptyChimeraFsException(org.dcache.chimera.DirNotEmptyChimeraFsException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) File(java.io.File)

Example 4 with FileNotFoundChimeraFsException

use of org.dcache.chimera.FileNotFoundChimeraFsException in project dcache by dCache.

the class ChimeraNameSpaceProvider method removeFileAttribute.

@Override
public void removeFileAttribute(Subject subject, PnfsId pnfsId, String attribute) throws CacheException {
    try {
        ExtendedInode inode = new ExtendedInode(_fs, pnfsId, NO_STAT).getLevel(2);
        ChimeraCacheInfo info = new ChimeraCacheInfo(inode);
        ChimeraCacheInfo.CacheFlags flags = info.getFlags();
        flags.remove(attribute);
        info.writeCacheInfo(inode);
    } catch (FileNotFoundChimeraFsException e) {
        throw new FileNotFoundCacheException("No such file or directory " + pnfsId);
    } catch (IOException e) {
        throw new CacheException(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e.getMessage());
    }
}
Also used : FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) LockedCacheException(diskCacheV111.util.LockedCacheException) AttributeExistsCacheException(diskCacheV111.util.AttributeExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFileCacheException(diskCacheV111.util.NotFileCacheException) CacheException(diskCacheV111.util.CacheException) NoAttributeCacheException(diskCacheV111.util.NoAttributeCacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException)

Example 5 with FileNotFoundChimeraFsException

use of org.dcache.chimera.FileNotFoundChimeraFsException in project dcache by dCache.

the class ChimeraNameSpaceProvider method clearCacheLocation.

@Override
public void clearCacheLocation(Subject subject, PnfsId pnfsId, String cacheLocation, boolean removeIfLast) throws CacheException {
    LOGGER.debug("clearCacheLocation : {} for {}", cacheLocation, pnfsId);
    try {
        ExtendedInode inode = new ExtendedInode(_fs, pnfsId, NO_STAT);
        _fs.clearInodeLocation(inode, StorageGenericLocation.DISK, cacheLocation);
        if (removeIfLast) {
            List<StorageLocatable> locations = _fs.getInodeLocations(inode, StorageGenericLocation.DISK);
            if (locations.isEmpty()) {
                LOGGER.debug("last location cleaned. removing file {}", inode);
                _fs.remove(inode);
            }
        }
    } catch (FileNotFoundChimeraFsException e) {
        throw new FileNotFoundCacheException("No such file or directory: " + pnfsId, e);
    } catch (ChimeraFsException e) {
        LOGGER.error("Exception in clearCacheLocation for {} : {}", pnfsId, e);
        throw new CacheException(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e.getMessage());
    }
}
Also used : FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) ChimeraFsException(org.dcache.chimera.ChimeraFsException) DirNotEmptyChimeraFsException(org.dcache.chimera.DirNotEmptyChimeraFsException) FileExistsChimeraFsException(org.dcache.chimera.FileExistsChimeraFsException) FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) LockedCacheException(diskCacheV111.util.LockedCacheException) AttributeExistsCacheException(diskCacheV111.util.AttributeExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFileCacheException(diskCacheV111.util.NotFileCacheException) CacheException(diskCacheV111.util.CacheException) NoAttributeCacheException(diskCacheV111.util.NoAttributeCacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) StorageLocatable(org.dcache.chimera.StorageLocatable) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException)

Aggregations

FileNotFoundChimeraFsException (org.dcache.chimera.FileNotFoundChimeraFsException)30 CacheException (diskCacheV111.util.CacheException)24 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)24 AttributeExistsCacheException (diskCacheV111.util.AttributeExistsCacheException)21 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)21 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)21 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)21 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)21 LockedCacheException (diskCacheV111.util.LockedCacheException)21 NoAttributeCacheException (diskCacheV111.util.NoAttributeCacheException)21 NotDirCacheException (diskCacheV111.util.NotDirCacheException)21 NotFileCacheException (diskCacheV111.util.NotFileCacheException)21 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)21 FileExistsChimeraFsException (org.dcache.chimera.FileExistsChimeraFsException)16 DirNotEmptyChimeraFsException (org.dcache.chimera.DirNotEmptyChimeraFsException)14 FileAttributes (org.dcache.vehicles.FileAttributes)14 IOException (java.io.IOException)13 UncheckedIOException (java.io.UncheckedIOException)13 ChimeraFsException (org.dcache.chimera.ChimeraFsException)13 FsInode (org.dcache.chimera.FsInode)9