1 /*
   2  * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2013 SAP AG. 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 
  27 /*
  28  * Portions Copyright (c) 2014 IBM Corporation
  29  */
  30 
  31 package sun.nio.fs;
  32 
  33 import java.nio.file.*;
  34 import java.nio.file.attribute.*;
  35 import java.io.IOException;
  36 import java.util.*;
  37 
  38 import static sun.nio.fs.AixNativeDispatcher.*;
  39 
  40 /**
  41  * AIX implementation of FileSystem
  42  */
  43 
  44 class AixFileSystem extends UnixFileSystem {
  45 
  46     AixFileSystem(UnixFileSystemProvider provider, String dir) {
  47         super(provider, dir);
  48     }
  49 
  50     @Override
  51     public WatchService newWatchService()
  52         throws IOException
  53     {
  54         return new PollingWatchService();
  55     }
  56 
  57     // lazy initialization of the list of supported attribute views
  58     private static class SupportedFileFileAttributeViewsHolder {
  59         static final Set<String> supportedFileAttributeViews =
  60             supportedFileAttributeViews();
  61         private static Set<String> supportedFileAttributeViews() {
  62             Set<String> result = new HashSet<String>();
  63             result.addAll(UnixFileSystem.standardFileAttributeViews());
  64             // additional Linux-specific views
  65             result.add("dos");
  66             result.add("user");
  67             return Collections.unmodifiableSet(result);
  68         }
  69     }
  70 
  71     @Override
  72     public Set<String> supportedFileAttributeViews() {
  73         return SupportedFileFileAttributeViewsHolder.supportedFileAttributeViews;
  74     }
  75 
  76     @Override
  77     void copyNonPosixAttributes(int ofd, int nfd) {
  78         AixUserDefinedFileAttributeView.copyExtendedAttributes(ofd, nfd);
  79     }
  80 
  81     /**
  82      * Returns object to iterate over the mount entries returned by mntctl
  83      */
  84     @Override
  85     Iterable<UnixMountEntry> getMountEntries() {
  86         UnixMountEntry[] entries = null;
  87         try {
  88             entries = getmntctl();
  89         } catch (UnixException x) {
  90             // nothing we can do
  91         }
  92         if (entries == null) {
  93             return Collections.emptyList();
  94         }
  95         return Arrays.asList(entries);
  96     }
  97 
  98     @Override
  99     FileStore getFileStore(UnixMountEntry entry) throws IOException {
 100         return new AixFileStore(this, entry);
 101     }
 102 }