Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / share / doc / papers / fsinterface / slides.t
1 .\" Copyright (c) 1986 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)slides.t    5.2 (Berkeley) 4/16/91
33 .\"
34 .so macros
35 .nf
36 .LL
37 Encapsulation of namei parameters
38 .NP 0
39 .ta .5i +\w'caddr_t\0\0'u +\w'struct\0\0'u +\w'vnode *nc_prevdir;\0\0\0\0\0'u
40 struct nameidata {
41    /* arguments and context: */
42         caddr_t ni_dirp;
43         enum    uio_seg ni_seg;
44         short   ni_nameiop;
45         struct  vnode *ni_cdir;
46         struct  vnode *ni_rdir;
47         struct  ucred *ni_cred;
48 .sp .2
49    /* shared with lookup and commit: */
50         caddr_t ni_pnbuf;
51         char    *ni_ptr;
52         int     ni_pathlen;
53         short   ni_more;
54         short   ni_loopcnt;
55 .sp .2
56    /* results: */
57         struct  vnode *ni_vp;
58         struct  vnode *ni_dvp;
59 .sp .2
60 /* BEGIN UFS SPECIFIC */
61         struct diroffcache {
62                 struct  vnode *nc_prevdir;
63                 long    nc_id;
64                 off_t   nc_prevoffset;
65         } ni_nc;
66 /* END UFS SPECIFIC */
67 };
68 .bp
69
70
71 .LL
72 Namei operations and modifiers
73
74 .NP 0
75 .ta \w'#define\0\0'u +\w'WANTPARENT\0\0'u +\w'0x40\0\0\0\0\0\0\0'u
76 #define LOOKUP  0       /* name lookup only */
77 #define CREATE  1       /* setup for creation */
78 #define DELETE  2       /* setup for deletion */
79 #define WANTPARENT      0x10    /* return parent vnode also */
80 #define NOCACHE 0x20    /* remove name from cache */
81 #define FOLLOW  0x40    /* follow symbolic links */
82 .bp
83
84 .LL
85 Namei operations and modifiers
86
87 .NP 0
88 .ta \w'#define\0\0'u +\w'WANTPARENT\0\0'u +\w'0x40\0\0\0\0\0\0\0'u
89 #define LOOKUP  0
90 #define CREATE  1
91 #define DELETE  2
92 #define WANTPARENT      0x10
93 #define NOCACHE 0x20
94 #define FOLLOW  0x40
95 .bp
96
97
98 .LL
99 Credentials
100
101 .NP 0
102 .ta .5i +\w'caddr_t\0\0\0'u +\w'struct\0\0'u +\w'vnode *nc_prevdir;\0\0\0\0\0'u
103 struct ucred {
104         u_short cr_ref;
105         uid_t   cr_uid;
106         short   cr_ngroups;
107         gid_t   cr_groups[NGROUPS];
108         /*
109          * The following either should not be here,
110          * or should be treated as opaque.
111          */
112         uid_t   cr_ruid;
113         gid_t   cr_svgid;
114 };
115 .bp
116 .LL
117 Scatter-gather I/O
118 .NP 0
119 .ta .5i +\w'caddr_t\0\0\0'u +\w'struct\0\0'u +\w'vnode *nc_prevdir;\0\0\0\0\0'u
120 struct uio {
121         struct  iovec *uio_iov;
122         int     uio_iovcnt;
123         off_t   uio_offset;
124         int     uio_resid;
125         enum    uio_rw uio_rw;
126 };
127
128 enum    uio_rw { UIO_READ, UIO_WRITE };
129
130
131
132 .ta .5i +\w'caddr_t\0\0\0'u +\w'vnode *nc_prevdir;\0\0\0\0\0'u
133 struct iovec {
134         caddr_t iov_base;
135         int     iov_len;
136         enum    uio_seg iov_segflg;
137         int     (*iov_op)();
138 };
139 .bp
140 .LL
141 Per-filesystem information
142 .NP 0
143 .ta .25i +\w'struct vfsops\0\0\0'u +\w'*vfs_vnodecovered;\0\0\0\0\0'u
144 struct vfs {
145         struct vfs      *vfs_next;
146 \fB+\fP struct vfs      *vfs_prev;
147         struct vfsops   *vfs_op;
148         struct vnode    *vfs_vnodecovered;
149         int     vfs_flag;
150 \fB!\fP int     vfs_fsize;
151 \fB+\fP int     vfs_bsize;
152 \fB!\fP uid_t   vfs_exroot;
153         short   vfs_exflags;
154         caddr_t vfs_data;
155 };
156
157 .NP 0
158 .ta \w'\fB+\fP 'u +\w'#define\0\0'u +\w'VFS_EXPORTED\0\0'u +\w'0x40\0\0\0\0\0'u
159         /* vfs flags: */
160         #define VFS_RDONLY      0x01
161 \fB+\fP #define VFS_NOEXEC      0x02
162         #define VFS_MLOCK       0x04
163         #define VFS_MWAIT       0x08
164         #define VFS_NOSUID      0x10
165         #define VFS_EXPORTED    0x20
166
167         /* exported vfs flags: */
168         #define EX_RDONLY       0x01
169 .bp
170
171
172 .LL
173 Operations supported on virtual file system.
174
175 .NP 0
176 .ta .25i +\w'int\0\0'u +\w'*vfs_mountroot();\0'u
177 struct vfsops {
178 \fB!\fP int     (*vfs_mount)(vfs, path, data, len);
179 \fB!\fP int     (*vfs_unmount)(vfs, forcibly);
180 \fB+\fP int     (*vfs_mountroot)();
181         int     (*vfs_root)(vfs, vpp);
182         int     (*vfs_statfs)(vfs, sbp);
183 \fB!\fP int     (*vfs_sync)(vfs, waitfor);
184 \fB+\fP int     (*vfs_fhtovp)(vfs, fhp, vpp);
185 \fB+\fP int     (*vfs_vptofh)(vp, fhp);
186 };
187 .bp
188
189
190 .LL
191 Dynamic file system information
192
193 .NP 0
194 .ta .5i +\w'struct\0\0\0'u +\w'*vfs_vnodecovered;\0\0\0\0\0'u
195 struct statfs {
196 \fB!\fP short   f_type;
197 \fB+\fP short   f_flags;
198 \fB!\fP long    f_fsize;
199 \fB+\fP long    f_bsize;
200         long    f_blocks;
201         long    f_bfree;
202         long    f_bavail;
203         long    f_files;
204         long    f_ffree;
205         fsid_t  f_fsid;
206 \fB+\fP char    *f_mntonname;
207 \fB+\fP char    *f_mntfromname;
208         long    f_spare[7];
209 };
210
211 typedef long fsid_t[2];
212 .bp
213 .LL
214 Filesystem objects (vnodes)
215 .NP 0
216 .ta .25i +\w'struct vnodeops\0\0'u +\w'*v_vfsmountedhere;\0\0\0'u
217 enum vtype      { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK };
218
219 struct vnode {
220         u_short v_flag;
221         u_short v_count;
222         u_short v_shlockc;
223         u_short v_exlockc;
224         struct vfs      *v_vfsmountedhere;
225         struct vfs      *v_vfsp;
226         struct vnodeops *v_op;
227 \fB+\fP struct text     *v_text;
228         enum vtype      v_type;
229         caddr_t v_data;
230 };
231 .ta \w'#define\0\0'u +\w'NOFOLLOW\0\0'u +\w'0x40\0\0\0\0\0\0\0'u
232
233 /* vnode flags */
234 #define VROOT   0x01
235 #define VTEXT   0x02
236 #define VEXLOCK 0x10
237 #define VSHLOCK 0x20
238 #define VLWAIT  0x40
239 .bp
240 .LL
241 Operations on vnodes
242
243 .NP 0
244 .ta .25i +\w'int\0\0'u  +\w'(*vn_getattr)(\0\0\0\0\0'u
245 struct vnodeops {
246 \fB!\fP int     (*vn_lookup)(ndp);
247 \fB!\fP int     (*vn_create)(ndp, vap, fflags);
248 \fB+\fP int     (*vn_mknod)(ndp, vap, fflags);
249 \fB!\fP int     (*vn_open)(vp, fflags, cred);
250         int     (*vn_close)(vp, fflags, cred);
251         int     (*vn_access)(vp, fflags, cred);
252         int     (*vn_getattr)(vp, vap, cred);
253         int     (*vn_setattr)(vp, vap, cred);
254 .sp .5
255 \fB+\fP int     (*vn_read)(vp, uiop,
256                         offp, ioflag, cred);
257 \fB+\fP int     (*vn_write)(vp, uiop,
258                         offp, ioflag, cred);
259 \fB!\fP int     (*vn_ioctl)(vp, com,
260                         data, fflag, cred);
261         int     (*vn_select)(vp, which, cred);
262 \fB+\fP int     (*vn_mmap)(vp, ..., cred);
263         int     (*vn_fsync)(vp, cred);
264 \fB+\fP int     (*vn_seek)(vp, offp, off,
265                         whence);
266 .bp
267 .LL
268 Operations on vnodes (cont)
269
270 .NP 0
271 .ta .25i +\w'int\0\0'u  +\w'(*vn_getattr)(\0\0\0\0\0'u
272
273 \fB!\fP int     (*vn_remove)(ndp);
274 \fB!\fP int     (*vn_link)(vp, ndp);
275 \fB!\fP int     (*vn_rename)(sndp, tndp);
276 \fB!\fP int     (*vn_mkdir)(ndp, vap);
277 \fB!\fP int     (*vn_rmdir)(ndp);
278 \fB!\fP int     (*vn_symlink)(ndp, vap, nm);
279 \fB!\fP int     (*vn_readdir)(vp, uiop,
280                         offp, ioflag, cred);
281 \fB!\fP int     (*vn_readlink)(vp, uiop,
282                         offp, ioflag, cred);
283 .sp .5
284 \fB+\fP int     (*vn_abortop)(ndp);
285 \fB!\fP int     (*vn_inactive)(vp);
286 };
287
288 .NP 0
289 .ta \w'#define\0\0'u +\w'NOFOLLOW\0\0'u +\w'0x40\0\0\0\0\0'u
290 /* flags for ioflag */
291 #define IO_UNIT 0x01
292 #define IO_APPEND       0x02
293 #define IO_SYNC 0x04
294 .bp
295
296 .LL
297 Vnode attributes
298
299 .NP 0
300 .ta .5i +\w'struct timeval\0\0'u +\w'*v_vfsmountedhere;\0\0\0'u
301 struct vattr {
302         enum vtype      va_type;
303         u_short va_mode;
304 \fB!\fP uid_t   va_uid;
305 \fB!\fP gid_t   va_gid;
306         long    va_fsid;
307 \fB!\fP long    va_fileid;
308         short   va_nlink;
309         u_long  va_size;
310 \fB+\fP u_long  va_size1;
311         long    va_blocksize;
312         struct timeval  va_atime;
313         struct timeval  va_mtime;
314         struct timeval  va_ctime;
315         dev_t   va_rdev;
316 \fB!\fP u_long  va_bytes;
317 \fB+\fP u_long  va_bytes1;
318 };