Search in sources :

Example 1 with FileExistsChimeraFsException

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());
    }
}
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 2 with FileExistsChimeraFsException

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);
    }
}
Also used : NoXdataChimeraException(org.dcache.chimera.NoXdataChimeraException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) LockedCacheException(diskCacheV111.util.LockedCacheException) AttributeExistsCacheException(diskCacheV111.util.AttributeExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFileCacheException(diskCacheV111.util.NotFileCacheException) CacheException(diskCacheV111.util.CacheException) NoAttributeCacheException(diskCacheV111.util.NoAttributeCacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) SetXattrMode(org.dcache.chimera.FileSystemProvider.SetXattrMode) NoAttributeCacheException(diskCacheV111.util.NoAttributeCacheException) FileExistsChimeraFsException(org.dcache.chimera.FileExistsChimeraFsException) FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) ChimeraFsException(org.dcache.chimera.ChimeraFsException) DirNotEmptyChimeraFsException(org.dcache.chimera.DirNotEmptyChimeraFsException) FileExistsChimeraFsException(org.dcache.chimera.FileExistsChimeraFsException) FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) FileSystemProvider(org.dcache.chimera.FileSystemProvider) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileAttributes(org.dcache.vehicles.FileAttributes) AttributeExistsCacheException(diskCacheV111.util.AttributeExistsCacheException)

Example 3 with FileExistsChimeraFsException

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

Example 4 with FileExistsChimeraFsException

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

Example 5 with FileExistsChimeraFsException

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

Aggregations

FileExistsChimeraFsException (org.dcache.chimera.FileExistsChimeraFsException)11 FileNotFoundChimeraFsException (org.dcache.chimera.FileNotFoundChimeraFsException)7 FsInode (org.dcache.chimera.FsInode)7 ExistException (org.dcache.nfs.status.ExistException)6 AttributeExistsCacheException (diskCacheV111.util.AttributeExistsCacheException)5 CacheException (diskCacheV111.util.CacheException)5 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)5 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)5 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)5 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)5 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)5 LockedCacheException (diskCacheV111.util.LockedCacheException)5 NoAttributeCacheException (diskCacheV111.util.NoAttributeCacheException)5 NotDirCacheException (diskCacheV111.util.NotDirCacheException)5 NotFileCacheException (diskCacheV111.util.NotFileCacheException)5 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)5 NotDirChimeraException (org.dcache.chimera.NotDirChimeraException)5 File (java.io.File)4 IOException (java.io.IOException)4 UncheckedIOException (java.io.UncheckedIOException)4