]> git.saurik.com Git - apple/xnu.git/blob - bsd/ufs/ffs/ffs_vnops.c
xnu-344.49.tar.gz
[apple/xnu.git] / bsd / ufs / ffs / ffs_vnops.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
26 /*
27 * Copyright (c) 1982, 1986, 1989, 1993
28 * The Regents of the University of California. All rights reserved.
29 *
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
32 * are met:
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. All advertising materials mentioning features or use of this software
39 * must display the following acknowledgement:
40 * This product includes software developed by the University of
41 * California, Berkeley and its contributors.
42 * 4. Neither the name of the University nor the names of its contributors
43 * may be used to endorse or promote products derived from this software
44 * without specific prior written permission.
45 *
46 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
47 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * SUCH DAMAGE.
57 *
58 * @(#)ffs_vnops.c 8.15 (Berkeley) 5/14/95
59 */
60
61 #include <rev_endian_fs.h>
62 #include <sys/param.h>
63 #include <sys/systm.h>
64 #include <sys/resourcevar.h>
65 #include <sys/kernel.h>
66 #include <sys/file.h>
67 #include <sys/stat.h>
68 #include <sys/buf.h>
69 #include <sys/proc.h>
70 #include <sys/conf.h>
71 #include <sys/mount.h>
72 #include <sys/vnode.h>
73 #include <sys/malloc.h>
74 #include <sys/ubc.h>
75 #include <sys/quota.h>
76
77 #include <sys/vm.h>
78 #include <vfs/vfs_support.h>
79
80 #include <miscfs/specfs/specdev.h>
81 #include <miscfs/fifofs/fifo.h>
82
83 #include <ufs/ufs/lockf.h>
84 #include <ufs/ufs/quota.h>
85 #include <ufs/ufs/inode.h>
86 #include <ufs/ufs/dir.h>
87 #include <ufs/ufs/ufsmount.h>
88 #include <ufs/ufs/ufs_extern.h>
89
90 #include <ufs/ffs/fs.h>
91 #include <ufs/ffs/ffs_extern.h>
92 #if REV_ENDIAN_FS
93 #include <ufs/ufs/ufs_byte_order.h>
94 #include <architecture/byte_order.h>
95 #endif /* REV_ENDIAN_FS */
96
97 #define VOPFUNC int (*)(void *)
98
99 /* Global vfs data structures for ufs. */
100 int (**ffs_vnodeop_p)(void *);
101 struct vnodeopv_entry_desc ffs_vnodeop_entries[] = {
102 { &vop_default_desc, (VOPFUNC)vn_default_error },
103 { &vop_lookup_desc, (VOPFUNC)ufs_lookup }, /* lookup */
104 { &vop_create_desc, (VOPFUNC)ufs_create }, /* create */
105 { &vop_whiteout_desc, (VOPFUNC)ufs_whiteout }, /* whiteout */
106 { &vop_mknod_desc, (VOPFUNC)ufs_mknod }, /* mknod */
107 { &vop_open_desc, (VOPFUNC)ufs_open }, /* open */
108 { &vop_close_desc, (VOPFUNC)ufs_close }, /* close */
109 { &vop_access_desc, (VOPFUNC)ufs_access }, /* access */
110 { &vop_getattr_desc, (VOPFUNC)ufs_getattr }, /* getattr */
111 { &vop_setattr_desc, (VOPFUNC)ufs_setattr }, /* setattr */
112 { &vop_read_desc, (VOPFUNC)ffs_read }, /* read */
113 { &vop_write_desc, (VOPFUNC)ffs_write }, /* write */
114 { &vop_lease_desc, (VOPFUNC)ufs_lease_check }, /* lease */
115 { &vop_ioctl_desc, (VOPFUNC)ufs_ioctl }, /* ioctl */
116 { &vop_select_desc, (VOPFUNC)ufs_select }, /* select */
117 { &vop_revoke_desc, (VOPFUNC)ufs_revoke }, /* revoke */
118 { &vop_mmap_desc, (VOPFUNC)ufs_mmap }, /* mmap */
119 { &vop_fsync_desc, (VOPFUNC)ffs_fsync }, /* fsync */
120 { &vop_seek_desc, (VOPFUNC)ufs_seek }, /* seek */
121 { &vop_remove_desc, (VOPFUNC)ufs_remove }, /* remove */
122 { &vop_link_desc, (VOPFUNC)ufs_link }, /* link */
123 { &vop_rename_desc, (VOPFUNC)ufs_rename }, /* rename */
124 { &vop_mkdir_desc, (VOPFUNC)ufs_mkdir }, /* mkdir */
125 { &vop_rmdir_desc, (VOPFUNC)ufs_rmdir }, /* rmdir */
126 { &vop_symlink_desc, (VOPFUNC)ufs_symlink }, /* symlink */
127 { &vop_readdir_desc, (VOPFUNC)ufs_readdir }, /* readdir */
128 { &vop_readlink_desc, (VOPFUNC)ufs_readlink }, /* readlink */
129 { &vop_abortop_desc, (VOPFUNC)ufs_abortop }, /* abortop */
130 { &vop_inactive_desc, (VOPFUNC)ufs_inactive }, /* inactive */
131 { &vop_reclaim_desc, (VOPFUNC)ffs_reclaim }, /* reclaim */
132 { &vop_lock_desc, (VOPFUNC)ufs_lock }, /* lock */
133 { &vop_unlock_desc, (VOPFUNC)ufs_unlock }, /* unlock */
134 { &vop_bmap_desc, (VOPFUNC)ufs_bmap }, /* bmap */
135 { &vop_strategy_desc, (VOPFUNC)ufs_strategy }, /* strategy */
136 { &vop_print_desc, (VOPFUNC)ufs_print }, /* print */
137 { &vop_islocked_desc, (VOPFUNC)ufs_islocked }, /* islocked */
138 { &vop_pathconf_desc, (VOPFUNC)ufs_pathconf }, /* pathconf */
139 { &vop_advlock_desc, (VOPFUNC)ufs_advlock }, /* advlock */
140 { &vop_blkatoff_desc, (VOPFUNC)ffs_blkatoff }, /* blkatoff */
141 { &vop_valloc_desc, (VOPFUNC)ffs_valloc }, /* valloc */
142 { &vop_reallocblks_desc, (VOPFUNC)ffs_reallocblks }, /* reallocblks */
143 { &vop_vfree_desc, (VOPFUNC)ffs_vfree }, /* vfree */
144 { &vop_truncate_desc, (VOPFUNC)ffs_truncate }, /* truncate */
145 { &vop_update_desc, (VOPFUNC)ffs_update }, /* update */
146 { &vop_bwrite_desc, (VOPFUNC)vn_bwrite },
147 { &vop_pagein_desc, (VOPFUNC)ffs_pagein }, /* Pagein */
148 { &vop_pageout_desc, (VOPFUNC)ffs_pageout }, /* Pageout */
149 { &vop_copyfile_desc, (VOPFUNC)err_copyfile }, /* Copy File */
150 { &vop_blktooff_desc, (VOPFUNC)ffs_blktooff }, /* blktooff */
151 { &vop_offtoblk_desc, (VOPFUNC)ffs_offtoblk }, /* offtoblk */
152 { &vop_cmap_desc, (VOPFUNC)ufs_cmap }, /* cmap */
153 { (struct vnodeop_desc*)NULL, (int(*)())NULL }
154 };
155 struct vnodeopv_desc ffs_vnodeop_opv_desc =
156 { &ffs_vnodeop_p, ffs_vnodeop_entries };
157
158 int (**ffs_specop_p)(void *);
159 struct vnodeopv_entry_desc ffs_specop_entries[] = {
160 { &vop_default_desc, (VOPFUNC)vn_default_error },
161 { &vop_lookup_desc, (VOPFUNC)spec_lookup }, /* lookup */
162 { &vop_create_desc, (VOPFUNC)spec_create }, /* create */
163 { &vop_mknod_desc, (VOPFUNC)spec_mknod }, /* mknod */
164 { &vop_open_desc, (VOPFUNC)spec_open }, /* open */
165 { &vop_close_desc, (VOPFUNC)ufsspec_close }, /* close */
166 { &vop_access_desc, (VOPFUNC)ufs_access }, /* access */
167 { &vop_getattr_desc, (VOPFUNC)ufs_getattr }, /* getattr */
168 { &vop_setattr_desc, (VOPFUNC)ufs_setattr }, /* setattr */
169 { &vop_read_desc, (VOPFUNC)ufsspec_read }, /* read */
170 { &vop_write_desc, (VOPFUNC)ufsspec_write }, /* write */
171 { &vop_lease_desc, (VOPFUNC)spec_lease_check }, /* lease */
172 { &vop_ioctl_desc, (VOPFUNC)spec_ioctl }, /* ioctl */
173 { &vop_select_desc, (VOPFUNC)spec_select }, /* select */
174 { &vop_revoke_desc, (VOPFUNC)spec_revoke }, /* revoke */
175 { &vop_mmap_desc, (VOPFUNC)spec_mmap }, /* mmap */
176 { &vop_fsync_desc, (VOPFUNC)ffs_fsync }, /* fsync */
177 { &vop_seek_desc, (VOPFUNC)spec_seek }, /* seek */
178 { &vop_remove_desc, (VOPFUNC)spec_remove }, /* remove */
179 { &vop_link_desc, (VOPFUNC)spec_link }, /* link */
180 { &vop_rename_desc, (VOPFUNC)spec_rename }, /* rename */
181 { &vop_mkdir_desc, (VOPFUNC)spec_mkdir }, /* mkdir */
182 { &vop_rmdir_desc, (VOPFUNC)spec_rmdir }, /* rmdir */
183 { &vop_symlink_desc, (VOPFUNC)spec_symlink }, /* symlink */
184 { &vop_readdir_desc, (VOPFUNC)spec_readdir }, /* readdir */
185 { &vop_readlink_desc, (VOPFUNC)spec_readlink }, /* readlink */
186 { &vop_abortop_desc, (VOPFUNC)spec_abortop }, /* abortop */
187 { &vop_inactive_desc, (VOPFUNC)ufs_inactive }, /* inactive */
188 { &vop_reclaim_desc, (VOPFUNC)ffs_reclaim }, /* reclaim */
189 { &vop_lock_desc, (VOPFUNC)ufs_lock }, /* lock */
190 { &vop_unlock_desc, (VOPFUNC)ufs_unlock }, /* unlock */
191 { &vop_bmap_desc, (VOPFUNC)spec_bmap }, /* bmap */
192 { &vop_strategy_desc, (VOPFUNC)spec_strategy }, /* strategy */
193 { &vop_print_desc, (VOPFUNC)ufs_print }, /* print */
194 { &vop_islocked_desc, (VOPFUNC)ufs_islocked }, /* islocked */
195 { &vop_pathconf_desc, (VOPFUNC)spec_pathconf }, /* pathconf */
196 { &vop_advlock_desc, (VOPFUNC)spec_advlock }, /* advlock */
197 { &vop_blkatoff_desc, (VOPFUNC)spec_blkatoff }, /* blkatoff */
198 { &vop_valloc_desc, (VOPFUNC)spec_valloc }, /* valloc */
199 { &vop_reallocblks_desc, (VOPFUNC)spec_reallocblks }, /* reallocblks */
200 { &vop_vfree_desc, (VOPFUNC)ffs_vfree }, /* vfree */
201 { &vop_truncate_desc, (VOPFUNC)spec_truncate }, /* truncate */
202 { &vop_update_desc, (VOPFUNC)ffs_update }, /* update */
203 { &vop_bwrite_desc, (VOPFUNC)vn_bwrite },
204 { &vop_devblocksize_desc, (VOPFUNC)spec_devblocksize }, /* devblocksize */
205 { &vop_pagein_desc, (VOPFUNC)ffs_pagein }, /* Pagein */
206 { &vop_pageout_desc, (VOPFUNC)ffs_pageout }, /* Pageout */
207 { &vop_copyfile_desc, (VOPFUNC)err_copyfile }, /* Copy File */
208 { &vop_blktooff_desc, (VOPFUNC)ffs_blktooff }, /* blktooff */
209 { &vop_offtoblk_desc, (VOPFUNC)ffs_offtoblk }, /* offtoblk */
210 { &vop_cmap_desc, (VOPFUNC)spec_cmap }, /* cmap */
211 { (struct vnodeop_desc*)NULL, (int(*)())NULL }
212 };
213 struct vnodeopv_desc ffs_specop_opv_desc =
214 { &ffs_specop_p, ffs_specop_entries };
215
216 #if FIFO
217 int (**ffs_fifoop_p)(void *);
218 struct vnodeopv_entry_desc ffs_fifoop_entries[] = {
219 { &vop_default_desc, (VOPFUNC)vn_default_error },
220 { &vop_lookup_desc, (VOPFUNC)fifo_lookup }, /* lookup */
221 { &vop_create_desc, (VOPFUNC)fifo_create }, /* create */
222 { &vop_mknod_desc, (VOPFUNC)fifo_mknod }, /* mknod */
223 { &vop_open_desc, (VOPFUNC)fifo_open }, /* open */
224 { &vop_close_desc, (VOPFUNC)ufsfifo_close }, /* close */
225 { &vop_access_desc, (VOPFUNC)ufs_access }, /* access */
226 { &vop_getattr_desc, (VOPFUNC)ufs_getattr }, /* getattr */
227 { &vop_setattr_desc, (VOPFUNC)ufs_setattr }, /* setattr */
228 { &vop_read_desc, (VOPFUNC)ufsfifo_read }, /* read */
229 { &vop_write_desc, (VOPFUNC)ufsfifo_write }, /* write */
230 { &vop_lease_desc, (VOPFUNC)fifo_lease_check }, /* lease */
231 { &vop_ioctl_desc, (VOPFUNC)fifo_ioctl }, /* ioctl */
232 { &vop_select_desc, (VOPFUNC)fifo_select }, /* select */
233 { &vop_revoke_desc, (VOPFUNC)fifo_revoke }, /* revoke */
234 { &vop_mmap_desc, (VOPFUNC)fifo_mmap }, /* mmap */
235 { &vop_fsync_desc, (VOPFUNC)ffs_fsync }, /* fsync */
236 { &vop_seek_desc, (VOPFUNC)fifo_seek }, /* seek */
237 { &vop_remove_desc, (VOPFUNC)fifo_remove }, /* remove */
238 { &vop_link_desc, (VOPFUNC)fifo_link }, /* link */
239 { &vop_rename_desc, (VOPFUNC)fifo_rename }, /* rename */
240 { &vop_mkdir_desc, (VOPFUNC)fifo_mkdir }, /* mkdir */
241 { &vop_rmdir_desc, (VOPFUNC)fifo_rmdir }, /* rmdir */
242 { &vop_symlink_desc, (VOPFUNC)fifo_symlink }, /* symlink */
243 { &vop_readdir_desc, (VOPFUNC)fifo_readdir }, /* readdir */
244 { &vop_readlink_desc, (VOPFUNC)fifo_readlink }, /* readlink */
245 { &vop_abortop_desc, (VOPFUNC)fifo_abortop }, /* abortop */
246 { &vop_inactive_desc, (VOPFUNC)ufs_inactive }, /* inactive */
247 { &vop_reclaim_desc, (VOPFUNC)ffs_reclaim }, /* reclaim */
248 { &vop_lock_desc, (VOPFUNC)ufs_lock }, /* lock */
249 { &vop_unlock_desc, (VOPFUNC)ufs_unlock }, /* unlock */
250 { &vop_bmap_desc, (VOPFUNC)fifo_bmap }, /* bmap */
251 { &vop_strategy_desc, (VOPFUNC)fifo_strategy }, /* strategy */
252 { &vop_print_desc, (VOPFUNC)ufs_print }, /* print */
253 { &vop_islocked_desc, (VOPFUNC)ufs_islocked }, /* islocked */
254 { &vop_pathconf_desc, (VOPFUNC)fifo_pathconf }, /* pathconf */
255 { &vop_advlock_desc, (VOPFUNC)fifo_advlock }, /* advlock */
256 { &vop_blkatoff_desc, (VOPFUNC)fifo_blkatoff }, /* blkatoff */
257 { &vop_valloc_desc, (VOPFUNC)fifo_valloc }, /* valloc */
258 { &vop_reallocblks_desc, (VOPFUNC)fifo_reallocblks }, /* reallocblks */
259 { &vop_vfree_desc, (VOPFUNC)ffs_vfree }, /* vfree */
260 { &vop_truncate_desc, (VOPFUNC)fifo_truncate }, /* truncate */
261 { &vop_update_desc, (VOPFUNC)ffs_update }, /* update */
262 { &vop_bwrite_desc, (VOPFUNC)vn_bwrite },
263 { &vop_pagein_desc, (VOPFUNC)ffs_pagein }, /* Pagein */
264 { &vop_pageout_desc, (VOPFUNC)ffs_pageout }, /* Pageout */
265 { &vop_copyfile_desc, (VOPFUNC)err_copyfile }, /* Copy File */
266 { &vop_blktooff_desc, (VOPFUNC)ffs_blktooff }, /* blktooff */
267 { &vop_offtoblk_desc, (VOPFUNC)ffs_offtoblk }, /* offtoblk */
268 { &vop_cmap_desc, (VOPFUNC)ufs_cmap }, /* cmap */
269 { (struct vnodeop_desc*)NULL, (int(*)())NULL }
270 };
271 struct vnodeopv_desc ffs_fifoop_opv_desc =
272 { &ffs_fifoop_p, ffs_fifoop_entries };
273 #endif /* FIFO */
274
275 /*
276 * Enabling cluster read/write operations.
277 */
278 int doclusterread = 0;
279 int doclusterwrite = 0;
280
281 #include <ufs/ufs/ufs_readwrite.c>
282
283 /*
284 * Synch an open file.
285 */
286 /* ARGSUSED */
287 int
288 ffs_fsync(ap)
289 struct vop_fsync_args /* {
290 struct vnode *a_vp;
291 struct ucred *a_cred;
292 int a_waitfor;
293 struct proc *a_p;
294 } */ *ap;
295 {
296 register struct vnode *vp = ap->a_vp;
297 register struct buf *bp;
298 struct timeval tv;
299 struct buf *nbp;
300 int s;
301 struct inode *ip = VTOI(vp);
302 int retry = 0;
303
304 /*
305 * Write out any clusters.
306 */
307 cluster_push(vp);
308
309 /*
310 * Flush all dirty buffers associated with a vnode.
311 */
312 loop:
313 s = splbio();
314 for (bp = vp->v_dirtyblkhd.lh_first; bp; bp = nbp) {
315 nbp = bp->b_vnbufs.le_next;
316 if ((bp->b_flags & B_BUSY))
317 continue;
318 if ((bp->b_flags & B_DELWRI) == 0)
319 panic("ffs_fsync: not dirty");
320 bremfree(bp);
321 bp->b_flags |= B_BUSY;
322 splx(s);
323 /*
324 * Wait for I/O associated with indirect blocks to complete,
325 * since there is no way to quickly wait for them below.
326 */
327 if (bp->b_vp == vp || ap->a_waitfor == MNT_NOWAIT)
328 (void) bawrite(bp);
329 else
330 (void) bwrite(bp);
331 goto loop;
332 }
333
334 if (ap->a_waitfor == MNT_WAIT) {
335 while (vp->v_numoutput) {
336 vp->v_flag |= VBWAIT;
337 tsleep((caddr_t)&vp->v_numoutput, PRIBIO + 1, "ffs_fsync", 0);
338 }
339
340 if (vp->v_dirtyblkhd.lh_first) {
341 /* still have some dirty buffers */
342 if (retry++ > 10) {
343 vprint("ffs_fsync: dirty", vp);
344 splx(s);
345 /*
346 * Looks like the requests are not
347 * getting queued to the driver.
348 * Retrying here causes a cpu bound loop.
349 * Yield to the other threads and hope
350 * for the best.
351 */
352 (void)tsleep((caddr_t)&vp->v_numoutput,
353 PRIBIO + 1, "ffs_fsync", hz/10);
354 retry = 0;
355 } else {
356 splx(s);
357 }
358 /* try again */
359 goto loop;
360 }
361 }
362 splx(s);
363 tv = time;
364 return (VOP_UPDATE(ap->a_vp, &tv, &tv, ap->a_waitfor == MNT_WAIT));
365 }
366
367 /*
368 * Reclaim an inode so that it can be used for other purposes.
369 */
370 int
371 ffs_reclaim(ap)
372 struct vop_reclaim_args /* {
373 struct vnode *a_vp;
374 struct proc *a_p;
375 } */ *ap;
376 {
377 register struct vnode *vp = ap->a_vp;
378 int error;
379
380 if (error = ufs_reclaim(vp, ap->a_p))
381 return (error);
382 FREE_ZONE(vp->v_data, sizeof (struct inode),
383 VFSTOUFS(vp->v_mount)->um_devvp->v_tag == VT_MFS ?
384 M_MFSNODE : M_FFSNODE);
385 vp->v_data = NULL;
386 return (0);
387 }
388
389 /* Blktooff converts a logical block number to a file offset */
390 int
391 ffs_blktooff(ap)
392 struct vop_blktooff_args /* {
393 struct vnode *a_vp;
394 daddr_t a_lblkno;
395 off_t *a_offset;
396 } */ *ap;
397 {
398 register struct inode *ip;
399 register FS *fs;
400 ufs_daddr_t bn;
401
402
403 if (ap->a_vp == NULL)
404 return (EINVAL);
405
406 ip = VTOI(ap->a_vp);
407 fs = ip->I_FS;
408 bn = ap->a_lblkno;
409
410 if ((long)bn < 0) {
411 panic("-ve blkno in ffs_blktooff");
412 bn = -(long)bn;
413 }
414
415 *ap->a_offset = (off_t)lblktosize(fs, bn);
416 return (0);
417 }
418
419 /* Blktooff converts a logical block number to a file offset */
420 int
421 ffs_offtoblk(ap)
422 struct vop_offtoblk_args /* {
423 struct vnode *a_vp;
424 off_t a_offset;
425 daddr_t *a_lblkno;
426 } */ *ap;
427 {
428 register struct inode *ip;
429 register FS *fs;
430
431 if (ap->a_vp == NULL)
432 return (EINVAL);
433
434 ip = VTOI(ap->a_vp);
435 fs = ip->I_FS;
436
437 *ap->a_lblkno = (daddr_t)lblkno(fs, ap->a_offset);
438 return (0);
439 }