1 /* $NetBSD: rump.h,v 1.50 2011/01/02 12:52:25 pooka Exp $ */ 2 3 /* 4 * Copyright (c) 2007 Antti Kantee. All Rights Reserved. 5 * 6 * Development of this software was supported by Google Summer of Code. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30 #ifndef _RUMP_RUMP_H_ 31 #define _RUMP_RUMP_H_ 32 33 /* 34 * NOTE: do not #include anything from <sys> here. Otherwise this 35 * has no chance of working on non-NetBSD platforms. 36 */ 37 38 struct mount; 39 struct vnode; 40 struct vattr; 41 struct componentname; 42 struct vfsops; 43 struct fid; 44 struct statvfs; 45 struct stat; 46 struct kauth_cred; 47 struct lwp; 48 struct modinfo; 49 struct uio; 50 51 /* yetch */ 52 #if defined(__NetBSD__) 53 #include <prop/proplib.h> 54 #else 55 #ifndef HAVE_PROP_DICTIONARY_T 56 #define HAVE_PROP_DICTIONARY_T 57 struct prop_dictionary; 58 typedef struct prop_dictionary *prop_dictionary_t; 59 #endif 60 #endif /* __NetBSD__ */ 61 62 #include <rump/rumpvnode_if.h> 63 #include <rump/rumpdefs.h> 64 65 /* rumpkern */ 66 enum rump_uiorw { RUMPUIO_READ, RUMPUIO_WRITE }; 67 68 enum rump_sigmodel { 69 RUMP_SIGMODEL_PANIC, 70 RUMP_SIGMODEL_IGNORE, 71 RUMP_SIGMODEL_HOST, 72 RUMP_SIGMODEL_RAISE, 73 RUMP_SIGMODEL_RECORD 74 }; 75 76 /* flags to rump_lwproc_rfork */ 77 #define RUMP_RFFDG 0x01 78 #define RUMP_RFCFDG 0x02 79 80 /* rumpvfs */ 81 #define RUMPCN_FREECRED 0x02 82 #define RUMP_ETFS_SIZE_ENDOFF ((uint64_t)-1) 83 enum rump_etfs_type { 84 RUMP_ETFS_REG, 85 RUMP_ETFS_BLK, 86 RUMP_ETFS_CHR, 87 RUMP_ETFS_DIR, /* only the registered directory */ 88 RUMP_ETFS_DIR_SUBDIRS /* dir + subdirectories (recursive) */ 89 }; 90 91 /* 92 * Something like rump capabilities would be nicer, but let's 93 * do this for a start. 94 */ 95 #define RUMP_VERSION 01 96 #define rump_init() rump__init(RUMP_VERSION) 97 98 /* um, what's the point ?-) */ 99 #ifdef _BEGIN_DECLS 100 _BEGIN_DECLS 101 #endif 102 103 int rump_boot_gethowto(void); 104 void rump_boot_sethowto(int); 105 void rump_boot_setsigmodel(enum rump_sigmodel); 106 107 void rump_schedule(void); 108 void rump_unschedule(void); 109 110 void rump_printevcnts(void); 111 112 int rump_daemonize_begin(void); 113 int rump__init(int); 114 int rump_init_server(const char *); 115 int rump_daemonize_done(int); 116 #define RUMP_DAEMONIZE_SUCCESS 0 117 118 #ifndef _KERNEL 119 #include <rump/rumpkern_if_pub.h> 120 #include <rump/rumpvfs_if_pub.h> 121 #include <rump/rumpnet_if_pub.h> 122 #endif 123 124 #ifdef _END_DECLS 125 _END_DECLS 126 #endif 127 128 /* 129 * Begin rump syscall conditionals. Yes, something a little better 130 * is required here. 131 */ 132 #ifdef RUMP_SYS_NETWORKING 133 #define socket(a,b,c) rump_sys_socket(a,b,c) 134 #define accept(a,b,c) rump_sys_accept(a,b,c) 135 #define bind(a,b,c) rump_sys_bind(a,b,c) 136 #define connect(a,b,c) rump_sys_connect(a,b,c) 137 #define getpeername(a,b,c) rump_sys_getpeername(a,b,c) 138 #define getsockname(a,b,c) rump_sys_getsockname(a,b,c) 139 #define listen(a,b) rump_sys_listen(a,b) 140 #define recvfrom(a,b,c,d,e,f) rump_sys_recvfrom(a,b,c,d,e,f) 141 #define recvmsg(a,b,c) rump_sys_recvmsg(a,b,c) 142 #define sendto(a,b,c,d,e,f) rump_sys_sendto(a,b,c,d,e,f) 143 #define sendmsg(a,b,c) rump_sys_sendmsg(a,b,c) 144 #define getsockopt(a,b,c,d,e) rump_sys_getsockopt(a,b,c,d,e) 145 #define setsockopt(a,b,c,d,e) rump_sys_setsockopt(a,b,c,d,e) 146 #define shutdown(a,b) rump_sys_shutdown(a,b) 147 #endif /* RUMP_SYS_NETWORKING */ 148 149 #ifdef RUMP_SYS_IOCTL 150 #define ioctl(...) rump_sys_ioctl(__VA_ARGS__) 151 #define fnctl(...) rump_sys_fcntl(__VA_ARGS__) 152 #endif /* RUMP_SYS_IOCTL */ 153 154 #ifdef RUMP_SYS_CLOSE 155 #define close(a) rump_sys_close(a) 156 #endif /* RUMP_SYS_CLOSE */ 157 158 #ifdef RUMP_SYS_OPEN 159 #define open(...) rump_sys_open(__VA_ARGS__) 160 #endif /* RUMP_SYS_OPEN */ 161 162 #ifdef RUMP_SYS_READWRITE 163 #define read(a,b,c) rump_sys_read(a,b,c) 164 #define readv(a,b,c) rump_sys_readv(a,b,c) 165 #define pread(a,b,c,d) rump_sys_pread(a,b,c,d) 166 #define preadv(a,b,c,d) rump_sys_preadv(a,b,c,d) 167 #define write(a,b,c) rump_sys_write(a,b,c) 168 #define writev(a,b,c) rump_sys_writev(a,b,c) 169 #define pwrite(a,b,c,d) rump_sys_pwrite(a,b,c,d) 170 #define pwritev(a,b,c,d) rump_sys_pwritev(a,b,c,d) 171 #endif /* RUMP_SYS_READWRITE */ 172 173 #ifdef RUMP_SYS_FILEOPS 174 #define mkdir(a,b) rump_sys_mkdir(a,b) 175 #define rmdir(a) rump_sys_rmdir(a) 176 #define link(a,b) rump_sys_link(a,b) 177 #define symlink(a,b) rump_sys_symlink(a,b) 178 #define unlink(a) rump_sys_unlink(a) 179 #define readlink(a,b,c) rump_sys_readlink(a,b,c) 180 #define chdir(a) rump_sys_chdir(a) 181 #define fsync(a) rump_sys_fsync(a) 182 #define sync() rump_sys_sync() 183 #define chown(a,b,c) rump_sys_chown(a,b,c) 184 #define fchown(a,b,c) rump_sys_fchown(a,b,c) 185 #define lchown(a,b,c) rump_sys_lchown(a,b,c) 186 #define lseek(a,b,c) rump_sys_lseek(a,b,c) 187 #define mknod(a,b,c) rump_sys_mknod(a,b,c) 188 #define rename(a,b) rump_sys_rename(a,b) 189 #define truncate(a,b) rump_sys_truncate(a,b) 190 #define ftruncate(a,b) rump_sys_ftruncate(a,b) 191 #define umask(a) rump_sys_umask(a) 192 #define getdents(a,b,c) rump_sys_getdents(a,b,c) 193 #endif /* RUMP_SYS_FILEOPS */ 194 195 #ifdef RUMP_SYS_STAT 196 #define stat(a,b) rump_sys_stat(a,b) 197 #define fstat(a,b) rump_sys_fstat(a,b) 198 #define lstat(a,b) rump_sys_lstat(a,b) 199 #endif /* RUMP_SYS_STAT */ 200 201 #ifdef RUMP_SYS_PROCOPS 202 #define getpid() rump_sys_getpid() 203 #endif /* RUMP_SYS_PROCOPS */ 204 205 #endif /* _RUMP_RUMP_H_ */ 206