Interface EmuUnixFile<T>

Type Parameters:
T - the type of values stored in the file
All Known Implementing Classes:
AbstractEmuUnixFile, BytesEmuUnixFileSystem.BytesEmuUnixFile, TaintEmuUnixFileSystem.TaintEmuUnixFile

public interface EmuUnixFile<T>
A simulated UNIX file

Contrast this with EmuUnixFileDescriptor, which is a process's handle to an open file, not the file itself.

  • Method Summary

    Change
    Modifier and Type
    Method
    Description
    default void
    Require the user to have read permission on this file, throwing EmuIOException if not
    default void
    Require the user to have write permission on this file, throwing EmuIOException if not
    Get the original pathname of this file
    Get the file's stat structure, as defined by the simulator.
    default boolean
    Check if the given user can read this file
    default boolean
    Check if the given user can write this file
    int
    read(long offset, T buf)
    Read contents from the file starting at the given offset into the given buffer
    read(PcodeArithmetic<T> arithmetic, T offset, T buf)
    Read contents from the file starting at the given offset into the given buffer
    void
    Erase the contents of the file
    int
    write(long offset, T buf)
    Write contents into the file starting at the given offset from the given buffer
    write(PcodeArithmetic<T> arithmetic, T offset, T buf)
    Write contents into the file starting at the given offset from the given buffer
  • Method Details

    • getPathname

      String getPathname()
      Get the original pathname of this file

      Depending on the fidelity of the file system simulator, and the actions taken by the target program, the file may no longer actually exist at this path, but it ought be have been the pathname at some point in the file life.

      Returns:
      the pathname
    • read

      T read(PcodeArithmetic<T> arithmetic, T offset, T buf)
      Read contents from the file starting at the given offset into the given buffer

      This roughly follows the semantics of the UNIX read(). While the offset and return value may depend on the arithmetic, the actual contents read from the file should not.

      Parameters:
      arithmetic - the arithmetic
      offset - the offset
      buf - the buffer
      Returns:
      the number of bytes read
    • read NEW

      int read(long offset, T buf)
      Read contents from the file starting at the given offset into the given buffer

      This roughly follows the semantics of the UNIX read(). While the offset and return value may depend on the arithmetic, the actual contents read from the file should not.

      Parameters:
      offset - the offset
      buf - the buffer
      Returns:
      the number of bytes read
    • write

      T write(PcodeArithmetic<T> arithmetic, T offset, T buf)
      Write contents into the file starting at the given offset from the given buffer

      This roughly follows the semantics of the UNIX write(). While the offset and return value may depend on the arithmetic, the actual contents written to the file should not.

      Parameters:
      arithmetic - the arithmetic
      offset - the offset
      buf - the buffer
      Returns:
      the number of bytes written
    • write NEW

      int write(long offset, T buf)
      Write contents into the file starting at the given offset from the given buffer

      This roughly follows the semantics of the UNIX write(). While the offset and return value may depend on the arithmetic, the actual contents written to the file should not.

      Parameters:
      offset - the offset
      buf - the buffer
      Returns:
      the number of bytes written
    • truncate

      void truncate()
      Erase the contents of the file
    • getStat

      EmuUnixFileStat getStat()
      Get the file's stat structure, as defined by the simulator.
      Returns:
      the stat
    • isReadable

      default boolean isReadable(EmuUnixUser user)
      Check if the given user can read this file
      Parameters:
      user - the user
      Returns:
      true if permitted, false otherwise
    • isWritable

      default boolean isWritable(EmuUnixUser user)
      Check if the given user can write this file
      Parameters:
      user - the user
      Returns:
      true if permitted, false otherwise
    • checkReadable

      default void checkReadable(EmuUnixUser user)
      Require the user to have read permission on this file, throwing EmuIOException if not
      Parameters:
      user - the user
    • checkWritable

      default void checkWritable(EmuUnixUser user)
      Require the user to have write permission on this file, throwing EmuIOException if not
      Parameters:
      user - the user