mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8165852: (fs) Mount point not found for a file which is present in overlayfs
Check /proc/mounts when the device ID boundary is reached Reviewed-by: alanb
This commit is contained in:
parent
989b326949
commit
473e36a9f3
2 changed files with 18 additions and 9 deletions
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -66,6 +66,8 @@ class LinuxFileStore
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 2: find mount point
|
// step 2: find mount point
|
||||||
|
List<UnixMountEntry> procMountsEntries =
|
||||||
|
fs.getMountEntries("/proc/mounts");
|
||||||
UnixPath parent = path.getParent();
|
UnixPath parent = path.getParent();
|
||||||
while (parent != null) {
|
while (parent != null) {
|
||||||
UnixFileAttributes attrs = null;
|
UnixFileAttributes attrs = null;
|
||||||
|
@ -74,16 +76,23 @@ class LinuxFileStore
|
||||||
} catch (UnixException x) {
|
} catch (UnixException x) {
|
||||||
x.rethrowAsIOException(parent);
|
x.rethrowAsIOException(parent);
|
||||||
}
|
}
|
||||||
if (attrs.dev() != dev())
|
if (attrs.dev() != dev()) {
|
||||||
break;
|
// 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;
|
path = parent;
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 3: lookup mounted file systems (use /proc/mounts to ensure we
|
// step 3: lookup mounted file systems (use /proc/mounts to
|
||||||
// find the file system even when not in /etc/mtab)
|
// ensure we find the file system even when not in /etc/mtab)
|
||||||
byte[] dir = path.asByteArray();
|
byte[] dir = path.asByteArray();
|
||||||
for (UnixMountEntry entry: fs.getMountEntries("/proc/mounts")) {
|
for (UnixMountEntry entry : procMountsEntries) {
|
||||||
if (Arrays.equals(dir, entry.dir()))
|
if (Arrays.equals(dir, entry.dir()))
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -75,7 +75,7 @@ class LinuxFileSystem extends UnixFileSystem {
|
||||||
/**
|
/**
|
||||||
* Returns object to iterate over the mount entries in the given fstab file.
|
* 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<>();
|
ArrayList<UnixMountEntry> entries = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
long fp = setmntent(Util.toBytes(fstab), Util.toBytes("r"));
|
long fp = setmntent(Util.toBytes(fstab), Util.toBytes("r"));
|
||||||
|
@ -101,7 +101,7 @@ class LinuxFileSystem extends UnixFileSystem {
|
||||||
* Returns object to iterate over the mount entries in /etc/mtab
|
* Returns object to iterate over the mount entries in /etc/mtab
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
Iterable<UnixMountEntry> getMountEntries() {
|
List<UnixMountEntry> getMountEntries() {
|
||||||
return getMountEntries("/etc/mtab");
|
return getMountEntries("/etc/mtab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue