11/*
2- * Copyright (c) 2008, 2015 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2008, 2018 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -66,6 +66,8 @@ UnixMountEntry findMountEntry() throws IOException {
6666 }
6767
6868 // step 2: find mount point
69+ List <UnixMountEntry > procMountsEntries =
70+ fs .getMountEntries ("/proc/mounts" );
6971 UnixPath parent = path .getParent ();
7072 while (parent != null ) {
7173 UnixFileAttributes attrs = null ;
@@ -74,16 +76,23 @@ UnixMountEntry findMountEntry() throws IOException {
7476 } catch (UnixException x ) {
7577 x .rethrowAsIOException (parent );
7678 }
77- if (attrs .dev () != dev ())
78- break ;
79+ if (attrs .dev () != dev ()) {
80+ // step 3: lookup mounted file systems (use /proc/mounts to
81+ // ensure we find the file system even when not in /etc/mtab)
82+ byte [] dir = path .asByteArray ();
83+ for (UnixMountEntry entry : procMountsEntries ) {
84+ if (Arrays .equals (dir , entry .dir ()))
85+ return entry ;
86+ }
87+ }
7988 path = parent ;
8089 parent = parent .getParent ();
8190 }
8291
83- // step 3: lookup mounted file systems (use /proc/mounts to ensure we
84- // find the file system even when not in /etc/mtab)
92+ // step 3: lookup mounted file systems (use /proc/mounts to
93+ // ensure we find the file system even when not in /etc/mtab)
8594 byte [] dir = path .asByteArray ();
86- for (UnixMountEntry entry : fs . getMountEntries ( "/proc/mounts" ) ) {
95+ for (UnixMountEntry entry : procMountsEntries ) {
8796 if (Arrays .equals (dir , entry .dir ()))
8897 return entry ;
8998 }
0 commit comments