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());
}
}
Aggregations