Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/nio/fs/BsdFileSystem.java
32288 views
/*1* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.nio.fs;2627import java.nio.file.*;28import java.io.IOException;29import java.util.*;30import java.security.AccessController;31import sun.security.action.GetPropertyAction;3233/**34* Bsd implementation of FileSystem35*/3637class BsdFileSystem extends UnixFileSystem {3839BsdFileSystem(UnixFileSystemProvider provider, String dir) {40super(provider, dir);41}4243@Override44public WatchService newWatchService()45throws IOException46{47// use polling implementation until we implement a BSD/kqueue one48return new PollingWatchService();49}5051// lazy initialization of the list of supported attribute views52private static class SupportedFileFileAttributeViewsHolder {53static final Set<String> supportedFileAttributeViews =54supportedFileAttributeViews();55private static Set<String> supportedFileAttributeViews() {56Set<String> result = new HashSet<String>();57result.addAll(standardFileAttributeViews());58return Collections.unmodifiableSet(result);59}60}6162@Override63public Set<String> supportedFileAttributeViews() {64return SupportedFileFileAttributeViewsHolder.supportedFileAttributeViews;65}6667@Override68void copyNonPosixAttributes(int ofd, int nfd) {69}7071/**72* Returns object to iterate over mount entries73*/74@Override75Iterable<UnixMountEntry> getMountEntries() {76ArrayList<UnixMountEntry> entries = new ArrayList<UnixMountEntry>();77try {78long iter = BsdNativeDispatcher.getfsstat();79try {80for (;;) {81UnixMountEntry entry = new UnixMountEntry();82int res = BsdNativeDispatcher.fsstatEntry(iter, entry);83if (res < 0)84break;85entries.add(entry);86}87} finally {88BsdNativeDispatcher.endfsstat(iter);89}9091} catch (UnixException x) {92// nothing we can do93}94return entries;95}96979899@Override100FileStore getFileStore(UnixMountEntry entry) throws IOException {101return new BsdFileStore(this, entry);102}103}104105106