mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8230085: (fs) FileStore::isReadOnly is always true on macOS Catalina
Reviewed-by: alanb
This commit is contained in:
parent
c0e1f9ee6c
commit
c57ad7ffc0
4 changed files with 44 additions and 17 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2019, 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
|
||||
|
@ -62,22 +62,14 @@ class BsdFileStore
|
|||
}
|
||||
|
||||
// step 2: find mount point
|
||||
UnixPath parent = path.getParent();
|
||||
while (parent != null) {
|
||||
UnixFileAttributes attrs = null;
|
||||
try {
|
||||
attrs = UnixFileAttributes.get(parent, true);
|
||||
} catch (UnixException x) {
|
||||
x.rethrowAsIOException(parent);
|
||||
}
|
||||
if (attrs.dev() != dev())
|
||||
break;
|
||||
path = parent;
|
||||
parent = parent.getParent();
|
||||
byte[] dir = null;
|
||||
try {
|
||||
dir = BsdNativeDispatcher.getmntonname(path);
|
||||
} catch (UnixException x) {
|
||||
x.rethrowAsIOException(path);
|
||||
}
|
||||
|
||||
// step 3: lookup mounted file systems
|
||||
byte[] dir = path.asByteArray();
|
||||
for (UnixMountEntry entry: fs.getMountEntries()) {
|
||||
if (Arrays.equals(dir, entry.dir()))
|
||||
return entry;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2019, 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
|
||||
|
@ -51,6 +51,20 @@ class BsdNativeDispatcher extends UnixNativeDispatcher {
|
|||
*/
|
||||
static native void endfsstat(long iter) throws UnixException;
|
||||
|
||||
/**
|
||||
* int statfs(const char *path, struct statfs *buf);
|
||||
* returns buf->f_mntonname (directory on which mounted)
|
||||
*/
|
||||
static byte[] getmntonname(UnixPath path) throws UnixException {
|
||||
NativeBuffer pathBuffer = copyToNativeBuffer(path);
|
||||
try {
|
||||
return getmntonname0(pathBuffer.address());
|
||||
} finally {
|
||||
pathBuffer.release();
|
||||
}
|
||||
}
|
||||
static native byte[] getmntonname0(long pathAddress) throws UnixException;
|
||||
|
||||
// initialize field IDs
|
||||
private static native void initIDs();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue