OpenAFS
OpenAFS distributed network file system
|
00001 /* 00002 * Copyright 2000, International Business Machines Corporation and others. 00003 * All Rights Reserved. 00004 * 00005 * This software has been released under the terms of the IBM Public 00006 * License. For details, see the LICENSE file in the top-level source 00007 * directory or online at http://www.openafs.org/dl/license10.html 00008 */ 00009 00010 #ifndef __AFS_SYSINCLUDESH__ 00011 #define __AFS_SYSINCLUDESH__ 1 00012 00013 #include <stdio.h> 00014 #include <afs/opr.h> 00015 00016 #if !defined(AFS_USR_DARWIN_ENV) && !defined(AFS_USR_FBSD_ENV) && !defined(AFS_USR_DFBSD_ENV) /* must be included after KERNEL undef'd */ 00017 #include <errno.h> 00018 #endif 00019 #include <stdlib.h> 00020 #include <string.h> 00021 #include <limits.h> 00022 #include <assert.h> 00023 #include <stdarg.h> 00024 00025 #if !defined(AFS_USR_DARWIN_ENV) && !defined(AFS_USR_FBSD_ENV) && !defined(AFS_USR_DFBSD_ENV) /* must be included after KERNEL undef'd */ 00026 #include <unistd.h> 00027 #include <ctype.h> 00028 #include <sys/types.h> 00029 #include <dirent.h> 00030 #include <setjmp.h> 00031 #endif 00032 00033 #ifdef AFS_USR_SUN5_ENV 00034 #include <signal.h> 00035 #include <sys/param.h> 00036 #include <sys/socket.h> 00037 #include <net/if.h> 00038 #include <sys/sockio.h> 00039 #include <sys/file.h> 00040 #include <sys/stat.h> 00041 #include <sys/fcntl.h> 00042 #include <netinet/in.h> 00043 #include <netdb.h> 00044 #include <arpa/inet.h> 00045 #endif /* AFS_USR_SUN5_ENV */ 00046 00047 00048 #ifdef AFS_USR_AIX_ENV 00049 #include <sys/param.h> 00050 #include <sys/socket.h> 00051 #include <net/if.h> 00052 #include <fcntl.h> 00053 #include <netinet/in.h> 00054 #include <sys/stropts.h> 00055 #include <netdb.h> 00056 #include <sys/timers.h> 00057 #include <arpa/inet.h> 00058 #endif /* AFS_USR_AIX_ENV */ 00059 00060 #ifdef AFS_USR_SGI_ENV 00061 #include <sys/param.h> 00062 #include <sys/socket.h> 00063 #include <net/if.h> 00064 #include <sys/sockio.h> 00065 #include <sys/file.h> 00066 #include <sys/stat.h> 00067 #include <sys/fcntl.h> 00068 #include <netinet/in.h> 00069 #include <netdb.h> 00070 #include <arpa/inet.h> 00071 #endif /* AFS_USR_SGI_ENV */ 00072 00073 #ifdef AFS_USR_HPUX_ENV 00074 #include <sys/param.h> 00075 #include <sys/socket.h> 00076 #include <net/if.h> 00077 #include <sys/file.h> 00078 #include <sys/stat.h> 00079 #include <sys/fcntl.h> 00080 #include <netinet/in.h> 00081 #include <netdb.h> 00082 #include <arpa/inet.h> 00083 #endif /* AFS_USR_HPUX_ENV */ 00084 00085 #ifdef AFS_USR_OSF_ENV 00086 #ifdef KERNEL 00087 #undef KERNEL 00088 #define AFS_USR_UNDEF_KERNEL_ENV 1 00089 #endif 00090 #include <sys/param.h> 00091 #include <sys/socket.h> 00092 #include <net/if.h> 00093 #include <sys/file.h> 00094 #include <sys/ioctl.h> 00095 #include <sys/stat.h> 00096 #include <sys/fcntl.h> 00097 #include <netinet/in.h> 00098 #include <netdb.h> 00099 #include <arpa/inet.h> 00100 #endif /* AFS_USR_OSF_ENV */ 00101 00102 #ifdef AFS_USR_LINUX22_ENV 00103 #include <sys/ioctl.h> /* _IOW() */ 00104 #include <sys/uio.h> /* struct iovec */ 00105 #include <sys/time.h> /* struct timeval */ 00106 #include <sys/param.h> 00107 #include <sys/types.h> 00108 #include <sys/socket.h> 00109 #include <net/if.h> 00110 #include <sys/file.h> 00111 #include <sys/stat.h> 00112 #include <sys/fcntl.h> 00113 #include <netinet/in.h> 00114 #include <netdb.h> 00115 #include <arpa/inet.h> 00116 #define FREAD 0x0001 00117 #endif /* AFS_USR_LINUX22_ENV */ 00118 00119 #if defined(AFS_USR_DARWIN_ENV) || defined(AFS_USR_FBSD_ENV) || defined(AFS_USR_DFBSD_ENV) 00120 #ifdef _KERNEL 00121 #undef _KERNEL 00122 #endif 00123 #ifdef KERNEL 00124 #undef KERNEL 00125 #define AFS_USR_UNDEF_KERNEL_ENV 1 00126 #endif 00127 #include <errno.h> 00128 #include <setjmp.h> 00129 #include <sys/param.h> 00130 #include <sys/types.h> 00131 #include <sys/socket.h> 00132 #include <net/if.h> 00133 #include <sys/file.h> 00134 #include <sys/ioctl.h> 00135 #include <sys/stat.h> 00136 #include <sys/fcntl.h> 00137 #include <sys/uio.h> 00138 #include <netinet/in.h> 00139 #include <netdb.h> 00140 #include <arpa/inet.h> 00141 #include <dirent.h> 00142 #include <ctype.h> 00143 #include <unistd.h> 00144 #ifndef O_SYNC 00145 #define O_SYNC O_FSYNC 00146 #endif 00147 #endif /* AFS_USR_DARWIN_ENV || AFS_USR_FBSD_ENV */ 00148 00149 #ifdef HAVE_SYS_BITYPES_H 00150 #include <sys/bitypes.h> 00151 #endif 00152 #ifdef HAVE_SYS_STATFS_H 00153 #include <sys/statfs.h> 00154 #endif 00155 #ifdef HAVE_SYS_STATVFS_H 00156 #include <sys/statvfs.h> 00157 #endif 00158 00159 #ifndef HAVE_FSBLKCNT_T 00160 typedef unsigned int fsblkcnt_t; 00161 #endif 00162 00163 #include <arpa/nameser.h> 00164 #ifdef HAVE_ARPA_NAMESER_COMPAT_H 00165 #include <arpa/nameser_compat.h> 00166 #endif 00167 #include <resolv.h> 00168 00169 /* glibc 2.2 has pthread_attr_setstacksize */ 00170 #if (defined(AFS_LINUX22_ENV) && !defined(AFS_USR_LINUX22_ENV)) || (defined(AFS_USR_LINUX22_ENV) && (__GLIBC_MINOR__ < 2)) 00171 #define pthread_attr_setstacksize(a,b) 0 00172 #endif 00173 00174 #include <sys/stat.h> /* afs_usrops.h uses struct stat in prototypes */ 00175 00176 #ifdef NETSCAPE_NSAPI 00177 00178 #include <nsapi.h> 00179 00180 #else /* NETSCAPE_NSAPI */ 00181 00182 #include <pthread.h> 00183 00184 #endif /* NETSCAPE_NSAPI */ 00185 00186 #ifdef AFS_USR_UNDEF_KERNEL_ENV 00187 #undef AFS_USR_UNDEF_KERNEL_ENV 00188 #define KERNEL 1 00189 #endif 00190 00191 /* 00192 * User space versions of kernel data structures. 00193 */ 00194 00195 #ifndef MAXNAMLEN 00196 #define MAXNAMLEN 512 00197 #endif 00198 00199 /* 00200 * This file contains data types and definitions for running 00201 * the AFS client in user space. Kernel data structures 00202 * are renamed from XXXX to usr_XXXX. 00203 */ 00204 00205 #ifdef UKERNEL 00206 00207 #undef socket 00208 #undef flock 00209 00210 #if defined(AFS_USR_DARWIN_ENV) || defined(AFS_USR_FBSD_ENV) 00211 #undef if_mtu 00212 #undef if_metric 00213 #endif 00214 00215 #define mount usr_mount 00216 #define fs usr_fs 00217 #define uio usr_uio 00218 #define fileops usr_fileops 00219 #define vnodeops usr_vnodeops 00220 #define vnode usr_vnode 00221 #define inode usr_inode 00222 #define whymountroot_t usr_whymountroot_t 00223 #define vfsops usr_vfsops 00224 #define vfs usr_vfs 00225 #define vattr usr_vattr 00226 #define buf usr_buf 00227 #define statfs usr_statfs 00228 #define file usr_file 00229 #define dirent usr_dirent 00230 #define flock usr_flock 00231 #define fid usr_fid 00232 #define sysent usr_sysent 00233 #define ifaddr usr_ifaddr 00234 #define ifnet usr_ifnet 00235 #define in_ifaddr usr_in_ifaddr 00236 #undef socket 00237 #define socket usr_socket 00238 #define crget usr_crget 00239 #define crcopy usr_crcopy 00240 #define crhold usr_crhold 00241 #define crfree usr_crfree 00242 #define vtype_t usr_vtype_t 00243 #define vcexcl usr_vcexcl 00244 #define m_free usr_m_free 00245 #define m_freem usr_m_freem 00246 #define m_adj usr_m_adj 00247 #define m_pullup usr_m_pullup 00248 #define uiomove usr_uiomove 00249 #define EXCL usr_EXCL 00250 #define NONEXCL usr_NONEXCL 00251 #define uio_rw usr_uio_rw 00252 #ifdef ino_t 00253 #undef ino_t 00254 #endif 00255 #define ino_t usr_ino_t 00256 #define offset_t usr_offset_t 00257 #define getpid() usr_getpid() 00258 #define setpag(A,B,C,D) usr_setpag((A),(B),(C),(D)) 00259 #define osi_getpid() afs_pointer_to_int(usr_thread_self()) 00260 #ifdef pid_t 00261 #undef pid_t 00262 #endif 00263 #define pid_t int 00264 00265 enum usr_vcexcl { usr_NONEXCL, usr_EXCL }; 00266 typedef long offset_t; 00267 #ifdef AFS_USR_OSF_ENV 00268 typedef int usr_ino_t; 00269 #else /* AFS_USR_OSF_ENV */ 00270 typedef long usr_ino_t; 00271 #endif /* AFS_USR_OSF_ENV */ 00272 00273 #if defined(AFS_USR_AIX_ENV) || defined(AFS_USR_SGI_ENV) 00274 #define SYS_setgroups 101 00275 #endif 00276 00277 #define ioctl() usr_ioctl() 00278 00279 #define label_t jmp_buf 00280 00281 #ifdef VFSTOM 00282 #undef VFSTOM 00283 #endif 00284 00285 #define VFSTOM(VP) ((struct usr_mount *)(VP)->vfs_mount) 00286 00287 #ifdef VINACT 00288 #undef VINACT 00289 #endif 00290 #ifdef VLOCK 00291 #undef VLOCK 00292 #endif 00293 #ifdef VNOMAP 00294 #undef VNOMAP 00295 #endif 00296 #ifdef VROOT 00297 #undef VROOT 00298 #endif 00299 #ifdef VSHARE 00300 #undef VSHARE 00301 #endif 00302 #ifdef VTEXT 00303 #undef VTEXT 00304 #endif 00305 #ifdef VWAIT 00306 #undef VWAIT 00307 #endif 00308 #ifdef VWASMAP 00309 #undef VWASMAP 00310 #endif 00311 #ifdef VXLOCK 00312 #undef VXLOCK 00313 #endif 00314 00315 #define VINACT 0x0001 00316 #define VLOCK 0x0002 00317 #define VNOMAP 0x0004 00318 #define VROOT 0x0008 00319 #define VSHARE 0x0010 00320 #define VTEXT 0x0020 00321 #define VWAIT 0x0040 00322 #define VWASMAP 0x0080 00323 #define VXLOCK 0x0100 00324 00325 #ifdef VNON 00326 #undef VNON 00327 #endif 00328 #ifdef VREG 00329 #undef VREG 00330 #endif 00331 #ifdef VDIR 00332 #undef VDIR 00333 #endif 00334 #ifdef VBLK 00335 #undef VBLK 00336 #endif 00337 #ifdef VCHR 00338 #undef VCHR 00339 #endif 00340 #ifdef VLNK 00341 #undef VLNK 00342 #endif 00343 #ifdef VFIFO 00344 #undef VFIFO 00345 #endif 00346 #ifdef VSOCK 00347 #undef VSOCK 00348 #endif 00349 00350 #define VNON 0 00351 #define VREG S_IFREG 00352 #define VDIR S_IFDIR 00353 #define VBLK S_IFBLK 00354 #define VCHR S_IFCHR 00355 #define VLNK S_IFLNK 00356 #define VSOCK S_IFSOCK 00357 #define VFIFO S_IFIFO 00358 00359 typedef int usr_vtype_t; 00360 00361 #ifdef VOP_RDWR 00362 #undef VOP_RDWR 00363 #endif 00364 00365 #define VOP_RDWR afs_osi_VOP_RDWR 00366 00367 #ifdef NDADDR 00368 #undef NDADDR 00369 #endif 00370 #ifdef NIADDR 00371 #undef NIADDR 00372 #endif 00373 00374 #define NDADDR 12 00375 #define NIADDR 3 00376 00377 #ifdef DTYPE_VNODE 00378 #undef DTYPE_VNODE 00379 #endif 00380 00381 #define DTYPE_VNODE 1 00382 00383 #ifdef IUPD 00384 #undef IUPD 00385 #endif 00386 #ifdef IACC 00387 #undef IACC 00388 #endif 00389 #ifdef IMOD 00390 #undef IMOD 00391 #endif 00392 #ifdef ICHG 00393 #undef ICHG 00394 #endif 00395 #ifdef INOACC 00396 #undef INOACC 00397 #endif 00398 #ifdef IMODTIME 00399 #undef IMODTIME 00400 #endif 00401 #ifdef IREF 00402 #undef IREF 00403 #endif 00404 #ifdef ISYNC 00405 #undef ISYNC 00406 #endif 00407 #ifdef IFASTSYMLNK 00408 #undef IFASTSYMLNK 00409 #endif 00410 #ifdef IMODACC 00411 #undef IMODACC 00412 #endif 00413 #ifdef IATTCHG 00414 #undef IATTCHG 00415 #endif 00416 #ifdef IBDWRITE 00417 #undef IBDWRITE 00418 #endif 00419 #ifdef IBAD 00420 #undef IBAD 00421 #endif 00422 #ifdef IDEL 00423 #undef IDEL 00424 #endif 00425 00426 #define IUPD 0x0001 00427 #define IACC 0x0002 00428 #define IMOD 0x0004 00429 #define ICHG 0x0008 00430 #define INOACC 0x0010 00431 #define IMODTIME 0x0020 00432 #define IREF 0x0040 00433 #define ISYNC 0x0080 00434 #define IFASTSYMLNK 0x0100 00435 #define IMODACC 0x0200 00436 #define IATTCHG 0x0400 00437 #define IBDWRITE 0x0800 00438 #define IBAD 0x1000 00439 #define IDEL 0x2000 00440 00441 #ifdef IFMT 00442 #undef IFMT 00443 #endif 00444 #ifdef IFIFO 00445 #undef IFIFO 00446 #endif 00447 #ifdef IFCHR 00448 #undef IFCHR 00449 #endif 00450 #ifdef IFDIR 00451 #undef IFDIR 00452 #endif 00453 #ifdef IFBLK 00454 #undef IFBLK 00455 #endif 00456 #ifdef IFREG 00457 #undef IFREG 00458 #endif 00459 #ifdef IFLNK 00460 #undef IFLNK 00461 #endif 00462 #ifdef IFSHAD 00463 #undef IFSHAD 00464 #endif 00465 #ifdef IFSOCK 00466 #undef IFSOCK 00467 #endif 00468 00469 #define IFMT 0170000 00470 #define IFIFO 0010000 00471 #define IFCHR 0020000 00472 #define IFDIR 0040000 00473 #define IFBLK 0060000 00474 #define IFREG 0100000 00475 #define IFLNK 0120000 00476 #define IFSHAD 0130000 00477 #define IFSOCK 0140000 00478 00479 #ifdef ISUID 00480 #undef ISUID 00481 #endif 00482 #ifdef ISGID 00483 #undef ISGID 00484 #endif 00485 #ifdef ISVTX 00486 #undef ISVTX 00487 #endif 00488 #ifdef IREAD 00489 #undef IREAD 00490 #endif 00491 #ifdef IWRITE 00492 #undef IWRITE 00493 #endif 00494 #ifdef IEXEC 00495 #undef IEXEC 00496 #endif 00497 00498 #define ISUID 04000 00499 #define ISGID 02000 00500 #define ISVTX 01000 00501 #define IREAD 0400 00502 #define IWRITE 0200 00503 #define IEXEC 0100 00504 00505 #ifdef I_SYNC 00506 #undef I_SYNC 00507 #endif 00508 #ifdef I_DSYNC 00509 #undef I_DSYNC 00510 #endif 00511 #ifdef I_ASYNC 00512 #undef I_ASYNC 00513 #endif 00514 00515 #define I_SYNC 1 00516 #define I_DSYNC 2 00517 #define I_ASYNC 0 00518 00519 #ifdef I_FREE 00520 #undef I_FREE 00521 #endif 00522 #ifdef I_DIR 00523 #undef I_DIR 00524 #endif 00525 #ifdef I_IBLK 00526 #undef I_IBLK 00527 #endif 00528 #ifdef I_CHEAP 00529 #undef I_CHEAP 00530 #endif 00531 #ifdef I_SHAD 00532 #undef I_SHAD 00533 #endif 00534 #ifdef I_QUOTA 00535 #undef I_QUOTA 00536 #endif 00537 00538 #define I_FREE 0x00000001 00539 #define I_DIR 0x00000002 00540 #define I_IBLK 0x00000004 00541 #define I_CHEAP 0x00000008 00542 #define I_SHAD 0x00000010 00543 #define I_QUOTA 0x00000020 00544 00545 #ifdef VTOI 00546 #undef VTOI 00547 #endif 00548 #ifdef ITOV 00549 #undef ITOV 00550 #endif 00551 00552 #define VTOI(VP) ((struct usr_inode *)(VP)->v_data) 00553 #define ITOV(IP) ((struct usr_vnode *)&(IP)->i_vnode) 00554 00555 #ifdef VN_HOLD 00556 #undef VN_HOLD 00557 #endif 00558 #ifdef VN_RELE 00559 #undef VN_RELE 00560 #endif 00561 00562 #ifdef ROOT_INIT 00563 #undef ROOT_INIT 00564 #endif 00565 #ifdef ROOT_REMOUNT 00566 #undef ROOT_REMOUNT 00567 #endif 00568 #ifdef ROOT_UNMOUNT 00569 #undef ROOT_UNMOUNT 00570 #endif 00571 #ifdef ROOT_FRONTMOUNT 00572 #undef ROOT_FRONTMOUNT 00573 #endif 00574 #ifdef ROOT_BACKMOUNT 00575 #undef ROOT_BACKMOUNT 00576 #endif 00577 00578 #define ROOT_INIT 0x0001 00579 #define ROOT_REMOUNT 0X0002 00580 #define ROOT_UNMOUNT 0x0003 00581 #define ROOT_FRONTMOUNT 0x0004 00582 #define ROOT_BACKMOUNT 0x0005 00583 00584 #ifdef MAXFIDSZ 00585 #undef MAXFIDSZ 00586 #endif 00587 00588 #define MAXFIDSZ 64 00589 00590 #ifdef FSTYPSZ 00591 #undef FSTYPSZ 00592 #endif 00593 00594 #define FSTYPSZ 16 00595 00596 #ifdef VFS_MOUNT 00597 #undef VFS_MOUNT 00598 #endif 00599 #ifdef VFS_UNMOUNT 00600 #undef VFS_UNMOUNT 00601 #endif 00602 #ifdef VFS_ROOT 00603 #undef VFS_ROOT 00604 #endif 00605 #ifdef VFS_STATFS 00606 #undef VFS_STATFFS 00607 #endif 00608 #ifdef VFS_SYNC 00609 #undef VFS_SYNC 00610 #endif 00611 #ifdef VFS_VGET 00612 #undef VFS_VGET 00613 #endif 00614 #ifdef VFS_MOUNTROOT 00615 #undef VFS_MOUNTROOT 00616 #endif 00617 #ifdef VFS_SWAPVP 00618 #undef VFS_SWAPVP 00619 #endif 00620 #ifdef VFS_MOUNT 00621 #undef VFS_MOUNT 00622 #endif 00623 00624 #define VFS_STATFS(vfsp, sp) ((sp)->f_bsize=4096, 0) 00625 00626 #ifdef FAPPEND 00627 #undef FAPPEND 00628 #endif 00629 #ifdef FSYNC 00630 #undef FSYNC 00631 #endif 00632 #ifdef FTRUNC 00633 #undef FTRUNC 00634 #endif 00635 #ifdef FWRITE 00636 #undef FWRITE 00637 #endif 00638 #ifdef IO_APPEND 00639 #undef IO_APPEND 00640 #endif 00641 #ifdef IO_SYNC 00642 #undef IO_SYNC 00643 #endif 00644 00645 #define FAPPEND 0x0100 00646 #define IO_APPEND FAPPEND 00647 #define FSYNC 0x0200 00648 #define IO_SYNC FSYNC 00649 #define FTRUNC 0x0400 00650 #define FWRITE 0x0800 00651 00652 #ifdef F_GETLK 00653 #undef F_GETLK 00654 #endif 00655 #ifdef F_RDLCK 00656 #undef F_RDLCK 00657 #endif 00658 #ifdef F_SETLK 00659 #undef F_SETLK 00660 #endif 00661 #ifdef F_SETLKW 00662 #undef F_SETLKW 00663 #endif 00664 #ifdef F_UNLCK 00665 #undef F_UNLCK 00666 #endif 00667 #ifdef F_WRLCK 00668 #undef F_WRLCK 00669 #endif 00670 00671 #define F_GETLK 0x0001 00672 #define F_RDLCK 0x0002 00673 #define F_SETLK 0x0003 00674 #define F_SETLKW 0x0004 00675 #define F_UNLCK 0x0005 00676 #define F_WRLCK 0x0006 00677 00678 #ifdef LOCK_SH 00679 #undef LOCK_SH 00680 #endif 00681 #ifdef LOCK_EX 00682 #undef LOCK_EX 00683 #endif 00684 #ifdef LOCK_NB 00685 #undef LOCK_NB 00686 #endif 00687 #ifdef LOCK_UN 00688 #undef LOCK_UN 00689 #endif 00690 00691 #define LOCK_SH F_RDLCK 00692 #define LOCK_UN F_UNLCK 00693 #define LOCK_EX F_WRLCK 00694 #define LOCK_NB 0x0007 00695 00696 #ifdef FEXLOCK 00697 #undef FEXLOCK 00698 #endif 00699 #ifdef FSHLOCK 00700 #undef FSHLOCK 00701 #endif 00702 00703 #define FEXLOCK F_WRLCK 00704 #define FSHLOCK F_RDLCK 00705 00706 #ifdef SSYS 00707 #undef SSYS 00708 #endif 00709 00710 #define SSYS 0x0001 00711 00712 enum usr_uio_rw { USR_UIO_READ, USR_UIO_WRITE }; 00713 00714 #ifdef UIO_READ 00715 #undef UIO_READ 00716 #endif 00717 #ifdef UIO_WRITE 00718 #undef UIO_WRITE 00719 #endif 00720 00721 #define UIO_READ 0x0000 00722 #define UIO_WRITE 0x0001 00723 00724 #ifdef UIO_USERSPACE 00725 #undef UIO_USERSPACE 00726 #endif 00727 #ifdef UIO_SYSSPACE 00728 #undef UIO_SYSSPACE 00729 #endif 00730 00731 #define UIO_USERSPACE 0x0000 00732 #define UIO_SYSSPACE 0x0001 00733 00734 #ifdef B_AGE 00735 #undef B_AGE 00736 #endif 00737 #ifdef B_ASYNC 00738 #undef B_ASYNC 00739 #endif 00740 #ifdef B_DELWRI 00741 #undef B_DELWRI 00742 #endif 00743 #ifdef B_DIRTY 00744 #undef B_DIRTY 00745 #endif 00746 #ifdef B_DONE 00747 #undef B_DONE 00748 #endif 00749 #ifdef B_ERROR 00750 #undef B_ERROR 00751 #endif 00752 #ifdef B_FREE 00753 #undef B_FREE 00754 #endif 00755 #ifdef B_NOCACHE 00756 #undef B_NOCACHE 00757 #endif 00758 #ifdef B_PFSTORE 00759 #undef B_PFSTORE 00760 #endif 00761 #ifdef B_READ 00762 #undef B_READ 00763 #endif 00764 #ifdef B_UBC 00765 #undef B_UBC 00766 #endif 00767 #ifdef B_WANTED 00768 #undef B_WANTED 00769 #endif 00770 #ifdef B_WRITE 00771 #undef B_WRITE 00772 #endif 00773 00774 #define B_AGE 0x0001 00775 #define B_ASYNC 0x0002 00776 #define B_DELWRI 0x0004 00777 #define B_DIRTY 0x0008 00778 #define B_DONE 0x0010 00779 #define B_ERROR 0x0020 00780 #define B_FREE 0x0040 00781 #define B_NOCACHE 0x0080 00782 #define B_PFSTORE 0x0100 00783 #define B_READ 0x0200 00784 #define B_UBC 0x0400 00785 #define B_WANTED 0x0800 00786 #define B_WRITE 0x1000 00787 00788 #ifdef MFREE 00789 #undef MFREE 00790 #endif 00791 #ifdef MINUSE 00792 #undef MINUSE 00793 #endif 00794 #ifdef MINTER 00795 #undef MINTER 00796 #endif 00797 #ifdef MUPDATE 00798 #undef MUPDATE 00799 #endif 00800 00801 #define MFREE 0 00802 #define MINUSE 1 00803 #define MINTER 2 00804 #define MUPDATE 4 00805 00806 #ifdef MSIZE 00807 #undef MSIZE 00808 #endif 00809 #ifdef MMAXOFF 00810 #undef MMAXOFF 00811 #endif 00812 00813 #define MSIZE 16384 00814 #define MMAXOFF 16384 00815 00816 #ifdef IA_SIN 00817 #undef IA_SIN 00818 #endif 00819 00820 #define IA_SIN(IA) (&(IA)->ia_addr) 00821 00822 #ifdef mtod 00823 #undef mtod 00824 #endif 00825 #ifdef dtom 00826 #undef dtom 00827 #endif 00828 #ifdef mtocl 00829 #undef mtocl 00830 #endif 00831 00832 #define mtod(m,t) ((t)((m)->m_data)) 00833 00834 #ifdef NBPG 00835 #undef NBPG 00836 #endif 00837 #define NBPG 4096 00838 00839 #define panic(S) do{fprintf(stderr, "%s", S);assert(0);}while(0) 00840 #define abort() assert(0) 00841 #define usr_assert(A) assert(A) 00842 00843 #ifdef NETSCAPE_NSAPI 00844 00845 /* 00846 * All CONDVARs created with the same CRITICAL end up being the 00847 * same CONDVAR, not a new one. If we want to use more than 00848 * one usr_cond_t with the same usr_mutex_t, then we need a CRITICAL 00849 * for each CONDVAR, otherwise we cannot know which thread we are 00850 * waking when we do the signal. 00851 */ 00852 typedef struct { 00853 int waiters; 00854 CRITICAL lock; 00855 CONDVAR cond; 00856 } usr_cond_t; 00857 00858 #define usr_mutex_t CRITICAL 00859 #define usr_thread_t SYS_THREAD 00860 #define usr_key_t int 00861 00862 #define usr_mutex_init(A) (*(A)=crit_init(), 0) 00863 #define usr_mutex_destroy(A) (crit_terminate(*(A)), 0) 00864 #define usr_mutex_lock(A) crit_enter(*(A)) 00865 #define usr_mutex_trylock(A) (crit_enter(*(A)),1) 00866 #define usr_mutex_unlock(A) crit_exit(*(A)) 00867 00868 #define usr_cond_init(A) \ 00869 ((A)->waiters = 0, \ 00870 (A)->lock = crit_init(), \ 00871 (A)->cond = condvar_init((A)->lock), 0) 00872 00873 #define usr_cond_destroy(A) \ 00874 (condvar_terminate((A)->cond), \ 00875 crit_terminate((A)->lock), 0) 00876 00877 #define usr_cond_signal(A) \ 00878 { \ 00879 crit_enter((A)->lock); \ 00880 if ((A)->waiters != 0) { \ 00881 condvar_notify((A)->cond);\ 00882 (A)->waiters -= 1; \ 00883 } \ 00884 crit_exit((A)->lock); \ 00885 } 00886 00887 #define usr_cond_broadcast(A) \ 00888 { \ 00889 crit_enter((A)->lock); \ 00890 while ((A)->waiters != 0) { \ 00891 condvar_notify((A)->cond); \ 00892 (A)->waiters -= 1; \ 00893 } \ 00894 crit_exit((A)->lock); \ 00895 } 00896 00897 #define usr_cond_wait(A,B) \ 00898 (crit_enter((A)->lock), \ 00899 crit_exit(*(B)), \ 00900 (A)->waiters += 1, \ 00901 condvar_wait((A)->cond), \ 00902 crit_exit((A)->lock), \ 00903 crit_enter(*(B)), 0) 00904 00905 #define usr_thread_create(A,B,C) \ 00906 ((*(A)=systhread_start(SYSTHREAD_DEFAULT_PRIORITY, \ 00907 0,B,C))==SYS_THREAD_ERROR) 00908 #define usr_thread_detach(A) 0 00909 #define usr_keycreate(A,B) (*(A)=systhread_newkey(),0) 00910 #define usr_setspecific(A,B) (systhread_setdata(A,B),0) 00911 #define usr_getspecific(A,B) (*(B)=systhread_getdata(A),0) 00912 #define usr_thread_self() systhread_current() 00913 #ifdef AFS_USR_SUN5_ENV 00914 #define usr_thread_sleep(A) \ 00915 poll(0, 0, (A)->tv_sec*1000+(A)->tv_nsec/1000000) 00916 #else /* AFS_USR_SUN5_ENV */ 00917 #define usr_thread_sleep(A) \ 00918 systhread_sleep((A)->tv_sec*1000+(A)->tv_nsec/1000000) 00919 #endif /* AFS_USR_SUN5_ENV */ 00920 00921 #define uprintf printf 00922 00923 #define usr_getpid() (int)(usr_thread_self()) 00924 00925 #define ISAFS_GLOCK() (usr_thread_self() == afs_global_owner) 00926 00927 #else /* NETSCAPE_NSAPI */ 00928 00929 /* 00930 * Mutex and condition variable used to implement sleep 00931 */ 00932 extern pthread_mutex_t usr_sleep_mutex; 00933 extern pthread_cond_t usr_sleep_cond; 00934 00935 #define usr_cond_t pthread_cond_t 00936 #define usr_mutex_t pthread_mutex_t 00937 #define usr_thread_t pthread_t 00938 #define usr_key_t pthread_key_t 00939 00940 #define usr_mutex_init(A) opr_Verify(pthread_mutex_init(A,NULL) == 0) 00941 #define usr_mutex_destroy(A) opr_Verify(pthread_mutex_destroy(A) == 0) 00942 #define usr_mutex_lock(A) opr_Verify(pthread_mutex_lock(A) == 0) 00943 #define usr_mutex_trylock(A) ((pthread_mutex_trylock(A)==0)?1:0) 00944 #define usr_mutex_unlock(A) opr_Verify(pthread_mutex_unlock(A) == 0) 00945 #define usr_cond_init(A) opr_Verify(pthread_cond_init(A,NULL) == 0) 00946 #define usr_cond_destroy(A) opr_Verify(pthread_cond_destroy(A) == 0) 00947 #define usr_cond_signal(A) opr_Verify(pthread_cond_signal(A) == 0) 00948 #define usr_cond_broadcast(A) opr_Verify(pthread_cond_broadcast(A) == 0) 00949 #define usr_cond_wait(A,B) pthread_cond_wait(A,B) 00950 #define usr_cond_timedwait(A,B,C) pthread_cond_timedwait(A,B,C) 00951 00952 #define usr_thread_create(A,B,C) \ 00953 do { \ 00954 pthread_attr_t attr; \ 00955 opr_Verify(pthread_attr_init(&attr) == 0); \ 00956 opr_Verify(pthread_attr_setstacksize(&attr, 122880) == 0); \ 00957 opr_Verify(pthread_create((A), &attr, (B), (void *)(C)) == 0); \ 00958 opr_Verify(pthread_attr_destroy(&attr) == 0); \ 00959 } while(0) 00960 #define usr_thread_join(A,B) pthread_join(A, B) 00961 #define usr_thread_detach(A) pthread_detach(A) 00962 #define usr_keycreate(A,B) opr_Verify(pthread_key_create(A,B) == 0) 00963 #define usr_setspecific(A,B) pthread_setspecific(A,B) 00964 #define usr_getspecific(A,B) (*(B)=pthread_getspecific(A),0) 00965 #define usr_thread_self() pthread_self() 00966 #define usr_thread_sleep(A) \ 00967 { \ 00968 struct timespec _sleep_ts; \ 00969 struct timeval _sleep_tv; \ 00970 gettimeofday(&_sleep_tv, NULL); \ 00971 _sleep_ts = *(A); \ 00972 _sleep_ts.tv_sec += _sleep_tv.tv_sec; \ 00973 _sleep_ts.tv_nsec += _sleep_tv.tv_usec * 1000; \ 00974 if (_sleep_ts.tv_nsec >= 1000000000) { \ 00975 _sleep_ts.tv_sec += 1; \ 00976 _sleep_ts.tv_nsec -= 1000000000; \ 00977 } \ 00978 opr_Verify(pthread_mutex_lock(&usr_sleep_mutex) == 0); \ 00979 pthread_cond_timedwait(&usr_sleep_cond, &usr_sleep_mutex, &_sleep_ts); \ 00980 opr_Verify(pthread_mutex_unlock(&usr_sleep_mutex) == 0); \ 00981 } 00982 00983 #define uprintf printf 00984 00985 #define usr_getpid() (int)(usr_thread_self()) 00986 #ifdef ISAFS_GLOCK 00987 #undef ISAFS_GLOCK 00988 #endif 00989 #define ISAFS_GLOCK() (usr_thread_self() == afs_global_owner) 00990 00991 #endif /* NETSCAPE_NSAPI */ 00992 00993 #define copyin(A,B,C) (memcpy((void *)B,(void *)A,C), 0) 00994 #define copyout(A,B,C) (memcpy((void *)B,(void *)A,C), 0) 00995 #define copyinstr(A,B,C,D) (strncpy(B,A,C),(*D)=strlen(B), 0) 00996 #define copyoutstr(A,B,C,D) (strncpy(B,A,C),(*D)=strlen(B), 0) 00997 00998 #define vattr_null(A) usr_vattr_null(A) 00999 01000 #define VN_HOLD(vp) \ 01001 { \ 01002 (vp)->v_count++; \ 01003 } 01004 01005 #define VN_RELE(vp) \ 01006 do { \ 01007 AFS_ASSERT_GLOCK(); \ 01008 usr_assert((vp)->v_count > 0); \ 01009 if (--((vp)->v_count) == 0) \ 01010 afs_inactive(VTOAFS(vp), get_user_struct()->u_cred); \ 01011 } while(0) 01012 01013 struct usr_statfs { 01014 unsigned long f_type; 01015 unsigned long f_bsize; 01016 unsigned long f_frsize; 01017 unsigned long f_ffree; 01018 unsigned long f_favail; 01019 struct { 01020 unsigned long val[2]; 01021 } f_fsid; 01022 char f_basetype[FSTYPSZ]; 01023 unsigned long f_flag; 01024 unsigned long f_namemax; 01025 unsigned long f_blocks; 01026 unsigned long f_bfree; 01027 unsigned long f_bavail; 01028 unsigned long f_files; 01029 }; 01030 01031 #define ATTR_MODE (1 << 0) 01032 #define ATTR_UID (1 << 1) 01033 #define ATTR_GID (1 << 2) 01034 #define ATTR_MTIME (1 << 3) 01035 #define ATTR_SIZE (1 << 4) 01036 01037 struct usr_vattr { 01038 int va_mask; /* bitmask of ATTR_* values above */ 01039 usr_vtype_t va_type; 01040 mode_t va_mode; 01041 uid_t va_uid; 01042 gid_t va_gid; 01043 int va_fsid; 01044 ino_t va_nodeid; 01045 nlink_t va_nlink; 01046 afs_size_t va_size; 01047 struct timeval va_atime; 01048 struct timeval va_mtime; 01049 struct timeval va_ctime; 01050 dev_t va_rdev; 01051 unsigned long va_blocksize; 01052 fsblkcnt_t va_blocks; 01053 unsigned long va_vcode; 01054 }; 01055 01056 #ifdef VSUID 01057 #undef VSUID 01058 #endif 01059 #ifdef VSGID 01060 #undef VSGID 01061 #endif 01062 #ifdef VSVTX 01063 #undef VSVTX 01064 #endif 01065 #ifdef VREAD 01066 #undef VREAD 01067 #endif 01068 #ifdef VWRITE 01069 #undef VWRITE 01070 #endif 01071 #ifdef VEXEC 01072 #undef VEXEC 01073 #endif 01074 01075 #define VSUID 04000 01076 #define VSGID 02000 01077 #define VSVTX 01000 01078 #define VREAD 00400 01079 #define VWRITE 00200 01080 #define VEXEC 00100 01081 01082 01083 struct usr_vnode { 01084 unsigned short v_flag; 01085 unsigned long v_count; 01086 struct usr_vnodeops *v_op; 01087 struct usr_vfs *v_vfsp; 01088 long v_type; 01089 unsigned long v_rdev; 01090 char *v_data; 01091 }; 01092 01093 struct usr_inode { 01094 daddr_t i_db[NDADDR]; 01095 struct usr_vnode *i_devvp; 01096 unsigned long i_dev; 01097 long i_flag; 01098 struct usr_inode *i_freef; 01099 struct usr_inode **i_freeb; 01100 long i_gid; 01101 daddr_t i_ib[NIADDR]; 01102 unsigned short i_mode; 01103 short i_nlink; 01104 unsigned long i_number; 01105 long i_size; 01106 long i_uid; 01107 struct usr_vnode i_vnode; 01108 struct { 01109 unsigned long ic_spare[4]; 01110 } i_ic; 01111 }; 01112 01113 struct usr_fileops { 01114 int (*vno_rw) (void); 01115 int (*vno_ioctl) (void); 01116 int (*vno_select) (void); 01117 int (*vno_closex) (void); 01118 }; 01119 01120 struct usr_file { 01121 unsigned short f_flag; 01122 offset_t f_offset; 01123 struct usr_ucred *f_cred; 01124 struct usr_fileops *f_ops; 01125 char *f_data; 01126 long f_type; 01127 }; 01128 01129 extern struct usr_file *getf(int); 01130 01131 #ifdef fid_len 01132 #undef fid_len 01133 #endif 01134 #ifdef fid_data 01135 #undef fid_data 01136 #endif 01137 01138 struct usr_fid { 01139 unsigned short fid_len; 01140 unsigned short fid_reserved; 01141 char fid_data[MAXFIDSZ]; 01142 }; 01143 01144 struct usr_flock { 01145 short l_type; 01146 short l_whence; 01147 off_t l_start; 01148 off_t l_len; 01149 long l_sysid; 01150 pid_t l_pid; 01151 }; 01152 01153 extern struct usr_ucred *usr_crget(void); 01154 extern struct usr_ucred *usr_crcopy(struct usr_ucred *); 01155 extern int usr_crhold(struct usr_ucred *); 01156 extern int usr_crfree(struct usr_ucred *); 01157 01158 struct usr_proc { 01159 unsigned long p_flag; 01160 pid_t p_pid; 01161 pid_t p_ppid; 01162 struct usr_ucred *p_ucred; 01163 char p_cursig; 01164 }; 01165 01166 struct usr_a { 01167 int fd; 01168 int syscall; 01169 int parm1; 01170 int parm2; 01171 int parm3; 01172 int parm4; 01173 int parm5; 01174 int parm6; 01175 }; 01176 01177 #ifdef uio_offset 01178 #undef uio_offset 01179 #endif 01180 01181 struct usr_uio { 01182 struct iovec *uio_iov; 01183 int uio_iovcnt; 01184 long uio_offset; 01185 int uio_segflg; 01186 short uio_fmode; 01187 int uio_resid; 01188 }; 01189 01190 #ifdef b_blkno 01191 #undef b_blkno 01192 #endif 01193 #ifdef b_vp 01194 #undef b_vp 01195 #endif 01196 01197 struct usr_buf { 01198 int b_flags; 01199 short b_dev; 01200 unsigned b_bcount; 01201 struct { 01202 char *b_addr; 01203 struct usr_fs *b_fs; 01204 } b_un; 01205 long b_blkno; 01206 unsigned int b_resid; 01207 struct usr_vnode *b_vp; 01208 }; 01209 01210 struct usr_socket { 01211 int sock; 01212 short port; 01213 }; 01214 01215 #define NDIRSIZ_LEN(len) \ 01216 ((sizeof (struct usr_dirent)+4 - (MAXNAMLEN+1)) + (((len)+1 + 3) &~ 3)) 01217 01218 struct vcache; 01219 #define afs_ucred_t struct usr_ucred 01220 #define AFS_FLOCK flock 01221 01222 01223 struct usr_vnodeops { 01224 int (*vn_open) (struct vcache **, afs_int32, afs_ucred_t *); 01225 int (*vn_close) (struct vcache *, afs_int32, afs_ucred_t *); 01226 int (*vn_rdwr) (struct usr_vnode *avc, struct usr_uio *uio, 01227 int rw, int io, struct usr_ucred *cred); 01228 int (*vn_ioctl) (void); 01229 int (*vn_select) (void); 01230 int (*vn_getattr) (struct vcache *avc, struct vattr *, afs_ucred_t *); 01231 int (*vn_setattr) (struct vcache *avc, struct vattr *, afs_ucred_t *); 01232 int (*vn_access) (struct vcache *avc, afs_int32, afs_ucred_t *); 01233 int (*vn_lookup) (struct vcache *adp, char *, struct vcache **, 01234 afs_ucred_t *, int); 01235 int (*vn_create) (struct vcache *adp, char *, struct vattr *, 01236 enum vcexcl, int, struct vcache **, afs_ucred_t *); 01237 int (*vn_remove) (struct vcache *adp, char *, afs_ucred_t *); 01238 int (*vn_link) (struct vcache *avc, struct vcache *adp, char *, 01239 afs_ucred_t *); 01240 int (*vn_rename) (struct vcache *aodp, char *, struct vcache *, char *, 01241 afs_ucred_t *); 01242 int (*vn_mkdir) (struct vcache *adp, char *, struct vattr *, 01243 struct vcache **, afs_ucred_t *); 01244 int (*vn_rmdir) (struct vcache *adp, char *, afs_ucred_t *); 01245 int (*vn_readdir) (struct vcache *avc, struct uio *, afs_ucred_t *); 01246 int (*vn_symlink) (struct vcache *adp, char *, struct vattr *, char *, 01247 afs_ucred_t *); 01248 int (*vn_readlink) (struct vcache *avc, struct uio *, afs_ucred_t *); 01249 int (*vn_fsync) (struct vcache *avc, afs_ucred_t *); 01250 int (*vn_inactive) (struct vcache *avc, afs_ucred_t *acred); 01251 int (*vn_bmap) (void); 01252 int (*vn_strategy) (void); 01253 int (*vn_bread) (void); 01254 int (*vn_brelse) (void); 01255 int (*vn_lockctl) (struct vcache *, struct AFS_FLOCK *, int, 01256 afs_ucred_t *); 01257 int (*vn_fid) (struct vcache *avc, struct fid **); 01258 }; 01259 01260 struct usr_fs { 01261 int dummy; 01262 }; 01263 01264 struct usr_mount { 01265 char m_flags; 01266 unsigned long m_dev; 01267 struct usr_inode *m_inodp; 01268 struct usr_buf *m_bufp; 01269 struct usr_vnode *m_mount; 01270 }; 01271 extern struct usr_mount *getmp(unsigned long); 01272 01273 typedef long usr_whymountroot_t; 01274 01275 struct usr_vfsops { 01276 int (*vfs_mount) (struct vfs *, char *, void *); 01277 int (*vfs_unmount) (struct vfs *); 01278 int (*vfs_root) (struct vfs *, struct vnode **); 01279 int (*vfs_statfs) (struct vfs *, struct statfs *); 01280 int (*vfs_mountroot) (struct vfs *); 01281 int (*vfs_swapvp) (void); 01282 }; 01283 01284 struct usr_vfs { 01285 struct usr_vnode *vfs_vnodecovered; 01286 struct { 01287 unsigned long val[2]; 01288 } vfs_fsid; 01289 char *vfs_data; 01290 unsigned long vfs_bsize; 01291 struct usr_mount *vfs_mount; 01292 struct usr_vfsops *vfs_op; 01293 }; 01294 01295 struct usr_ifnet { 01296 struct usr_ifnet *if_next; 01297 short if_flags; 01298 u_int if_mtu; 01299 u_int if_metric; 01300 struct usr_ifaddr *if_addrlist; 01301 }; 01302 extern struct usr_ifnet *usr_ifnet; 01303 01304 struct usr_ifaddr { 01305 struct usr_ifaddr *ifa_next; 01306 struct usr_ifnet *ifa_ifp; 01307 struct sockaddr ifa_addr; 01308 }; 01309 01310 #ifdef ia_ifp 01311 #undef ia_ifp 01312 #endif 01313 #ifdef ia_addr 01314 #undef ia_addr 01315 #endif 01316 01317 struct usr_in_ifaddr { 01318 struct usr_in_ifaddr *ia_next; 01319 struct usr_ifnet *ia_ifp; 01320 struct sockaddr_in ia_addr; 01321 unsigned long ia_net; 01322 unsigned long ia_netmask; 01323 unsigned long ia_subnet; 01324 unsigned long ia_subnetmask; 01325 struct in_addr ia_netbroadcast; 01326 }; 01327 extern struct usr_in_ifaddr *usr_in_ifaddr; 01328 01329 #endif /* UKERNEL */ 01330 01331 struct min_direct { 01332 #if defined(AFS_USR_OSF_ENV) 01333 unsigned int d_fileno; 01334 #else /* AFS_OFS_ENV || AFS_USR_OSF_ENV */ 01335 unsigned long d_fileno; 01336 #endif /* AFS_OFS_ENV || AFS_USR_OSF_ENV */ 01337 unsigned short d_reclen; 01338 unsigned short d_namlen; 01339 }; 01340 01341 #ifndef NGROUPS 01342 #define NGROUPS NGROUPS_MAX 01343 #endif 01344 #ifndef NOGROUP 01345 #define NOGROUP (-1) 01346 #endif 01347 #ifdef cr_gid 01348 #undef cr_gid 01349 #endif 01350 01351 struct usr_ucred { 01352 unsigned long cr_ref; 01353 long cr_uid; 01354 long cr_gid; 01355 long cr_ruid; 01356 long cr_rgid; 01357 long cr_suid; 01358 long cr_sgid; 01359 long cr_ngroups; 01360 gid_t cr_groups[NGROUPS]; 01361 }; 01362 01363 #ifdef u_rval1 01364 #undef u_rval1 01365 #endif 01366 01367 struct usr_user { 01368 int u_error; 01369 int u_prio; 01370 char *u_ap; 01371 int u_rval1; 01372 long u_viceid; 01373 unsigned long u_expiration; 01374 struct usr_proc *u_procp; 01375 struct usr_ucred *u_cred; 01376 struct { 01377 int r_val1; 01378 } u_r; 01379 }; 01380 #define u_rval1 u_r.r_val1 01381 01382 extern struct usr_user *get_user_struct(void); 01383 01384 #define USR_DIRSIZE 2048 01385 01386 struct usr_dirent { 01387 unsigned long d_ino; 01388 unsigned long d_off; 01389 unsigned short d_reclen; 01390 char d_name[MAXNAMLEN + 1]; 01391 }; 01392 01393 typedef struct { 01394 int dd_fd; 01395 int dd_loc; 01396 int dd_size; 01397 int dd_reserved; 01398 char *dd_buf; 01399 } usr_DIR; 01400 01401 extern unsigned short usr_rx_port; 01402 01403 #define AFS_LOOKUP_NOEVAL 1 01404 01405 #endif /* __AFS_SYSINCLUDESH__ so idempotent */