Search in sources :

Example 1 with ExistException

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());
    }
}
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 ExistException

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

Example 3 with ExistException

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

Example 4 with ExistException

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");
    }
}
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)

Example 5 with ExistException

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

Aggregations

FileExistsChimeraFsException (org.dcache.chimera.FileExistsChimeraFsException)6 FsInode (org.dcache.chimera.FsInode)6 ExistException (org.dcache.nfs.status.ExistException)6 FileNotFoundChimeraFsException (org.dcache.chimera.FileNotFoundChimeraFsException)2 NotDirChimeraException (org.dcache.chimera.NotDirChimeraException)2 NotDirException (org.dcache.nfs.status.NotDirException)2 DirNotEmptyChimeraFsException (org.dcache.chimera.DirNotEmptyChimeraFsException)1 FileSystemProvider (org.dcache.chimera.FileSystemProvider)1 NoXdataChimeraException (org.dcache.chimera.NoXdataChimeraException)1 PermissionDeniedChimeraFsException (org.dcache.chimera.PermissionDeniedChimeraFsException)1 QuotaChimeraFsException (org.dcache.chimera.QuotaChimeraFsException)1 DQuotException (org.dcache.nfs.status.DQuotException)1 NoEntException (org.dcache.nfs.status.NoEntException)1 NoXattrException (org.dcache.nfs.status.NoXattrException)1 NotEmptyException (org.dcache.nfs.status.NotEmptyException)1 PermException (org.dcache.nfs.status.PermException)1