home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilss / sockets / include / sys / h / file < prev    next >
Encoding:
Text File  |  1995-01-11  |  2.9 KB  |  116 lines

  1. /*
  2.  * $Header: /ax/networking:include/sys/file.h:networking  1.1  $
  3.  * $Source: /ax/networking:include/sys/file.h: $
  4.  *
  5.  * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
  6.  *
  7.  * $Log:    file.h,v $
  8.  * Revision 1.1  95/01/11  10:19:15  kwelton
  9.  * Initial revision
  10.  * 
  11.  * Revision 1.4  88/09/11  18:00:16  keith
  12.  * Make inclusion of fcntl.h conditional on it not already benn done.
  13.  * This allows user programs (eg pstat, netstat, etc) to do an explictit
  14.  * #define KERNEL (to get the definitions of kernel data structures)
  15.  * without the compiler attempting to look for "../h/fcntl.h"
  16.  * 
  17.  * Revision 1.3  88/06/17  20:19:16  beta
  18.  * Acorn Unix initial beta version
  19.  * 
  20.  */
  21. /* @(#)file.h    1.5 87/07/21 3.2/4.3NFSSRC */
  22. /*
  23.  * Copyright (c) 1982, 1986 Regents of the University of California.
  24.  * All rights reserved.  The Berkeley software License Agreement
  25.  * specifies the terms and conditions for redistribution.
  26.  *
  27.  *    @(#)file.h    7.1 (Berkeley) 6/4/86
  28.  */
  29.  
  30. #ifndef __FCNTL_HEADER__
  31. #  ifdef KERNEL
  32. #    include "fcntl.h"
  33. #  else KERNEL
  34. #    include <sys/fcntl.h>
  35. #  endif KERNEL
  36. #endif !__FCNTL_HEADER__
  37.  
  38. #ifdef KERNEL
  39. /*
  40.  * Descriptor table entry.
  41.  * One for each kernel object.
  42.  */
  43. struct    file {
  44.     int    f_flag;        /* see below */
  45.     short    f_type;        /* descriptor type */
  46.     short    f_count;    /* reference count */
  47.     short    f_msgcount;    /* references from message queue */
  48.     struct    fileops {
  49.         int    (*fo_rw)();
  50.         int    (*fo_ioctl)();
  51.         int    (*fo_select)();
  52.         int    (*fo_close)();
  53.     } *f_ops;
  54.     caddr_t    f_data;        /* ptr to file specific struct (vnode/socket) */
  55.     off_t    f_offset;
  56.     struct    ucred *f_cred;    /* credentials of user who opened file */
  57. };
  58.  
  59. #ifdef    DYNALLOC
  60. struct    file *file, *fileNFILE;
  61. #else    DYNALLOC
  62. struct    file stat_file[NFILE], *file, *fileNFILE;
  63. #endif    DYNALLOC
  64. int    nfile;
  65. struct    file *getf();
  66. struct    file *falloc();
  67. #endif
  68.  
  69. /*
  70.  * flags- also for fcntl call.
  71.  */
  72. #define    FOPEN        (-1)
  73. #define    FREAD        00001        /* descriptor read/receive'able */
  74. #define    FWRITE        00002        /* descriptor write/send'able */
  75. #define    FMARK        00020        /* mark during gc() */
  76. #define    FDEFER        00040        /* defer for next gc pass */
  77. #define    FSHLOCK        00200        /* shared lock present */
  78. #define    FEXLOCK        00400        /* exclusive lock present */
  79.  
  80. /* bits to save after open */
  81. #define    FMASK        00113
  82. #define    FCNTLCANT    (FREAD|FWRITE|FMARK|FDEFER|FSHLOCK|FEXLOCK)
  83.  
  84. /*
  85.  * User definitions.
  86.  */
  87.  
  88. /*
  89.  * Flock call.
  90.  */
  91. #define    LOCK_SH        1    /* shared lock */
  92. #define    LOCK_EX        2    /* exclusive lock */
  93. #define    LOCK_NB        4    /* don't block when locking */
  94. #define    LOCK_UN        8    /* unlock */
  95.  
  96. /*
  97.  * Lseek call.
  98.  */
  99. #define    L_SET        0    /* absolute offset */
  100. #define    L_INCR        1    /* relative to current offset */
  101. #define    L_XTND        2    /* relative to end of file */
  102.  
  103. #ifdef KERNEL
  104. #define    GETF(fp, fd) { \
  105.     if ((unsigned)(fd) >= NOFILE || ((fp) = u.u_ofile[fd]) == NULL) { \
  106.         u.u_error = EBADF; \
  107.         return; \
  108.     } \
  109. }
  110.  
  111. #define    DTYPE_VNODE    1    /* file */
  112. #define    DTYPE_SOCKET    2    /* communications endpoint */
  113. #endif
  114.  
  115. /* EOF file.h */
  116.