home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / include / sys / ubc.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  5.4 KB  |  159 lines

  1. /*
  2.  * Copyright (c) 1999, 2000 Apple Computer, Inc. All rights reserved.
  3.  *
  4.  * @APPLE_LICENSE_HEADER_START@
  5.  * 
  6.  * The contents of this file constitute Original Code as defined in and
  7.  * are subject to the Apple Public Source License Version 1.1 (the
  8.  * "License").  You may not use this file except in compliance with the
  9.  * License.  Please obtain a copy of the License at
  10.  * http://www.apple.com/publicsource and read it before using this file.
  11.  * 
  12.  * This Original Code and all software distributed under the License are
  13.  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  14.  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  15.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  16.  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
  17.  * License for the specific language governing rights and limitations
  18.  * under the License.
  19.  * 
  20.  * @APPLE_LICENSE_HEADER_END@
  21.  */
  22. /* 
  23.  *    File:    ubc.h
  24.  *    Author:    Umesh Vaishampayan [umeshv@apple.com]
  25.  *        05-Aug-1999    umeshv    Created.
  26.  *
  27.  *    Header file for Unified Buffer Cache.
  28.  *
  29.  */ 
  30.  
  31. #ifndef    _SYS_UBC_H_
  32. #define    _SYS_UBC_H_
  33.  
  34. #include <sys/types.h>
  35. #include <sys/ucred.h>
  36. #include <sys/vnode.h>
  37.  
  38. #include <sys/cdefs.h>
  39.  
  40. #include <mach/memory_object_types.h>
  41.  
  42. #define UBC_INFO_NULL    ((struct ubc_info *) 0)
  43. #define UBC_NOINFO        ((struct ubc_info *)0xDEADD1ED)
  44.  
  45. extern struct zone    *ubc_info_zone;
  46.  
  47. /*
  48.  *    The following data structure keeps the information to associate
  49.  *    a vnode to the correspondig VM objects.
  50.  */
  51.  
  52. struct ubc_info {
  53.     memory_object_t            ui_pager;    /* pager */
  54.     memory_object_control_t    ui_control;    /* VM control for the pager */
  55.     long                    ui_flags;    /* flags */
  56.     struct vnode             *ui_vnode;    /* The vnode for this ubc_info */
  57.     struct ucred             *ui_ucred;    /* holds credentials for NFS paging */
  58.     int                        ui_refcount;/* ref count on the ubc_info */
  59.     off_t                    ui_size;    /* file size for the vnode */
  60.     long                    ui_mapped;    /* is it currently mapped */
  61. };
  62.  
  63. /* Defines for ui_flags */
  64. #define    UI_NONE            0x00000000        /* none */
  65. #define    UI_HASPAGER        0x00000001        /* has a pager associated */
  66. #define    UI_INITED        0x00000002        /* newly initialized vnode */
  67. #define UI_HASOBJREF    0x00000004        /* hold a reference on object */
  68. #define UI_WASMAPPED    0x00000008        /* vnode was mapped */
  69. #define    UI_DONTCACHE    0x00000010        /* do not cache object */
  70.  
  71. /*
  72.  * exported primitives for loadable file systems.
  73.  */
  74.  
  75. __BEGIN_DECLS
  76. int    ubc_info_init __P((struct vnode *));
  77. void    ubc_info_deallocate  __P((struct ubc_info *));
  78. int    ubc_setsize __P((struct vnode *, off_t));
  79. off_t    ubc_getsize __P((struct vnode *));
  80. int    ubc_uncache __P((struct vnode *));
  81. int    ubc_umount __P((struct mount *));
  82. void    ubc_unmountall __P(());
  83. int    ubc_setcred __P((struct vnode *, struct proc *));
  84. struct ucred *ubc_getcred __P((struct vnode *));
  85. memory_object_t ubc_getpager __P((struct vnode *));
  86. memory_object_control_t ubc_getobject __P((struct vnode *, int));
  87. int ubc_setpager __P((struct vnode *, memory_object_t));
  88. int ubc_setflags __P((struct vnode *, int));
  89. int ubc_clearflags __P((struct vnode *, int));
  90. int ubc_issetflags __P((struct vnode *, int));
  91. off_t ubc_blktooff __P((struct vnode *, daddr_t));
  92. daddr_t ubc_offtoblk __P((struct vnode *, off_t));
  93. int ubc_clean __P((struct vnode *, int));
  94. int    ubc_pushdirty __P((struct vnode *));
  95. int    ubc_pushdirty_range __P((struct vnode *, off_t, off_t));
  96. int ubc_hold __P((struct vnode *));
  97. void ubc_rele __P((struct vnode *));
  98. void ubc_map __P((struct vnode *));
  99. int    ubc_destroy_named __P((struct vnode *));
  100. int    ubc_release_named __P((struct vnode *));
  101. int    ubc_invalidate __P((struct vnode *, off_t, size_t));
  102. int    ubc_isinuse __P((struct vnode *, int));
  103.  
  104. int    ubc_page_op __P((struct vnode *, off_t, int, vm_offset_t *, int *));
  105.  
  106. /* cluster IO routines */
  107. int    cluster_read __P((struct vnode *, struct uio *, off_t, int, int));
  108. int    advisory_read __P((struct vnode *, off_t, off_t, int, int));
  109. int    cluster_write __P((struct vnode *, struct uio*, off_t, off_t,
  110.         off_t, off_t,  int, int));
  111. int    cluster_push __P((struct vnode *));
  112. int    cluster_pageout __P((struct vnode *, upl_t, vm_offset_t, off_t, int,
  113.         off_t, int, int));
  114. int    cluster_pagein __P((struct vnode *, upl_t, vm_offset_t, off_t, int,
  115.         off_t, int, int));
  116. int    cluster_bp __P((struct buf *));
  117.  
  118. /* UPL routines */
  119. int    ubc_create_upl __P((struct vnode *, off_t, long, upl_t *,
  120.         upl_page_info_t **, int));
  121. int ubc_upl_map __P((upl_t, vm_offset_t *));
  122. int ubc_upl_unmap __P((upl_t));
  123. int ubc_upl_commit __P((upl_t));
  124. int ubc_upl_commit_range __P((upl_t, vm_offset_t, vm_size_t, int));
  125. int ubc_upl_abort __P((upl_t, int));
  126. int ubc_upl_abort_range __P((upl_t, vm_offset_t, vm_size_t, int));
  127. upl_page_info_t *ubc_upl_pageinfo __P((upl_t));
  128. __END_DECLS
  129.  
  130. #define UBCINFOMISSING(vp) \
  131.     ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_INFO_NULL))
  132.  
  133. #define UBCINFORECLAIMED(vp) \
  134.     ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_NOINFO))
  135.  
  136. #define UBCINFOEXISTS(vp) \
  137.     ((vp) && ((vp)->v_type == VREG) && \
  138.         ((vp)->v_ubcinfo) && ((vp)->v_ubcinfo != UBC_NOINFO))
  139.  
  140. #define UBCISVALID(vp) \
  141.     ((vp) && ((vp)->v_type == VREG) && !((vp)->v_flag & VSYSTEM))
  142.  
  143. #define UBCINVALID(vp) \
  144.     (((vp) == NULL) || ((vp) && ((vp)->v_type != VREG))     \
  145.         || ((vp) && ((vp)->v_flag & VSYSTEM)))
  146.  
  147. #define UBCINFOCHECK(fun, vp)  \
  148.     if ((vp) && ((vp)->v_type == VREG) &&   \
  149.             (((vp)->v_ubcinfo == UBC_INFO_NULL)     \
  150.             || ((vp)->v_ubcinfo == UBC_NOINFO))) \
  151.         panic("%s: lost ubc_info", (fun));
  152.  
  153. /* Flags for ubc_getobject() */
  154. #define UBC_FLAGS_NONE        0x0000
  155. #define UBC_HOLDOBJECT        0x0001
  156.  
  157. #endif    /* _SYS_UBC_H_ */
  158.  
  159.