Search in sources :

Example 1 with IsDirChimeraException

use of org.dcache.chimera.IsDirChimeraException 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)

Aggregations

FileNotFoundChimeraFsException (org.dcache.chimera.FileNotFoundChimeraFsException)1 FsInode (org.dcache.chimera.FsInode)1 InvalidArgumentChimeraException (org.dcache.chimera.InvalidArgumentChimeraException)1 IsDirChimeraException (org.dcache.chimera.IsDirChimeraException)1 PermissionDeniedChimeraFsException (org.dcache.chimera.PermissionDeniedChimeraFsException)1 InvalException (org.dcache.nfs.status.InvalException)1 IsDirException (org.dcache.nfs.status.IsDirException)1 PermException (org.dcache.nfs.status.PermException)1 StaleException (org.dcache.nfs.status.StaleException)1