case SYS_accept: return sys_accept(a,b,c);
case SYS_shutdown: return sys_shutdown(a,b);
case SYS_sysctl: return sys_sysctl(a,b,c,d,e,f);
+ case SYS_sendto: return sys_sendto(a,b,c,d,e,f);
+ case SYS_recvfrom: return sys_recvfrom(a,b,c,d,e,f);
+ case SYS_select: return sys_select(a,b,c,d,e);
default: return super._syscall(syscall,a,b,c,d,e,f);
}
return n;
}
- // FEATURE: UDP is totally broken
-
static class SocketFD extends FD {
public static final int TYPE_STREAM = 0;
public static final int TYPE_DGRAM = 1;
int flags;
int options;
- Object o;
+
+ Socket s;
+ ServerSocket ss;
+ DatagramSocket ds;
+
InetAddress bindAddr;
int bindPort = -1;
+ InetAddress connectAddr;
+ int connectPort = -1;
+
DatagramPacket dp;
InputStream is;
OutputStream os;
- public SocketFD(int type) { flags = type; }
+ private static final byte[] EMPTY = new byte[0];
+ public SocketFD(int type) {
+ flags = type;
+ if(type == TYPE_DGRAM)
+ dp = new DatagramPacket(EMPTY,0);
+ }
public void setOptions() {
try {
- if(o != null && type() == TYPE_STREAM && !listen()) {
- Platform.socketSetKeepAlive((Socket)o,(options & SO_KEEPALIVE) != 0);
+ if(s != null && type() == TYPE_STREAM && !listen()) {
+ Platform.socketSetKeepAlive(s,(options & SO_KEEPALIVE) != 0);
}
} catch(SocketException e) {
if(STDERR_DIAG) e.printStackTrace();
}
public void _close() {
- if(o != null) {
- try {
- if(type() == TYPE_STREAM) {
- if(listen()) ((ServerSocket)o).close();
- else ((Socket)o).close();
- } else {
- ((DatagramSocket)o).close();
- }
- } catch(IOException e) {
- /* ignore */
- }
+ try {
+ if(s != null) s.close();
+ if(ss != null) ss.close();
+ if(ds != null) ds.close();
+ } catch(IOException e) {
+ /* ignore */
}
}
public int read(byte[] a, int off, int length) throws ErrnoException {
- if(type() == TYPE_STREAM) {
- if(is == null) throw new ErrnoException(EPIPE);
- try {
- int n = is.read(a,off,length);
- return n < 0 ? 0 : n;
- } catch(IOException e) {
- throw new ErrnoException(EIO);
- }
- } else {
- if(off != 0) throw new IllegalArgumentException("off must be 0");
- DatagramSocket ds = (DatagramSocket) o;
- dp.setData(a);
- dp.setLength(length);
- try {
- ds.receive(dp);
- } catch(IOException e) {
- throw new ErrnoException(EIO);
- }
- return dp.getLength();
+ if(type() == TYPE_DGRAM) return recvfrom(a,off,length,null,null);
+ if(is == null) throw new ErrnoException(EPIPE);
+ try {
+ int n = is.read(a,off,length);
+ return n < 0 ? 0 : n;
+ } catch(IOException e) {
+ throw new ErrnoException(EIO);
}
}
+ public int recvfrom(byte[] a, int off, int length, InetAddress[] sockAddr, int[] port) throws ErrnoException {
+ if(type() == TYPE_STREAM) return read(a,off,length);
+
+ if(off != 0) throw new IllegalArgumentException("off must be 0");
+ dp.setData(a);
+ dp.setLength(length);
+ try {
+ if(ds == null) ds = new DatagramSocket();
+ ds.receive(dp);
+ } catch(IOException e) {
+ if(STDERR_DIAG) e.printStackTrace();
+ throw new ErrnoException(EIO);
+ }
+ if(sockAddr != null) {
+ sockAddr[0] = dp.getAddress();
+ port[0] = dp.getPort();
+ }
+ return dp.getLength();
+ }
+
public int write(byte[] a, int off, int length) throws ErrnoException {
- if(type() == TYPE_STREAM) {
- if(os == null) throw new ErrnoException(EPIPE);
- try {
- os.write(a,off,length);
- return length;
- } catch(IOException e) {
- throw new ErrnoException(EIO);
- }
- } else {
- if(off != 0) throw new IllegalArgumentException("off must be 0");
- DatagramSocket ds = (DatagramSocket) o;
- dp.setData(a);
- dp.setLength(length);
- try {
- ds.send(dp);
- } catch(IOException e) {
- throw new ErrnoException(EIO);
- }
- return dp.getLength();
+ if(type() == TYPE_DGRAM) return sendto(a,off,length,null,-1);
+
+ if(os == null) throw new ErrnoException(EPIPE);
+ try {
+ os.write(a,off,length);
+ return length;
+ } catch(IOException e) {
+ throw new ErrnoException(EIO);
}
}
+
+ public int sendto(byte[] a, int off, int length, InetAddress destAddr, int destPort) throws ErrnoException {
+ if(off != 0) throw new IllegalArgumentException("off must be 0");
+ if(type() == TYPE_STREAM) return write(a,off,length);
+
+ if(destAddr == null) {
+ destAddr = connectAddr;
+ destPort = connectPort;
+
+ if(destAddr == null) throw new ErrnoException(ENOTCONN);
+ }
+
+ dp.setAddress(destAddr);
+ dp.setPort(destPort);
+ dp.setData(a);
+ dp.setLength(length);
+
+ try {
+ if(ds == null) ds = new DatagramSocket();
+ ds.send(dp);
+ } catch(IOException e) {
+ if(STDERR_DIAG) e.printStackTrace();
+ if("Network is unreachable".equals(e.getMessage())) throw new ErrnoException(EHOSTUNREACH);
+ throw new ErrnoException(EIO);
+ }
+ return dp.getLength();
+ }
public int flags() { return O_RDWR; }
public FStat _fstat() { return new SocketFStat(); }
private int sys_connect(int fdn, int addr, int namelen) throws ErrnoException, FaultException {
SocketFD fd = getSocketFD(fdn);
- if(fd.type() == SocketFD.TYPE_STREAM && fd.o != null) return -EISCONN;
+ if(fd.type() == SocketFD.TYPE_STREAM && (fd.s != null || fd.ss != null)) return -EISCONN;
int word1 = memRead(addr);
if( ((word1 >>> 16)&0xff) != AF_INET) return -EAFNOSUPPORT;
int port = word1 & 0xffff;
return -EADDRNOTAVAIL;
}
+ fd.connectAddr = inetAddr;
+ fd.connectPort = port;
+
try {
switch(fd.type()) {
case SocketFD.TYPE_STREAM: {
Socket s = new Socket(inetAddr,port);
- fd.o = s;
+ fd.s = s;
fd.setOptions();
fd.is = s.getInputStream();
fd.os = s.getOutputStream();
break;
}
- case SocketFD.TYPE_DGRAM: {
- if(fd.dp == null) fd.dp = new DatagramPacket(null,0);
- fd.dp.setAddress(inetAddr);
- fd.dp.setPort(port);
+ case SocketFD.TYPE_DGRAM:
break;
- }
default:
throw new Error("should never happen");
}
private int sys_bind(int fdn, int addr, int namelen) throws FaultException, ErrnoException {
SocketFD fd = getSocketFD(fdn);
- if(fd.type() == SocketFD.TYPE_STREAM && fd.o != null) return -EISCONN;
+ if(fd.type() == SocketFD.TYPE_STREAM && (fd.s != null || fd.ss != null)) return -EISCONN;
int word1 = memRead(addr);
if( ((word1 >>> 16)&0xff) != AF_INET) return -EAFNOSUPPORT;
int port = word1 & 0xffff;
return 0;
}
case SocketFD.TYPE_DGRAM: {
- DatagramSocket s = (DatagramSocket) fd.o;
- if(s != null) s.close();
+ if(fd.ds != null) fd.ds.close();
try {
- fd.o = inetAddr != null ? new DatagramSocket(port,inetAddr) : new DatagramSocket(port);
+ fd.ds = inetAddr != null ? new DatagramSocket(port,inetAddr) : new DatagramSocket(port);
} catch(IOException e) {
return -EADDRINUSE;
}
private int sys_listen(int fdn, int backlog) throws ErrnoException {
SocketFD fd = getSocketFD(fdn);
if(fd.type() != SocketFD.TYPE_STREAM) return -EOPNOTSUPP;
- if(fd.o != null) return -EISCONN;
+ if(fd.ss != null || fd.s != null) return -EISCONN;
if(fd.bindPort < 0) return -EOPNOTSUPP;
try {
- fd.o = new ServerSocket(fd.bindPort,backlog,fd.bindAddr);
+ fd.ss = new ServerSocket(fd.bindPort,backlog,fd.bindAddr);
fd.flags |= SocketFD.LISTEN;
return 0;
} catch(IOException e) {
int size = memRead(lenaddr);
- ServerSocket s = (ServerSocket) fd.o;
+ ServerSocket s = fd.ss;
Socket client;
try {
client = s.accept();
}
SocketFD clientFD = new SocketFD(SocketFD.TYPE_STREAM);
- clientFD.o = client;
+ clientFD.s = client;
try {
clientFD.is = client.getInputStream();
clientFD.os = client.getOutputStream();
private int sys_shutdown(int fdn, int how) throws ErrnoException {
SocketFD fd = getSocketFD(fdn);
if(fd.type() != SocketFD.TYPE_STREAM || fd.listen()) return -EOPNOTSUPP;
- if(fd.o == null) return -ENOTCONN;
+ if(fd.s == null) return -ENOTCONN;
- Socket s = (Socket) fd.o;
+ Socket s = fd.s;
try {
if(how == SHUT_RD || how == SHUT_RDWR) Platform.socketHalfClose(s,false);
return 0;
}
+ private int sys_sendto(int fdn, int addr, int count, int flags, int destAddr, int socklen) throws ErrnoException,ReadFaultException {
+ SocketFD fd = getSocketFD(fdn);
+ if(flags != 0) throw new ErrnoException(EINVAL);
+
+ int word1 = memRead(destAddr);
+ if( ((word1 >>> 16)&0xff) != AF_INET) return -EAFNOSUPPORT;
+ int port = word1 & 0xffff;
+ InetAddress inetAddr;
+ byte[] ip = new byte[4];
+ copyin(destAddr+4,ip,4);
+ try {
+ inetAddr = Platform.inetAddressFromBytes(ip);
+ } catch(UnknownHostException e) {
+ return -EADDRNOTAVAIL;
+ }
+
+ count = Math.min(count,MAX_CHUNK);
+ byte[] buf = byteBuf(count);
+ copyin(addr,buf,count);
+ try {
+ return fd.sendto(buf,0,count,inetAddr,port);
+ } catch(ErrnoException e) {
+ if(e.errno == EPIPE) exit(128+13,true);
+ throw e;
+ }
+ }
+
+ private int sys_recvfrom(int fdn, int addr, int count, int flags, int sourceAddr, int socklenAddr) throws ErrnoException, FaultException {
+ SocketFD fd = getSocketFD(fdn);
+ if(flags != 0) throw new ErrnoException(EINVAL);
+
+ InetAddress[] inetAddr = sourceAddr == 0 ? null : new InetAddress[1];
+ int[] port = sourceAddr == 0 ? null : new int[1];
+
+ count = Math.min(count,MAX_CHUNK);
+ byte[] buf = byteBuf(count);
+ int n = fd.recvfrom(buf,0,count,inetAddr,port);
+ copyout(buf,addr,n);
+
+ if(sourceAddr != 0) {
+ memWrite(sourceAddr,(AF_INET << 16) | port[0]);
+ byte[] ip = inetAddr[0].getAddress();
+ copyout(ip,sourceAddr+4,4);
+ }
+
+ return n;
+ }
+
+ private int sys_select(int n, int readFDs, int writeFDs, int exceptFDs, int timevalAddr) throws ReadFaultException, ErrnoException {
+ return -ENOSYS;
+ }
+
private static String hostName() {
try {
return InetAddress.getLocalHost().getHostName();
public static final int SYS_listen = 62;
public static final int SYS_bind = 63;
public static final int SYS_shutdown = 64;
+ public static final int SYS_sendto = 65;
+ public static final int SYS_recvfrom = 66;
+ public static final int SYS_select = 67;
public static final int AF_INET = 2;
public static final int SOCK_STREAM = 1;
public static final int SOCK_DGRAM = 2;
public static final int SHUT_WR = 1;
public static final int SHUT_RDWR = 2;
public static final int INADDR_ANY = 0;
- public static final int CTL_MAXNAME = 12;
- public static final int CTL_UNSPEC = 0; /* unused */
- public static final int CTL_KERN = 1; /* "high kernel": proc, limits */
- public static final int CTL_VM = 2; /* virtual memory */
- public static final int CTL_VFS = 3; /* file system, mount type is next */
- public static final int CTL_NET = 4; /* network, see socket.h */
- public static final int CTL_DEBUG = 5; /* debugging parameters */
- public static final int CTL_HW = 6; /* generic cpu/io */
- public static final int CTL_MACHDEP = 7; /* machine dependent */
- public static final int CTL_USER = 8; /* user-level */
- public static final int CTL_P1003_1B = 9; /* POSIX 1003.1B */
- public static final int CTL_MAXID = 10; /* number of valid top-level ids */
- public static final int KERN_OSTYPE = 1; /* string: system version */
- public static final int KERN_OSRELEASE = 2; /* string: system release */
- public static final int KERN_OSREV = 3; /* int: system revision */
- public static final int KERN_VERSION = 4; /* string: compile time info */
- public static final int KERN_MAXVNODES = 5; /* int: max vnodes */
- public static final int KERN_MAXPROC = 6; /* int: max processes */
- public static final int KERN_MAXFILES = 7; /* int: max open files */
- public static final int KERN_ARGMAX = 8; /* int: max arguments to exec */
- public static final int KERN_SECURELVL = 9; /* int: system security level */
- public static final int KERN_HOSTNAME = 10; /* string: hostname */
- public static final int KERN_HOSTID = 11; /* int: host identifier */
- public static final int KERN_CLOCKRATE = 12; /* struct: struct clockrate */
- public static final int KERN_VNODE = 13; /* struct: vnode structures */
- public static final int KERN_PROC = 14; /* struct: process entries */
- public static final int KERN_FILE = 15; /* struct: file entries */
- public static final int KERN_PROF = 16; /* node: kernel profiling info */
- public static final int KERN_POSIX1 = 17; /* int: POSIX.1 version */
- public static final int KERN_NGROUPS = 18; /* int: # of supplemental group ids */
- public static final int KERN_JOB_CONTROL = 19; /* int: is job control available */
- public static final int KERN_SAVED_IDS = 20; /* int: saved set-user/group-ID */
- public static final int KERN_BOOTTIME = 21; /* struct: time kernel was booted */
- public static final int KERN_NISDOMAINNAME = 22; /* string: YP domain name */
- public static final int KERN_UPDATEINTERVAL = 23; /* int: update process sleep time */
- public static final int KERN_OSRELDATE = 24; /* int: OS release date */
- public static final int KERN_NTP_PLL = 25; /* node: NTP PLL control */
- public static final int KERN_BOOTFILE = 26; /* string: name of booted kernel */
- public static final int KERN_MAXFILESPERPROC = 27; /* int: max open files per proc */
- public static final int KERN_MAXPROCPERUID = 28; /* int: max processes per uid */
- public static final int KERN_DUMPDEV = 29; /* dev_t: device to dump on */
- public static final int KERN_IPC = 30; /* node: anything related to IPC */
- public static final int KERN_DUMMY = 31; /* unused */
- public static final int KERN_PS_STRINGS = 32; /* int: address of PS_STRINGS */
- public static final int KERN_USRSTACK = 33; /* int: address of USRSTACK */
- public static final int KERN_LOGSIGEXIT = 34; /* int: do we log sigexit procs? */
- public static final int KERN_MAXID = 35; /* number of valid kern ids */
- public static final int KERN_PROC_ALL = 0; /* everything */
- public static final int KERN_PROC_PID = 1; /* by process id */
- public static final int KERN_PROC_PGRP = 2; /* by process group id */
- public static final int KERN_PROC_SESSION = 3; /* by session of pid */
- public static final int KERN_PROC_TTY = 4; /* by controlling tty */
- public static final int KERN_PROC_UID = 5; /* by effective uid */
- public static final int KERN_PROC_RUID = 6; /* by real uid */
- public static final int KERN_PROC_ARGS = 7; /* get/set arguments/proctitle */
- public static final int KIPC_MAXSOCKBUF = 1; /* int: max size of a socket buffer */
- public static final int KIPC_SOCKBUF_WASTE = 2; /* int: wastage factor in sockbuf */
- public static final int KIPC_SOMAXCONN = 3; /* int: max length of connection q */
- public static final int KIPC_MAX_LINKHDR = 4; /* int: max length of link header */
- public static final int KIPC_MAX_PROTOHDR = 5; /* int: max length of network header */
- public static final int KIPC_MAX_HDR = 6; /* int: max total length of headers */
- public static final int KIPC_MAX_DATALEN = 7; /* int: max length of data? */
- public static final int KIPC_MBSTAT = 8; /* struct: mbuf usage statistics */
- public static final int KIPC_NMBCLUSTERS = 9; /* int: maximum mbuf clusters */
- public static final int HW_MACHINE = 1; /* string: machine class */
- public static final int HW_MODEL = 2; /* string: specific machine model */
- public static final int HW_NCPU = 3; /* int: number of cpus */
- public static final int HW_BYTEORDER = 4; /* int: machine byte order */
- public static final int HW_PHYSMEM = 5; /* int: total memory */
- public static final int HW_USERMEM = 6; /* int: non-kernel memory */
- public static final int HW_PAGESIZE = 7; /* int: software page size */
- public static final int HW_DISKNAMES = 8; /* strings: disk drive names */
- public static final int HW_DISKSTATS = 9; /* struct: diskstats[] */
- public static final int HW_FLOATINGPT = 10; /* int: has HW floating point? */
- public static final int HW_MACHINE_ARCH = 11; /* string: machine architecture */
- public static final int HW_MAXID = 12; /* number of valid hw ids */
- public static final int USER_CS_PATH = 1; /* string: _CS_PATH */
- public static final int USER_BC_BASE_MAX = 2; /* int: BC_BASE_MAX */
- public static final int USER_BC_DIM_MAX = 3; /* int: BC_DIM_MAX */
- public static final int USER_BC_SCALE_MAX = 4; /* int: BC_SCALE_MAX */
- public static final int USER_BC_STRING_MAX = 5; /* int: BC_STRING_MAX */
- public static final int USER_COLL_WEIGHTS_MAX = 6; /* int: COLL_WEIGHTS_MAX */
- public static final int USER_EXPR_NEST_MAX = 7; /* int: EXPR_NEST_MAX */
- public static final int USER_LINE_MAX = 8; /* int: LINE_MAX */
- public static final int USER_RE_DUP_MAX = 9; /* int: RE_DUP_MAX */
- public static final int USER_POSIX2_VERSION = 10; /* int: POSIX2_VERSION */
- public static final int USER_POSIX2_C_BIND = 11; /* int: POSIX2_C_BIND */
- public static final int USER_POSIX2_C_DEV = 12; /* int: POSIX2_C_DEV */
- public static final int USER_POSIX2_CHAR_TERM = 13; /* int: POSIX2_CHAR_TERM */
- public static final int USER_POSIX2_FORT_DEV = 14; /* int: POSIX2_FORT_DEV */
- public static final int USER_POSIX2_FORT_RUN = 15; /* int: POSIX2_FORT_RUN */
- public static final int USER_POSIX2_LOCALEDEF = 16; /* int: POSIX2_LOCALEDEF */
- public static final int USER_POSIX2_SW_DEV = 17; /* int: POSIX2_SW_DEV */
- public static final int USER_POSIX2_UPE = 18; /* int: POSIX2_UPE */
- public static final int USER_STREAM_MAX = 19; /* int: POSIX2_STREAM_MAX */
- public static final int USER_TZNAME_MAX = 20; /* int: POSIX2_TZNAME_MAX */
- public static final int USER_MAXID = 21; /* number of valid user ids */
- public static final int CTL_P1003_1B_ASYNCHRONOUS_IO = 1; /* boolean */
- public static final int CTL_P1003_1B_MAPPED_FILES = 2; /* boolean */
- public static final int CTL_P1003_1B_MEMLOCK = 3; /* boolean */
- public static final int CTL_P1003_1B_MEMLOCK_RANGE = 4; /* boolean */
- public static final int CTL_P1003_1B_MEMORY_PROTECTION = 5; /* boolean */
- public static final int CTL_P1003_1B_MESSAGE_PASSING = 6; /* boolean */
- public static final int CTL_P1003_1B_PRIORITIZED_IO = 7; /* boolean */
- public static final int CTL_P1003_1B_PRIORITY_SCHEDULING = 8; /* boolean */
- public static final int CTL_P1003_1B_REALTIME_SIGNALS = 9; /* boolean */
- public static final int CTL_P1003_1B_SEMAPHORES = 10; /* boolean */
- public static final int CTL_P1003_1B_FSYNC = 11; /* boolean */
- public static final int CTL_P1003_1B_SHARED_MEMORY_OBJECTS = 12; /* boolean */
- public static final int CTL_P1003_1B_SYNCHRONIZED_IO = 13; /* boolean */
- public static final int CTL_P1003_1B_TIMERS = 14; /* boolean */
- public static final int CTL_P1003_1B_AIO_LISTIO_MAX = 15; /* int */
- public static final int CTL_P1003_1B_AIO_MAX = 16; /* int */
- public static final int CTL_P1003_1B_AIO_PRIO_DELTA_MAX = 17; /* int */
- public static final int CTL_P1003_1B_DELAYTIMER_MAX = 18; /* int */
- public static final int CTL_P1003_1B_MQ_OPEN_MAX = 19; /* int */
- public static final int CTL_P1003_1B_PAGESIZE = 20; /* int */
- public static final int CTL_P1003_1B_RTSIG_MAX = 21; /* int */
- public static final int CTL_P1003_1B_SEM_NSEMS_MAX = 22; /* int */
- public static final int CTL_P1003_1B_SEM_VALUE_MAX = 23; /* int */
- public static final int CTL_P1003_1B_SIGQUEUE_MAX = 24; /* int */
- public static final int CTL_P1003_1B_TIMER_MAX = 25; /* int */
- public static final int CTL_P1003_1B_MAXID = 26;
public static final int EPERM = 1; /* Not super-user */
public static final int ENOENT = 2; /* No such file or directory */
public static final int ESRCH = 3; /* No such process */
public static final int EXPR_NEST_MAX = 32; /* max expressions nested in expr(1) */
public static final int LINE_MAX = 2048; /* max bytes in an input line */
public static final int RE_DUP_MAX = 255; /* max RE's in interval notation */
+ public static final int CTL_MAXNAME = 12;
+ public static final int CTL_UNSPEC = 0; /* unused */
+ public static final int CTL_KERN = 1; /* "high kernel": proc, limits */
+ public static final int CTL_VM = 2; /* virtual memory */
+ public static final int CTL_VFS = 3; /* file system, mount type is next */
+ public static final int CTL_NET = 4; /* network, see socket.h */
+ public static final int CTL_DEBUG = 5; /* debugging parameters */
+ public static final int CTL_HW = 6; /* generic cpu/io */
+ public static final int CTL_MACHDEP = 7; /* machine dependent */
+ public static final int CTL_USER = 8; /* user-level */
+ public static final int CTL_P1003_1B = 9; /* POSIX 1003.1B */
+ public static final int CTL_MAXID = 10; /* number of valid top-level ids */
+ public static final int KERN_OSTYPE = 1; /* string: system version */
+ public static final int KERN_OSRELEASE = 2; /* string: system release */
+ public static final int KERN_OSREV = 3; /* int: system revision */
+ public static final int KERN_VERSION = 4; /* string: compile time info */
+ public static final int KERN_MAXVNODES = 5; /* int: max vnodes */
+ public static final int KERN_MAXPROC = 6; /* int: max processes */
+ public static final int KERN_MAXFILES = 7; /* int: max open files */
+ public static final int KERN_ARGMAX = 8; /* int: max arguments to exec */
+ public static final int KERN_SECURELVL = 9; /* int: system security level */
+ public static final int KERN_HOSTNAME = 10; /* string: hostname */
+ public static final int KERN_HOSTID = 11; /* int: host identifier */
+ public static final int KERN_CLOCKRATE = 12; /* struct: struct clockrate */
+ public static final int KERN_VNODE = 13; /* struct: vnode structures */
+ public static final int KERN_PROC = 14; /* struct: process entries */
+ public static final int KERN_FILE = 15; /* struct: file entries */
+ public static final int KERN_PROF = 16; /* node: kernel profiling info */
+ public static final int KERN_POSIX1 = 17; /* int: POSIX.1 version */
+ public static final int KERN_NGROUPS = 18; /* int: # of supplemental group ids */
+ public static final int KERN_JOB_CONTROL = 19; /* int: is job control available */
+ public static final int KERN_SAVED_IDS = 20; /* int: saved set-user/group-ID */
+ public static final int KERN_BOOTTIME = 21; /* struct: time kernel was booted */
+ public static final int KERN_NISDOMAINNAME = 22; /* string: YP domain name */
+ public static final int KERN_UPDATEINTERVAL = 23; /* int: update process sleep time */
+ public static final int KERN_OSRELDATE = 24; /* int: OS release date */
+ public static final int KERN_NTP_PLL = 25; /* node: NTP PLL control */
+ public static final int KERN_BOOTFILE = 26; /* string: name of booted kernel */
+ public static final int KERN_MAXFILESPERPROC = 27; /* int: max open files per proc */
+ public static final int KERN_MAXPROCPERUID = 28; /* int: max processes per uid */
+ public static final int KERN_DUMPDEV = 29; /* dev_t: device to dump on */
+ public static final int KERN_IPC = 30; /* node: anything related to IPC */
+ public static final int KERN_DUMMY = 31; /* unused */
+ public static final int KERN_PS_STRINGS = 32; /* int: address of PS_STRINGS */
+ public static final int KERN_USRSTACK = 33; /* int: address of USRSTACK */
+ public static final int KERN_LOGSIGEXIT = 34; /* int: do we log sigexit procs? */
+ public static final int KERN_MAXID = 35; /* number of valid kern ids */
+ public static final int KERN_PROC_ALL = 0; /* everything */
+ public static final int KERN_PROC_PID = 1; /* by process id */
+ public static final int KERN_PROC_PGRP = 2; /* by process group id */
+ public static final int KERN_PROC_SESSION = 3; /* by session of pid */
+ public static final int KERN_PROC_TTY = 4; /* by controlling tty */
+ public static final int KERN_PROC_UID = 5; /* by effective uid */
+ public static final int KERN_PROC_RUID = 6; /* by real uid */
+ public static final int KERN_PROC_ARGS = 7; /* get/set arguments/proctitle */
+ public static final int KIPC_MAXSOCKBUF = 1; /* int: max size of a socket buffer */
+ public static final int KIPC_SOCKBUF_WASTE = 2; /* int: wastage factor in sockbuf */
+ public static final int KIPC_SOMAXCONN = 3; /* int: max length of connection q */
+ public static final int KIPC_MAX_LINKHDR = 4; /* int: max length of link header */
+ public static final int KIPC_MAX_PROTOHDR = 5; /* int: max length of network header */
+ public static final int KIPC_MAX_HDR = 6; /* int: max total length of headers */
+ public static final int KIPC_MAX_DATALEN = 7; /* int: max length of data? */
+ public static final int KIPC_MBSTAT = 8; /* struct: mbuf usage statistics */
+ public static final int KIPC_NMBCLUSTERS = 9; /* int: maximum mbuf clusters */
+ public static final int HW_MACHINE = 1; /* string: machine class */
+ public static final int HW_MODEL = 2; /* string: specific machine model */
+ public static final int HW_NCPU = 3; /* int: number of cpus */
+ public static final int HW_BYTEORDER = 4; /* int: machine byte order */
+ public static final int HW_PHYSMEM = 5; /* int: total memory */
+ public static final int HW_USERMEM = 6; /* int: non-kernel memory */
+ public static final int HW_PAGESIZE = 7; /* int: software page size */
+ public static final int HW_DISKNAMES = 8; /* strings: disk drive names */
+ public static final int HW_DISKSTATS = 9; /* struct: diskstats[] */
+ public static final int HW_FLOATINGPT = 10; /* int: has HW floating point? */
+ public static final int HW_MACHINE_ARCH = 11; /* string: machine architecture */
+ public static final int HW_MAXID = 12; /* number of valid hw ids */
+ public static final int USER_CS_PATH = 1; /* string: _CS_PATH */
+ public static final int USER_BC_BASE_MAX = 2; /* int: BC_BASE_MAX */
+ public static final int USER_BC_DIM_MAX = 3; /* int: BC_DIM_MAX */
+ public static final int USER_BC_SCALE_MAX = 4; /* int: BC_SCALE_MAX */
+ public static final int USER_BC_STRING_MAX = 5; /* int: BC_STRING_MAX */
+ public static final int USER_COLL_WEIGHTS_MAX = 6; /* int: COLL_WEIGHTS_MAX */
+ public static final int USER_EXPR_NEST_MAX = 7; /* int: EXPR_NEST_MAX */
+ public static final int USER_LINE_MAX = 8; /* int: LINE_MAX */
+ public static final int USER_RE_DUP_MAX = 9; /* int: RE_DUP_MAX */
+ public static final int USER_POSIX2_VERSION = 10; /* int: POSIX2_VERSION */
+ public static final int USER_POSIX2_C_BIND = 11; /* int: POSIX2_C_BIND */
+ public static final int USER_POSIX2_C_DEV = 12; /* int: POSIX2_C_DEV */
+ public static final int USER_POSIX2_CHAR_TERM = 13; /* int: POSIX2_CHAR_TERM */
+ public static final int USER_POSIX2_FORT_DEV = 14; /* int: POSIX2_FORT_DEV */
+ public static final int USER_POSIX2_FORT_RUN = 15; /* int: POSIX2_FORT_RUN */
+ public static final int USER_POSIX2_LOCALEDEF = 16; /* int: POSIX2_LOCALEDEF */
+ public static final int USER_POSIX2_SW_DEV = 17; /* int: POSIX2_SW_DEV */
+ public static final int USER_POSIX2_UPE = 18; /* int: POSIX2_UPE */
+ public static final int USER_STREAM_MAX = 19; /* int: POSIX2_STREAM_MAX */
+ public static final int USER_TZNAME_MAX = 20; /* int: POSIX2_TZNAME_MAX */
+ public static final int USER_MAXID = 21; /* number of valid user ids */
+ public static final int CTL_P1003_1B_ASYNCHRONOUS_IO = 1; /* boolean */
+ public static final int CTL_P1003_1B_MAPPED_FILES = 2; /* boolean */
+ public static final int CTL_P1003_1B_MEMLOCK = 3; /* boolean */
+ public static final int CTL_P1003_1B_MEMLOCK_RANGE = 4; /* boolean */
+ public static final int CTL_P1003_1B_MEMORY_PROTECTION = 5; /* boolean */
+ public static final int CTL_P1003_1B_MESSAGE_PASSING = 6; /* boolean */
+ public static final int CTL_P1003_1B_PRIORITIZED_IO = 7; /* boolean */
+ public static final int CTL_P1003_1B_PRIORITY_SCHEDULING = 8; /* boolean */
+ public static final int CTL_P1003_1B_REALTIME_SIGNALS = 9; /* boolean */
+ public static final int CTL_P1003_1B_SEMAPHORES = 10; /* boolean */
+ public static final int CTL_P1003_1B_FSYNC = 11; /* boolean */
+ public static final int CTL_P1003_1B_SHARED_MEMORY_OBJECTS = 12; /* boolean */
+ public static final int CTL_P1003_1B_SYNCHRONIZED_IO = 13; /* boolean */
+ public static final int CTL_P1003_1B_TIMERS = 14; /* boolean */
+ public static final int CTL_P1003_1B_AIO_LISTIO_MAX = 15; /* int */
+ public static final int CTL_P1003_1B_AIO_MAX = 16; /* int */
+ public static final int CTL_P1003_1B_AIO_PRIO_DELTA_MAX = 17; /* int */
+ public static final int CTL_P1003_1B_DELAYTIMER_MAX = 18; /* int */
+ public static final int CTL_P1003_1B_MQ_OPEN_MAX = 19; /* int */
+ public static final int CTL_P1003_1B_PAGESIZE = 20; /* int */
+ public static final int CTL_P1003_1B_RTSIG_MAX = 21; /* int */
+ public static final int CTL_P1003_1B_SEM_NSEMS_MAX = 22; /* int */
+ public static final int CTL_P1003_1B_SEM_VALUE_MAX = 23; /* int */
+ public static final int CTL_P1003_1B_SIGQUEUE_MAX = 24; /* int */
+ public static final int CTL_P1003_1B_TIMER_MAX = 25; /* int */
+ public static final int CTL_P1003_1B_MAXID = 26;
public static final int F_UNLKSYS = 4;
public static final int F_CNVT = 12;
public static final int F_SETFD = 2;