[cp-patches] RFC: File bug Fix and small VM interface change
rogers.email at gmail.com
Wed Apr 9 18:59:39 UTC 2008
this looks like a good patch so +1 from me. Just to note that we've been
discussing the VMFile interface in a Jikes RVM tracker  and that on
IRC MJW pointed out that GCJ's implementation appeared to vary from that
of Classpath   .
Mario Torre wrote:
> Hello all!
> I would like to submit this fix.
> The problem is that to detect if a file is writable we actually open it
> for writing... Even worse, in the case of a directory, we write to it a
> temp file!
> There are a number of issues that I see wrong here, but what worries me
> most is that these operations can kill filesystem that reside on compact
> flash memories and other devices that have a limited number of write.
> The current fix does two things.
> 1. introduce a new method, native, canWriteDirectory(String path)
> This method is meant to be implemented by whoever implements the VM
> interface, so that it can do nice things with their target environment.
> The default implementation works on Linux and should work on any *nix
> operating systems. I've left canWriteDirectory(File file) for backward
> compatibility, but I guess no one uses this anyway (it defer to the
> native method).
> 2. Change the implementation of Java_java_io_VMFile_canWrite and
> Java_java_io_VMFile_canRead so that they use cpio_checkAccess now,
> instead of doing the old "The lazy man's way out" (which is also more
> code, btw...)
> I'm going to submit this today if no one complains, any ideas?
> Ah, before I forget, there are a number of unrelated fixes like
> indentation and all the function signature now reflect the fact that
> these methods are static (jclass instead of jobject). It would be handy
> here to use mercurial (hg record) to separate patchsets.
> 2008-04-09 Mario Torre <neugens at aicas.com>
> * java/io/File.java (canWrite): use canWriteDirectory(String).
> * vm/reference/java/io/VMFile.java (canWriteDirectory): new native
> * native/jni/java-io/java_io_VMFile.c: correct indentation, sync
> names with header file definition.
> (Java_java_io_VMFile_canRead): use cpio_checkAccess to get access
> permission. Removed unused variable.
> (Java_java_io_VMFile_canWrite): likewise.
> (Java_java_io_VMFile_canWriteDirectory): new function.
More information about the Classpath-patches