dksubr.c revision 1.28.2.3 1 /* $NetBSD: dksubr.c,v 1.28.2.3 2007/08/19 19:24:20 ad Exp $ */
2
3 /*-
4 * Copyright (c) 1996, 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe and Roland C. Dowdeswell.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.28.2.3 2007/08/19 19:24:20 ad Exp $");
41
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/stat.h>
45 #include <sys/proc.h>
46 #include <sys/ioctl.h>
47 #include <sys/device.h>
48 #include <sys/disk.h>
49 #include <sys/disklabel.h>
50 #include <sys/buf.h>
51 #include <sys/bufq.h>
52 #include <sys/vnode.h>
53 #include <sys/fcntl.h>
54 #include <sys/namei.h>
55
56 #include <dev/dkvar.h>
57
58 int dkdebug = 0;
59
60 #ifdef DEBUG
61 #define DKDB_FOLLOW 0x1
62 #define DKDB_INIT 0x2
63 #define DKDB_VNODE 0x4
64
65 #define IFDEBUG(x,y) if (dkdebug & (x)) y
66 #define DPRINTF(x,y) IFDEBUG(x, printf y)
67 #define DPRINTF_FOLLOW(y) DPRINTF(DKDB_FOLLOW, y)
68 #else
69 #define IFDEBUG(x,y)
70 #define DPRINTF(x,y)
71 #define DPRINTF_FOLLOW(y)
72 #endif
73
74 #define DKLABELDEV(dev) \
75 (MAKEDISKDEV(major((dev)), DISKUNIT((dev)), RAW_PART))
76
77 static void dk_makedisklabel(struct dk_intf *, struct dk_softc *);
78
79 void
80 dk_sc_init(struct dk_softc *dksc, void *osc, char *xname)
81 {
82
83 memset(dksc, 0x0, sizeof(*dksc));
84 dksc->sc_osc = osc;
85 strncpy(dksc->sc_xname, xname, DK_XNAME_SIZE);
86 dksc->sc_dkdev.dk_name = dksc->sc_xname;
87 }
88
89 /* ARGSUSED */
90 int
91 dk_open(struct dk_intf *di, struct dk_softc *dksc, dev_t dev,
92 int flags, int fmt, struct lwp *l)
93 {
94 struct disklabel *lp = dksc->sc_dkdev.dk_label;
95 int part = DISKPART(dev);
96 int pmask = 1 << part;
97 int ret = 0;
98 struct disk *dk = &dksc->sc_dkdev;
99
100 DPRINTF_FOLLOW(("dk_open(%s, %p, 0x%x, 0x%x)\n",
101 di->di_dkname, dksc, dev, flags));
102
103 if ((ret = lockmgr(&dk->dk_openlock, LK_EXCLUSIVE, NULL)) != 0)
104 return ret;
105
106 part = DISKPART(dev);
107
108 /*
109 * If there are wedges, and this is not RAW_PART, then we
110 * need to fail.
111 */
112 if (dk->dk_nwedges != 0 && part != RAW_PART) {
113 ret = EBUSY;
114 goto done;
115 }
116
117 pmask = 1 << part;
118
119 /*
120 * If we're init'ed and there are no other open partitions then
121 * update the in-core disklabel.
122 */
123 if ((dksc->sc_flags & DKF_INITED)) {
124 if (dk->dk_openmask == 0) {
125 dk_getdisklabel(di, dksc, dev);
126 }
127 /* XXX re-discover wedges? */
128 }
129
130 /* Fail if we can't find the partition. */
131 if ((part != RAW_PART) &&
132 (((dksc->sc_flags & DKF_INITED) == 0) ||
133 ((part >= lp->d_npartitions) ||
134 (lp->d_partitions[part].p_fstype == FS_UNUSED)))) {
135 ret = ENXIO;
136 goto done;
137 }
138
139 /* Mark our unit as open. */
140 switch (fmt) {
141 case S_IFCHR:
142 dk->dk_copenmask |= pmask;
143 break;
144 case S_IFBLK:
145 dk->dk_bopenmask |= pmask;
146 break;
147 }
148
149 dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask;
150
151 done:
152 lockmgr(&dk->dk_openlock, LK_RELEASE, NULL);
153 return ret;
154 }
155
156 /* ARGSUSED */
157 int
158 dk_close(struct dk_intf *di, struct dk_softc *dksc, dev_t dev,
159 int flags, int fmt, struct lwp *l)
160 {
161 int part = DISKPART(dev);
162 int pmask = 1 << part;
163 int ret;
164 struct disk *dk = &dksc->sc_dkdev;
165
166 DPRINTF_FOLLOW(("dk_close(%s, %p, 0x%x, 0x%x)\n",
167 di->di_dkname, dksc, dev, flags));
168
169 if ((ret = lockmgr(&dk->dk_openlock, LK_EXCLUSIVE, NULL)) != 0)
170 return ret;
171
172 switch (fmt) {
173 case S_IFCHR:
174 dk->dk_copenmask &= ~pmask;
175 break;
176 case S_IFBLK:
177 dk->dk_bopenmask &= ~pmask;
178 break;
179 }
180 dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask;
181
182 lockmgr(&dk->dk_openlock, LK_RELEASE, NULL);
183 return 0;
184 }
185
186 void
187 dk_strategy(struct dk_intf *di, struct dk_softc *dksc, struct buf *bp)
188 {
189 int s;
190 int wlabel;
191 daddr_t blkno;
192
193 DPRINTF_FOLLOW(("dk_strategy(%s, %p, %p)\n",
194 di->di_dkname, dksc, bp));
195
196 if (!(dksc->sc_flags & DKF_INITED)) {
197 DPRINTF_FOLLOW(("dk_strategy: not inited\n"));
198 bp->b_error = ENXIO;
199 biodone(bp);
200 return;
201 }
202
203 /* XXX look for some more errors, c.f. ld.c */
204
205 bp->b_resid = bp->b_bcount;
206
207 /* If there is nothing to do, then we are done */
208 if (bp->b_bcount == 0) {
209 biodone(bp);
210 return;
211 }
212
213 wlabel = dksc->sc_flags & (DKF_WLABEL|DKF_LABELLING);
214 if (DISKPART(bp->b_dev) != RAW_PART &&
215 bounds_check_with_label(&dksc->sc_dkdev, bp, wlabel) <= 0) {
216 biodone(bp);
217 return;
218 }
219
220 blkno = bp->b_blkno;
221 if (DISKPART(bp->b_dev) != RAW_PART) {
222 struct partition *pp;
223
224 pp =
225 &dksc->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)];
226 blkno += pp->p_offset;
227 }
228 bp->b_rawblkno = blkno;
229
230 /*
231 * Start the unit by calling the start routine
232 * provided by the individual driver.
233 */
234 s = splbio();
235 BUFQ_PUT(dksc->sc_bufq, bp);
236 dk_start(di, dksc);
237 splx(s);
238 return;
239 }
240
241 void
242 dk_start(struct dk_intf *di, struct dk_softc *dksc)
243 {
244 struct buf *bp;
245
246 DPRINTF_FOLLOW(("dk_start(%s, %p)\n", di->di_dkname, dksc));
247
248 /* Process the work queue */
249 while ((bp = BUFQ_GET(dksc->sc_bufq)) != NULL) {
250 if (di->di_diskstart(dksc, bp) != 0) {
251 BUFQ_PUT(dksc->sc_bufq, bp);
252 break;
253 }
254 }
255 }
256
257 void
258 dk_iodone(struct dk_intf *di, struct dk_softc *dksc)
259 {
260
261 DPRINTF_FOLLOW(("dk_iodone(%s, %p)\n", di->di_dkname, dksc));
262
263 /* We kick the queue in case we are able to get more work done */
264 dk_start(di, dksc);
265 }
266
267 int
268 dk_size(struct dk_intf *di, struct dk_softc *dksc, dev_t dev)
269 {
270 struct disklabel *lp;
271 int is_open;
272 int part;
273 int size;
274
275 if ((dksc->sc_flags & DKF_INITED) == 0)
276 return -1;
277
278 part = DISKPART(dev);
279 is_open = dksc->sc_dkdev.dk_openmask & (1 << part);
280
281 if (!is_open && di->di_open(dev, 0, S_IFBLK, curlwp))
282 return -1;
283
284 lp = dksc->sc_dkdev.dk_label;
285 if (lp->d_partitions[part].p_fstype != FS_SWAP)
286 size = -1;
287 else
288 size = lp->d_partitions[part].p_size *
289 (lp->d_secsize / DEV_BSIZE);
290
291 if (!is_open && di->di_close(dev, 0, S_IFBLK, curlwp))
292 return 1;
293
294 return size;
295 }
296
297 int
298 dk_ioctl(struct dk_intf *di, struct dk_softc *dksc, dev_t dev,
299 u_long cmd, void *data, int flag, struct lwp *l)
300 {
301 struct disklabel *lp;
302 struct disk *dk;
303 #ifdef __HAVE_OLD_DISKLABEL
304 struct disklabel newlabel;
305 #endif
306 int error = 0;
307
308 DPRINTF_FOLLOW(("dk_ioctl(%s, %p, 0x%x, 0x%lx)\n",
309 di->di_dkname, dksc, dev, cmd));
310
311 /* ensure that the pseudo disk is open for writes for these commands */
312 switch (cmd) {
313 case DIOCSDINFO:
314 case DIOCWDINFO:
315 #ifdef __HAVE_OLD_DISKLABEL
316 case ODIOCSDINFO:
317 case ODIOCWDINFO:
318 #endif
319 case DIOCWLABEL:
320 if ((flag & FWRITE) == 0)
321 return EBADF;
322 }
323
324 /* ensure that the pseudo-disk is initialized for these */
325 switch (cmd) {
326 case DIOCGDINFO:
327 case DIOCSDINFO:
328 case DIOCWDINFO:
329 case DIOCGPART:
330 case DIOCWLABEL:
331 case DIOCGDEFLABEL:
332 #ifdef __HAVE_OLD_DISKLABEL
333 case ODIOCGDINFO:
334 case ODIOCSDINFO:
335 case ODIOCWDINFO:
336 case ODIOCGDEFLABEL:
337 #endif
338 if ((dksc->sc_flags & DKF_INITED) == 0)
339 return ENXIO;
340 }
341
342 switch (cmd) {
343 case DIOCGDINFO:
344 *(struct disklabel *)data = *(dksc->sc_dkdev.dk_label);
345 break;
346
347 #ifdef __HAVE_OLD_DISKLABEL
348 case ODIOCGDINFO:
349 newlabel = *(dksc->sc_dkdev.dk_label);
350 if (newlabel.d_npartitions > OLDMAXPARTITIONS)
351 return ENOTTY;
352 memcpy(data, &newlabel, sizeof (struct olddisklabel));
353 break;
354 #endif
355
356 case DIOCGPART:
357 ((struct partinfo *)data)->disklab = dksc->sc_dkdev.dk_label;
358 ((struct partinfo *)data)->part =
359 &dksc->sc_dkdev.dk_label->d_partitions[DISKPART(dev)];
360 break;
361
362 case DIOCWDINFO:
363 case DIOCSDINFO:
364 #ifdef __HAVE_OLD_DISKLABEL
365 case ODIOCWDINFO:
366 case ODIOCSDINFO:
367 #endif
368 #ifdef __HAVE_OLD_DISKLABEL
369 if (cmd == ODIOCSDINFO || cmd == ODIOCWDINFO) {
370 memset(&newlabel, 0, sizeof newlabel);
371 memcpy(&newlabel, data, sizeof (struct olddisklabel));
372 lp = &newlabel;
373 } else
374 #endif
375 lp = (struct disklabel *)data;
376
377 dk = &dksc->sc_dkdev;
378 error = lockmgr(&dk->dk_openlock, LK_EXCLUSIVE, NULL);
379 if (error) {
380 break;
381 }
382
383 dksc->sc_flags |= DKF_LABELLING;
384
385 error = setdisklabel(dksc->sc_dkdev.dk_label,
386 lp, 0, dksc->sc_dkdev.dk_cpulabel);
387 if (error == 0) {
388 if (cmd == DIOCWDINFO
389 #ifdef __HAVE_OLD_DISKLABEL
390 || cmd == ODIOCWDINFO
391 #endif
392 )
393 error = writedisklabel(DKLABELDEV(dev),
394 di->di_strategy, dksc->sc_dkdev.dk_label,
395 dksc->sc_dkdev.dk_cpulabel);
396 }
397
398 dksc->sc_flags &= ~DKF_LABELLING;
399 error = lockmgr(&dk->dk_openlock, LK_RELEASE, NULL);
400 break;
401
402 case DIOCWLABEL:
403 if (*(int *)data != 0)
404 dksc->sc_flags |= DKF_WLABEL;
405 else
406 dksc->sc_flags &= ~DKF_WLABEL;
407 break;
408
409 case DIOCGDEFLABEL:
410 dk_getdefaultlabel(di, dksc, (struct disklabel *)data);
411 break;
412
413 #ifdef __HAVE_OLD_DISKLABEL
414 case ODIOCGDEFLABEL:
415 dk_getdefaultlabel(di, dksc, &newlabel);
416 if (newlabel.d_npartitions > OLDMAXPARTITIONS)
417 return ENOTTY;
418 memcpy(data, &newlabel, sizeof (struct olddisklabel));
419 break;
420 #endif
421
422 case DIOCAWEDGE:
423 {
424 struct dkwedge_info *dkw = (void *)data;
425
426 if ((flag & FWRITE) == 0)
427 return (EBADF);
428
429 /* If the ioctl happens here, the parent is us. */
430 strcpy(dkw->dkw_parent, dksc->sc_dkdev.dk_name);
431 return (dkwedge_add(dkw));
432 }
433
434 case DIOCDWEDGE:
435 {
436 struct dkwedge_info *dkw = (void *)data;
437
438 if ((flag & FWRITE) == 0)
439 return (EBADF);
440
441 /* If the ioctl happens here, the parent is us. */
442 strcpy(dkw->dkw_parent, dksc->sc_dkdev.dk_name);
443 return (dkwedge_del(dkw));
444 }
445
446 case DIOCLWEDGES:
447 {
448 struct dkwedge_list *dkwl = (void *)data;
449
450 return (dkwedge_list(&dksc->sc_dkdev, dkwl, l));
451 }
452
453 case DIOCGSTRATEGY:
454 {
455 struct disk_strategy *dks = (void *)data;
456 int s;
457
458 s = splbio();
459 strlcpy(dks->dks_name, bufq_getstrategyname(dksc->sc_bufq),
460 sizeof(dks->dks_name));
461 splx(s);
462 dks->dks_paramlen = 0;
463
464 return 0;
465 }
466
467 case DIOCSSTRATEGY:
468 {
469 struct disk_strategy *dks = (void *)data;
470 struct bufq_state *new;
471 struct bufq_state *old;
472 int s;
473
474 if ((flag & FWRITE) == 0) {
475 return EBADF;
476 }
477 if (dks->dks_param != NULL) {
478 return EINVAL;
479 }
480 dks->dks_name[sizeof(dks->dks_name) - 1] = 0; /* ensure term */
481 error = bufq_alloc(&new, dks->dks_name,
482 BUFQ_EXACT|BUFQ_SORT_RAWBLOCK);
483 if (error) {
484 return error;
485 }
486 s = splbio();
487 old = dksc->sc_bufq;
488 bufq_move(new, old);
489 dksc->sc_bufq = new;
490 splx(s);
491 bufq_free(old);
492
493 return 0;
494 }
495
496 default:
497 error = ENOTTY;
498 }
499
500 return error;
501 }
502
503 /*
504 * dk_dump dumps all of physical memory into the partition specified.
505 * This requires substantially more framework than {s,w}ddump, and hence
506 * is probably much more fragile.
507 *
508 * XXX: we currently do not implement this.
509 */
510
511 #define DKF_READYFORDUMP (DKF_INITED|DKF_TAKEDUMP)
512 #define DKFF_READYFORDUMP(x) (((x) & DKF_READYFORDUMP) == DKF_READYFORDUMP)
513 static volatile int dk_dumping = 0;
514
515 /* ARGSUSED */
516 int
517 dk_dump(struct dk_intf *di, struct dk_softc *dksc, dev_t dev,
518 daddr_t blkno, void *va, size_t size)
519 {
520
521 /*
522 * ensure that we consider this device to be safe for dumping,
523 * and that the device is configured.
524 */
525 if (!DKFF_READYFORDUMP(dksc->sc_flags))
526 return ENXIO;
527
528 /* ensure that we are not already dumping */
529 if (dk_dumping)
530 return EFAULT;
531 dk_dumping = 1;
532
533 /* XXX: unimplemented */
534
535 dk_dumping = 0;
536
537 /* XXX: actually for now, we are going to leave this alone */
538 return ENXIO;
539 }
540
541 /* ARGSUSED */
542 void
543 dk_getdefaultlabel(struct dk_intf *di, struct dk_softc *dksc,
544 struct disklabel *lp)
545 {
546 struct dk_geom *pdg = &dksc->sc_geom;
547
548 memset(lp, 0, sizeof(*lp));
549
550 lp->d_secperunit = dksc->sc_size;
551 lp->d_secsize = pdg->pdg_secsize;
552 lp->d_nsectors = pdg->pdg_nsectors;
553 lp->d_ntracks = pdg->pdg_ntracks;
554 lp->d_ncylinders = pdg->pdg_ncylinders;
555 lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
556
557 strncpy(lp->d_typename, di->di_dkname, sizeof(lp->d_typename));
558 lp->d_type = di->di_dtype;
559 strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
560 lp->d_rpm = 3600;
561 lp->d_interleave = 1;
562 lp->d_flags = 0;
563
564 lp->d_partitions[RAW_PART].p_offset = 0;
565 lp->d_partitions[RAW_PART].p_size = dksc->sc_size;
566 lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
567 lp->d_npartitions = RAW_PART + 1;
568
569 lp->d_magic = DISKMAGIC;
570 lp->d_magic2 = DISKMAGIC;
571 lp->d_checksum = dkcksum(dksc->sc_dkdev.dk_label);
572 }
573
574 /* ARGSUSED */
575 void
576 dk_getdisklabel(struct dk_intf *di, struct dk_softc *dksc, dev_t dev)
577 {
578 struct disklabel *lp = dksc->sc_dkdev.dk_label;
579 struct cpu_disklabel *clp = dksc->sc_dkdev.dk_cpulabel;
580 struct partition *pp;
581 int i;
582 const char *errstring;
583
584 memset(clp, 0x0, sizeof(*clp));
585 dk_getdefaultlabel(di, dksc, lp);
586 errstring = readdisklabel(DKLABELDEV(dev), di->di_strategy,
587 dksc->sc_dkdev.dk_label, dksc->sc_dkdev.dk_cpulabel);
588 if (errstring) {
589 dk_makedisklabel(di, dksc);
590 if (dksc->sc_flags & DKF_WARNLABEL)
591 printf("%s: %s\n", dksc->sc_xname, errstring);
592 return;
593 }
594
595 if ((dksc->sc_flags & DKF_LABELSANITY) == 0)
596 return;
597
598 /* Sanity check */
599 if (lp->d_secperunit != dksc->sc_size)
600 printf("WARNING: %s: total sector size in disklabel (%d) "
601 "!= the size of %s (%lu)\n", dksc->sc_xname,
602 lp->d_secperunit, di->di_dkname, (u_long)dksc->sc_size);
603
604 for (i=0; i < lp->d_npartitions; i++) {
605 pp = &lp->d_partitions[i];
606 if (pp->p_offset + pp->p_size > dksc->sc_size)
607 printf("WARNING: %s: end of partition `%c' exceeds "
608 "the size of %s (%lu)\n", dksc->sc_xname,
609 'a' + i, di->di_dkname, (u_long)dksc->sc_size);
610 }
611 }
612
613 /* ARGSUSED */
614 static void
615 dk_makedisklabel(struct dk_intf *di, struct dk_softc *dksc)
616 {
617 struct disklabel *lp = dksc->sc_dkdev.dk_label;
618
619 lp->d_partitions[RAW_PART].p_fstype = FS_BSDFFS;
620 strncpy(lp->d_packname, "default label", sizeof(lp->d_packname));
621 lp->d_checksum = dkcksum(lp);
622 }
623
624 /* This function is taken from ccd.c:1.76 --rcd */
625
626 /*
627 * XXX this function looks too generic for dksubr.c, shouldn't we
628 * put it somewhere better?
629 */
630
631 /*
632 * Lookup the provided name in the filesystem. If the file exists,
633 * is a valid block device, and isn't being used by anyone else,
634 * set *vpp to the file's vnode.
635 */
636 int
637 dk_lookup(const char *path, struct lwp *l, struct vnode **vpp,
638 enum uio_seg segflg)
639 {
640 struct nameidata nd;
641 struct vnode *vp;
642 struct vattr va;
643 int error;
644
645 if (l == NULL)
646 return ESRCH; /* Is ESRCH the best choice? */
647
648 NDINIT(&nd, LOOKUP, FOLLOW, segflg, path, l);
649 if ((error = vn_open(&nd, FREAD | FWRITE, 0)) != 0) {
650 DPRINTF((DKDB_FOLLOW|DKDB_INIT),
651 ("dk_lookup: vn_open error = %d\n", error));
652 return error;
653 }
654
655 vp = nd.ni_vp;
656 if ((error = VOP_GETATTR(vp, &va, l->l_cred, l)) != 0) {
657 DPRINTF((DKDB_FOLLOW|DKDB_INIT),
658 ("dk_lookup: getattr error = %d\n", error));
659 goto out;
660 }
661
662 /* XXX: eventually we should handle VREG, too. */
663 if (va.va_type != VBLK) {
664 error = ENOTBLK;
665 goto out;
666 }
667
668 /* XXX: wedges have a writecount of 1; this is disgusting */
669 if (vp->v_usecount > 1 + (major(va.va_rdev) == 168)) {
670 error = EBUSY;
671 goto out;
672 }
673
674 IFDEBUG(DKDB_VNODE, vprint("dk_lookup: vnode info", vp));
675
676 VOP_UNLOCK(vp, 0);
677 *vpp = vp;
678 return 0;
679 out:
680 VOP_UNLOCK(vp, 0);
681 (void) vn_close(vp, FREAD | FWRITE, l->l_cred, l);
682 return error;
683 }
684