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