src/java.base/macosx/classes/sun/nio/fs/BsdFileStore.java
changeset 58131 3054503bad7d
parent 47216 71c04702a3d5
equal deleted inserted replaced
58130:ff0eae1719d0 58131:3054503bad7d
     1 /*
     1 /*
     2  * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    60         } catch (UnixException x) {
    60         } catch (UnixException x) {
    61             x.rethrowAsIOException(file());
    61             x.rethrowAsIOException(file());
    62         }
    62         }
    63 
    63 
    64         // step 2: find mount point
    64         // step 2: find mount point
    65         UnixPath parent = path.getParent();
    65         byte[] dir = null;
    66         while (parent != null) {
    66         try {
    67             UnixFileAttributes attrs = null;
    67             dir = BsdNativeDispatcher.getmntonname(path);
    68             try {
    68         } catch (UnixException x) {
    69                 attrs = UnixFileAttributes.get(parent, true);
    69             x.rethrowAsIOException(path);
    70             } catch (UnixException x) {
       
    71                 x.rethrowAsIOException(parent);
       
    72             }
       
    73             if (attrs.dev() != dev())
       
    74                 break;
       
    75             path = parent;
       
    76             parent = parent.getParent();
       
    77         }
    70         }
    78 
    71 
    79         // step 3: lookup mounted file systems
    72         // step 3: lookup mounted file systems
    80         byte[] dir = path.asByteArray();
       
    81         for (UnixMountEntry entry: fs.getMountEntries()) {
    73         for (UnixMountEntry entry: fs.getMountEntries()) {
    82             if (Arrays.equals(dir, entry.dir()))
    74             if (Arrays.equals(dir, entry.dir()))
    83                 return entry;
    75                 return entry;
    84         }
    76         }
    85 
    77