use of org.dcache.nfs.status.ExistException 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.nfs.status.ExistException 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.nfs.status.ExistException 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.nfs.status.ExistException 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");
}
}
use of org.dcache.nfs.status.ExistException in project dcache by dCache.
the class ChimeraVfs method setXattr.
@Override
public void setXattr(Inode inode, String attr, byte[] value, SetXattrMode mode) throws IOException {
FsInode fsInode = toFsInode(inode);
// try dcache dot files first
var dcache_attr = SpecialXattrs.byName(attr);
if (dcache_attr.isPresent()) {
dcache_attr.get().set(fsInode, value);
return;
}
try {
if (attr.startsWith(XATTR_TAG_PREFIX) && fsInode.isDirectory()) {
String tagName = attr.substring(XATTR_TAG_PREFIX.length());
if (mode == SetXattrMode.CREATE) {
_fs.createTag(fsInode, tagName);
}
if (mode == SetXattrMode.EITHER) {
try {
_fs.statTag(fsInode, tagName);
} catch (FileNotFoundChimeraFsException e) {
_fs.createTag(fsInode, tagName);
}
}
_fs.setTag(fsInode, tagName, value, 0, value.length);
} else {
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(fsInode, attr, value, m);
}
} catch (NoXdataChimeraException e) {
throw new NoXattrException(e.getMessage(), e);
} catch (FileExistsChimeraFsException e) {
throw new ExistException(e.getMessage(), e);
}
}
Aggregations