Search in sources :

Example 1 with FsInode

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);
    }
}
Also used : NoXdataChimeraException(org.dcache.chimera.NoXdataChimeraException) FsInode(org.dcache.chimera.FsInode) NoXattrException(org.dcache.nfs.status.NoXattrException)

Example 2 with FsInode

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());
    }
}
Also used : DQuotException(org.dcache.nfs.status.DQuotException) FsInode(org.dcache.chimera.FsInode) QuotaChimeraFsException(org.dcache.chimera.QuotaChimeraFsException) ExistException(org.dcache.nfs.status.ExistException) FileExistsChimeraFsException(org.dcache.chimera.FileExistsChimeraFsException)

Example 3 with FsInode

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.");
    }
}
Also used : FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) FsInode(org.dcache.chimera.FsInode) NoEntException(org.dcache.nfs.status.NoEntException)

Example 4 with FsInode

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);
    }
}
Also used : NoXdataChimeraException(org.dcache.chimera.NoXdataChimeraException) FsInode(org.dcache.chimera.FsInode) PermException(org.dcache.nfs.status.PermException) NoXattrException(org.dcache.nfs.status.NoXattrException)

Example 5 with FsInode

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);
    }
}
Also used : AceType(org.dcache.acl.enums.AceType) org.dcache.nfs.v4.xdr.acetype4(org.dcache.nfs.v4.xdr.acetype4) Arrays(java.util.Arrays) FsInode(org.dcache.chimera.FsInode) NoEntException(org.dcache.nfs.status.NoEntException) IsDirException(org.dcache.nfs.status.IsDirException) LoggerFactory(org.slf4j.LoggerFactory) FileState(org.dcache.chimera.FileState) org.dcache.nfs.v4.xdr.acemask4(org.dcache.nfs.v4.xdr.acemask4) ByteBuffer(java.nio.ByteBuffer) InvalidArgumentChimeraException(org.dcache.chimera.InvalidArgumentChimeraException) UnixPermission(org.dcache.chimera.UnixPermission) FsInode_PCUR(org.dcache.chimera.FsInode_PCUR) FsInode_PLOC(org.dcache.chimera.FsInode_PLOC) BadHandleException(org.dcache.nfs.status.BadHandleException) FsInode_CKSTYP(org.dcache.chimera.FsInode_CKSTYP) DirectoryStreamHelper(org.dcache.chimera.DirectoryStreamHelper) Stat(org.dcache.nfs.vfs.Stat) NotDirException(org.dcache.nfs.status.NotDirException) StorageGenericLocation(org.dcache.chimera.StorageGenericLocation) InvalException(org.dcache.nfs.status.InvalException) FsInode_PATHOF(org.dcache.chimera.FsInode_PATHOF) ACE4_INHERIT_ONLY_ACE(org.dcache.nfs.v4.xdr.nfs4_prot.ACE4_INHERIT_ONLY_ACE) FsStat(org.dcache.nfs.vfs.FsStat) NotDirChimeraException(org.dcache.chimera.NotDirChimeraException) PermissionDeniedChimeraFsException(org.dcache.chimera.PermissionDeniedChimeraFsException) FsInode_PCRC(org.dcache.chimera.FsInode_PCRC) NoXdataChimeraException(org.dcache.chimera.NoXdataChimeraException) FileSystemProvider(org.dcache.chimera.FileSystemProvider) NfsIdMapping(org.dcache.nfs.v4.NfsIdMapping) NotEmptyException(org.dcache.nfs.status.NotEmptyException) Collectors(java.util.stream.Collectors) org.dcache.nfs.v4.xdr.nfsace4(org.dcache.nfs.v4.xdr.nfsace4) StandardCharsets(java.nio.charset.StandardCharsets) FsInode_CONST(org.dcache.chimera.FsInode_CONST) org.dcache.nfs.v4.xdr.aceflag4(org.dcache.nfs.v4.xdr.aceflag4) NoXattrException(org.dcache.nfs.status.NoXattrException) JdbcFs(org.dcache.chimera.JdbcFs) List(java.util.List) Stream(java.util.stream.Stream) org.dcache.nfs.v4.xdr.verifier4(org.dcache.nfs.v4.xdr.verifier4) FsInode_PSET(org.dcache.chimera.FsInode_PSET) Optional(java.util.Optional) ChimeraFsException(org.dcache.chimera.ChimeraFsException) DirNotEmptyChimeraFsException(org.dcache.chimera.DirNotEmptyChimeraFsException) FsInode_TAG(org.dcache.chimera.FsInode_TAG) AccessController(java.security.AccessController) ChimeraDirectoryEntry(org.dcache.chimera.ChimeraDirectoryEntry) DQuotException(org.dcache.nfs.status.DQuotException) StaleException(org.dcache.nfs.status.StaleException) AceFlags(org.dcache.acl.enums.AceFlags) FsInode_PINS(org.dcache.chimera.FsInode_PINS) ACCESS4_EXTEND(org.dcache.nfs.v4.xdr.nfs4_prot.ACCESS4_EXTEND) ACCESS4_MODIFY(org.dcache.nfs.v4.xdr.nfs4_prot.ACCESS4_MODIFY) DirectoryEntry(org.dcache.nfs.vfs.DirectoryEntry) QuotaChimeraFsException(org.dcache.chimera.QuotaChimeraFsException) FsInodeType(org.dcache.chimera.FsInodeType) TreeSet(java.util.TreeSet) IsDirChimeraException(org.dcache.chimera.IsDirChimeraException) NfsIoException(org.dcache.nfs.status.NfsIoException) ArrayList(java.util.ArrayList) FileExistsChimeraFsException(org.dcache.chimera.FileExistsChimeraFsException) BadOwnerException(org.dcache.nfs.status.BadOwnerException) ExistException(org.dcache.nfs.status.ExistException) StringTokenizer(java.util.StringTokenizer) Acls(org.dcache.nfs.v4.acl.Acls) DirectoryStream(org.dcache.nfs.vfs.DirectoryStream) FsInode_NAMEOF(org.dcache.chimera.FsInode_NAMEOF) org.dcache.nfs.v4.xdr.utf8str_mixed(org.dcache.nfs.v4.xdr.utf8str_mixed) FsInode_ID(org.dcache.chimera.FsInode_ID) STAT(org.dcache.chimera.FileSystemProvider.StatCacheOption.STAT) PermException(org.dcache.nfs.status.PermException) Inode(org.dcache.nfs.vfs.Inode) AclCheckable(org.dcache.nfs.vfs.AclCheckable) Who(org.dcache.acl.enums.Who) org.dcache.nfs.v4.xdr.uint32_t(org.dcache.nfs.v4.xdr.uint32_t) Logger(org.slf4j.Logger) UTF_8(java.nio.charset.StandardCharsets.UTF_8) UnixSubjects(org.dcache.nfs.util.UnixSubjects) FsInode_PARENT(org.dcache.chimera.FsInode_PARENT) IOException(java.io.IOException) ACE(org.dcache.acl.ACE) Subject(javax.security.auth.Subject) NO_STAT(org.dcache.chimera.FileSystemProvider.StatCacheOption.NO_STAT) FsInode_SURI(org.dcache.chimera.FsInode_SURI) FsInode_TAGS(org.dcache.chimera.FsInode_TAGS) FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) VisibleForTesting(com.google.common.annotations.VisibleForTesting) VirtualFileSystem(org.dcache.nfs.vfs.VirtualFileSystem) FsInode(org.dcache.chimera.FsInode) DirectoryStream(org.dcache.nfs.vfs.DirectoryStream) ChimeraDirectoryEntry(org.dcache.chimera.ChimeraDirectoryEntry) DirectoryEntry(org.dcache.nfs.vfs.DirectoryEntry) ChimeraDirectoryEntry(org.dcache.chimera.ChimeraDirectoryEntry)

Aggregations

FsInode (org.dcache.chimera.FsInode)36 Test (org.junit.Test)13 PnfsId (diskCacheV111.util.PnfsId)9 FileExistsChimeraFsException (org.dcache.chimera.FileExistsChimeraFsException)9 FileNotFoundChimeraFsException (org.dcache.chimera.FileNotFoundChimeraFsException)9 ExistException (org.dcache.nfs.status.ExistException)7 StorageInfo (diskCacheV111.vehicles.StorageInfo)6 Stat (org.dcache.chimera.posix.Stat)6 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)6 NoXdataChimeraException (org.dcache.chimera.NoXdataChimeraException)5 PermException (org.dcache.nfs.status.PermException)5 StaleException (org.dcache.nfs.status.StaleException)5 ACE (org.dcache.acl.ACE)4 NotDirChimeraException (org.dcache.chimera.NotDirChimeraException)4 PermissionDeniedChimeraFsException (org.dcache.chimera.PermissionDeniedChimeraFsException)4 CacheException (diskCacheV111.util.CacheException)3 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)3 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3