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

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