Package jnr.posix

Class LazyPOSIX

java.lang.Object
jnr.posix.LazyPOSIX
All Implemented Interfaces:
POSIX

final class LazyPOSIX extends Object implements POSIX
  • Field Details

    • handler

      private final POSIXHandler handler
    • useNativePosix

      private final boolean useNativePosix
    • posix

      private volatile POSIX posix
  • Constructor Details

    • LazyPOSIX

      LazyPOSIX(POSIXHandler handler, boolean useNativePosix)
  • Method Details

    • posix

      private final POSIX posix()
    • loadPOSIX

      private final POSIX loadPOSIX()
    • newProcessMaker

      public ProcessMaker newProcessMaker(String... command)
      Specified by:
      newProcessMaker in interface POSIX
    • newProcessMaker

      public ProcessMaker newProcessMaker()
      Specified by:
      newProcessMaker in interface POSIX
    • allocateStat

      public FileStat allocateStat()
      Specified by:
      allocateStat in interface POSIX
    • allocateMsgHdr

      public MsgHdr allocateMsgHdr()
      Specified by:
      allocateMsgHdr in interface POSIX
    • chdir

      public int chdir(String path)
      Specified by:
      chdir in interface POSIX
    • chmod

      public int chmod(String filename, int mode)
      Specified by:
      chmod in interface POSIX
    • fchmod

      public int fchmod(int fd, int mode)
      Specified by:
      fchmod in interface POSIX
    • chown

      public int chown(String filename, int user, int group)
      Specified by:
      chown in interface POSIX
    • crypt

      public CharSequence crypt(CharSequence key, CharSequence salt)
      Specified by:
      crypt in interface POSIX
    • crypt

      public byte[] crypt(byte[] key, byte[] salt)
      Description copied from interface: POSIX
      Call the crypt function with the given key and salt as raw null-terminated byte (C char) strings.
      Specified by:
      crypt in interface POSIX
      Parameters:
      key - null-terminated key bytes
      salt - null-terminated salt bytes
      Returns:
      null-terminated crypted bytes, or null if there was an error
    • fchown

      public int fchown(int fd, int user, int group)
      Specified by:
      fchown in interface POSIX
    • endgrent

      public int endgrent()
      Specified by:
      endgrent in interface POSIX
    • endpwent

      public int endpwent()
      Specified by:
      endpwent in interface POSIX
    • errno

      public int errno()
      Specified by:
      errno in interface POSIX
    • errno

      public void errno(int value)
      Specified by:
      errno in interface POSIX
    • exec

      public int exec(String path, String... args)
      Description copied from interface: POSIX
      Shell expanding and escaping version of exec which handles all the preparation of a command line or command list.
      Specified by:
      exec in interface POSIX
      Parameters:
      path - the path to execute
      args - the arguments to pass, with arg0 equal to the desired process name
      Returns:
      does not return if successful; -1 if failed
    • exec

      public int exec(String path, String[] args, String[] envp)
      Description copied from interface: POSIX
      Shell expanding and escaping version of exec which handles all the preparation of a command line or command list.
      Specified by:
      exec in interface POSIX
      Parameters:
      path - the path to execute
      args - the arguments to pass, with arg0 equal to the desired process name
      envp - a set of KEY=VALUE environment strings to set for the new execution
      Returns:
      does not return if successful; -1 if failed
    • execv

      public int execv(String path, String[] argv)
      Specified by:
      execv in interface POSIX
    • execve

      public int execve(String path, String[] argv, String[] envp)
      Specified by:
      execve in interface POSIX
    • fork

      public int fork()
      Specified by:
      fork in interface POSIX
    • fstat

      public FileStat fstat(int fd)
      Specified by:
      fstat in interface POSIX
    • fstat

      public int fstat(int fd, FileStat stat)
      Specified by:
      fstat in interface POSIX
    • fstat

      public FileStat fstat(FileDescriptor descriptor)
      Specified by:
      fstat in interface POSIX
    • fstat

      public int fstat(FileDescriptor descriptor, FileStat stat)
      Specified by:
      fstat in interface POSIX
    • getegid

      public int getegid()
      Specified by:
      getegid in interface POSIX
    • geteuid

      public int geteuid()
      Specified by:
      geteuid in interface POSIX
    • getgid

      public int getgid()
      Specified by:
      getgid in interface POSIX
    • getdtablesize

      public int getdtablesize()
      Specified by:
      getdtablesize in interface POSIX
    • getgrent

      public Group getgrent()
      Specified by:
      getgrent in interface POSIX
    • getgrgid

      public Group getgrgid(int which)
      Specified by:
      getgrgid in interface POSIX
    • getgrnam

      public Group getgrnam(String which)
      Specified by:
      getgrnam in interface POSIX
    • getlogin

      public String getlogin()
      Specified by:
      getlogin in interface POSIX
    • getpgid

      public int getpgid()
      Specified by:
      getpgid in interface POSIX
    • getpgid

      public int getpgid(int pid)
      Specified by:
      getpgid in interface POSIX
    • getpgrp

      public int getpgrp()
      Specified by:
      getpgrp in interface POSIX
    • getpid

      public int getpid()
      Specified by:
      getpid in interface POSIX
    • getppid

      public int getppid()
      Specified by:
      getppid in interface POSIX
    • getpriority

      public int getpriority(int which, int who)
      Specified by:
      getpriority in interface POSIX
    • getpwent

      public Passwd getpwent()
      Specified by:
      getpwent in interface POSIX
    • getpwnam

      public Passwd getpwnam(String which)
      Specified by:
      getpwnam in interface POSIX
    • getpwuid

      public Passwd getpwuid(int which)
      Specified by:
      getpwuid in interface POSIX
    • getuid

      public int getuid()
      Specified by:
      getuid in interface POSIX
    • getrlimit

      public int getrlimit(int resource, RLimit rlim)
      Specified by:
      getrlimit in interface POSIX
    • getrlimit

      public int getrlimit(int resource, jnr.ffi.Pointer rlim)
      Specified by:
      getrlimit in interface POSIX
    • getrlimit

      public RLimit getrlimit(int resource)
      Specified by:
      getrlimit in interface POSIX
    • setrlimit

      public int setrlimit(int resource, RLimit rlim)
      Specified by:
      setrlimit in interface POSIX
    • setrlimit

      public int setrlimit(int resource, jnr.ffi.Pointer rlim)
      Specified by:
      setrlimit in interface POSIX
    • setrlimit

      public int setrlimit(int resource, long rlimCur, long rlimMax)
      Specified by:
      setrlimit in interface POSIX
    • isatty

      public boolean isatty(FileDescriptor descriptor)
      Specified by:
      isatty in interface POSIX
    • isatty

      public int isatty(int descriptor)
      Specified by:
      isatty in interface POSIX
    • kill

      public int kill(int pid, int signal)
      Specified by:
      kill in interface POSIX
    • kill

      public int kill(long pid, int signal)
      Specified by:
      kill in interface POSIX
    • signal

      public SignalHandler signal(jnr.constants.platform.Signal sig, SignalHandler handler)
      Specified by:
      signal in interface POSIX
    • raise

      public int raise(int sig)
      Specified by:
      raise in interface POSIX
    • lchmod

      public int lchmod(String filename, int mode)
      Specified by:
      lchmod in interface POSIX
    • lchown

      public int lchown(String filename, int user, int group)
      Specified by:
      lchown in interface POSIX
    • link

      public int link(String oldpath, String newpath)
      Specified by:
      link in interface POSIX
    • lstat

      public FileStat lstat(String path)
      Specified by:
      lstat in interface POSIX
    • lstat

      public int lstat(String path, FileStat stat)
      Specified by:
      lstat in interface POSIX
    • mkdir

      public int mkdir(String path, int mode)
      Specified by:
      mkdir in interface POSIX
    • readlink

      public String readlink(String path) throws IOException
      Specified by:
      readlink in interface POSIX
      Throws:
      IOException
    • readlink

      public int readlink(CharSequence path, byte[] buf, int bufsize)
      Specified by:
      readlink in interface POSIX
    • readlink

      public int readlink(CharSequence path, ByteBuffer buf, int bufsize)
      Specified by:
      readlink in interface POSIX
    • readlink

      public int readlink(CharSequence path, jnr.ffi.Pointer bufPtr, int bufsize)
      Specified by:
      readlink in interface POSIX
    • rmdir

      public int rmdir(String path)
      Specified by:
      rmdir in interface POSIX
    • setegid

      public int setegid(int egid)
      Specified by:
      setegid in interface POSIX
    • seteuid

      public int seteuid(int euid)
      Specified by:
      seteuid in interface POSIX
    • setgid

      public int setgid(int gid)
      Specified by:
      setgid in interface POSIX
    • setgrent

      public int setgrent()
      Specified by:
      setgrent in interface POSIX
    • setpgid

      public int setpgid(int pid, int pgid)
      Specified by:
      setpgid in interface POSIX
    • setpgrp

      public int setpgrp(int pid, int pgrp)
      Specified by:
      setpgrp in interface POSIX
    • setpriority

      public int setpriority(int which, int who, int prio)
      Specified by:
      setpriority in interface POSIX
    • setpwent

      public int setpwent()
      Specified by:
      setpwent in interface POSIX
    • setsid

      public int setsid()
      Specified by:
      setsid in interface POSIX
    • setuid

      public int setuid(int uid)
      Specified by:
      setuid in interface POSIX
    • stat

      public FileStat stat(String path)
      Specified by:
      stat in interface POSIX
    • stat

      public int stat(String path, FileStat stat)
      Specified by:
      stat in interface POSIX
    • symlink

      public int symlink(String oldpath, String newpath)
      Specified by:
      symlink in interface POSIX
    • umask

      public int umask(int mask)
      Specified by:
      umask in interface POSIX
    • utimes

      public int utimes(String path, long[] atimeval, long[] mtimeval)
      Specified by:
      utimes in interface POSIX
    • utimes

      public int utimes(String path, jnr.ffi.Pointer times)
      Specified by:
      utimes in interface POSIX
    • futimes

      public int futimes(int fd, long[] atimeval, long[] mtimeval)
      Specified by:
      futimes in interface POSIX
    • lutimes

      public int lutimes(String path, long[] atimeval, long[] mtimeval)
      Specified by:
      lutimes in interface POSIX
    • utimensat

      public int utimensat(int dirfd, String path, long[] atimespec, long[] mtimespec, int flag)
      Specified by:
      utimensat in interface POSIX
    • utimensat

      public int utimensat(int dirfd, String path, jnr.ffi.Pointer times, int flag)
      Specified by:
      utimensat in interface POSIX
    • futimens

      public int futimens(int fd, long[] atimespec, long[] mtimespec)
      Specified by:
      futimens in interface POSIX
    • futimens

      public int futimens(int fd, jnr.ffi.Pointer times)
      Specified by:
      futimens in interface POSIX
    • wait

      public int wait(int[] status)
      Specified by:
      wait in interface POSIX
    • waitpid

      public int waitpid(int pid, int[] status, int flags)
      Specified by:
      waitpid in interface POSIX
    • waitpid

      public int waitpid(long pid, int[] status, int flags)
      Specified by:
      waitpid in interface POSIX
    • isNative

      public boolean isNative()
      Specified by:
      isNative in interface POSIX
    • libc

      public LibC libc()
      Description copied from interface: POSIX
      Returns null if isNative returns false.
      Specified by:
      libc in interface POSIX
      Returns:
      the LibC implementation for this POSIX
    • environ

      public jnr.ffi.Pointer environ()
      Specified by:
      environ in interface POSIX
    • getenv

      public String getenv(String envName)
      Specified by:
      getenv in interface POSIX
    • setenv

      public int setenv(String envName, String envValue, int overwrite)
      Specified by:
      setenv in interface POSIX
    • unsetenv

      public int unsetenv(String envName)
      Specified by:
      unsetenv in interface POSIX
    • posix_spawnp

      public long posix_spawnp(String path, Collection<? extends SpawnFileAction> fileActions, Collection<? extends CharSequence> argv, Collection<? extends CharSequence> envp)
      Specified by:
      posix_spawnp in interface POSIX
    • posix_spawnp

      public long posix_spawnp(String path, Collection<? extends SpawnFileAction> fileActions, Collection<? extends SpawnAttribute> spawnAttributes, Collection<? extends CharSequence> argv, Collection<? extends CharSequence> envp)
      Specified by:
      posix_spawnp in interface POSIX
    • sysconf

      public long sysconf(jnr.constants.platform.Sysconf name)
      Specified by:
      sysconf in interface POSIX
    • confstr

      public int confstr(jnr.constants.platform.Confstr name, ByteBuffer buf, int len)
      Specified by:
      confstr in interface POSIX
    • fpathconf

      public int fpathconf(int fd, jnr.constants.platform.Pathconf name)
      Specified by:
      fpathconf in interface POSIX
    • times

      public Times times()
      Specified by:
      times in interface POSIX
    • flock

      public int flock(int fd, int mode)
      Specified by:
      flock in interface POSIX
    • dup

      public int dup(int fd)
      Specified by:
      dup in interface POSIX
    • dup2

      public int dup2(int oldFd, int newFd)
      Specified by:
      dup2 in interface POSIX
    • fcntlInt

      public int fcntlInt(int fd, jnr.constants.platform.Fcntl fcntlConst, int arg)
      Specified by:
      fcntlInt in interface POSIX
    • fcntl

      public int fcntl(int fd, jnr.constants.platform.Fcntl fcntlConst)
      Specified by:
      fcntl in interface POSIX
    • fcntl

      public int fcntl(int fd, jnr.constants.platform.Fcntl fcntlConst, int arg)
      Specified by:
      fcntl in interface POSIX
    • fcntl

      @Deprecated public int fcntl(int fd, jnr.constants.platform.Fcntl fcntlConst, int... arg)
      Deprecated.
      Description copied from interface: POSIX
      fcntl(2)
      Specified by:
      fcntl in interface POSIX
      Parameters:
      fd - the file descriptor on which to act
      fcntlConst - the Fcntl enum value for the flag to set
      arg - arguments for the flag or null if none
      Returns:
      0 if success, -1 if error
      See Also:
    • access

      public int access(CharSequence path, int amode)
      Specified by:
      access in interface POSIX
    • close

      public int close(int fd)
      Specified by:
      close in interface POSIX
    • unlink

      public int unlink(CharSequence path)
      Specified by:
      unlink in interface POSIX
    • open

      public int open(CharSequence path, int flags, int perm)
      Specified by:
      open in interface POSIX
    • read

      public long read(int fd, byte[] buf, long n)
      Specified by:
      read in interface POSIX
    • write

      public long write(int fd, byte[] buf, long n)
      Specified by:
      write in interface POSIX
    • read

      public long read(int fd, ByteBuffer buf, long n)
      Specified by:
      read in interface POSIX
    • write

      public long write(int fd, ByteBuffer buf, long n)
      Specified by:
      write in interface POSIX
    • pread

      public long pread(int fd, byte[] buf, long n, long offset)
      Specified by:
      pread in interface POSIX
    • pwrite

      public long pwrite(int fd, byte[] buf, long n, long offset)
      Specified by:
      pwrite in interface POSIX
    • pread

      public long pread(int fd, ByteBuffer buf, long n, long offset)
      Specified by:
      pread in interface POSIX
    • pwrite

      public long pwrite(int fd, ByteBuffer buf, long n, long offset)
      Specified by:
      pwrite in interface POSIX
    • read

      public int read(int fd, byte[] buf, int n)
      Specified by:
      read in interface POSIX
    • write

      public int write(int fd, byte[] buf, int n)
      Specified by:
      write in interface POSIX
    • read

      public int read(int fd, ByteBuffer buf, int n)
      Specified by:
      read in interface POSIX
    • write

      public int write(int fd, ByteBuffer buf, int n)
      Specified by:
      write in interface POSIX
    • pread

      public int pread(int fd, byte[] buf, int n, int offset)
      Specified by:
      pread in interface POSIX
    • pwrite

      public int pwrite(int fd, byte[] buf, int n, int offset)
      Specified by:
      pwrite in interface POSIX
    • pread

      public int pread(int fd, ByteBuffer buf, int n, int offset)
      Specified by:
      pread in interface POSIX
    • pwrite

      public int pwrite(int fd, ByteBuffer buf, int n, int offset)
      Specified by:
      pwrite in interface POSIX
    • lseek

      public int lseek(int fd, long offset, int whence)
      Specified by:
      lseek in interface POSIX
    • lseekLong

      public long lseekLong(int fd, long offset, int whence)
      Specified by:
      lseekLong in interface POSIX
    • pipe

      public int pipe(int[] fds)
      Specified by:
      pipe in interface POSIX
    • socketpair

      public int socketpair(int domain, int type, int protocol, int[] fds)
      Specified by:
      socketpair in interface POSIX
    • sendmsg

      public int sendmsg(int socket, MsgHdr message, int flags)
      Specified by:
      sendmsg in interface POSIX
    • recvmsg

      public int recvmsg(int socket, MsgHdr message, int flags)
      Specified by:
      recvmsg in interface POSIX
    • truncate

      public int truncate(CharSequence path, long length)
      Specified by:
      truncate in interface POSIX
    • ftruncate

      public int ftruncate(int fd, long offset)
      Specified by:
      ftruncate in interface POSIX
    • rename

      public int rename(CharSequence oldName, CharSequence newName)
      Specified by:
      rename in interface POSIX
    • getcwd

      public String getcwd()
      Specified by:
      getcwd in interface POSIX
    • fsync

      public int fsync(int fd)
      Specified by:
      fsync in interface POSIX
    • fdatasync

      public int fdatasync(int fd)
      Specified by:
      fdatasync in interface POSIX
    • mkfifo

      public int mkfifo(String path, int mode)
      Specified by:
      mkfifo in interface POSIX
    • gethostname

      public String gethostname()
      Specified by:
      gethostname in interface POSIX
    • daemon

      public int daemon(int nochdir, int noclose)
      Specified by:
      daemon in interface POSIX
    • getgroups

      public long[] getgroups()
      Specified by:
      getgroups in interface POSIX
    • getgroups

      public int getgroups(int size, int[] groups)
      Specified by:
      getgroups in interface POSIX
    • nl_langinfo

      public String nl_langinfo(int item)
      Specified by:
      nl_langinfo in interface POSIX
    • setlocale

      public String setlocale(int category, String locale)
      Specified by:
      setlocale in interface POSIX
    • strerror

      public String strerror(int code)
      Specified by:
      strerror in interface POSIX
    • allocateTimeval

      public Timeval allocateTimeval()
      Specified by:
      allocateTimeval in interface POSIX
    • gettimeofday

      public int gettimeofday(Timeval tv)
      Specified by:
      gettimeofday in interface POSIX