1 /* 2 * Copyright (c) 2008, 2013, 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 package sun.nio.fs; 28 29 import java.nio.file.attribute.*; 30 import java.util.*; 31 import java.io.IOException; 32 33 /** 34 * AIX implementation of FileStore 35 */ 36 37 class AixFileStore 38 extends UnixFileStore 39 { 40 41 AixFileStore(UnixPath file) throws IOException { 42 super(file); 43 } 44 45 AixFileStore(UnixFileSystem fs, UnixMountEntry entry) throws IOException { 46 super(fs, entry); 47 } 48 49 /** 50 * Finds, and returns, the mount entry for the file system where the file 51 * resides. 52 */ 53 @Override 54 UnixMountEntry findMountEntry() throws IOException { 55 AixFileSystem fs = (AixFileSystem)file().getFileSystem(); 56 57 // step 1: get realpath 58 UnixPath path = null; 59 try { 60 byte[] rp = UnixNativeDispatcher.realpath(file()); 61 path = new UnixPath(fs, rp); 62 } catch (UnixException x) { 63 x.rethrowAsIOException(file()); 64 } 65 66 // step 2: find mount point 67 UnixPath parent = path.getParent(); 68 while (parent != null) { 69 UnixFileAttributes attrs = null; 70 try { 71 attrs = UnixFileAttributes.get(parent, true); 72 } catch (UnixException x) { 73 x.rethrowAsIOException(parent); 74 } 75 if (attrs.dev() != dev()) 76 break; 77 path = parent; 78 parent = parent.getParent(); 79 } 80 81 // step 3: lookup mounted file systems 82 byte[] dir = path.asByteArray(); 83 for (UnixMountEntry entry: fs.getMountEntries()) { 84 if (Arrays.equals(dir, entry.dir())) 85 return entry; 86 } 87 88 throw new IOException("Mount point not found"); 89 } 90 91 // returns true if extended attributes enabled on file system where given 92 // file resides, returns false if disabled or unable to determine. 93 private boolean isExtendedAttributesEnabled(UnixPath path) { 94 return false; 95 } 96 97 @Override 98 public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) { 99 return super.supportsFileAttributeView(type); 100 } 101 102 @Override 103 public boolean supportsFileAttributeView(String name) { 104 return super.supportsFileAttributeView(name); 105 } 106 }