use of org.dcache.chimera.FsInode in project dcache by dCache.
the class ChimeraVfs method getXattr.
@Override
public byte[] getXattr(Inode inode, String attr) throws IOException {
FsInode fsInode = toFsInode(inode);
try {
if (attr.startsWith(XATTR_TAG_PREFIX) && fsInode.isDirectory()) {
String tagName = attr.substring(XATTR_TAG_PREFIX.length());
byte[] buf = new byte[1024];
int n = _fs.getTag(fsInode, tagName, buf, 0, buf.length);
if (n == 0) {
throw new NoXattrException("tag doesn't exist or empty");
}
return Arrays.copyOf(buf, n);
}
// try dcache dot files first
var dcache_attr = SpecialXattrs.byName(attr);
if (dcache_attr.isPresent()) {
return dcache_attr.get().read(fsInode);
}
// just a regular extended attribute
return _fs.getXattr(fsInode, attr);
} catch (NoXdataChimeraException e) {
throw new NoXattrException(e.getMessage(), e);
}
}
use of org.dcache.chimera.FsInode 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.FsInode 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.FsInode in project dcache by dCache.
the class ChimeraVfs method removeXattr.
@Override
public void removeXattr(Inode inode, String attr) throws IOException {
FsInode fsInode = toFsInode(inode);
// try dcache dot files first
var dcache_attr = SpecialXattrs.byName(attr);
if (dcache_attr.isPresent()) {
throw new PermException("Can't remove dCache attribute");
}
try {
if (attr.startsWith(XATTR_TAG_PREFIX) && fsInode.isDirectory()) {
String tagName = attr.substring(XATTR_TAG_PREFIX.length());
_fs.removeTag(fsInode, tagName);
} else {
_fs.removeXattr(fsInode, attr);
}
} catch (NoXdataChimeraException e) {
throw new NoXattrException(e.getMessage(), e);
}
}
use of org.dcache.chimera.FsInode in project dcache by dCache.
the class ChimeraVfs method list.
@Override
public DirectoryStream list(Inode inode, byte[] verifier, long cookie) throws IOException {
FsInode parentFsInode = toFsInode(inode);
// ignore whatever is sent by client
byte[] currentVerifier = directoryVerifier(inode);
try (Stream<ChimeraDirectoryEntry> dirStream = DirectoryStreamHelper.streamOf(parentFsInode)) {
TreeSet<DirectoryEntry> list = dirStream.map(e -> new DirectoryEntry(e.getName(), toInode(e.getInode()), fromChimeraStat(e.getStat()), directoryCookieOf(e.getStat(), e.getName()))).collect(Collectors.toCollection(TreeSet::new));
return new DirectoryStream(currentVerifier, list);
}
}
Aggregations