rump_vfs.c revision 1.85 1 1.85 pgoyette /* $NetBSD: rump_vfs.c,v 1.85 2016/11/16 23:24:47 pgoyette Exp $ */
2 1.1 pooka
3 1.1 pooka /*
4 1.1 pooka * Copyright (c) 2008 Antti Kantee. All Rights Reserved.
5 1.1 pooka *
6 1.1 pooka * Development of this software was supported by the
7 1.1 pooka * Finnish Cultural Foundation.
8 1.1 pooka *
9 1.1 pooka * Redistribution and use in source and binary forms, with or without
10 1.1 pooka * modification, are permitted provided that the following conditions
11 1.1 pooka * are met:
12 1.1 pooka * 1. Redistributions of source code must retain the above copyright
13 1.1 pooka * notice, this list of conditions and the following disclaimer.
14 1.1 pooka * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 pooka * notice, this list of conditions and the following disclaimer in the
16 1.1 pooka * documentation and/or other materials provided with the distribution.
17 1.1 pooka *
18 1.1 pooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 1.1 pooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 1.1 pooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 1.1 pooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 1.1 pooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 1.1 pooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 1.1 pooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 1.1 pooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 1.1 pooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 1.1 pooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 1.1 pooka * SUCH DAMAGE.
29 1.1 pooka */
30 1.1 pooka
31 1.5 pooka #include <sys/cdefs.h>
32 1.85 pgoyette __KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.85 2016/11/16 23:24:47 pgoyette Exp $");
33 1.5 pooka
34 1.1 pooka #include <sys/param.h>
35 1.1 pooka #include <sys/buf.h>
36 1.6 pooka #include <sys/conf.h>
37 1.16 pooka #include <sys/evcnt.h>
38 1.80 pooka #include <sys/fcntl.h>
39 1.1 pooka #include <sys/filedesc.h>
40 1.45 pooka #include <sys/fstrans.h>
41 1.11 pooka #include <sys/lockf.h>
42 1.15 pooka #include <sys/kthread.h>
43 1.1 pooka #include <sys/module.h>
44 1.1 pooka #include <sys/namei.h>
45 1.1 pooka #include <sys/queue.h>
46 1.48 pooka #include <sys/stat.h>
47 1.1 pooka #include <sys/vfs_syscalls.h>
48 1.1 pooka #include <sys/vnode.h>
49 1.1 pooka #include <sys/wapbl.h>
50 1.85 pgoyette #include <sys/bufq.h>
51 1.1 pooka
52 1.1 pooka #include <miscfs/specfs/specdev.h>
53 1.1 pooka
54 1.84 pooka #include <rump-sys/kern.h>
55 1.84 pooka #include <rump-sys/vfs.h>
56 1.84 pooka
57 1.1 pooka #include <rump/rump.h>
58 1.1 pooka #include <rump/rumpuser.h>
59 1.1 pooka
60 1.67 mrg extern struct cwdinfo cwdi0;
61 1.44 pooka const char *rootfstype = ROOT_FSTYPE_ANY;
62 1.1 pooka
63 1.1 pooka static void
64 1.1 pooka pvfs_init(struct proc *p)
65 1.1 pooka {
66 1.1 pooka
67 1.1 pooka p->p_cwdi = cwdinit();
68 1.1 pooka }
69 1.1 pooka
70 1.1 pooka static void
71 1.1 pooka pvfs_rele(struct proc *p)
72 1.1 pooka {
73 1.1 pooka
74 1.1 pooka cwdfree(p->p_cwdi);
75 1.1 pooka }
76 1.1 pooka
77 1.71 pooka static void
78 1.71 pooka fini(void)
79 1.71 pooka {
80 1.71 pooka
81 1.71 pooka vfs_shutdown();
82 1.81 pooka rumpblk_fini();
83 1.71 pooka }
84 1.71 pooka
85 1.71 pooka static void
86 1.71 pooka drainbufs(int npages)
87 1.71 pooka {
88 1.71 pooka
89 1.71 pooka mutex_enter(&bufcache_lock);
90 1.71 pooka buf_drain(npages);
91 1.71 pooka mutex_exit(&bufcache_lock);
92 1.71 pooka }
93 1.71 pooka
94 1.71 pooka RUMP_COMPONENT(RUMP__FACTION_VFS)
95 1.1 pooka {
96 1.39 pooka extern struct vfsops rumpfs_vfsops;
97 1.10 pooka char buf[64];
98 1.78 pooka char *mbase;
99 1.38 pooka int rv, i;
100 1.1 pooka
101 1.71 pooka /* initialize indirect interfaces */
102 1.71 pooka rump_vfs_fini = fini;
103 1.71 pooka rump_vfs_drainbufs = drainbufs;
104 1.71 pooka
105 1.75 pooka if (rumpuser_getparam("RUMP_NVNODES", buf, sizeof(buf)) == 0) {
106 1.10 pooka desiredvnodes = strtoul(buf, NULL, 10);
107 1.10 pooka } else {
108 1.50 pooka desiredvnodes = 1<<10;
109 1.10 pooka }
110 1.10 pooka
111 1.16 pooka rumpblk_init();
112 1.16 pooka
113 1.38 pooka for (i = 0; i < ncpu; i++) {
114 1.38 pooka struct cpu_info *ci = cpu_lookup(i);
115 1.38 pooka cache_cpu_init(ci);
116 1.38 pooka }
117 1.58 pooka
118 1.58 pooka /* make number of bufpages 5% of total memory limit */
119 1.58 pooka if (rump_physmemlimit != RUMPMEM_UNLIMITED) {
120 1.58 pooka extern u_int bufpages;
121 1.58 pooka bufpages = rump_physmemlimit / (20 * PAGE_SIZE);
122 1.58 pooka }
123 1.58 pooka
124 1.85 pgoyette bufq_init();
125 1.1 pooka vfsinit();
126 1.1 pooka bufinit();
127 1.1 pooka cwd_sys_init();
128 1.11 pooka lf_init();
129 1.40 pooka spec_init();
130 1.45 pooka fstrans_init();
131 1.11 pooka
132 1.39 pooka root_device = &rump_rootdev;
133 1.36 pooka
134 1.37 pooka /* bootstrap cwdi (rest done in vfs_mountroot() */
135 1.37 pooka proc0.p_cwdi = &cwdi0;
136 1.37 pooka proc0.p_cwdi = cwdinit();
137 1.37 pooka
138 1.39 pooka vfs_attach(&rumpfs_vfsops);
139 1.35 pooka vfs_mountroot();
140 1.1 pooka
141 1.79 pooka /* "mtree": create /dev and /tmp */
142 1.77 pooka do_sys_mkdir("/dev", 0755, UIO_SYSSPACE);
143 1.80 pooka do_sys_mkdir("/tmp", 01777, UIO_SYSSPACE);
144 1.80 pooka do_sys_chmodat(curlwp, AT_FDCWD, "/tmp", 01777, 0);
145 1.41 pooka
146 1.1 pooka rump_proc_vfs_init = pvfs_init;
147 1.1 pooka rump_proc_vfs_release = pvfs_rele;
148 1.1 pooka
149 1.15 pooka if (rump_threads) {
150 1.15 pooka if ((rv = kthread_create(PRI_IOFLUSH, KTHREAD_MPSAFE, NULL,
151 1.15 pooka sched_sync, NULL, NULL, "ioflush")) != 0)
152 1.15 pooka panic("syncer thread create failed: %d", rv);
153 1.16 pooka } else {
154 1.16 pooka syncdelay = 0;
155 1.15 pooka }
156 1.43 pooka
157 1.47 pooka /*
158 1.47 pooka * On archs where the native kernel ABI is supported, map
159 1.47 pooka * host module directory to rump. This means that kernel
160 1.47 pooka * modules from the host will be autoloaded to rump kernels.
161 1.47 pooka */
162 1.78 pooka if (rump_nativeabi_p()) {
163 1.78 pooka if (rumpuser_getparam("RUMP_MODULEBASE", buf, sizeof(buf)) == 0)
164 1.78 pooka mbase = buf;
165 1.78 pooka else
166 1.78 pooka mbase = module_base;
167 1.78 pooka
168 1.78 pooka if (strlen(mbase) != 0 && *mbase != '0') {
169 1.78 pooka rump_etfs_register(module_base, mbase,
170 1.78 pooka RUMP_ETFS_DIR_SUBDIRS);
171 1.78 pooka }
172 1.53 pooka }
173 1.47 pooka
174 1.43 pooka module_init_class(MODULE_CLASS_VFS);
175 1.48 pooka
176 1.72 pooka /*
177 1.72 pooka * Don't build device names for a large set of devices by
178 1.72 pooka * default. While the pseudo-devfs is a fun experiment,
179 1.72 pooka * creating many many device nodes may increase rump kernel
180 1.72 pooka * bootstrap time by ~40%. Device nodes should be created
181 1.72 pooka * per-demand in the component constructors.
182 1.72 pooka */
183 1.72 pooka #if 0
184 1.72 pooka {
185 1.72 pooka extern struct devsw_conv devsw_conv0[];
186 1.72 pooka extern int max_devsw_convs;
187 1.48 pooka rump_vfs_builddevs(devsw_conv0, max_devsw_convs);
188 1.72 pooka }
189 1.72 pooka #else
190 1.72 pooka rump_vfs_builddevs(NULL, 0);
191 1.72 pooka #endif
192 1.56 pooka
193 1.73 pooka /* attach null device and create /dev/{null,zero} */
194 1.73 pooka rump_devnull_init();
195 1.73 pooka
196 1.56 pooka rump_component_init(RUMP_COMPONENT_VFS);
197 1.1 pooka }
198 1.1 pooka
199 1.62 pooka struct rumpcn {
200 1.62 pooka struct componentname rcn_cn;
201 1.62 pooka char *rcn_path;
202 1.62 pooka };
203 1.62 pooka
204 1.1 pooka struct componentname *
205 1.32 pooka rump_makecn(u_long nameiop, u_long flags, const char *name, size_t namelen,
206 1.1 pooka kauth_cred_t creds, struct lwp *l)
207 1.1 pooka {
208 1.62 pooka struct rumpcn *rcn;
209 1.1 pooka struct componentname *cnp;
210 1.1 pooka
211 1.62 pooka rcn = kmem_zalloc(sizeof(*rcn), KM_SLEEP);
212 1.62 pooka cnp = &rcn->rcn_cn;
213 1.62 pooka
214 1.62 pooka rcn->rcn_path = PNBUF_GET();
215 1.62 pooka strlcpy(rcn->rcn_path, name, MAXPATHLEN);
216 1.62 pooka cnp->cn_nameptr = rcn->rcn_path;
217 1.1 pooka
218 1.1 pooka cnp->cn_nameiop = nameiop;
219 1.65 pooka cnp->cn_flags = flags & (MODMASK | PARAMASK);
220 1.1 pooka
221 1.1 pooka cnp->cn_namelen = namelen;
222 1.1 pooka
223 1.1 pooka cnp->cn_cred = creds;
224 1.1 pooka
225 1.1 pooka return cnp;
226 1.1 pooka }
227 1.1 pooka
228 1.1 pooka void
229 1.32 pooka rump_freecn(struct componentname *cnp, int flags)
230 1.1 pooka {
231 1.62 pooka struct rumpcn *rcn = (void *)cnp;
232 1.1 pooka
233 1.1 pooka if (flags & RUMPCN_FREECRED)
234 1.32 pooka rump_cred_put(cnp->cn_cred);
235 1.1 pooka
236 1.62 pooka PNBUF_PUT(rcn->rcn_path);
237 1.63 pooka kmem_free(rcn, sizeof(*rcn));
238 1.1 pooka }
239 1.1 pooka
240 1.1 pooka /* hey baby, what's your namei? */
241 1.1 pooka int
242 1.32 pooka rump_namei(uint32_t op, uint32_t flags, const char *namep,
243 1.1 pooka struct vnode **dvpp, struct vnode **vpp, struct componentname **cnpp)
244 1.1 pooka {
245 1.59 dholland struct pathbuf *pb;
246 1.1 pooka struct nameidata nd;
247 1.1 pooka int rv;
248 1.1 pooka
249 1.59 dholland pb = pathbuf_create(namep);
250 1.59 dholland if (pb == NULL) {
251 1.59 dholland return ENOMEM;
252 1.59 dholland }
253 1.59 dholland NDINIT(&nd, op, flags, pb);
254 1.1 pooka rv = namei(&nd);
255 1.59 dholland if (rv) {
256 1.59 dholland pathbuf_destroy(pb);
257 1.1 pooka return rv;
258 1.59 dholland }
259 1.1 pooka
260 1.1 pooka if (dvpp) {
261 1.1 pooka KASSERT(flags & LOCKPARENT);
262 1.1 pooka *dvpp = nd.ni_dvp;
263 1.1 pooka } else {
264 1.1 pooka KASSERT((flags & LOCKPARENT) == 0);
265 1.1 pooka }
266 1.1 pooka
267 1.1 pooka if (vpp) {
268 1.1 pooka *vpp = nd.ni_vp;
269 1.1 pooka } else {
270 1.1 pooka if (nd.ni_vp) {
271 1.1 pooka if (flags & LOCKLEAF)
272 1.1 pooka vput(nd.ni_vp);
273 1.1 pooka else
274 1.1 pooka vrele(nd.ni_vp);
275 1.1 pooka }
276 1.1 pooka }
277 1.1 pooka
278 1.1 pooka if (cnpp) {
279 1.1 pooka struct componentname *cnp;
280 1.1 pooka
281 1.1 pooka cnp = kmem_alloc(sizeof(*cnp), KM_SLEEP);
282 1.1 pooka memcpy(cnp, &nd.ni_cnd, sizeof(*cnp));
283 1.1 pooka *cnpp = cnp;
284 1.1 pooka }
285 1.59 dholland pathbuf_destroy(pb);
286 1.1 pooka
287 1.1 pooka return rv;
288 1.1 pooka }
289 1.1 pooka
290 1.1 pooka void
291 1.69 pooka rump_getvninfo(struct vnode *vp, enum rump_vtype *vtype,
292 1.31 pooka voff_t *vsize, dev_t *vdev)
293 1.1 pooka {
294 1.1 pooka
295 1.70 pooka *vtype = (enum rump_vtype)vp->v_type;
296 1.1 pooka *vsize = vp->v_size;
297 1.1 pooka if (vp->v_specnode)
298 1.1 pooka *vdev = vp->v_rdev;
299 1.1 pooka else
300 1.1 pooka *vdev = 0;
301 1.1 pooka }
302 1.1 pooka
303 1.1 pooka struct vfsops *
304 1.32 pooka rump_vfslist_iterate(struct vfsops *ops)
305 1.1 pooka {
306 1.1 pooka
307 1.1 pooka if (ops == NULL)
308 1.1 pooka return LIST_FIRST(&vfs_list);
309 1.1 pooka else
310 1.1 pooka return LIST_NEXT(ops, vfs_list);
311 1.1 pooka }
312 1.1 pooka
313 1.1 pooka struct vfsops *
314 1.32 pooka rump_vfs_getopsbyname(const char *name)
315 1.1 pooka {
316 1.1 pooka
317 1.1 pooka return vfs_getopsbyname(name);
318 1.1 pooka }
319 1.1 pooka
320 1.19 pooka int
321 1.32 pooka rump_vfs_getmp(const char *path, struct mount **mpp)
322 1.19 pooka {
323 1.19 pooka struct vnode *vp;
324 1.19 pooka int rv;
325 1.19 pooka
326 1.23 dholland if ((rv = namei_simple_user(path, NSM_FOLLOW_TRYEMULROOT, &vp)) != 0)
327 1.19 pooka return rv;
328 1.19 pooka
329 1.19 pooka *mpp = vp->v_mount;
330 1.19 pooka vrele(vp);
331 1.19 pooka return 0;
332 1.19 pooka }
333 1.19 pooka
334 1.1 pooka struct vattr*
335 1.32 pooka rump_vattr_init(void)
336 1.1 pooka {
337 1.1 pooka struct vattr *vap;
338 1.1 pooka
339 1.1 pooka vap = kmem_alloc(sizeof(struct vattr), KM_SLEEP);
340 1.1 pooka vattr_null(vap);
341 1.1 pooka
342 1.1 pooka return vap;
343 1.1 pooka }
344 1.1 pooka
345 1.1 pooka void
346 1.69 pooka rump_vattr_settype(struct vattr *vap, enum rump_vtype vt)
347 1.1 pooka {
348 1.1 pooka
349 1.70 pooka vap->va_type = (enum vtype)vt;
350 1.1 pooka }
351 1.1 pooka
352 1.1 pooka void
353 1.32 pooka rump_vattr_setmode(struct vattr *vap, mode_t mode)
354 1.1 pooka {
355 1.1 pooka
356 1.1 pooka vap->va_mode = mode;
357 1.1 pooka }
358 1.1 pooka
359 1.1 pooka void
360 1.32 pooka rump_vattr_setrdev(struct vattr *vap, dev_t dev)
361 1.1 pooka {
362 1.1 pooka
363 1.1 pooka vap->va_rdev = dev;
364 1.1 pooka }
365 1.1 pooka
366 1.1 pooka void
367 1.32 pooka rump_vattr_free(struct vattr *vap)
368 1.1 pooka {
369 1.1 pooka
370 1.1 pooka kmem_free(vap, sizeof(*vap));
371 1.1 pooka }
372 1.1 pooka
373 1.1 pooka void
374 1.32 pooka rump_vp_incref(struct vnode *vp)
375 1.1 pooka {
376 1.1 pooka
377 1.29 pooka vref(vp);
378 1.1 pooka }
379 1.1 pooka
380 1.1 pooka int
381 1.32 pooka rump_vp_getref(struct vnode *vp)
382 1.1 pooka {
383 1.1 pooka
384 1.1 pooka return vp->v_usecount;
385 1.1 pooka }
386 1.1 pooka
387 1.1 pooka void
388 1.32 pooka rump_vp_rele(struct vnode *vp)
389 1.1 pooka {
390 1.1 pooka
391 1.1 pooka vrele(vp);
392 1.1 pooka }
393 1.1 pooka
394 1.1 pooka void
395 1.32 pooka rump_vp_interlock(struct vnode *vp)
396 1.1 pooka {
397 1.1 pooka
398 1.66 rmind mutex_enter(vp->v_interlock);
399 1.1 pooka }
400 1.1 pooka
401 1.1 pooka int
402 1.32 pooka rump_vfs_unmount(struct mount *mp, int mntflags)
403 1.1 pooka {
404 1.1 pooka
405 1.1 pooka return VFS_UNMOUNT(mp, mntflags);
406 1.1 pooka }
407 1.1 pooka
408 1.1 pooka int
409 1.32 pooka rump_vfs_root(struct mount *mp, struct vnode **vpp, int lock)
410 1.1 pooka {
411 1.1 pooka int rv;
412 1.1 pooka
413 1.1 pooka rv = VFS_ROOT(mp, vpp);
414 1.1 pooka if (rv)
415 1.1 pooka return rv;
416 1.1 pooka
417 1.1 pooka if (!lock)
418 1.55 hannken VOP_UNLOCK(*vpp);
419 1.1 pooka
420 1.1 pooka return 0;
421 1.1 pooka }
422 1.1 pooka
423 1.1 pooka int
424 1.32 pooka rump_vfs_statvfs(struct mount *mp, struct statvfs *sbp)
425 1.1 pooka {
426 1.1 pooka
427 1.1 pooka return VFS_STATVFS(mp, sbp);
428 1.1 pooka }
429 1.1 pooka
430 1.1 pooka int
431 1.32 pooka rump_vfs_sync(struct mount *mp, int wait, kauth_cred_t cred)
432 1.1 pooka {
433 1.1 pooka
434 1.1 pooka return VFS_SYNC(mp, wait ? MNT_WAIT : MNT_NOWAIT, cred);
435 1.1 pooka }
436 1.1 pooka
437 1.1 pooka int
438 1.32 pooka rump_vfs_fhtovp(struct mount *mp, struct fid *fid, struct vnode **vpp)
439 1.1 pooka {
440 1.1 pooka
441 1.1 pooka return VFS_FHTOVP(mp, fid, vpp);
442 1.1 pooka }
443 1.1 pooka
444 1.1 pooka int
445 1.32 pooka rump_vfs_vptofh(struct vnode *vp, struct fid *fid, size_t *fidsize)
446 1.1 pooka {
447 1.1 pooka
448 1.1 pooka return VFS_VPTOFH(vp, fid, fidsize);
449 1.1 pooka }
450 1.1 pooka
451 1.51 pooka int
452 1.51 pooka rump_vfs_extattrctl(struct mount *mp, int cmd, struct vnode *vp,
453 1.51 pooka int attrnamespace, const char *attrname)
454 1.51 pooka {
455 1.51 pooka
456 1.51 pooka return VFS_EXTATTRCTL(mp, cmd, vp, attrnamespace, attrname);
457 1.51 pooka }
458 1.51 pooka
459 1.1 pooka /*ARGSUSED*/
460 1.1 pooka void
461 1.32 pooka rump_vfs_syncwait(struct mount *mp)
462 1.1 pooka {
463 1.1 pooka int n;
464 1.1 pooka
465 1.1 pooka n = buf_syncwait();
466 1.1 pooka if (n)
467 1.1 pooka printf("syncwait: unsynced buffers: %d\n", n);
468 1.1 pooka }
469 1.1 pooka
470 1.52 pooka /*
471 1.52 pooka * Dump info about mount point. No locking.
472 1.52 pooka */
473 1.83 hannken static bool
474 1.83 hannken rump_print_selector(void *cl, struct vnode *vp)
475 1.83 hannken {
476 1.83 hannken int *full = cl;
477 1.83 hannken
478 1.83 hannken vfs_vnode_print(vp, *full, (void *)rumpuser_dprintf);
479 1.83 hannken return false;
480 1.83 hannken }
481 1.83 hannken
482 1.52 pooka void
483 1.52 pooka rump_vfs_mount_print(const char *path, int full)
484 1.52 pooka {
485 1.52 pooka #ifdef DEBUGPRINT
486 1.52 pooka struct vnode *mvp;
487 1.83 hannken struct vnode_iterator *marker;
488 1.52 pooka int error;
489 1.52 pooka
490 1.52 pooka rumpuser_dprintf("\n==== dumping mountpoint at ``%s'' ====\n\n", path);
491 1.52 pooka if ((error = namei_simple_user(path, NSM_FOLLOW_NOEMULROOT, &mvp))!=0) {
492 1.52 pooka rumpuser_dprintf("==== lookup error %d ====\n\n", error);
493 1.52 pooka return;
494 1.52 pooka }
495 1.52 pooka vfs_mount_print(mvp->v_mount, full, (void *)rumpuser_dprintf);
496 1.52 pooka if (full) {
497 1.52 pooka rumpuser_dprintf("\n== dumping vnodes ==\n\n");
498 1.83 hannken vfs_vnode_iterator_init(mvp->v_mount, &marker);
499 1.83 hannken vfs_vnode_iterator_next(marker, rump_print_selector, &full);
500 1.83 hannken vfs_vnode_iterator_destroy(marker);
501 1.52 pooka }
502 1.52 pooka vrele(mvp);
503 1.52 pooka rumpuser_dprintf("\n==== done ====\n\n");
504 1.52 pooka #else
505 1.52 pooka rumpuser_dprintf("mount dump not supported without DEBUGPRINT\n");
506 1.52 pooka #endif
507 1.52 pooka }
508 1.52 pooka
509 1.1 pooka void
510 1.1 pooka rump_biodone(void *arg, size_t count, int error)
511 1.1 pooka {
512 1.1 pooka struct buf *bp = arg;
513 1.1 pooka
514 1.1 pooka bp->b_resid = bp->b_bcount - count;
515 1.1 pooka KASSERT(bp->b_resid >= 0);
516 1.1 pooka bp->b_error = error;
517 1.1 pooka
518 1.1 pooka biodone(bp);
519 1.1 pooka }
520