Part 1/many USERFS support. Bring in the initial userfs infrastructure.
[dragonfly.git] / sys / sys / vfscache.h
1 /*
2  * Copyright (c) 2004 The DragonFly Project.  All rights reserved.
3  *
4  * This code is derived from software contributed to The DragonFly Project
5  * by Matthew Dillon <dillon@backplane.com>
6  * 
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name of The DragonFly Project nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific, prior written permission.
20  * 
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *
35  * Copyright (c) 1989, 1993
36  *      The Regents of the University of California.  All rights reserved.
37  *
38  * Redistribution and use in source and binary forms, with or without
39  * modification, are permitted provided that the following conditions
40  * are met:
41  * 1. Redistributions of source code must retain the above copyright
42  *    notice, this list of conditions and the following disclaimer.
43  * 2. Redistributions in binary form must reproduce the above copyright
44  *    notice, this list of conditions and the following disclaimer in the
45  *    documentation and/or other materials provided with the distribution.
46  * 3. All advertising materials mentioning features or use of this software
47  *    must display the following acknowledgement:
48  *      This product includes software developed by the University of
49  *      California, Berkeley and its contributors.
50  * 4. Neither the name of the University nor the names of its contributors
51  *    may be used to endorse or promote products derived from this software
52  *    without specific prior written permission.
53  *
54  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64  * SUCH DAMAGE.
65  *
66  * $DragonFly: src/sys/sys/vfscache.h,v 1.10 2007/08/13 17:49:16 dillon Exp $
67  */
68 /*
69  * This module serves as a focal point for virtually all filesystem and
70  * device related calls.  It is or will be responsible for all high level
71  * kernel management for filesystem and device operations, including but
72  * limited to:
73  *
74  *      Function                        Status
75  *      ----------------                -----
76  *      Journaling                      TODO
77  *      Range Locking                   TODO
78  *      Cache Coherency                 TODO
79  *      VNode Operations Dispatch       TODO
80  *      Mount Point Operations          TODO
81  *      FileOps Operations              TODO
82  */
83
84 #ifndef _SYS_VFSCACHE_H_
85 #define _SYS_VFSCACHE_H_
86
87 #ifndef _SYS_TYPES_H_
88 #include <sys/types.h>
89 #endif
90 #ifndef _SYS_TIME_H_
91 #include <sys/time.h>
92 #endif
93 #ifndef _SYS_VFSOPS_H_
94 #include <sys/vfsops.h>
95 #endif
96
97 /*
98  * Vnode types.  VNON means no type.
99  */
100 enum vtype      { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };
101
102 /*
103  * Vnode tag types.
104  * These are for the benefit of external programs only (e.g., pstat)
105  * and should NEVER be inspected by the kernel.
106  */
107 enum vtagtype   {
108         VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_PC, VT_LFS, VT_LOFS, VT_FDESC,
109         VT_PORTAL, VT_NULL, VT_UNUSED10, VT_KERNFS, VT_PROCFS, VT_AFS,
110         VT_ISOFS, VT_UNION, VT_MSDOSFS, VT_TFS, VT_VFS, VT_CODA, VT_NTFS,
111         VT_HPFS, VT_NWFS, VT_SMBFS, VT_UDF, VT_EXT2FS, VT_SYNTH,
112         VT_USERFS
113 };
114
115 /*
116  * Vnode attributes.  A field value of VNOVAL represents a field whose value
117  * is unavailable (getattr) or which is not to be changed (setattr).
118  */
119 struct vattr {
120         enum vtype      va_type;        /* vnode type (for create) */
121         nlink_t         va_nlink;       /* number of references to file */
122         u_short         va_mode;        /* files access mode and type */
123         uid_t           va_uid;         /* owner user id */
124         gid_t           va_gid;         /* owner group id */
125         udev_t          va_fsid;        /* file system id */
126         long            va_fileid;      /* file id */
127         u_quad_t        va_size;        /* file size in bytes */
128         long            va_blocksize;   /* blocksize preferred for i/o */
129         struct timespec va_atime;       /* time of last access */
130         struct timespec va_mtime;       /* time of last modification */
131         struct timespec va_ctime;       /* time file changed */
132         u_long          va_gen;         /* generation number of file */
133         u_long          va_flags;       /* flags defined for file */
134         int             va_rmajor;      /* device the special file represents */
135         int             va_rminor;
136         u_quad_t        va_bytes;       /* bytes of disk space held by file */
137         u_quad_t        va_filerev;     /* file modification number */
138         u_int           va_vaflags;     /* operations flags, see below */
139         long            va_spare;       /* remain quad aligned */
140         int64_t         va_fsmid;       /* filesystem modification id */
141 };
142
143 /*
144  * Flags for va_vaflags.
145  */
146 #define VA_UTIMES_NULL  0x01            /* utimes argument was NULL */
147 #define VA_EXCLUSIVE    0x02            /* exclusive create request */
148
149 #if 0   /* NOT YET */
150
151 /*
152  * The vfscache structure holds the system cacheable elements associated with 
153  * a file or device.  This structure is most typically embedded within a
154  * vnode.
155  */
156 struct vfscache {
157         int                     fc_flags;
158         struct vm_object        *fc_object;     /* cached data */
159         struct vattr            fc_attr;        /* cached attribute data */
160 };
161
162 #define FCF_ATTR_GOOD           0x00000001      /* FUTURE */
163 #define FCF_ATTR_ATIME          0x00010000      /* FUTURE attr modifications */
164 #define FCF_ATTR_MTIME          0x00020000      /* FUTURE attr modifications */
165 #define FCF_ATTR_CTIME          0x00040000      /* FUTURE attr modifications */
166 #define FCF_ATTR_UID            0x00080000      /* FUTURE attr modifications */
167 #define FCF_ATTR_GID            0x00100000      /* FUTURE attr modifications */
168 #define FCF_ATTR_SIZE           0x00200000      /* FUTURE attr modifications */
169
170 #endif
171
172 #endif
173