create a small ram disk and fill it, so the write fails for lack of space? --elliott
On Wed, Nov 4, 2009 at 14:53, Mark Hindess <[email protected]> wrote: > > In message <[email protected]>, > Jesse Wilson writes: >> >> On Wed, Nov 4, 2009 at 4:11 AM, Tim Ellison <[email protected]> wrote: >> >> > Like everyone else, I'm avoiding studying sources of Sun code, so can >> > you show the test case here (or on a JIRA)? >> >> I attached it in the first message, but it looks like the mailing list >> software silently discards attachments. Here's the test inline: >> >> import java.io.BufferedOutputStream; >> >> import java.io.FileNotFoundException; >> >> import java.io.FileOutputStream; >> >> import java.io.IOException; >> >> import java.io.OutputStream; >> >> >> public class Scratch { >> >> >> public static void main(String[] args) throws Exception { >> >> new ProcessBuilder() >> >> .command("/usr/bin/hdiutil", "create", "-fs", "HFS+", "-size", >> "10m", >> >> "-volname", "refreshing", "-attach", "/tmp/refreshing.dmg") >> >> .start() >> >> .waitFor(); >> >> >> ChmoddedFileMaker coke = new >> ChmoddedFileMaker("/Volumes/refreshing/refreshing.txt"); >> >> ChmoddedFileMaker pepsi = new >> ChmoddedFileMaker("/Volumes/refreshing/refreshing.txt"); >> >> >> // this write will succeed because the volume exists >> >> coke.writeAndChmod("Coke"); >> >> >> new ProcessBuilder().command("/sbin/umount", "-f", >> "/Volumes/refreshing/") >> >> .start() >> >> .waitFor(); >> >> >> // this write will fail because the volume has disappeared >> >> pepsi.writeAndChmod("Pepsi"); >> >> } >> >> >> static class ChmoddedFileMaker { >> >> private final String file; >> >> private final OutputStream out; >> >> >> ChmoddedFileMaker(String file) throws FileNotFoundException { >> >> this.file = file; >> >> this.out = new BufferedOutputStream(new FileOutputStream(this.file)); >> >> } >> >> >> void writeAndChmod(String contents) throws IOException, >> InterruptedException { >> >> out.write(contents.getBytes()); >> >> out.close(); >> >> } >> >> } >> >> } >> >> >> When this program is executed on the RI, the 2nd write fails but no >> exceptions are thrown. > > I'm struggling to reproduce this on Linux. I tried using two scripts to > do the mounting and umounting. That is, something like these: > > #!/bin/sh > set -e > exec >$0.log 2>&1 > dd if=/dev/zero of=/tmp/refreshing.fs bs=1k count=1k > mke2fs -F /tmp/refreshing.fs > mkdir /tmp/refreshing > sudo mount -o loop /tmp/refreshing.fs /tmp/refreshing > > and: > > #!/bin/sh > set -e > exec >$0.log 2>&1 > sudo umount -d -f /tmp/refreshing > rmdir /tmp/refreshing > > but the umount fails. Doing a lazy umount (-l) works but (obviously) > the write also works in this case too. Force unmounting just isn't as > forceful on Linux. > > That's not to say we shouldn't fix it. I just thought I'd mention it > in case anyone else is trying the same thing or in case anyone has any > other ideas on reproducing on our "supported" platforms. > > -Mark. > > > -- Elliott Hughes - http://who/enh - http://jessies.org/~enh/
