source: trunk/minix/include/unistd.h@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 8.7 KB
Line 
1/* The <unistd.h> header contains a few miscellaneous manifest constants. */
2
3#ifndef _UNISTD_H
4#define _UNISTD_H
5
6#ifndef _TYPES_H
7#include <sys/types.h>
8#endif
9
10/* Values used by access(). POSIX Table 2-8. */
11#define F_OK 0 /* test if file exists */
12#define X_OK 1 /* test if file is executable */
13#define W_OK 2 /* test if file is writable */
14#define R_OK 4 /* test if file is readable */
15
16/* Values used for whence in lseek(fd, offset, whence). POSIX Table 2-9. */
17#define SEEK_SET 0 /* offset is absolute */
18#define SEEK_CUR 1 /* offset is relative to current position */
19#define SEEK_END 2 /* offset is relative to end of file */
20
21/* This value is required by POSIX Table 2-10. */
22#define _POSIX_VERSION 199009L /* which standard is being conformed to */
23
24/* These three definitions are required by POSIX Sec. 8.2.1.2. */
25#define STDIN_FILENO 0 /* file descriptor for stdin */
26#define STDOUT_FILENO 1 /* file descriptor for stdout */
27#define STDERR_FILENO 2 /* file descriptor for stderr */
28
29#ifdef _MINIX
30/* How to exit the system or stop a server process. */
31#define RBT_HALT 0 /* shutdown and return to monitor */
32#define RBT_REBOOT 1 /* reboot the system through the monitor */
33#define RBT_PANIC 2 /* a server panics */
34#define RBT_MONITOR 3 /* let the monitor do this */
35#define RBT_RESET 4 /* hard reset the system */
36#define RBT_INVALID 5 /* first invalid reboot flag */
37
38#define _PM_SEG_FLAG (1L << 30) /* for read() and write() to FS by PM */
39#endif
40
41/* What system info to retrieve with sysgetinfo(). */
42#define SI_KINFO 0 /* get kernel info via PM */
43#define SI_PROC_ADDR 1 /* address of process table */
44#define SI_PROC_TAB 2 /* copy of entire process table */
45#define SI_DMAP_TAB 3 /* get device <-> driver mappings */
46#define SI_MEM_ALLOC 4 /* get memory allocation data */
47#define SI_DATA_STORE 5 /* get copy of data store */
48#define SI_LOADINFO 6 /* get copy of load average structure */
49#define SI_KPROC_TAB 7 /* copy of kernel process table */
50
51/* NULL must be defined in <unistd.h> according to POSIX Sec. 2.7.1. */
52#define NULL ((void *)0)
53
54/* The following relate to configurable system variables. POSIX Table 4-2. */
55#define _SC_ARG_MAX 1
56#define _SC_CHILD_MAX 2
57#define _SC_CLOCKS_PER_SEC 3
58#define _SC_CLK_TCK 3
59#define _SC_NGROUPS_MAX 4
60#define _SC_OPEN_MAX 5
61#define _SC_JOB_CONTROL 6
62#define _SC_SAVED_IDS 7
63#define _SC_VERSION 8
64#define _SC_STREAM_MAX 9
65#define _SC_TZNAME_MAX 10
66#define _SC_PAGESIZE 11
67#define _SC_PAGE_SIZE _SC_PAGESIZE
68
69/* The following relate to configurable pathname variables. POSIX Table 5-2. */
70#define _PC_LINK_MAX 1 /* link count */
71#define _PC_MAX_CANON 2 /* size of the canonical input queue */
72#define _PC_MAX_INPUT 3 /* type-ahead buffer size */
73#define _PC_NAME_MAX 4 /* file name size */
74#define _PC_PATH_MAX 5 /* pathname size */
75#define _PC_PIPE_BUF 6 /* pipe size */
76#define _PC_NO_TRUNC 7 /* treatment of long name components */
77#define _PC_VDISABLE 8 /* tty disable */
78#define _PC_CHOWN_RESTRICTED 9 /* chown restricted or not */
79
80/* POSIX defines several options that may be implemented or not, at the
81 * implementer's whim. This implementer has made the following choices:
82 *
83 * _POSIX_JOB_CONTROL not defined: no job control
84 * _POSIX_SAVED_IDS not defined: no saved uid/gid
85 * _POSIX_NO_TRUNC defined as -1: long path names are truncated
86 * _POSIX_CHOWN_RESTRICTED defined: you can't give away files
87 * _POSIX_VDISABLE defined: tty functions can be disabled
88 */
89#define _POSIX_NO_TRUNC (-1)
90#define _POSIX_CHOWN_RESTRICTED 1
91
92/* Function Prototypes. */
93_PROTOTYPE( void _exit, (int _status) );
94_PROTOTYPE( int access, (const char *_path, int _amode) );
95_PROTOTYPE( unsigned int alarm, (unsigned int _seconds) );
96_PROTOTYPE( int chdir, (const char *_path) );
97_PROTOTYPE( int fchdir, (int fd) );
98_PROTOTYPE( int chown, (const char *_path, _mnx_Uid_t _owner, _mnx_Gid_t _group) );
99_PROTOTYPE( int close, (int _fd) );
100_PROTOTYPE( char *ctermid, (char *_s) );
101_PROTOTYPE( char *cuserid, (char *_s) );
102_PROTOTYPE( int dup, (int _fd) );
103_PROTOTYPE( int dup2, (int _fd, int _fd2) );
104_PROTOTYPE( int execl, (const char *_path, const char *_arg, ...) );
105_PROTOTYPE( int execle, (const char *_path, const char *_arg, ...) );
106_PROTOTYPE( int execlp, (const char *_file, const char *arg, ...) );
107_PROTOTYPE( int execv, (const char *_path, char *const _argv[]) );
108_PROTOTYPE( int execve, (const char *_path, char *const _argv[],
109 char *const _envp[]) );
110_PROTOTYPE( int execvp, (const char *_file, char *const _argv[]) );
111_PROTOTYPE( pid_t fork, (void) );
112_PROTOTYPE( long fpathconf, (int _fd, int _name) );
113_PROTOTYPE( char *getcwd, (char *_buf, size_t _size) );
114_PROTOTYPE( gid_t getegid, (void) );
115_PROTOTYPE( uid_t geteuid, (void) );
116_PROTOTYPE( gid_t getgid, (void) );
117_PROTOTYPE( int getgroups, (int _gidsetsize, gid_t _grouplist[]) );
118_PROTOTYPE( char *getlogin, (void) );
119_PROTOTYPE( pid_t getpgrp, (void) );
120_PROTOTYPE( pid_t getpid, (void) );
121_PROTOTYPE( pid_t getnpid, (int proc_nr) );
122_PROTOTYPE( pid_t getppid, (void) );
123_PROTOTYPE( uid_t getuid, (void) );
124_PROTOTYPE( int isatty, (int _fd) );
125_PROTOTYPE( int link, (const char *_existing, const char *_new) );
126_PROTOTYPE( off_t lseek, (int _fd, off_t _offset, int _whence) );
127_PROTOTYPE( long pathconf, (const char *_path, int _name) );
128_PROTOTYPE( int pause, (void) );
129_PROTOTYPE( int pipe, (int _fildes[2]) );
130_PROTOTYPE( ssize_t read, (int _fd, void *_buf, size_t _n) );
131_PROTOTYPE( int rmdir, (const char *_path) );
132_PROTOTYPE( int setgid, (_mnx_Gid_t _gid) );
133_PROTOTYPE( int setegid, (_mnx_Gid_t _gid) );
134_PROTOTYPE( int setpgid, (pid_t _pid, pid_t _pgid) );
135_PROTOTYPE( pid_t setsid, (void) );
136_PROTOTYPE( int setuid, (_mnx_Uid_t _uid) );
137_PROTOTYPE( int seteuid, (_mnx_Uid_t _uid) );
138_PROTOTYPE( unsigned int sleep, (unsigned int _seconds) );
139_PROTOTYPE( long sysconf, (int _name) );
140_PROTOTYPE( pid_t tcgetpgrp, (int _fd) );
141_PROTOTYPE( int tcsetpgrp, (int _fd, pid_t _pgrp_id) );
142_PROTOTYPE( char *ttyname, (int _fd) );
143_PROTOTYPE( int unlink, (const char *_path) );
144_PROTOTYPE( ssize_t write, (int _fd, const void *_buf, size_t _n) );
145_PROTOTYPE( int truncate, (const char *_path, off_t _length) );
146_PROTOTYPE( int ftruncate, (int _fd, off_t _length) );
147
148/* Open Group Base Specifications Issue 6 (not complete) */
149_PROTOTYPE( int symlink, (const char *path1, const char *path2) );
150_PROTOTYPE( int readlink, (const char *, char *, size_t) );
151_PROTOTYPE( int getopt, (int _argc, char * const _argv[], char const *_opts) );
152extern char *optarg;
153extern int optind, opterr, optopt;
154_PROTOTYPE( int usleep, (useconds_t _useconds) );
155
156#ifdef _MINIX
157#ifndef _TYPE_H
158#include <minix/type.h>
159#endif
160_PROTOTYPE( int brk, (char *_addr) );
161_PROTOTYPE( int chroot, (const char *_name) );
162_PROTOTYPE( int mknod, (const char *_name, _mnx_Mode_t _mode, Dev_t _addr) );
163_PROTOTYPE( int mknod4, (const char *_name, _mnx_Mode_t _mode, Dev_t _addr,
164 long _size) );
165_PROTOTYPE( char *mktemp, (char *_template) );
166_PROTOTYPE( int mount, (char *_spec, char *_name, int _flag) );
167_PROTOTYPE( long ptrace, (int _req, pid_t _pid, long _addr, long _data) );
168_PROTOTYPE( char *sbrk, (int _incr) );
169_PROTOTYPE( int sync, (void) );
170_PROTOTYPE( int fsync, (int fd) );
171_PROTOTYPE( int umount, (const char *_name) );
172_PROTOTYPE( int reboot, (int _how, ...) );
173_PROTOTYPE( int gethostname, (char *_hostname, size_t _len) );
174_PROTOTYPE( int getdomainname, (char *_domain, size_t _len) );
175_PROTOTYPE( int ttyslot, (void) );
176_PROTOTYPE( int fttyslot, (int _fd) );
177_PROTOTYPE( char *crypt, (const char *_key, const char *_salt) );
178_PROTOTYPE( int getsysinfo, (int who, int what, void *where) );
179_PROTOTYPE( int getsigset, (sigset_t *sigset) );
180_PROTOTYPE( int getprocnr, (void) );
181_PROTOTYPE( int getnprocnr, (pid_t pid) );
182_PROTOTYPE( int getpprocnr, (void) );
183_PROTOTYPE( int _pm_findproc, (char *proc_name, int *proc_nr) );
184_PROTOTYPE( int allocmem, (phys_bytes size, phys_bytes *base) );
185_PROTOTYPE( int freemem, (phys_bytes size, phys_bytes base) );
186#define DEV_MAP 1
187#define DEV_UNMAP 2
188#define mapdriver(driver, device, style) devctl(DEV_MAP, driver, device, style)
189#define unmapdriver(device) devctl(DEV_UNMAP, 0, device, 0)
190_PROTOTYPE( int devctl, (int ctl_req, int driver, int device, int style));
191
192/* For compatibility with other Unix systems */
193_PROTOTYPE( int getpagesize, (void) );
194_PROTOTYPE( int setgroups, (int ngroups, const gid_t *gidset) );
195_PROTOTYPE( int initgroups, (const char *name, gid_t basegid) );
196
197#endif
198
199#endif /* _UNISTD_H */
Note: See TracBrowser for help on using the repository browser.