Re: Forcing File Open and File Read Errors



Peter Olcott wrote:
I need to be able to force file open and file read errors to verify that exception processing is working correctly. What are all the ways that these two errors can be synthesized?

Forcing file open to fail is easy: Just make sure there's
no file of the desired name, or that your process doesn't have
permission to open it in the desired mode, or that your process
doesn't have 'x' permission on some directory in its path.

Forcing a read error on a file that's been opened successfully
is harder. You could take an axe to the disk containing the file,
but your eye-hand coordination would need to be pretty good: if
the file's content has already been cached, the disk might not
be needed (for a while, anyhow). Best bet (and this applies to
other system calls too, including open) is to use an interposition
library that catches all calls to open, read, whatever, forwards
most of them to the actual system calls, but occasionally decides
to burp back an error for no good reason whatsoever. See also
"fault injection."

--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxxx
.



Relevant Pages

  • Re: make a disk sector unreadable?
    ... >>commercial places do so that they need my disk to verify use of ... Don't do stuff without the user's permission. ... Frog - This method of "copy protection" is so easily defeated by using a bit ...
    (comp.security.misc)
  • Re: grinding on HDD
    ... do you have media sniffers or indexing enabled in an office suite on in disk ... Backup your data without overwriting any previous backup ... Verify HD cables are the correct type & securely fitted ... If Optical drives dissappear from the BIOS bootup... ...
    (alt.comp.hardware.pc-homebuilt)
  • Re: has K3B been abandoned?
    ... I gave up on asking k3b to verify anything. ... Then it waits for the disk to be recognized by the ... but a simple lack of a time delay bug is too ... I had the identical problem with Nautilus so K3B is not the problem ...
    (Fedora)
  • Re: has K3B been abandoned?
    ... the presence of a bug (arguably here in kernel-space) does ... I gave up on asking k3b to verify anything. ... Then it waits for the disk to be recognized by the drive NOT! ... but a simple lack of a time delay bug is too much trouble to fix I ...
    (Fedora)
  • Re: "Disk full"/"cannot save AutoRecover file" - redux
    ... Since your Command + S is working, that means you have write permission to ... "The disk is full trying to write to. ... Make sure that you have specified a valid location for AutoRecover ...
    (microsoft.public.mac.office.word)