Skip to content

Commit

Permalink
Merge pull request #75 from SAP/JDK-8165852
Browse files Browse the repository at this point in the history
8165852: (fs) Mount point not found for a file which is present in ov…
  • Loading branch information
René Schünemann authored Mar 20, 2018
2 parents 3e21a8c + 5f806b6 commit 1f3b68c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
21 changes: 15 additions & 6 deletions src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -66,6 +66,8 @@ UnixMountEntry findMountEntry() throws IOException {
}

// step 2: find mount point
List<UnixMountEntry> procMountsEntries =
fs.getMountEntries("/proc/mounts");
UnixPath parent = path.getParent();
while (parent != null) {
UnixFileAttributes attrs = null;
Expand All @@ -74,16 +76,23 @@ UnixMountEntry findMountEntry() throws IOException {
} catch (UnixException x) {
x.rethrowAsIOException(parent);
}
if (attrs.dev() != dev())
break;
if (attrs.dev() != dev()) {
// step 3: lookup mounted file systems (use /proc/mounts to
// ensure we find the file system even when not in /etc/mtab)
byte[] dir = path.asByteArray();
for (UnixMountEntry entry : procMountsEntries) {
if (Arrays.equals(dir, entry.dir()))
return entry;
}
}
path = parent;
parent = parent.getParent();
}

// step 3: lookup mounted file systems (use /proc/mounts to ensure we
// find the file system even when not in /etc/mtab)
// step 3: lookup mounted file systems (use /proc/mounts to
// ensure we find the file system even when not in /etc/mtab)
byte[] dir = path.asByteArray();
for (UnixMountEntry entry: fs.getMountEntries("/proc/mounts")) {
for (UnixMountEntry entry : procMountsEntries) {
if (Arrays.equals(dir, entry.dir()))
return entry;
}
Expand Down
6 changes: 3 additions & 3 deletions src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -75,7 +75,7 @@ void copyNonPosixAttributes(int ofd, int nfd) {
/**
* Returns object to iterate over the mount entries in the given fstab file.
*/
Iterable<UnixMountEntry> getMountEntries(String fstab) {
List<UnixMountEntry> getMountEntries(String fstab) {
ArrayList<UnixMountEntry> entries = new ArrayList<>();
try {
long fp = setmntent(Util.toBytes(fstab), Util.toBytes("r"));
Expand All @@ -101,7 +101,7 @@ Iterable<UnixMountEntry> getMountEntries(String fstab) {
* Returns object to iterate over the mount entries in /etc/mtab
*/
@Override
Iterable<UnixMountEntry> getMountEntries() {
List<UnixMountEntry> getMountEntries() {
return getMountEntries("/etc/mtab");
}

Expand Down

0 comments on commit 1f3b68c

Please # to comment.