home *** CD-ROM | disk | FTP | other *** search
/ ftp.mayn.de / ftp.mayn.de-pub.zip / ftp.mayn.de-pub / apple / apple_unix / Sys_stuff / file.h < prev    next >
C/C++ Source or Header  |  2017-03-06  |  6KB  |  175 lines

  1. #if !defined(__sys_file_h)
  2. #define __sys_file_h
  3.  
  4. #if !defined(_NO_IDENTS) && defined(_HEAD_IDENTS)
  5. # pragma ident "@(#)head:sys/file.h    1.23 92/12/18 {Apple version 3.0 90/11/29 11:37:56}"
  6. #endif
  7.  
  8. /*
  9.  * Copyright 1987-91 Apple Computer, Inc.
  10.  * All Rights Reserved.
  11.  *
  12.  * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF APPLE COMPUTER, INC.
  13.  * The copyright notice above does not evidence any actual or
  14.  * intended publication of such source code.
  15.  */
  16.  
  17. /* Copyright 1984-85 AT&T */
  18. /* Copyright 1980-87 The Regents of the University of California */
  19.  
  20. #if !defined(__sys_types_h)
  21. # if defined(__MPW_C__)
  22. #   include "/:usr:include:sys:types.h"
  23. # else
  24. #   include <sys/types.h>
  25. # endif
  26. #endif 
  27.  
  28. /*
  29.  * Descriptor table entry.
  30.  * One for each kernel object.
  31.  */
  32. struct    file {
  33.     struct    file    *f_freel;    /* free list */
  34.     struct    file    *f_activef;    /* active list forward */
  35.     struct    file    *f_activeb;    /* active list backwards */
  36.     int    f_flag;        /* see below */
  37.     short    f_type;        /* descriptor type */
  38.     short    f_count;    /* reference count */
  39.     short    f_asiocnt;    /* outstanding asio's on this file */
  40.     short    f_msgcount;    /* references from message queue */
  41.     struct    fileops {
  42.         int    (*fo_rw)();
  43.         int    (*fo_ioctl)();
  44.         int    (*fo_select)();
  45.         int    (*fo_close)();
  46.         int    (*fo_stat)();
  47.         int     (*fo_setxinfo)();
  48.     } *f_ops;
  49.     caddr_t    f_data;        /* ptr to file specific struct (vnode/socket) */
  50.     off_t    f_offset;
  51.     struct    ucred *f_cred;    /* credentials of user who opened file */
  52. };
  53.  
  54. #ifdef KERNEL
  55.   extern int GNOFILE;            /* size of global file table(s) */
  56.   extern struct file *file_freel;    /* file table free list */
  57.   extern struct file *file_activel;    /* file table active list */
  58.  
  59.   struct file *getf();
  60.   struct file *falloc();
  61. #endif /* KERNEL */
  62.  
  63. /*
  64.  * flags- also for fcntl call.
  65.  */
  66. #define    FOPEN        (-1)
  67. #define    FREAD        0x00000001    /* descriptor read/receive'able */
  68. #define    FWRITE        0x00000002    /* descriptor write/send'able */
  69. #define    FNDELAY        0x00000004    /* no delay */
  70. #define    FAPPEND        0x00000008    /* append on each write */
  71.  
  72. #define    FSHLOCK        0x00000010    /* shared lock present */
  73. #define    FEXLOCK        0x00000020    /* exclusive lock present */
  74. #define    FASYNC        0x00000040    /* signal pgrp when data ready */
  75. #define    FSYNC        0x00000080    /* sychronous writes */
  76.  
  77. /* open only modes */
  78. #define    FCREAT        0x00000100    /* create if nonexistent */
  79. #define    FTRUNC        0x00000200    /* truncate to zero length */
  80. #define    FEXCL        0x00000400    /* error if already created */
  81.  
  82. #define    FKERNEL        0x00000800    /* kernel is doing open */
  83. #define FMARK            0x00001000    /* mark during gc */
  84. #define FDEFER            0x00002000    /* defer for next gc pass */
  85. #define FNONBLOCK       0x00004000    /* no delay POSIX style */
  86. #define    FNOCTTY         0x00008000    /* don't assign controlling tty */
  87. #define    FGETCTTY        0x00010000    /* force controlling tty assignment */
  88. #if SEC_BASE
  89. #define FSTOPIO         0x00020000      /* no further I/O operations */
  90. #endif
  91. #define FASIOSLP    0x00040000    /* waiting for asio in closef() */
  92. #define FNOHUP          0x20000000      /* don't hang up on close */
  93. #define FLOCKOUT        0x40000000      /* exclusive use only */
  94. #define FGLOBAL         0x80000000      /* force allocation from the global table */
  95.  
  96. /* bits to save after open */
  97. #define FMASK        (FREAD | FWRITE | FNDELAY | FNONBLOCK | FAPPEND | FASYNC | FNOCTTY | FGETCTTY | FSYNC | FGLOBAL)
  98.  
  99. #if SEC_BASE
  100. #define FCNTLCANT       (FREAD | FWRITE | FSHLOCK | FEXLOCK | FCREAT | FTRUNC | FEXCL | FKERNEL | FMARK | FDEFER | FNOCTTY | FGETCTTY | FSTOPIO)
  101. #else
  102. #define    FCNTLCANT    (FREAD | FWRITE | FSHLOCK | FEXLOCK | FCREAT | FTRUNC | FEXCL | FKERNEL | FMARK | FDEFER | FNOCTTY | FGETCTTY)
  103. #endif
  104.  
  105. #ifndef    F_DUPFD
  106. /* fcntl(2) requests--from <fcntl.h> */
  107. #define    F_DUPFD        0    /* Duplicate fildes */
  108. #define    F_GETFD        1    /* Get fildes flags */
  109. #define    F_SETFD        2    /* Set fildes flags */
  110. #define    F_GETFL        3    /* Get file flags */
  111. #define    F_SETFL        4    /* Set file flags */
  112. #define    F_GETLK        5    /* Get file lock */
  113. #define    F_SETLK        6    /* Set file lock */
  114. #define    F_SETLKW    7    /* Set file lock and wait */
  115. #define    F_GETOWN    8    /* Get owner */
  116. #define    F_SETOWN    9    /* Set owner */
  117. #endif
  118.  
  119. /*
  120.  * User definitions.
  121.  */
  122.  
  123. /*
  124.  * Open call.
  125.  */
  126.  
  127. #ifndef __fcntl_h    /* most are defined in fcntl.h already */
  128. #define    O_RDONLY    000        /* open for reading */
  129. #define    O_WRONLY    001        /* open for writing */
  130. #define    O_RDWR        002        /* open for read & write */
  131. #define    O_NDELAY    FNDELAY        /* non-blocking open */
  132. #define O_NONBLOCK    FNONBLOCK    /* non-blocking posix style */
  133. #define    O_APPEND    FAPPEND        /* append on each write */
  134. #define    O_CREAT        FCREAT        /* open with file create */
  135. #define    O_TRUNC        FTRUNC        /* open with truncation */
  136. #define    O_EXCL        FEXCL        /* error on create if file exists */
  137. #define    O_NOCTTY    FNOCTTY        /* don't assign controlling tty */
  138. #define    O_GETCTTY    FGETCTTY    /* force controlling tty assignment */
  139. #define O_GLOBAL        FGLOBAL         /* force allocation from the global table */
  140. #define O_SYNC        FSYNC            /* synchronous writes */
  141. #endif    /* !__fcntl_h */
  142. #define O_NOHUP         FNOHUP       /* don't hang up on close */
  143. #define O_LOCKOUT    FLOCKOUT        /* exclusive use only */
  144.  
  145.  
  146. /*
  147.  * Flock call.
  148.  */
  149. #define    LOCK_SH        1    /* shared lock */
  150. #define    LOCK_EX        2    /* exclusive lock */
  151. #define    LOCK_NB        4    /* don't block when locking */
  152. #define    LOCK_UN        8    /* unlock */
  153.  
  154. /*
  155.  * Access call.
  156.  */
  157. #define    F_OK        0    /* does file exist */
  158. #define    X_OK        1    /* is it executable by caller */
  159. #define    W_OK        2    /* writable by caller */
  160. #define    R_OK        4    /* readable by caller */
  161.  
  162. /*
  163.  * Lseek call.
  164.  */
  165. #define    L_SET        0    /* absolute offset */
  166. #define    L_INCR        1    /* relative to current offset */
  167. #define    L_XTND        2    /* relative to end of file */
  168.  
  169. #ifdef KERNEL
  170. # define DTYPE_VNODE    1    /* file */
  171. # define DTYPE_SOCKET    2    /* communications endpoint */
  172. #endif
  173.  
  174. #endif /* __sys_file_h */
  175.