Skip to content

Commit 1f3b68c

Browse files
author
René Schünemann
authored
Merge pull request #75 from SAP/JDK-8165852
8165852: (fs) Mount point not found for a file which is present in ov…
2 parents 3e21a8c + 5f806b6 commit 1f3b68c

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
}

src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2013, 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
@@ -75,7 +75,7 @@ void copyNonPosixAttributes(int ofd, int nfd) {
7575
/**
7676
* Returns object to iterate over the mount entries in the given fstab file.
7777
*/
78-
Iterable<UnixMountEntry> getMountEntries(String fstab) {
78+
List<UnixMountEntry> getMountEntries(String fstab) {
7979
ArrayList<UnixMountEntry> entries = new ArrayList<>();
8080
try {
8181
long fp = setmntent(Util.toBytes(fstab), Util.toBytes("r"));
@@ -101,7 +101,7 @@ Iterable<UnixMountEntry> getMountEntries(String fstab) {
101101
* Returns object to iterate over the mount entries in /etc/mtab
102102
*/
103103
@Override
104-
Iterable<UnixMountEntry> getMountEntries() {
104+
List<UnixMountEntry> getMountEntries() {
105105
return getMountEntries("/etc/mtab");
106106
}
107107

0 commit comments

Comments
 (0)