Blame jdk8165852-pr3468-mount_point_not_found_for_a_file_which_is_present_in_overlayfs.patch

35adfaf
35adfaf
# HG changeset patch
35adfaf
# User bpb
35adfaf
# Date 1515783982 28800
35adfaf
# Node ID b8843bca95b5e0eed5bbb4dc195c89c727c7aede
35adfaf
# Parent  61d7ce442d95f5f30c84037a50cf6361bf7c37e1
35adfaf
8165852: (fs) Mount point not found for a file which is present in overlayfs
35adfaf
Summary: Check /proc/mounts when the device ID boundary is reached
35adfaf
Reviewed-by: alanb
35adfaf
35adfaf
diff -r 61d7ce442d95 -r b8843bca95b5 src/solaris/classes/sun/nio/fs/LinuxFileStore.java
35adfaf
--- openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java	Tue Jul 24 05:10:45 2018 -0400
35adfaf
+++ openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java	Fri Jan 12 11:06:22 2018 -0800
35adfaf
@@ -1,5 +1,5 @@
35adfaf
 /*
35adfaf
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
35adfaf
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
35adfaf
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
35adfaf
  *
35adfaf
  * This code is free software; you can redistribute it and/or modify it
35adfaf
@@ -66,6 +66,8 @@
35adfaf
         }
35adfaf
 
35adfaf
         // step 2: find mount point
35adfaf
+        List<UnixMountEntry> procMountsEntries =
35adfaf
+            fs.getMountEntries("/proc/mounts");
35adfaf
         UnixPath parent = path.getParent();
35adfaf
         while (parent != null) {
35adfaf
             UnixFileAttributes attrs = null;
35adfaf
@@ -74,16 +76,23 @@
35adfaf
             } catch (UnixException x) {
35adfaf
                 x.rethrowAsIOException(parent);
35adfaf
             }
35adfaf
-            if (attrs.dev() != dev())
35adfaf
-                break;
35adfaf
+            if (attrs.dev() != dev()) {
35adfaf
+                // step 3: lookup mounted file systems (use /proc/mounts to
35adfaf
+                // ensure we find the file system even when not in /etc/mtab)
35adfaf
+                byte[] dir = path.asByteArray();
35adfaf
+                for (UnixMountEntry entry : procMountsEntries) {
35adfaf
+                    if (Arrays.equals(dir, entry.dir()))
35adfaf
+                        return entry;
35adfaf
+                }
35adfaf
+            }
35adfaf
             path = parent;
35adfaf
             parent = parent.getParent();
35adfaf
         }
35adfaf
 
35adfaf
-        // step 3: lookup mounted file systems (use /proc/mounts to ensure we
35adfaf
-        // find the file system even when not in /etc/mtab)
35adfaf
+        // step 3: lookup mounted file systems (use /proc/mounts to
35adfaf
+        // ensure we find the file system even when not in /etc/mtab)
35adfaf
         byte[] dir = path.asByteArray();
35adfaf
-        for (UnixMountEntry entry: fs.getMountEntries("/proc/mounts")) {
35adfaf
+        for (UnixMountEntry entry : procMountsEntries) {
35adfaf
             if (Arrays.equals(dir, entry.dir()))
35adfaf
                 return entry;
35adfaf
         }
35adfaf
diff -r 61d7ce442d95 -r b8843bca95b5 src/solaris/classes/sun/nio/fs/LinuxFileSystem.java
35adfaf
--- openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java	Tue Jul 24 05:10:45 2018 -0400
35adfaf
+++ openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java	Fri Jan 12 11:06:22 2018 -0800
35adfaf
@@ -1,5 +1,5 @@
35adfaf
 /*
35adfaf
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
35adfaf
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
35adfaf
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
35adfaf
  *
35adfaf
  * This code is free software; you can redistribute it and/or modify it
35adfaf
@@ -75,7 +75,7 @@
35adfaf
     /**
35adfaf
      * Returns object to iterate over the mount entries in the given fstab file.
35adfaf
      */
35adfaf
-    Iterable<UnixMountEntry> getMountEntries(String fstab) {
35adfaf
+    List<UnixMountEntry> getMountEntries(String fstab) {
35adfaf
         ArrayList<UnixMountEntry> entries = new ArrayList<>();
35adfaf
         try {
35adfaf
             long fp = setmntent(Util.toBytes(fstab), Util.toBytes("r"));
35adfaf
@@ -101,7 +101,7 @@
35adfaf
      * Returns object to iterate over the mount entries in /etc/mtab
35adfaf
      */
35adfaf
     @Override
35adfaf
-    Iterable<UnixMountEntry> getMountEntries() {
35adfaf
+    List<UnixMountEntry> getMountEntries() {
35adfaf
         return getMountEntries("/etc/mtab");
35adfaf
     }
35adfaf
 
35adfaf