# HG changeset patch # User bpb # Date 1515783982 28800 # Node ID bdbbf56c302eaf3f24a4525ade56b559fff6f6ff # Parent a5f815d1060bc4b5173d3e384e6c09f90b4b04ae 8165852: (fs) Mount point not found for a file which is present in overlayfs Summary: Check /proc/mounts when the device ID boundary is reached Reviewed-by: alanb diff -r a5f815d1060b -r bdbbf56c302e src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java --- a/src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java Fri Jan 12 16:49:58 2018 +0000 +++ b/src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java Fri Jan 12 11:06:22 2018 -0800 @@ -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 @@ -66,6 +66,8 @@ } // step 2: find mount point + List procMountsEntries = + fs.getMountEntries("/proc/mounts"); UnixPath parent = path.getParent(); while (parent != null) { UnixFileAttributes attrs = null; @@ -74,16 +76,23 @@ } 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; } diff -r a5f815d1060b -r bdbbf56c302e src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java --- a/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java Fri Jan 12 16:49:58 2018 +0000 +++ b/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java Fri Jan 12 11:06:22 2018 -0800 @@ -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 @@ -75,7 +75,7 @@ /** * Returns object to iterate over the mount entries in the given fstab file. */ - Iterable getMountEntries(String fstab) { + List getMountEntries(String fstab) { ArrayList entries = new ArrayList<>(); try { long fp = setmntent(Util.toBytes(fstab), Util.toBytes("r")); @@ -101,7 +101,7 @@ * Returns object to iterate over the mount entries in /etc/mtab */ @Override - Iterable getMountEntries() { + List getMountEntries() { return getMountEntries("/etc/mtab"); }