Class PosixShim

java.lang.Object
org.jruby.util.io.PosixShim

public class PosixShim extends Object
Representations of as many native posix functions as possible applied to an NIO channel
  • Field Details

    • LOCK_SH

      public static final int LOCK_SH
      See Also:
    • LOCK_EX

      public static final int LOCK_EX
      See Also:
    • LOCK_NB

      public static final int LOCK_NB
      See Also:
    • LOCK_UN

      public static final int LOCK_UN
      See Also:
    • SEEK_SET

      public static final int SEEK_SET
      See Also:
    • SEEK_CUR

      public static final int SEEK_CUR
      See Also:
    • SEEK_END

      public static final int SEEK_END
      See Also:
    • NATIVE_EOF

      private static final int NATIVE_EOF
      See Also:
    • JAVA_EOF

      private static final int JAVA_EOF
      See Also:
    • WAIT_MACROS

      public static final PosixShim.WaitMacros WAIT_MACROS
    • error

      public Throwable error
      The last Throwable exception raised by a call.
    • errno

      private final ThreadLocal<jnr.constants.platform.Errno> errno
    • errmsg

      public String errmsg
      The recommended error message, if any.
    • posix

      private final jnr.posix.POSIX posix
      The POSIX instance to use for native calls
    • runtime

      private final Ruby runtime
      The current runtime
    • _umaskLock

      private static final Object _umaskLock
      An object to synchronize calls to umask
    • _cachedUmask

      private static int _cachedUmask
      The last umask we set
  • Constructor Details

    • PosixShim

      public PosixShim(Ruby runtime)
  • Method Details

    • lseek

      public long lseek(ChannelFD fd, long offset, int type)
    • write

      public int write(ChannelFD fd, byte[] bytes, int offset, int length, boolean nonblock)
    • read

      public int read(ChannelFD fd, byte[] target, int offset, int length, boolean nonblock)
    • flock

      public int flock(ChannelFD fd, int lockMode)
    • dup2

      public int dup2(ChannelFD filedes, ChannelFD filedes2)
    • close

      public int close(ChannelFD fd)
    • close

      public int close(Closeable closeable)
    • pipe

      public Channel[] pipe()
    • getErrno

      public jnr.constants.platform.Errno getErrno()
      The appropriate errno value for the last thrown error, if any.
    • setErrno

      public void setErrno(jnr.constants.platform.Errno errno)
    • setCloexec

      public int setCloexec(int fd, boolean cloexec)
    • fcntlSetFD

      public int fcntlSetFD(int fd, int flags)
    • fcntlGetFD

      public int fcntlGetFD(int fd)
    • open

      public Channel open(String cwd, String path, int flags, int perm)
    • open

      public Channel open(String cwd, String path, ModeFlags flags, int perm)
    • open

      @Deprecated public Channel open(String cwd, String path, ModeFlags flags, int perm, ClassLoader classLoader)
      Deprecated.
    • umask

      public static int umask(jnr.posix.POSIX posix)
      Joy of POSIX, only way to get the umask is to set the umask, then set it back. That's unsafe in a threaded program. We minimize but may not totally remove this race by caching the obtained or previously set (see umask() above) umask and using that as the initial set value which, cross fingers, is a no-op. The cache access is then synchronized. TODO: Better?
    • umask

      public static int umask(jnr.posix.POSIX posix, int newMask)
    • ftruncate

      public int ftruncate(ChannelFD fd, long pos)
    • size

      public long size(ChannelFD fd)
    • clear

      private void clear()
    • checkSharedExclusive

      private int checkSharedExclusive(ChannelFD fd, int lockMode)
    • lockFailedReturn

      private static int lockFailedReturn(int lockMode)
    • lockStateChanges

      private static boolean lockStateChanges(FileLock lock, int lockMode)
    • unlock

      private int unlock(ChannelFD fd) throws IOException
      Throws:
      IOException
    • lock

      private int lock(ChannelFD fd, boolean exclusive) throws IOException
      Throws:
      IOException
    • tryLock

      private int tryLock(ChannelFD fd, boolean exclusive) throws IOException
      Throws:
      IOException