aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystem.java
blob: 495b72e45543a913242df30f4cb1f365f3ded9df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.task.util.fs;

import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.WatchService;
import java.nio.file.attribute.UserPrincipalLookupService;
import java.util.Set;

/**
 * @author valerijf
 */
public class ContainerFileSystem extends FileSystem {

    private final ContainerFileSystemProvider containerFsProvider;

    ContainerFileSystem(ContainerFileSystemProvider containerFsProvider) {
        this.containerFsProvider = containerFsProvider;
    }

    @Override
    public ContainerFileSystemProvider provider() {
        return containerFsProvider;
    }

    @Override
    public boolean isOpen() {
        return true;
    }

    @Override
    public boolean isReadOnly() {
        return false;
    }

    @Override
    public String getSeparator() {
        return "/";
    }

    @Override
    public Set<String> supportedFileAttributeViews() {
        return Set.of("basic", "posix", "unix", "owner");
    }

    @Override
    public UserPrincipalLookupService getUserPrincipalLookupService() {
        return containerFsProvider.userPrincipalLookupService();
    }

    @Override
    public ContainerPath getPath(String first, String... more) {
        return ContainerPath.fromPathInContainer(this, Path.of(first, more));
    }

    @Override
    public void close() throws IOException {
        throw new UnsupportedOperationException();
    }

    @Override
    public Iterable<Path> getRootDirectories() {
        throw new UnsupportedOperationException();
    }

    @Override
    public Iterable<FileStore> getFileStores() {
        throw new UnsupportedOperationException();
    }

    @Override
    public PathMatcher getPathMatcher(String syntaxAndPattern) {
        throw new UnsupportedOperationException();
    }

    @Override
    public WatchService newWatchService() {
        throw new UnsupportedOperationException();
    }

    public static ContainerFileSystem create(Path containerStorageRoot, int uidOffset, int gidOffset) {
        return new ContainerFileSystemProvider(containerStorageRoot, uidOffset, gidOffset).getFileSystem(null);
    }
}