4632N/A/*
4632N/A * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
4632N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4632N/A *
4632N/A * This code is free software; you can redistribute it and/or modify it
4632N/A * under the terms of the GNU General Public License version 2 only, as
4632N/A * published by the Free Software Foundation. Oracle designates this
4632N/A * particular file as subject to the "Classpath" exception as provided
4632N/A * by Oracle in the LICENSE file that accompanied this code.
4632N/A *
4632N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4632N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4632N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4632N/A * version 2 for more details (a copy is included in the LICENSE file that
4632N/A * accompanied this code).
4632N/A *
4632N/A * You should have received a copy of the GNU General Public License version
4632N/A * 2 along with this work; if not, write to the Free Software Foundation,
4632N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4632N/A *
4632N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4632N/A * or visit www.oracle.com if you need additional information or have any
4632N/A * questions.
4632N/A */
4632N/A
4632N/Apackage sun.nio.fs;
4632N/A
4632N/Aimport java.nio.file.*;
4632N/Aimport java.io.IOException;
4632N/Aimport java.util.*;
4632N/Aimport java.security.AccessController;
4632N/Aimport sun.security.action.GetPropertyAction;
4632N/A
4632N/A/**
4632N/A * Bsd implementation of FileSystem
4632N/A */
4632N/A
4632N/Aclass BsdFileSystem extends UnixFileSystem {
4632N/A
4632N/A BsdFileSystem(UnixFileSystemProvider provider, String dir) {
4632N/A super(provider, dir);
4632N/A }
4632N/A
4632N/A @Override
4632N/A public WatchService newWatchService()
4632N/A throws IOException
4632N/A {
4632N/A // use polling implementation until we implement a BSD/kqueue one
4632N/A return new PollingWatchService();
4632N/A }
4632N/A
4632N/A // lazy initialization of the list of supported attribute views
4632N/A private static class SupportedFileFileAttributeViewsHolder {
4632N/A static final Set<String> supportedFileAttributeViews =
4632N/A supportedFileAttributeViews();
4632N/A private static Set<String> supportedFileAttributeViews() {
4632N/A Set<String> result = new HashSet<String>();
4632N/A result.addAll(standardFileAttributeViews());
4632N/A return Collections.unmodifiableSet(result);
4632N/A }
4632N/A }
4632N/A
4632N/A @Override
4632N/A public Set<String> supportedFileAttributeViews() {
4632N/A return SupportedFileFileAttributeViewsHolder.supportedFileAttributeViews;
4632N/A }
4632N/A
4632N/A @Override
4632N/A void copyNonPosixAttributes(int ofd, int nfd) {
4632N/A }
4632N/A
4632N/A /**
4632N/A * Returns object to iterate over mount entries
4632N/A */
4632N/A @Override
4632N/A Iterable<UnixMountEntry> getMountEntries() {
4632N/A ArrayList<UnixMountEntry> entries = new ArrayList<UnixMountEntry>();
4632N/A try {
4632N/A long iter = BsdNativeDispatcher.getfsstat();
4632N/A try {
4632N/A for (;;) {
4632N/A UnixMountEntry entry = new UnixMountEntry();
4632N/A int res = BsdNativeDispatcher.fsstatEntry(iter, entry);
4632N/A if (res < 0)
4632N/A break;
4632N/A entries.add(entry);
4632N/A }
4632N/A } finally {
4632N/A BsdNativeDispatcher.endfsstat(iter);
4632N/A }
4632N/A
4632N/A } catch (UnixException x) {
4632N/A // nothing we can do
4632N/A }
4632N/A return entries;
4632N/A }
4632N/A
4632N/A
4632N/A
4632N/A @Override
4632N/A FileStore getFileStore(UnixMountEntry entry) throws IOException {
4632N/A return new BsdFileStore(this, entry);
4632N/A }
4632N/A}