1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -66,6 +66,8 @@ UnixMountEntry findMountEntry() throws IOException {
66
66
}
67
67
68
68
// step 2: find mount point
69
+ List <UnixMountEntry > procMountsEntries =
70
+ fs .getMountEntries ("/proc/mounts" );
69
71
UnixPath parent = path .getParent ();
70
72
while (parent != null ) {
71
73
UnixFileAttributes attrs = null ;
@@ -74,16 +76,23 @@ UnixMountEntry findMountEntry() throws IOException {
74
76
} catch (UnixException x ) {
75
77
x .rethrowAsIOException (parent );
76
78
}
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
+ }
79
88
path = parent ;
80
89
parent = parent .getParent ();
81
90
}
82
91
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)
85
94
byte [] dir = path .asByteArray ();
86
- for (UnixMountEntry entry : fs . getMountEntries ( "/proc/mounts" ) ) {
95
+ for (UnixMountEntry entry : procMountsEntries ) {
87
96
if (Arrays .equals (dir , entry .dir ()))
88
97
return entry ;
89
98
}
0 commit comments