home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Header: /ax/networking:include/sys/file.h:networking 1.1 $
- * $Source: /ax/networking:include/sys/file.h: $
- *
- * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
- *
- * $Log: file.h,v $
- * Revision 1.1 95/01/11 10:19:15 kwelton
- * Initial revision
- *
- * Revision 1.4 88/09/11 18:00:16 keith
- * Make inclusion of fcntl.h conditional on it not already benn done.
- * This allows user programs (eg pstat, netstat, etc) to do an explictit
- * #define KERNEL (to get the definitions of kernel data structures)
- * without the compiler attempting to look for "../h/fcntl.h"
- *
- * Revision 1.3 88/06/17 20:19:16 beta
- * Acorn Unix initial beta version
- *
- */
- /* @(#)file.h 1.5 87/07/21 3.2/4.3NFSSRC */
- /*
- * Copyright (c) 1982, 1986 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- *
- * @(#)file.h 7.1 (Berkeley) 6/4/86
- */
-
- #ifndef __FCNTL_HEADER__
- # ifdef KERNEL
- # include "fcntl.h"
- # else KERNEL
- # include <sys/fcntl.h>
- # endif KERNEL
- #endif !__FCNTL_HEADER__
-
- #ifdef KERNEL
- /*
- * Descriptor table entry.
- * One for each kernel object.
- */
- struct file {
- int f_flag; /* see below */
- short f_type; /* descriptor type */
- short f_count; /* reference count */
- short f_msgcount; /* references from message queue */
- struct fileops {
- int (*fo_rw)();
- int (*fo_ioctl)();
- int (*fo_select)();
- int (*fo_close)();
- } *f_ops;
- caddr_t f_data; /* ptr to file specific struct (vnode/socket) */
- off_t f_offset;
- struct ucred *f_cred; /* credentials of user who opened file */
- };
-
- #ifdef DYNALLOC
- struct file *file, *fileNFILE;
- #else DYNALLOC
- struct file stat_file[NFILE], *file, *fileNFILE;
- #endif DYNALLOC
- int nfile;
- struct file *getf();
- struct file *falloc();
- #endif
-
- /*
- * flags- also for fcntl call.
- */
- #define FOPEN (-1)
- #define FREAD 00001 /* descriptor read/receive'able */
- #define FWRITE 00002 /* descriptor write/send'able */
- #define FMARK 00020 /* mark during gc() */
- #define FDEFER 00040 /* defer for next gc pass */
- #define FSHLOCK 00200 /* shared lock present */
- #define FEXLOCK 00400 /* exclusive lock present */
-
- /* bits to save after open */
- #define FMASK 00113
- #define FCNTLCANT (FREAD|FWRITE|FMARK|FDEFER|FSHLOCK|FEXLOCK)
-
- /*
- * User definitions.
- */
-
- /*
- * Flock call.
- */
- #define LOCK_SH 1 /* shared lock */
- #define LOCK_EX 2 /* exclusive lock */
- #define LOCK_NB 4 /* don't block when locking */
- #define LOCK_UN 8 /* unlock */
-
- /*
- * Lseek call.
- */
- #define L_SET 0 /* absolute offset */
- #define L_INCR 1 /* relative to current offset */
- #define L_XTND 2 /* relative to end of file */
-
- #ifdef KERNEL
- #define GETF(fp, fd) { \
- if ((unsigned)(fd) >= NOFILE || ((fp) = u.u_ofile[fd]) == NULL) { \
- u.u_error = EBADF; \
- return; \
- } \
- }
-
- #define DTYPE_VNODE 1 /* file */
- #define DTYPE_SOCKET 2 /* communications endpoint */
- #endif
-
- /* EOF file.h */
-