Initial Spring 2016 commit.
This commit is contained in:
50
kern/include/kern/endian.h
Normal file
50
kern/include/kern/endian.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2009
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_ENDIAN_H_
|
||||
#define _KERN_ENDIAN_H_
|
||||
|
||||
/*
|
||||
* Machine-independent and exported endianness definitions.
|
||||
*
|
||||
* Note: get these via <endian.h> in the kernel and <arpa/inet.h> in
|
||||
* userland.
|
||||
*
|
||||
* This is the historic BSD way of defining endianness.
|
||||
*/
|
||||
|
||||
#define _LITTLE_ENDIAN 1234
|
||||
#define _BIG_ENDIAN 4321
|
||||
#define _PDP_ENDIAN 3412
|
||||
|
||||
/* This defines _BYTE_ORDER to one of the above. */
|
||||
#include <kern/machine/endian.h>
|
||||
|
||||
|
||||
#endif /* _KERN_ENDIAN_H_ */
|
114
kern/include/kern/errmsg.h
Normal file
114
kern/include/kern/errmsg.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_ERRMSG_H_
|
||||
#define _KERN_ERRMSG_H_
|
||||
|
||||
/*
|
||||
* Error strings.
|
||||
* This table must agree with kern/errno.h.
|
||||
*
|
||||
* Note that since this actually defines sys_errlist and sys_nerrlist, it
|
||||
* should only be included in one file. For the kernel, that file is
|
||||
* lib/misc.c; for userland it's lib/libc/strerror.c.
|
||||
*/
|
||||
const char *const sys_errlist[] = {
|
||||
"Operation succeeded", /* 0 */
|
||||
"Function not implemented", /* ENOSYS */
|
||||
"(undefined error 2)", /* unused */
|
||||
"Out of memory", /* ENOMEM */
|
||||
"Operation would block", /* EAGAIN (also EWOULDBLOCK) */
|
||||
"Interrupted system call", /* EINTR */
|
||||
"Bad memory reference", /* EFAULT */
|
||||
"String too long", /* ENAMETOOLONG */
|
||||
"Invalid argument", /* EINVAL */
|
||||
"Operation not permitted", /* EPERM */
|
||||
"Permission denied", /* EACCES */
|
||||
"Too many processes", /* EMPROC (EPROCLIM in Unix) */
|
||||
"Too many processes in system",/* ENPROC */
|
||||
"File is not executable", /* ENOEXEC */
|
||||
"Argument list too long", /* E2BIG */
|
||||
"No such process", /* ESRCH */
|
||||
"No child processes", /* ECHILD */
|
||||
"Not a directory", /* ENOTDIR */
|
||||
"Is a directory", /* EISDIR */
|
||||
"No such file or directory", /* ENOENT */
|
||||
"Too many levels of symbolic links",/* ELOOP */
|
||||
"Directory not empty", /* ENOTEMPTY */
|
||||
"File or object exists", /* EEXIST */
|
||||
"Too many hard links", /* EMLINK */
|
||||
"Cross-device link", /* EXDEV */
|
||||
"No such device", /* ENODEV */
|
||||
"Device not available", /* ENXIO */
|
||||
"Device or resource busy", /* EBUSY */
|
||||
"Too many open files", /* EMFILE */
|
||||
"Too many open files in system",/* ENFILE */
|
||||
"Bad file number", /* EBADF */
|
||||
"Invalid or inappropriate ioctl",/* EIOCTL (ENOTTY in Unix) */
|
||||
"Input/output error", /* EIO */
|
||||
"Illegal seek", /* ESPIPE */
|
||||
"Broken pipe", /* EPIPE */
|
||||
"Read-only file system", /* EROFS */
|
||||
"No space left on device", /* ENOSPC */
|
||||
"Disc quota exceeded", /* EDQUOT */
|
||||
"File too large", /* EFBIG */
|
||||
"Invalid file type or format",/* EFTYPE */
|
||||
"Argument out of range", /* EDOM */
|
||||
"Result out of range", /* ERANGE */
|
||||
"Invalid multibyte character sequence",/* EILSEQ */
|
||||
"Not a socket", /* ENOTSOCK */
|
||||
"Is a socket", /* EISSOCK (EOPNOTSUPP in Unix) */
|
||||
"Socket is already connected",/* EISCONN */
|
||||
"Socket is not connected", /* ENOTCONN */
|
||||
"Socket has been shut down", /* ESHUTDOWN */
|
||||
"Protocol family not supported",/* EPFNOSUPPORT */
|
||||
"Socket type not supported", /* ESOCKTNOSUPPORT */
|
||||
"Protocol not supported", /* EPROTONOSUPPORT */
|
||||
"Protocol wrong type for socket",/* EPROTOTYPE */
|
||||
"Address family not supported by protocol family",/* EAFNOSUPPORT */
|
||||
"Protocol option not available",/* ENOPROTOOPT */
|
||||
"Address already in use", /* EADDRINUSE */
|
||||
"Cannot assign requested address",/* EADDRNOTAVAIL */
|
||||
"Network is down", /* ENETDOWN */
|
||||
"Network is unreachable", /* ENETUNREACH */
|
||||
"Host is down", /* EHOSTDOWN */
|
||||
"Host is unreachable", /* EHOSTUNREACH */
|
||||
"Connection refused", /* ECONNREFUSED */
|
||||
"Connection timed out", /* ETIMEDOUT */
|
||||
"Connection reset by peer", /* ECONNRESET */
|
||||
"Message too large", /* EMSGSIZE */
|
||||
"Threads operation not supported",/* ENOTSUP */
|
||||
};
|
||||
|
||||
/*
|
||||
* Number of entries in sys_errlist.
|
||||
*/
|
||||
const int sys_nerr = sizeof(sys_errlist)/sizeof(const char *);
|
||||
|
||||
#endif /* _KERN_ERRMSG_H_ */
|
111
kern/include/kern/errno.h
Normal file
111
kern/include/kern/errno.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_ERRNO_H_
|
||||
#define _KERN_ERRNO_H_
|
||||
|
||||
/*
|
||||
* If you change this, be sure to make appropriate corresponding changes
|
||||
* to kern/errmsg.h as well. You might also want to change the man page
|
||||
* for errno to document the new error.
|
||||
*
|
||||
* This has been changed relative to OS/161 1.x to make the grouping
|
||||
* more logical.
|
||||
*
|
||||
* Also note that this file has to work from assembler, so it should
|
||||
* contain only symbolic constants.
|
||||
*/
|
||||
|
||||
#define ENOSYS 1 /* Function not implemented */
|
||||
/* unused 2 */
|
||||
#define ENOMEM 3 /* Out of memory */
|
||||
#define EAGAIN 4 /* Operation would block */
|
||||
#define EINTR 5 /* Interrupted system call */
|
||||
#define EFAULT 6 /* Bad memory reference */
|
||||
#define ENAMETOOLONG 7 /* String too long */
|
||||
#define EINVAL 8 /* Invalid argument */
|
||||
#define EPERM 9 /* Operation not permitted */
|
||||
#define EACCES 10 /* Permission denied */
|
||||
#define EMPROC 11 /* Too many processes */
|
||||
#define ENPROC 12 /* Too many processes in system */
|
||||
#define ENOEXEC 13 /* File is not executable */
|
||||
#define E2BIG 14 /* Argument list too long */
|
||||
#define ESRCH 15 /* No such process */
|
||||
#define ECHILD 16 /* No child processes */
|
||||
#define ENOTDIR 17 /* Not a directory */
|
||||
#define EISDIR 18 /* Is a directory */
|
||||
#define ENOENT 19 /* No such file or directory */
|
||||
#define ELOOP 20 /* Too many levels of symbolic links */
|
||||
#define ENOTEMPTY 21 /* Directory not empty */
|
||||
#define EEXIST 22 /* File or object exists */
|
||||
#define EMLINK 23 /* Too many hard links */
|
||||
#define EXDEV 24 /* Cross-device link */
|
||||
#define ENODEV 25 /* No such device */
|
||||
#define ENXIO 26 /* Device not available */
|
||||
#define EBUSY 27 /* Device or resource busy */
|
||||
#define EMFILE 28 /* Too many open files */
|
||||
#define ENFILE 29 /* Too many open files in system */
|
||||
#define EBADF 30 /* Bad file number */
|
||||
#define EIOCTL 31 /* Invalid or inappropriate ioctl */
|
||||
#define EIO 32 /* Input/output error */
|
||||
#define ESPIPE 33 /* Illegal seek */
|
||||
#define EPIPE 34 /* Broken pipe */
|
||||
#define EROFS 35 /* Read-only file system */
|
||||
#define ENOSPC 36 /* No space left on device */
|
||||
#define EDQUOT 37 /* Disc quota exceeded */
|
||||
#define EFBIG 38 /* File too large */
|
||||
#define EFTYPE 39 /* Invalid file type or format */
|
||||
#define EDOM 40 /* Argument out of range */
|
||||
#define ERANGE 41 /* Result out of range */
|
||||
#define EILSEQ 42 /* Invalid multibyte character sequence */
|
||||
#define ENOTSOCK 43 /* Not a socket */
|
||||
#define EISSOCK 44 /* Is a socket */
|
||||
#define EISCONN 45 /* Socket is already connected */
|
||||
#define ENOTCONN 46 /* Socket is not connected */
|
||||
#define ESHUTDOWN 47 /* Socket has been shut down */
|
||||
#define EPFNOSUPPORT 48 /* Protocol family not supported */
|
||||
#define ESOCKTNOSUPPORT 49 /* Socket type not supported */
|
||||
#define EPROTONOSUPPORT 50 /* Protocol not supported */
|
||||
#define EPROTOTYPE 51 /* Protocol wrong type for socket */
|
||||
#define EAFNOSUPPORT 52 /* Address family not supported by protocol family */
|
||||
#define ENOPROTOOPT 53 /* Protocol option not available */
|
||||
#define EADDRINUSE 54 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 55 /* Cannot assign requested address */
|
||||
#define ENETDOWN 56 /* Network is down */
|
||||
#define ENETUNREACH 57 /* Network is unreachable */
|
||||
#define EHOSTDOWN 58 /* Host is down */
|
||||
#define EHOSTUNREACH 59 /* Host is unreachable */
|
||||
#define ECONNREFUSED 60 /* Connection refused */
|
||||
#define ETIMEDOUT 61 /* Connection timed out */
|
||||
#define ECONNRESET 62 /* Connection reset by peer */
|
||||
#define EMSGSIZE 63 /* Message too large */
|
||||
#define ENOTSUP 64 /* Threads operation not supported */
|
||||
|
||||
|
||||
#endif /* _KERN_ERRNO_H_ */
|
100
kern/include/kern/fcntl.h
Normal file
100
kern/include/kern/fcntl.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_FCNTL_H_
|
||||
#define _KERN_FCNTL_H_
|
||||
|
||||
/*
|
||||
* Constants for libc's <fcntl.h>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Important
|
||||
*/
|
||||
|
||||
/* Flags for open: choose one of these: */
|
||||
#define O_RDONLY 0 /* Open for read */
|
||||
#define O_WRONLY 1 /* Open for write */
|
||||
#define O_RDWR 2 /* Open for read and write */
|
||||
/* then or in any of these: */
|
||||
#define O_CREAT 4 /* Create file if it doesn't exist */
|
||||
#define O_EXCL 8 /* With O_CREAT, fail if file already exists */
|
||||
#define O_TRUNC 16 /* Truncate file upon open */
|
||||
#define O_APPEND 32 /* All writes happen at EOF (optional feature) */
|
||||
#define O_NOCTTY 64 /* Required by POSIX, != 0, but does nothing */
|
||||
|
||||
/* Additional related definition */
|
||||
#define O_ACCMODE 3 /* mask for O_RDONLY/O_WRONLY/O_RDWR */
|
||||
|
||||
/*
|
||||
* Not so important
|
||||
*/
|
||||
|
||||
/* operation codes for flock() */
|
||||
#define LOCK_SH 1 /* shared lock */
|
||||
#define LOCK_EX 2 /* exclusive lock */
|
||||
#define LOCK_UN 3 /* release the lock */
|
||||
#define LOCK_NB 4 /* flag: don't block */
|
||||
|
||||
/*
|
||||
* Mostly pretty useless
|
||||
*/
|
||||
|
||||
/* fcntl() operations */
|
||||
#define F_DUPFD 0 /* like dup() but not quite */
|
||||
#define F_GETFD 1 /* get per-handle flags */
|
||||
#define F_SETFD 2 /* set per-handle flags */
|
||||
#define F_GETFL 3 /* get per-file flags (O_* open flags) */
|
||||
#define F_SETFL 4 /* set per-file flags (O_* open flags) */
|
||||
#define F_GETOWN 5 /* get process/pgroup for SIGURG and SIGIO */
|
||||
#define F_SETOWN 6 /* set process/pgroup for SIGURG and SIGIO */
|
||||
#define F_GETLK 7 /* inspect record locks */
|
||||
#define F_SETLK 8 /* acquire record locks nonblocking */
|
||||
#define F_SETLKW 9 /* acquire record locks and wait */
|
||||
|
||||
/* flag for F_GETFD and F_SETFD */
|
||||
#define FD_CLOEXEC 1 /* close-on-exec */
|
||||
|
||||
/* modes for fcntl (F_GETLK/SETLK) locking */
|
||||
#define F_RDLCK 0 /* shared lock */
|
||||
#define F_WRLCK 1 /* exclusive lock */
|
||||
#define F_UNLCK 2 /* unlock */
|
||||
|
||||
/* struct for fcntl (F_GETLK/SETLK) locking */
|
||||
struct flock {
|
||||
off_t l_start; /* place in file */
|
||||
int l_whence; /* SEEK_SET, SEEK_CUR, or SEEK_END */
|
||||
int l_type; /* F_RDLCK or F_WRLCK */
|
||||
off_t l_len; /* length of locked region */
|
||||
pid_t l_pid; /* process that holds the lock */
|
||||
};
|
||||
|
||||
|
||||
#endif /* _KERN_FCNTL_H_ */
|
39
kern/include/kern/ioctl.h
Normal file
39
kern/include/kern/ioctl.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_IOCTL_H_
|
||||
#define _KERN_IOCTL_H_
|
||||
|
||||
/*
|
||||
* ioctl operation codes
|
||||
*/
|
||||
|
||||
/* (none yet) */
|
||||
|
||||
#endif /* _KERN_IOCTL_H_*/
|
68
kern/include/kern/iovec.h
Normal file
68
kern/include/kern/iovec.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_IOVEC_H_
|
||||
#define _KERN_IOVEC_H_
|
||||
|
||||
/*
|
||||
* iovec structure, used in the readv/writev scatter/gather I/O calls,
|
||||
* and within the kernel for keeping track of blocks of data for I/O.
|
||||
*/
|
||||
|
||||
struct iovec {
|
||||
/*
|
||||
* For maximum type safety, when in the kernel, distinguish
|
||||
* user pointers from kernel pointers.
|
||||
*
|
||||
* (A pointer is a user pointer if it *came* from userspace,
|
||||
* not necessarily if it *points* to userspace. If a system
|
||||
* call passes 0xdeadbeef, it points to the kernel, but it's
|
||||
* still a user pointer.)
|
||||
*
|
||||
* In userspace, there are only user pointers; also, the name
|
||||
* iov_base is defined by POSIX.
|
||||
*
|
||||
* Note that to work properly (without extra unwanted fiddling
|
||||
* around) this scheme requires that void* and userptr_t have
|
||||
* the same machine representation. Machines where this isn't
|
||||
* true are theoretically possible under the C standard, but
|
||||
* do not exist in practice.
|
||||
*/
|
||||
#ifdef _KERNEL
|
||||
union {
|
||||
userptr_t iov_ubase; /* user-supplied pointer */
|
||||
void *iov_kbase; /* kernel-supplied pointer */
|
||||
};
|
||||
#else
|
||||
void *iov_base; /* user-supplied pointer */
|
||||
#endif
|
||||
size_t iov_len; /* Length of data */
|
||||
};
|
||||
|
||||
#endif /* _KERN_IOVEC_H_ */
|
109
kern/include/kern/limits.h
Normal file
109
kern/include/kern/limits.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_LIMITS_H_
|
||||
#define _KERN_LIMITS_H_
|
||||
|
||||
/*
|
||||
* Constants for libc's <limits.h> - system limits.
|
||||
*
|
||||
* The symbols are prefixed with __ here to avoid namespace pollution
|
||||
* in libc. Use <limits.h> (in either userspace or the kernel) to get
|
||||
* the proper names.
|
||||
*
|
||||
* These are Unix-style limits that Unix defines; you can change them
|
||||
* around or add others as needed or as are appropriate to your system
|
||||
* design.
|
||||
*
|
||||
* Likewise, the default values provided here are fairly reasonable,
|
||||
* but you can change them around pretty freely and userspace code
|
||||
* should adapt. Do change these as needed to match your
|
||||
* implementation.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Important, both as part of the system call API and for system behavior.
|
||||
*
|
||||
* 255 for NAME_MAX and 1024 for PATH_MAX are conventional. ARG_MAX
|
||||
* should be at least 16K. In real systems it often runs to 256K or
|
||||
* more.
|
||||
*/
|
||||
|
||||
/* Longest filename (without directory) not including null terminator */
|
||||
#define __NAME_MAX 255
|
||||
|
||||
/* Longest full path name */
|
||||
#define __PATH_MAX 1024
|
||||
|
||||
/* Max bytes for an exec function (should be at least 16K) */
|
||||
#define __ARG_MAX (64 * 1024)
|
||||
|
||||
|
||||
/*
|
||||
* Important for system behavior, but not a big part of the API.
|
||||
*
|
||||
* Most modern systems don't have OPEN_MAX at all, and instead go by
|
||||
* whatever limit is set with setrlimit().
|
||||
*/
|
||||
|
||||
/* Min value for a process ID (that can be assigned to a user process) */
|
||||
#define __PID_MIN 2
|
||||
|
||||
/* Max value for a process ID (change this to match your implementation) */
|
||||
#define __PID_MAX 32767
|
||||
|
||||
/* Max open files per process */
|
||||
#define __OPEN_MAX 128
|
||||
|
||||
/* Max bytes for atomic pipe I/O -- see description in the pipe() man page */
|
||||
#define __PIPE_BUF 512
|
||||
|
||||
|
||||
/*
|
||||
* Not so important parts of the API. (Especially in OS/161 where we
|
||||
* don't do credentials by default.)
|
||||
*/
|
||||
|
||||
/* Max number of supplemental group IDs in process credentials */
|
||||
#define __NGROUPS_MAX 32
|
||||
|
||||
/* Max login name size (for setlogin/getlogin), incl. null */
|
||||
#define __LOGIN_NAME_MAX 17
|
||||
|
||||
|
||||
/*
|
||||
* Not very important at all.
|
||||
*/
|
||||
|
||||
/* Max number of iovec structures at once for readv/writev/preadv/pwritev */
|
||||
#define __IOV_MAX 1024
|
||||
|
||||
|
||||
#endif /* _KERN_LIMITS_H_ */
|
45
kern/include/kern/reboot.h
Normal file
45
kern/include/kern/reboot.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_REBOOT_H_
|
||||
#define _KERN_REBOOT_H_
|
||||
|
||||
/*
|
||||
* Constants for libc's <sys/reboot.h> and the reboot() system call.
|
||||
* (Not all that important.)
|
||||
*/
|
||||
|
||||
|
||||
/* Codes for reboot */
|
||||
#define RB_REBOOT 0 /* Reboot system */
|
||||
#define RB_HALT 1 /* Halt system and do not reboot */
|
||||
#define RB_POWEROFF 2 /* Halt system and power off */
|
||||
|
||||
|
||||
#endif /* _KERN_REBOOT_H_ */
|
92
kern/include/kern/resource.h
Normal file
92
kern/include/kern/resource.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_RESOURCE_H_
|
||||
#define _KERN_RESOURCE_H_
|
||||
|
||||
/*
|
||||
* Definitions for resource usage and limits.
|
||||
*
|
||||
* Not very important.
|
||||
*/
|
||||
|
||||
|
||||
/* priorities for setpriority() */
|
||||
#define PRIO_MIN (-20)
|
||||
#define PRIO_MAX 20
|
||||
|
||||
/* "which" codes for setpriority() */
|
||||
#define PRIO_PROCESS 0
|
||||
#define PRIO_PGRP 1
|
||||
#define PRIO_USER 2
|
||||
|
||||
/* flags for getrusage() */
|
||||
#define RUSAGE_SELF 0
|
||||
#define RUSAGE_CHILDREN (-1)
|
||||
|
||||
struct rusage {
|
||||
struct timeval ru_utime;
|
||||
struct timeval ru_stime;
|
||||
__size_t ru_maxrss; /* maximum RSS during lifespan (kb) */
|
||||
__counter_t ru_ixrss; /* text memory usage (kb-ticks) */
|
||||
__counter_t ru_idrss; /* data memory usage (kb-ticks) */
|
||||
__counter_t ru_isrss; /* stack memory usage (kb-ticks) */
|
||||
__counter_t ru_minflt; /* minor VM faults (count) */
|
||||
__counter_t ru_majflt; /* major VM faults (count) */
|
||||
__counter_t ru_nswap; /* whole-process swaps (count) */
|
||||
__counter_t ru_inblock; /* file blocks read (count) */
|
||||
__counter_t ru_oublock; /* file blocks written (count) */
|
||||
__counter_t ru_msgrcv; /* socket/pipe packets rcv'd (count) */
|
||||
__counter_t ru_msgsnd; /* socket/pipe packets sent (count) */
|
||||
__counter_t ru_nsignals; /* signals delivered (count) */
|
||||
__counter_t ru_nvcsw; /* voluntary context switches (count)*/
|
||||
__counter_t ru_nivcsw; /* involuntary ditto (count) */
|
||||
};
|
||||
|
||||
/* limit codes for getrusage/setrusage */
|
||||
|
||||
#define RLIMIT_NPROC 0 /* max procs per user (count) */
|
||||
#define RLIMIT_NOFILE 1 /* max open files per proc (count) */
|
||||
#define RLIMIT_CPU 2 /* cpu usage (seconds) */
|
||||
#define RLIMIT_DATA 3 /* max .data/sbrk size (bytes) */
|
||||
#define RLIMIT_STACK 4 /* max stack size (bytes) */
|
||||
#define RLIMIT_MEMLOCK 5 /* max locked memory region (bytes) */
|
||||
#define RLIMIT_RSS 6 /* max RSS (bytes) */
|
||||
#define RLIMIT_CORE 7 /* core file size (bytes) */
|
||||
#define RLIMIT_FSIZE 8 /* max file size (bytes) */
|
||||
#define __RLIMIT_NUM 9 /* number of limits */
|
||||
|
||||
struct rlimit {
|
||||
__rlim_t rlim_cur; /* soft limit */
|
||||
__rlim_t rlim_max; /* hard limit */
|
||||
};
|
||||
|
||||
#define RLIM_INFINITY (~(__rlim_t)0)
|
||||
|
||||
#endif /* _KERN_RESOURCE_H_ */
|
47
kern/include/kern/seek.h
Normal file
47
kern/include/kern/seek.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_SEEK_H_
|
||||
#define _KERN_SEEK_H_
|
||||
|
||||
/*
|
||||
* Codes for lseek(), which are shared in libc between <fcntl.h> and
|
||||
* <unistd.h> and thus get their own file.
|
||||
*
|
||||
* These are pretty important. Back in the day (like 20+ years ago)
|
||||
* people would often just write the values 0, 1, and 2, but that's
|
||||
* really not recommended.
|
||||
*/
|
||||
|
||||
#define SEEK_SET 0 /* Seek relative to beginning of file */
|
||||
#define SEEK_CUR 1 /* Seek relative to current position in file */
|
||||
#define SEEK_END 2 /* Seek relative to end of file */
|
||||
|
||||
|
||||
#endif /* _KERN_SEEK_H_ */
|
101
kern/include/kern/sfs.h
Normal file
101
kern/include/kern/sfs.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009, 2014
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_SFS_H_
|
||||
#define _KERN_SFS_H_
|
||||
|
||||
|
||||
/*
|
||||
* SFS definitions visible to userspace. This covers the on-disk format
|
||||
* and is used by tools that work on SFS volumes, such as mksfs.
|
||||
*/
|
||||
|
||||
#define SFS_MAGIC 0xabadf001 /* magic number identifying us */
|
||||
#define SFS_BLOCKSIZE 512 /* size of our blocks */
|
||||
#define SFS_VOLNAME_SIZE 32 /* max length of volume name */
|
||||
#define SFS_NDIRECT 15 /* # of direct blocks in inode */
|
||||
#define SFS_NINDIRECT 1 /* # of indirect blocks in inode */
|
||||
#define SFS_NDINDIRECT 0 /* # of 2x indirect blocks in inode */
|
||||
#define SFS_NTINDIRECT 0 /* # of 3x indirect blocks in inode */
|
||||
#define SFS_DBPERIDB 128 /* # direct blks per indirect blk */
|
||||
#define SFS_NAMELEN 60 /* max length of filename */
|
||||
#define SFS_SUPER_BLOCK 0 /* block the superblock lives in */
|
||||
#define SFS_FREEMAP_START 2 /* 1st block of the freemap */
|
||||
#define SFS_NOINO 0 /* inode # for free dir entry */
|
||||
#define SFS_ROOTDIR_INO 1 /* loc'n of the root dir inode */
|
||||
|
||||
/* Number of bits in a block */
|
||||
#define SFS_BITSPERBLOCK (SFS_BLOCKSIZE * CHAR_BIT)
|
||||
|
||||
/* Utility macro */
|
||||
#define SFS_ROUNDUP(a,b) ((((a)+(b)-1)/(b))*b)
|
||||
|
||||
/* Size of free block bitmap (in bits) */
|
||||
#define SFS_FREEMAPBITS(nblocks) SFS_ROUNDUP(nblocks, SFS_BITSPERBLOCK)
|
||||
|
||||
/* Size of free block bitmap (in blocks) */
|
||||
#define SFS_FREEMAPBLOCKS(nblocks) (SFS_FREEMAPBITS(nblocks)/SFS_BITSPERBLOCK)
|
||||
|
||||
/* File types for sfi_type */
|
||||
#define SFS_TYPE_INVAL 0 /* Should not appear on disk */
|
||||
#define SFS_TYPE_FILE 1
|
||||
#define SFS_TYPE_DIR 2
|
||||
|
||||
/*
|
||||
* On-disk superblock
|
||||
*/
|
||||
struct sfs_superblock {
|
||||
uint32_t sb_magic; /* Magic number; should be SFS_MAGIC */
|
||||
uint32_t sb_nblocks; /* Number of blocks in fs */
|
||||
char sb_volname[SFS_VOLNAME_SIZE]; /* Name of this volume */
|
||||
uint32_t reserved[118]; /* unused, set to 0 */
|
||||
};
|
||||
|
||||
/*
|
||||
* On-disk inode
|
||||
*/
|
||||
struct sfs_dinode {
|
||||
uint32_t sfi_size; /* Size of this file (bytes) */
|
||||
uint16_t sfi_type; /* One of SFS_TYPE_* above */
|
||||
uint16_t sfi_linkcount; /* # hard links to this file */
|
||||
uint32_t sfi_direct[SFS_NDIRECT]; /* Direct blocks */
|
||||
uint32_t sfi_indirect; /* Indirect block */
|
||||
uint32_t sfi_waste[128-3-SFS_NDIRECT]; /* unused space, set to 0 */
|
||||
};
|
||||
|
||||
/*
|
||||
* On-disk directory entry
|
||||
*/
|
||||
struct sfs_direntry {
|
||||
uint32_t sfd_ino; /* Inode number */
|
||||
char sfd_name[SFS_NAMELEN]; /* Filename */
|
||||
};
|
||||
|
||||
|
||||
#endif /* _KERN_SFS_H_ */
|
131
kern/include/kern/signal.h
Normal file
131
kern/include/kern/signal.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
* the permission of UNIX System Laboratories, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)signal.h 8.4 (Berkeley) 5/4/95
|
||||
*/
|
||||
|
||||
#ifndef _KERN_SIGNAL_H_
|
||||
#define _KERN_SIGNAL_H_
|
||||
|
||||
/*
|
||||
* Machine-independent definitions for signals.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The signals.
|
||||
*
|
||||
* The values of many of these are "well known", particularly 1, 9,
|
||||
* 10, and 11.
|
||||
*
|
||||
* Note that Unix signals are a semantic cesspool; many have special
|
||||
* properties or are supposed to interact with the system in special
|
||||
* ways. It is gross.
|
||||
*/
|
||||
|
||||
#define SIGHUP 1 /* Hangup */
|
||||
#define SIGINT 2 /* Interrupt (^C) */
|
||||
#define SIGQUIT 3 /* Quit (typically ^\) */
|
||||
#define SIGILL 4 /* Illegal instruction */
|
||||
#define SIGTRAP 5 /* Breakpoint trap */
|
||||
#define SIGABRT 6 /* abort() call */
|
||||
#define SIGEMT 7 /* Emulator trap */
|
||||
#define SIGFPE 8 /* Floating point exception */
|
||||
#define SIGKILL 9 /* Hard kill (unblockable) */
|
||||
#define SIGBUS 10 /* Bus error, typically bad pointer alignment*/
|
||||
#define SIGSEGV 11 /* Segmentation fault */
|
||||
#define SIGSYS 12 /* Bad system call */
|
||||
#define SIGPIPE 13 /* Broken pipe */
|
||||
#define SIGALRM 14 /* alarm() expired */
|
||||
#define SIGTERM 15 /* Termination requested (default kill) */
|
||||
#define SIGURG 16 /* Urgent data on socket */
|
||||
#define SIGSTOP 17 /* Hard process stop (unblockable) */
|
||||
#define SIGTSTP 18 /* Terminal stop (^Z) */
|
||||
#define SIGCONT 19 /* Time to continue after stop */
|
||||
#define SIGCHLD 20 /* Child process exited */
|
||||
#define SIGTTIN 21 /* Stop on tty read while in background */
|
||||
#define SIGTTOU 22 /* Stop on tty write while in background */
|
||||
#define SIGIO 23 /* Nonblocking or async I/O is now ready */
|
||||
#define SIGXCPU 24 /* CPU time resource limit exceeded */
|
||||
#define SIGXFSZ 25 /* File size resource limit exceeded */
|
||||
#define SIGVTALRM 26 /* Like SIGALRM but in virtual time */
|
||||
#define SIGPROF 27 /* Profiling timer */
|
||||
#define SIGWINCH 28 /* Window size change on tty */
|
||||
#define SIGINFO 29 /* Information request (typically ^T) */
|
||||
#define SIGUSR1 20 /* Application-defined */
|
||||
#define SIGUSR2 31 /* Application-defined */
|
||||
#define SIGPWR 32 /* Power failure */
|
||||
#define _NSIG 32
|
||||
|
||||
|
||||
/* Type for a set of signals; used by e.g. sigprocmask(). */
|
||||
typedef __u32 sigset_t;
|
||||
|
||||
/* flags for sigaction.sa_flags */
|
||||
#define SA_ONSTACK 1 /* Use sigaltstack() stack. */
|
||||
#define SA_RESTART 2 /* Restart syscall instead of interrupting. */
|
||||
#define SA_RESETHAND 4 /* Clear handler after one usage. */
|
||||
|
||||
/* codes for sigprocmask() */
|
||||
#define SIG_BLOCK 1 /* Block selected signals. */
|
||||
#define SIG_UNBLOCK 2 /* Unblock selected signals. */
|
||||
#define SIG_SETMASK 3 /* Set mask to the selected signals. */
|
||||
|
||||
/* Type for a signal handler function. */
|
||||
typedef void (*__sigfunc)(int);
|
||||
|
||||
/* Magic values for signal handlers. */
|
||||
#define SIG_DFL ((__sigfunc) 0) /* Default behavior. */
|
||||
#define SIG_IGN ((__sigfunc) 1) /* Ignore the signal. */
|
||||
|
||||
/*
|
||||
* Struct for sigaction().
|
||||
*/
|
||||
struct sigaction {
|
||||
__sigfunc sa_handler;
|
||||
sigset_t sa_mask;
|
||||
unsigned sa_flags;
|
||||
};
|
||||
|
||||
/*
|
||||
* Struct for sigaltstack().
|
||||
* (not very important)
|
||||
*/
|
||||
struct sigaltstack {
|
||||
void *ss_sp;
|
||||
size_t ss_size;
|
||||
unsigned ss_flags;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _KERN_SIGNAL_H_ */
|
116
kern/include/kern/socket.h
Normal file
116
kern/include/kern/socket.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_SOCKET_H_
|
||||
#define _KERN_SOCKET_H_
|
||||
|
||||
/*
|
||||
* Socket-related definitions, for <sys/socket.h>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Important
|
||||
*/
|
||||
|
||||
/* Socket types that we (might) support. */
|
||||
#define SOCK_STREAM 1 /* stream */
|
||||
#define SOCK_DGRAM 2 /* packet */
|
||||
#define SOCK_RAW 3 /* raw packet */
|
||||
|
||||
/* Address families that we (might) support. */
|
||||
#define AF_UNSPEC 0
|
||||
#define AF_UNIX 1
|
||||
#define AF_INET 2
|
||||
#define AF_INET6 3
|
||||
|
||||
/* Protocol families. Pointless layer of indirection in the standard API. */
|
||||
#define PF_UNSPEC AF_UNSPEC
|
||||
#define PF_UNIX AF_UNIX
|
||||
#define PF_INET AF_INET
|
||||
#define PF_INET6 AF_INET6
|
||||
|
||||
/*
|
||||
* Socket address structures. Socket addresses are polymorphic, and
|
||||
* the polymorphism is handled by casting pointers. It's fairly gross,
|
||||
* but way too deeply standardized to ever change.
|
||||
*
|
||||
* Each address family defines a sockaddr type (sockaddr_un,
|
||||
* sockaddr_in, etc.) struct sockaddr is the common prefix of all
|
||||
* these, and struct sockaddr_storage is defined to be large enough to
|
||||
* hold any of them.
|
||||
*
|
||||
* The complex padding in sockaddr_storage forces it to be aligned,
|
||||
* which wouldn't happen if it were just a char array.
|
||||
*/
|
||||
|
||||
struct sockaddr {
|
||||
__u8 sa_len;
|
||||
__u8 sa_family;
|
||||
};
|
||||
|
||||
#define _SS_SIZE 128
|
||||
struct sockaddr_storage {
|
||||
__u8 ss_len;
|
||||
__u8 ss_family;
|
||||
__u8 __ss_pad1;
|
||||
__u8 __ss_pad2;
|
||||
__u32 __ss_pad3;
|
||||
__u64 __ss_pad4;
|
||||
char __ss_pad5[_SS_SIZE - sizeof(__u64) - sizeof(__u32) - 4*sizeof(__u8)];
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Not very important.
|
||||
*/
|
||||
|
||||
/*
|
||||
* msghdr structures for sendmsg() and recvmsg().
|
||||
*/
|
||||
|
||||
struct msghdr {
|
||||
void *msg_name; /* really sockaddr; address, or null */
|
||||
socklen_t msg_namelen; /* size of msg_name object, or 0 */
|
||||
struct iovec *msg_iov; /* I/O buffers */
|
||||
int msg_iovlen; /* number of iovecs */
|
||||
void *msg_control; /* auxiliary data area, or null */
|
||||
socklen_t msg_controllen; /* size of msg_control area */
|
||||
int msg_flags; /* flags */
|
||||
};
|
||||
|
||||
struct cmsghdr {
|
||||
socklen_t cmsg_len; /* length of control data, including header */
|
||||
int cmsg_level; /* protocol layer item originates from */
|
||||
int cmsg_type; /* protocol-specific message type */
|
||||
/* char cmsg_data[];*/ /* data follows the header */
|
||||
};
|
||||
|
||||
|
||||
#endif /* _KERN_SOCKET_H_ */
|
71
kern/include/kern/stat.h
Normal file
71
kern/include/kern/stat.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_STAT_H_
|
||||
#define _KERN_STAT_H_
|
||||
|
||||
/*
|
||||
* The stat structure, for returning file information via stat(),
|
||||
* fstat(), and lstat().
|
||||
*
|
||||
* Fields corresponding to things you aren't implementing should be
|
||||
* set to zero.
|
||||
*
|
||||
* The file types are in kern/stattypes.h.
|
||||
*/
|
||||
struct stat {
|
||||
/* Essential fields */
|
||||
off_t st_size; /* file size in bytes */
|
||||
mode_t st_mode; /* file type and protection mode */
|
||||
nlink_t st_nlink; /* number of hard links */
|
||||
blkcnt_t st_blocks; /* number of blocks file is using */
|
||||
|
||||
/* Identity */
|
||||
dev_t st_dev; /* device object lives on */
|
||||
ino_t st_ino; /* inode number (serial number) of object */
|
||||
dev_t st_rdev; /* device object is (if a device) */
|
||||
|
||||
/* Timestamps */
|
||||
time_t st_atime; /* last access time: seconds */
|
||||
time_t st_ctime; /* inode change time: seconds */
|
||||
time_t st_mtime; /* modification time: seconds */
|
||||
__u32 st_atimensec; /* last access time: nanoseconds */
|
||||
__u32 st_ctimensec; /* inode change time: nanoseconds */
|
||||
__u32 st_mtimensec; /* modification time: nanoseconds */
|
||||
|
||||
/* Permissions (also st_mode) */
|
||||
uid_t st_uid; /* owner */
|
||||
gid_t st_gid; /* group */
|
||||
|
||||
/* Other */
|
||||
__u32 st_gen; /* file generation number (root only) */
|
||||
blksize_t st_blksize; /* recommended I/O block size */
|
||||
};
|
||||
|
||||
#endif /* _KERN_STAT_H_ */
|
55
kern/include/kern/stattypes.h
Normal file
55
kern/include/kern/stattypes.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_STATTYPES_H_
|
||||
#define _KERN_STATTYPES_H_
|
||||
|
||||
/*
|
||||
* Further supporting material for stat(), fstat(), and lstat().
|
||||
*
|
||||
* File types for st_mode. (The permissions are the low 12 bits.)
|
||||
*
|
||||
* These are also used, shifted right by those 12 bits, in struct
|
||||
* dirent in libc, which is why they get their own file.
|
||||
*
|
||||
* Non-underscore versions of the names can be gotten from <stat.h>
|
||||
* (kernel) or <sys/stat.h> (userland).
|
||||
*/
|
||||
|
||||
#define _S_IFMT 070000 /* mask for type of file */
|
||||
#define _S_IFREG 010000 /* ordinary regular file */
|
||||
#define _S_IFDIR 020000 /* directory */
|
||||
#define _S_IFLNK 030000 /* symbolic link */
|
||||
#define _S_IFIFO 040000 /* pipe or named pipe */
|
||||
#define _S_IFSOCK 050000 /* socket */
|
||||
#define _S_IFCHR 060000 /* character device */
|
||||
#define _S_IFBLK 070000 /* block device */
|
||||
|
||||
|
||||
#endif /* _KERN_STATTYPES_H_ */
|
203
kern/include/kern/syscall.h
Normal file
203
kern/include/kern/syscall.h
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_SYSCALL_H_
|
||||
#define _KERN_SYSCALL_H_
|
||||
|
||||
/*
|
||||
* System call numbers.
|
||||
*
|
||||
* To foster compatibility, this file contains a number for every
|
||||
* more-or-less standard Unix system call that someone might
|
||||
* conceivably implement on OS/161. The commented-out ones are ones
|
||||
* we're pretty sure you won't be implementing. The others, you might
|
||||
* or might not. Check your own course materials to find out what's
|
||||
* specifically required of you.
|
||||
*
|
||||
* Caution: this file is parsed by a shell script to generate the assembly
|
||||
* language system call stubs. Don't add weird stuff between the markers.
|
||||
*/
|
||||
|
||||
/*CALLBEGIN*/
|
||||
|
||||
// -- Process-related --
|
||||
#define SYS_fork 0
|
||||
#define SYS_vfork 1
|
||||
#define SYS_execv 2
|
||||
#define SYS__exit 3
|
||||
#define SYS_waitpid 4
|
||||
#define SYS_getpid 5
|
||||
#define SYS_getppid 6
|
||||
// (virtual memory)
|
||||
#define SYS_sbrk 7
|
||||
#define SYS_mmap 8
|
||||
#define SYS_munmap 9
|
||||
#define SYS_mprotect 10
|
||||
//#define SYS_madvise 11
|
||||
//#define SYS_mincore 12
|
||||
//#define SYS_mlock 13
|
||||
//#define SYS_munlock 14
|
||||
//#define SYS_munlockall 15
|
||||
//#define SYS_minherit 16
|
||||
// (security/credentials)
|
||||
#define SYS_umask 17
|
||||
#define SYS_issetugid 18
|
||||
#define SYS_getresuid 19
|
||||
#define SYS_setresuid 20
|
||||
#define SYS_getresgid 21
|
||||
#define SYS_setresgid 22
|
||||
#define SYS_getgroups 23
|
||||
#define SYS_setgroups 24
|
||||
#define SYS___getlogin 25
|
||||
#define SYS___setlogin 26
|
||||
// (signals)
|
||||
#define SYS_kill 27
|
||||
#define SYS_sigaction 28
|
||||
#define SYS_sigpending 29
|
||||
#define SYS_sigprocmask 30
|
||||
#define SYS_sigsuspend 31
|
||||
#define SYS_sigreturn 32
|
||||
//#define SYS_sigaltstack 33
|
||||
// (resource tracking and usage)
|
||||
//#define SYS_wait4 34
|
||||
//#define SYS_getrusage 35
|
||||
// (resource limits)
|
||||
//#define SYS_getrlimit 36
|
||||
//#define SYS_setrlimit 37
|
||||
// (process priority control)
|
||||
//#define SYS_getpriority 38
|
||||
//#define SYS_setpriority 39
|
||||
// (process groups, sessions, and job control)
|
||||
//#define SYS_getpgid 40
|
||||
//#define SYS_setpgid 41
|
||||
//#define SYS_getsid 42
|
||||
//#define SYS_setsid 43
|
||||
// (userlevel debugging)
|
||||
//#define SYS_ptrace 44
|
||||
|
||||
// -- File-handle-related --
|
||||
#define SYS_open 45
|
||||
#define SYS_pipe 46
|
||||
#define SYS_dup 47
|
||||
#define SYS_dup2 48
|
||||
#define SYS_close 49
|
||||
#define SYS_read 50
|
||||
#define SYS_pread 51
|
||||
//#define SYS_readv 52
|
||||
//#define SYS_preadv 53
|
||||
#define SYS_getdirentry 54
|
||||
#define SYS_write 55
|
||||
#define SYS_pwrite 56
|
||||
//#define SYS_writev 57
|
||||
//#define SYS_pwritev 58
|
||||
#define SYS_lseek 59
|
||||
#define SYS_flock 60
|
||||
#define SYS_ftruncate 61
|
||||
#define SYS_fsync 62
|
||||
#define SYS_fcntl 63
|
||||
#define SYS_ioctl 64
|
||||
#define SYS_select 65
|
||||
#define SYS_poll 66
|
||||
|
||||
// -- Pathname-related --
|
||||
#define SYS_link 67
|
||||
#define SYS_remove 68
|
||||
#define SYS_mkdir 69
|
||||
#define SYS_rmdir 70
|
||||
#define SYS_mkfifo 71
|
||||
#define SYS_rename 72
|
||||
#define SYS_access 73
|
||||
// (current directory)
|
||||
#define SYS_chdir 74
|
||||
#define SYS_fchdir 75
|
||||
#define SYS___getcwd 76
|
||||
// (symbolic links)
|
||||
#define SYS_symlink 77
|
||||
#define SYS_readlink 78
|
||||
// (mount)
|
||||
#define SYS_mount 79
|
||||
#define SYS_unmount 80
|
||||
|
||||
|
||||
// -- Any-file-related --
|
||||
#define SYS_stat 81
|
||||
#define SYS_fstat 82
|
||||
#define SYS_lstat 83
|
||||
// (timestamps)
|
||||
#define SYS_utimes 84
|
||||
#define SYS_futimes 85
|
||||
#define SYS_lutimes 86
|
||||
// (security/permissions)
|
||||
#define SYS_chmod 87
|
||||
#define SYS_chown 88
|
||||
#define SYS_fchmod 89
|
||||
#define SYS_fchown 90
|
||||
#define SYS_lchmod 91
|
||||
#define SYS_lchown 92
|
||||
// (file system info)
|
||||
//#define SYS_statfs 93
|
||||
//#define SYS_fstatfs 94
|
||||
//#define SYS_getfsstat 95
|
||||
// (POSIX dynamic system limits stuff)
|
||||
//#define SYS_pathconf 96
|
||||
//#define SYS_fpathconf 97
|
||||
|
||||
// -- Sockets and networking --
|
||||
#define SYS_socket 98
|
||||
#define SYS_bind 99
|
||||
#define SYS_connect 100
|
||||
#define SYS_listen 101
|
||||
#define SYS_accept 102
|
||||
//#define SYS_socketpair 103
|
||||
#define SYS_shutdown 104
|
||||
#define SYS_getsockname 105
|
||||
#define SYS_getpeername 106
|
||||
#define SYS_getsockopt 107
|
||||
#define SYS_setsockopt 108
|
||||
//#define SYS_recvfrom 109
|
||||
//#define SYS_sendto 110
|
||||
//#define SYS_recvmsg 111
|
||||
//#define SYS_sendmsg 112
|
||||
|
||||
// -- Time-related --
|
||||
#define SYS___time 113
|
||||
#define SYS___settime 114
|
||||
#define SYS_nanosleep 115
|
||||
//#define SYS_getitimer 116
|
||||
//#define SYS_setitimer 117
|
||||
|
||||
// -- Other --
|
||||
#define SYS_sync 118
|
||||
#define SYS_reboot 119
|
||||
//#define SYS___sysctl 120
|
||||
|
||||
/*CALLEND*/
|
||||
|
||||
|
||||
#endif /* _KERN_SYSCALL_H_ */
|
70
kern/include/kern/time.h
Normal file
70
kern/include/kern/time.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_TIME_H_
|
||||
#define _KERN_TIME_H_
|
||||
|
||||
/*
|
||||
* Time-related definitions, for <sys/time.h> and others.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Time with fractional seconds. Important. Unfortunately, to be
|
||||
* compatible, we need both timeval and timespec.
|
||||
*/
|
||||
|
||||
struct timeval {
|
||||
__time_t tv_sec; /* seconds */
|
||||
__i32 tv_usec; /* microseconds */
|
||||
};
|
||||
|
||||
struct timespec {
|
||||
__time_t tv_sec; /* seconds */
|
||||
__i32 tv_nsec; /* nanoseconds */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Bits for interval timers. Obscure and not really that important.
|
||||
*/
|
||||
|
||||
/* codes for the various timers */
|
||||
#define ITIMER_REAL 0 /* Real (wall-clock) time. */
|
||||
#define ITIMER_VIRTUAL 1 /* Virtual (when process is executing) time. */
|
||||
#define ITIMER_PROF 2 /* For execution profiling. */
|
||||
|
||||
/* structure for setitimer/getitimer */
|
||||
struct itimerval {
|
||||
struct timeval it_interval; /* Time to reload after expiry. */
|
||||
struct timeval it_value; /* Time to count. */
|
||||
};
|
||||
|
||||
|
||||
#endif /* _KERN_TIME_H_ */
|
92
kern/include/kern/types.h
Normal file
92
kern/include/kern/types.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_TYPES_H_
|
||||
#define _KERN_TYPES_H_
|
||||
|
||||
/* Get machine-dependent types. */
|
||||
#include <kern/machine/types.h>
|
||||
|
||||
/*
|
||||
* Machine-independent types visible to user level.
|
||||
*
|
||||
* Define everything with leading underscores to avoid polluting the C
|
||||
* namespace for applications.
|
||||
*
|
||||
* The C standard (and additionally the POSIX standard) define rules
|
||||
* for what families of symbol names are allowed to be used by
|
||||
* application programmers, and what families of symbol names can be
|
||||
* defined by various standard header files. The C library needs to
|
||||
* conform to those rules, to the extent reasonably practical, to make
|
||||
* sure that application code compiles and behaves as intended.
|
||||
*
|
||||
* Many of the C library's headers need to use one or more of these
|
||||
* types in places where the "real" name of the type cannot be
|
||||
* exposed, or expose the names of some of these types and not others.
|
||||
* (For example, <string.h> is supposed to define size_t, but is not
|
||||
* supposed to also define e.g. pid_t.)
|
||||
*
|
||||
* For this reason we define everything with two underscores in front
|
||||
* of it; in C such symbol names are reserved for the implementation,
|
||||
* which we are, so this file can be included anywhere in any libc
|
||||
* header without causing namespace problems. The "real" type names
|
||||
* are defined with an additional layer of typedefs; this happens for
|
||||
* the kernel in <types.h> and for userland in (mostly) <sys/types.h>
|
||||
* and also various other places as per relevant standards.
|
||||
*/
|
||||
|
||||
typedef __u32 __blkcnt_t; /* Count of blocks */
|
||||
typedef __u32 __blksize_t; /* Size of an I/O block */
|
||||
typedef __u64 __counter_t; /* Event counter */
|
||||
typedef __u32 __daddr_t; /* Disk block number */
|
||||
typedef __u32 __dev_t; /* Hardware device ID */
|
||||
typedef __u32 __fsid_t; /* Filesystem ID */
|
||||
typedef __i32 __gid_t; /* Group ID */
|
||||
typedef __u32 __in_addr_t; /* Internet address */
|
||||
typedef __u32 __in_port_t; /* Internet port number */
|
||||
typedef __u32 __ino_t; /* Inode number */
|
||||
typedef __u32 __mode_t; /* File access mode */
|
||||
typedef __u16 __nlink_t; /* Number of links (intentionally only 16 bits) */
|
||||
typedef __i64 __off_t; /* Offset within file */
|
||||
typedef __i32 __pid_t; /* Process ID */
|
||||
typedef __u64 __rlim_t; /* Resource limit quantity */
|
||||
typedef __u8 __sa_family_t;/* Socket address family */
|
||||
typedef __i64 __time_t; /* Time in seconds */
|
||||
typedef __i32 __uid_t; /* User ID */
|
||||
|
||||
typedef int __nfds_t; /* Number of file handles */
|
||||
typedef int __socklen_t; /* Socket-related length */
|
||||
|
||||
/* See note in <stdarg.h> */
|
||||
#ifdef __GNUC__
|
||||
typedef __builtin_va_list __va_list;
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _KERN_TYPES_H_ */
|
39
kern/include/kern/unistd.h
Normal file
39
kern/include/kern/unistd.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_UNISTD_H_
|
||||
#define _KERN_UNISTD_H_
|
||||
|
||||
/* Constants for read/write/etc: special file handles */
|
||||
#define STDIN_FILENO 0 /* Standard input */
|
||||
#define STDOUT_FILENO 1 /* Standard output */
|
||||
#define STDERR_FILENO 2 /* Standard error */
|
||||
|
||||
|
||||
#endif /* _KERN_UNISTD_H_ */
|
79
kern/include/kern/wait.h
Normal file
79
kern/include/kern/wait.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2008
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _KERN_WAIT_H_
|
||||
#define _KERN_WAIT_H_
|
||||
|
||||
/*
|
||||
* Definitions for wait().
|
||||
*/
|
||||
|
||||
|
||||
/* Flags for waitpid() and equivalent. */
|
||||
#define WNOHANG 1 /* Nonblocking. */
|
||||
#define WUNTRACED 2 /* Report stopping as well as exiting processes. */
|
||||
|
||||
/* Special "pids" to wait for. */
|
||||
#define WAIT_ANY (-1) /* Any child process. */
|
||||
#define WAIT_MYPGRP 0 /* Any process in the same process group. */
|
||||
|
||||
/*
|
||||
* Result encoding.
|
||||
*
|
||||
* The lowest two bits say what happened; the rest encodes up to 30
|
||||
* bits of exit code. Note that the traditional Unix encoding, which
|
||||
* is different, wastes most of the bits and can only transmit 8 bits
|
||||
* of exit code...
|
||||
*/
|
||||
#define _WWHAT(x) ((x)&3) /* lower two bits say what happened */
|
||||
#define _WVAL(x) ((x)>>2) /* the rest is the value */
|
||||
#define _MKWVAL(x) ((x)<<2) /* encode a value */
|
||||
|
||||
/* Four things can happen... */
|
||||
#define __WEXITED 0 /* Process exited by calling _exit(). */
|
||||
#define __WSIGNALED 1 /* Process received a fatal signal. */
|
||||
#define __WCORED 2 /* Process dumped core on a fatal signal. */
|
||||
#define __WSTOPPED 3 /* Process stopped (and didn't exit). */
|
||||
|
||||
/* Test macros, used by applications. */
|
||||
#define WIFEXITED(x) (_WWHAT(x)==__WEXITED)
|
||||
#define WIFSIGNALED(x) (_WWHAT(x)==__WSIGNALED || _WWHAT(x)==__WCORED)
|
||||
#define WIFSTOPPED(x) (_WWHAT(x)==__WSTOPPED)
|
||||
#define WEXITSTATUS(x) (_WVAL(x))
|
||||
#define WTERMSIG(x) (_WVAL(x))
|
||||
#define WSTOPSIG(x) (_WVAL(x))
|
||||
#define WCOREDUMP(x) (_WWHAT(x)==__WCORED)
|
||||
|
||||
/* Encoding macros, used by the kernel to generate the wait result. */
|
||||
#define _MKWAIT_EXIT(x) (_MKWVAL(x)|__WEXITED)
|
||||
#define _MKWAIT_SIG(x) (_MKWVAL(x)|__WSIGNALED)
|
||||
#define _MKWAIT_CORE(x) (_MKWVAL(x)|__WCORED)
|
||||
#define _MKWAIT_STOP(x) (_MKWVAL(x)|__WSTOPPED)
|
||||
|
||||
#endif /* _KERN_WAIT_H_ */
|
Reference in New Issue
Block a user