The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bsd/hfs/hfs_cnode.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    8  * This file contains Original Code and/or Modifications of Original Code
    9  * as defined in and that are subject to the Apple Public Source License
   10  * Version 2.0 (the 'License'). You may not use this file except in
   11  * compliance with the License. Please obtain a copy of the License at
   12  * http://www.opensource.apple.com/apsl/ and read it before using this
   13  * file.
   14  * 
   15  * The Original Code and all software distributed under the License are
   16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   20  * Please see the License for the specific language governing rights and
   21  * limitations under the License.
   22  * 
   23  * @APPLE_LICENSE_HEADER_END@
   24  */
   25 #ifndef _HFS_CNODE_H_
   26 #define _HFS_CNODE_H_
   27 
   28 #include <sys/appleapiopts.h>
   29 
   30 #ifdef KERNEL
   31 #ifdef __APPLE_API_PRIVATE
   32 #include <sys/types.h>
   33 #include <sys/lock.h>
   34 #include <sys/queue.h>
   35 #include <sys/stat.h>
   36 #include <sys/vnode.h>
   37 #include <sys/quota.h>
   38 
   39 #include <hfs/hfs_catalog.h>
   40 #include <hfs/rangelist.h>
   41 
   42 
   43 /*
   44  * The filefork is used to represent an HFS file fork (data or resource).
   45  * Reading or writing any of these fields requires holding cnode lock.
   46  */
   47 struct filefork {
   48         struct cnode    *ff_cp;         /* cnode associated with this fork */
   49         struct rl_head  ff_invalidranges; /* Areas of disk that should read back as zeroes */
   50         long                    ff_evtonly_refs;        /* number of vnode references used solely for events (O_EVTONLY) */
   51         union {
   52           struct hfslockf *ffu_lockf;   /* Head of byte-level lock list. */
   53           void *ffu_sysdata;            /* private data for system files */
   54           char *ffu_symlinkptr;         /* symbolic link pathname */
   55         } ff_un;
   56         struct cat_fork ff_data;
   57 };
   58 typedef struct filefork filefork_t;
   59 
   60 /* Aliases for common fields */
   61 #define ff_size         ff_data.cf_size
   62 #define ff_clumpsize    ff_data.cf_clump
   63 #define ff_bytesread    ff_data.cf_bytesread
   64 #define ff_blocks       ff_data.cf_blocks
   65 #define ff_extents      ff_data.cf_extents
   66 #define ff_unallocblocks ff_data.cf_vblocks
   67 
   68 #define ff_symlinkptr   ff_un.ffu_symlinkptr
   69 #define ff_lockf        ff_un.ffu_lockf
   70 
   71 
   72 /* The btree code still needs these... */
   73 #define fcbEOF          ff_size
   74 #define fcbExtents      ff_extents
   75 #define fcbBTCBPtr      ff_un.ffu_sysdata
   76 
   77 
   78 /*
   79  * Directory index entry
   80  */
   81 struct  hfs_index {
   82         SLIST_ENTRY(hfs_index) hi_link;
   83         int     hi_index;
   84         void    *hi_thread;     /* thread that created index entry */
   85         char    hi_name[1];
   86 };
   87 
   88 /*
   89  * The cnode is used to represent each active (or recently active)
   90  * file or directory in the HFS filesystem.
   91  *
   92  * Reading or writing any of these fields requires holding c_lock.
   93  */
   94 struct cnode {
   95         struct lock__bsd__      c_lock;         /* cnode's lock */
   96         LIST_ENTRY(cnode)       c_hash;         /* cnode's hash chain */
   97         u_int32_t               c_flag;         /* cnode's runtime flags */
   98         struct vnode            *c_vp;          /* vnode for data fork or dir */
   99         struct vnode            *c_rsrc_vp;     /* vnode for resource fork */
  100         struct vnode            *c_devvp;       /* vnode for block I/O */
  101         dev_t                   c_dev;          /* cnode's device */
  102         struct dquot            *c_dquot[MAXQUOTAS]; /* cnode's quota info */
  103         struct klist            c_knotes;       /* knotes attached to this vnode */
  104         cnid_t                  c_childhint;    /* catalog hint for children */
  105         struct cat_desc         c_desc;         /* cnode's descriptor */
  106         struct cat_attr         c_attr;         /* cnode's attributes */
  107         SLIST_HEAD(hfs_indexhead, hfs_index) c_indexlist;  /* directory index list */
  108         long                c_evtonly_refs;     /* number of vnode references used solely for events (O_EVTONLY) */
  109         struct filefork         *c_datafork;    /* cnode's data fork */
  110         struct filefork         *c_rsrcfork;    /* cnode's rsrc fork */
  111 };
  112 typedef struct cnode cnode_t;
  113 
  114 /* Aliases for common cnode fields */
  115 #define c_cnid          c_desc.cd_cnid
  116 #define c_hint          c_desc.cd_hint
  117 #define c_parentcnid    c_desc.cd_parentcnid
  118 #define c_encoding      c_desc.cd_encoding
  119 
  120 #define c_fileid        c_attr.ca_fileid
  121 #define c_mode          c_attr.ca_mode
  122 #define c_nlink         c_attr.ca_nlink
  123 #define c_uid           c_attr.ca_uid
  124 #define c_gid           c_attr.ca_gid
  125 #define c_rdev          c_attr.ca_rdev
  126 #define c_atime         c_attr.ca_atime
  127 #define c_mtime         c_attr.ca_mtime
  128 #define c_mtime_nsec    c_attr.ca_mtime_nsec
  129 #define c_ctime         c_attr.ca_ctime
  130 #define c_itime         c_attr.ca_itime
  131 #define c_btime         c_attr.ca_btime
  132 #define c_flags         c_attr.ca_flags
  133 #define c_finderinfo    c_attr.ca_finderinfo
  134 #define c_blocks        c_attr.ca_blocks
  135 #define c_entries       c_attr.ca_entries
  136 #define c_zftimeout     c_childhint
  137 
  138 
  139 /* Runtime cnode flags (kept in c_flag) */
  140 #define C_ACCESS        0x00001 /* Access time update request */
  141 #define C_CHANGE        0x00002 /* Change time update request */
  142 #define C_UPDATE        0x00004 /* Modification time update request */
  143 #define C_MODIFIED      0x00008 /* CNode has been modified */
  144 
  145 #define C_RELOCATING    0x00010 /* CNode's fork is being relocated */
  146 #define C_NOEXISTS      0x00020 /* CNode has been deleted, catalog entry is gone */
  147 #define C_DELETED       0x00040 /* CNode has been marked to be deleted */
  148 #define C_HARDLINK      0x00080 /* CNode is a hard link */
  149 
  150 #define C_ALLOC         0x00100 /* CNode is being allocated */
  151 #define C_WALLOC        0x00200 /* Waiting for allocation to finish */
  152 #define C_TRANSIT       0x00400 /* CNode is getting recycled  */
  153 #define C_WTRANSIT      0x00800 /* Waiting for cnode getting recycled  */
  154 #define C_NOBLKMAP      0x01000 /* CNode blocks cannot be mapped */
  155 #define C_WBLKMAP       0x02000 /* Waiting for block map */
  156 
  157 #define C_ZFWANTSYNC    0x04000 /* fsync requested and file has holes */
  158 #define C_VPREFHELD     0x08000 /* resource fork has done a vget() on c_vp (for its parent ptr) */
  159 
  160 #define C_FROMSYNC      0x10000 /* fsync was called from sync */ 
  161 #define C_FORCEUPDATE   0x20000 /* force the catalog entry update */
  162 
  163 
  164 #define ZFTIMELIMIT     (5 * 60)
  165 
  166 /*
  167  * Convert between cnode pointers and vnode pointers
  168  */
  169 #define VTOC(vp)        ((struct cnode *)(vp)->v_data)
  170 
  171 #define CTOV(cp,rsrc)   (((rsrc) && S_ISREG((cp)->c_mode)) ? \
  172                         (cp)->c_rsrc_vp : (cp)->c_vp)
  173 
  174 /*
  175  * Convert between vnode pointers and file forks
  176  *
  177  * Note: no CTOF since that is ambiguous
  178  */
  179 
  180 #define FTOC(fp)        ((fp)->ff_cp)
  181 
  182 #define VTOF(vp)        ((vp) == VTOC((vp))->c_rsrc_vp ?        \
  183                          VTOC((vp))->c_rsrcfork :               \
  184                          VTOC((vp))->c_datafork)
  185 
  186 #define FTOV(fp)        ((fp) == FTOC(fp)->c_rsrcfork ?         \
  187                          FTOC(fp)->c_rsrc_vp :                  \
  188                          FTOC(fp)->c_vp)
  189 
  190 #define EVTONLYREFS(vp) ((vp->v_type == VREG) ? VTOF(vp)->ff_evtonly_refs : VTOC(vp)->c_evtonly_refs)
  191 
  192 /*
  193  * Test for a resource fork
  194  */
  195 #define FORK_IS_RSRC(fp)        ((fp) == FTOC(fp)->c_rsrcfork)
  196 
  197 #define VNODE_IS_RSRC(vp)       ((vp) == VTOC((vp))->c_rsrc_vp)
  198 
  199 
  200 /*
  201  * CTIMES should be an inline function...
  202  */
  203 #define C_TIMEMASK      (C_ACCESS | C_CHANGE | C_UPDATE)
  204 
  205 #define C_CHANGEMASK    (C_ACCESS | C_CHANGE | C_UPDATE | C_MODIFIED)
  206 
  207 #define ATIME_ACCURACY          1
  208 #define ATIME_ONDISK_ACCURACY   300
  209 
  210 #define CTIMES(cp, t1, t2) {                                                    \
  211         if ((cp)->c_flag & C_TIMEMASK) {                                        \
  212                 /*                                                              \
  213                  * Only do the update if it is more than just                   \
  214                  * the C_ACCESS field being updated.                            \
  215                  */                                                             \
  216                 if (((cp)->c_flag & C_CHANGEMASK) != C_ACCESS) {                \
  217                         if ((cp)->c_flag & C_ACCESS) {                          \
  218                                 (cp)->c_atime = (t1)->tv_sec;                   \
  219                         }                                                       \
  220                         if ((cp)->c_flag & C_UPDATE) {                          \
  221                                 (cp)->c_mtime = (t2)->tv_sec;                   \
  222                                 (cp)->c_mtime_nsec = (t2)->tv_usec * 1000;      \
  223                         }                                                       \
  224                         if ((cp)->c_flag & C_CHANGE) {                          \
  225                                 (cp)->c_ctime = time.tv_sec;                    \
  226                         }                                                       \
  227                         (cp)->c_flag |= C_MODIFIED;                             \
  228                         (cp)->c_flag &= ~C_TIMEMASK;                            \
  229                 }                                                               \
  230         }                                                                       \
  231 }
  232 
  233 /* This overlays the fid structure (see mount.h). */
  234 struct hfsfid {
  235         u_int16_t hfsfid_len;   /* Length of structure. */
  236         u_int16_t hfsfid_pad;   /* Force 32-bit alignment. */
  237         /* The following data is filesystem-dependent, up to MAXFIDSZ (16) bytes: */
  238         u_int32_t hfsfid_cnid;  /* Catalog node ID. */
  239         u_int32_t hfsfid_gen;   /* Generation number (create date). */
  240 };
  241 
  242 
  243 /*
  244  * HFS cnode hash functions.
  245  */
  246 extern void  hfs_chashinit(void);
  247 extern void  hfs_chashinsert(struct cnode *cp);
  248 extern void  hfs_chashremove(struct cnode *cp);
  249 extern struct cnode * hfs_chashget(dev_t dev, ino_t inum, int wantrsrc,
  250                                 struct vnode **vpp, struct vnode **rvpp);
  251 
  252 #endif /* __APPLE_API_PRIVATE */
  253 #endif /* KERNEL */
  254 
  255 #endif /* ! _HFS_CNODE_H_ */

Cache object: 6e25751475c0cd6acdfb532214a58389


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.