1/*
2 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2013 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.  Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26
27package sun.nio.fs;
28
29import java.nio.file.*;
30import java.nio.file.attribute.*;
31import java.io.IOException;
32import java.util.*;
33import static sun.nio.fs.AixNativeDispatcher.*;
34
35/**
36 * AIX implementation of FileSystem
37 */
38
39class AixFileSystem extends UnixFileSystem {
40
41    AixFileSystem(UnixFileSystemProvider provider, String dir) {
42        super(provider, dir);
43    }
44
45    @Override
46    public WatchService newWatchService()
47        throws IOException
48    {
49        return new PollingWatchService();
50    }
51
52    // lazy initialization of the list of supported attribute views
53    private static class SupportedFileFileAttributeViewsHolder {
54        static final Set<String> supportedFileAttributeViews =
55            supportedFileAttributeViews();
56        private static Set<String> supportedFileAttributeViews() {
57            Set<String> result = new HashSet<String>();
58            result.addAll(UnixFileSystem.standardFileAttributeViews());
59            return Collections.unmodifiableSet(result);
60        }
61    }
62
63    @Override
64    public Set<String> supportedFileAttributeViews() {
65        return SupportedFileFileAttributeViewsHolder.supportedFileAttributeViews;
66    }
67
68    @Override
69    void copyNonPosixAttributes(int ofd, int nfd) {
70        // TODO: Implement if needed.
71    }
72
73    /**
74     * Returns object to iterate over the mount entries returned by mntctl
75     */
76    @Override
77    Iterable<UnixMountEntry> getMountEntries() {
78        UnixMountEntry[] entries = null;
79        try {
80            entries = getmntctl();
81        } catch (UnixException x) {
82            // nothing we can do
83        }
84        if (entries == null) {
85            return Collections.emptyList();
86        }
87        return Arrays.asList(entries);
88    }
89
90    @Override
91    FileStore getFileStore(UnixMountEntry entry) throws IOException {
92        return new AixFileStore(this, entry);
93    }
94}
95