use of org.dcache.chimera.FileExistsChimeraFsException in project dcache by dCache.
the class ChimeraVfs method create.
@Override
public Inode create(Inode parent, Stat.Type type, String path, Subject subject, int mode) throws IOException {
int uid = (int) UnixSubjects.getUid(subject);
int gid = (int) UnixSubjects.getPrimaryGid(subject);
try {
FsInode parentFsInode = toFsInode(parent);
FsInode fsInode = _fs.createFile(parentFsInode, path, uid, gid, mode | typeToChimera(type), typeToChimera(type));
return toInode(fsInode);
} catch (FileExistsChimeraFsException e) {
throw new ExistException("path already exists");
} catch (QuotaChimeraFsException e) {
throw new DQuotException(e.getMessage());
}
}
use of org.dcache.chimera.FileExistsChimeraFsException in project dcache by dCache.
the class ChimeraNameSpaceProvider method writeExtendedAttribute.
public void writeExtendedAttribute(Subject subject, FsPath path, String name, byte[] value, SetExtendedAttributeMode mode) throws CacheException {
try {
ExtendedInode target = pathToInode(subject, path.toString());
if (!Subjects.isExemptFromNamespaceChecks(subject)) {
FileAttributes attributes = getFileAttributesForPermissionHandler(target);
if (target.isDirectory()) {
if (_permissionHandler.canCreateFile(subject, attributes) != ACCESS_ALLOWED) {
throw new PermissionDeniedCacheException("Access denied");
}
} else {
if (_permissionHandler.canWriteFile(subject, attributes) != ACCESS_ALLOWED) {
throw new PermissionDeniedCacheException("Access denied");
}
}
}
FileSystemProvider.SetXattrMode m;
switch(mode) {
case CREATE:
m = FileSystemProvider.SetXattrMode.CREATE;
break;
case REPLACE:
m = FileSystemProvider.SetXattrMode.REPLACE;
break;
case EITHER:
m = FileSystemProvider.SetXattrMode.EITHER;
break;
default:
throw new RuntimeException();
}
_fs.setXattr(target, name, value, m);
} catch (NoXdataChimeraException e) {
throw new NoAttributeCacheException(e.getMessage(), e);
} catch (FileExistsChimeraFsException e) {
throw new AttributeExistsCacheException(e.getMessage(), e);
} catch (FileNotFoundChimeraFsException e) {
throw new FileNotFoundCacheException("No such file " + path);
} catch (ChimeraFsException e) {
throw new CacheException("Failed to list extended attributes: " + Exceptions.messageOrClassName(e), e);
}
}
use of org.dcache.chimera.FileExistsChimeraFsException in project dcache by dCache.
the class ChimeraVfs method symlink.
@Override
public Inode symlink(Inode parent, String path, String link, Subject subject, int mode) throws IOException {
int uid = (int) UnixSubjects.getUid(subject);
int gid = (int) UnixSubjects.getPrimaryGid(subject);
try {
FsInode parentFsInode = toFsInode(parent);
FsInode fsInode = _fs.createLink(parentFsInode, path, uid, gid, mode, link.getBytes(StandardCharsets.UTF_8));
return toInode(fsInode);
} catch (FileExistsChimeraFsException e) {
throw new ExistException("path already exists");
}
}
use of org.dcache.chimera.FileExistsChimeraFsException in project dcache by dCache.
the class ChimeraVfs method mkdir.
@Override
public Inode mkdir(Inode parent, String path, Subject subject, int mode) throws IOException {
int uid = (int) UnixSubjects.getUid(subject);
int gid = (int) UnixSubjects.getPrimaryGid(subject);
try {
FsInode parentFsInode = toFsInode(parent);
FsInode fsInode = parentFsInode.mkdir(path, uid, gid, mode);
return toInode(fsInode);
} catch (FileExistsChimeraFsException e) {
throw new ExistException("path already exists");
}
}
use of org.dcache.chimera.FileExistsChimeraFsException in project dcache by dCache.
the class ChimeraVfs method link.
@Override
public Inode link(Inode parent, Inode link, String path, Subject subject) throws IOException {
FsInode parentFsInode = toFsInode(parent);
FsInode linkInode = toFsInode(link);
try {
FsInode fsInode = _fs.createHLink(parentFsInode, linkInode, path);
return toInode(fsInode);
} catch (NotDirChimeraException e) {
throw new NotDirException("parent not a directory");
} catch (FileExistsChimeraFsException e) {
throw new ExistException("path already exists");
}
}
Aggregations