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