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