1 /* 2 * Copyright (c) 1991 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)lfs_subr.c 7.10 (Berkeley) 05/14/92 8 */ 9 10 #include <sys/param.h> 11 #include <sys/namei.h> 12 #include <sys/vnode.h> 13 #include <sys/buf.h> 14 15 #include <ufs/ufs/quota.h> 16 #include <ufs/ufs/inode.h> 17 18 #include <ufs/lfs/lfs.h> 19 #include <ufs/lfs/lfs_extern.h> 20 21 /* 22 * Return buffer with the contents of block "offset" from the beginning of 23 * directory "ip". If "res" is non-zero, fill it in with a pointer to the 24 * remaining space in the directory. 25 */ 26 int 27 lfs_blkatoff (ap) 28 struct vop_blkatoff_args *ap; 29 #define vp (ap->a_vp) 30 #define offset (ap->a_offset) 31 #define res (ap->a_res) 32 #define bpp (ap->a_bpp) 33 { 34 register struct lfs *fs; 35 struct inode *ip; 36 struct buf *bp; 37 daddr_t lbn; 38 int bsize, error; 39 40 ip = VTOI(vp); 41 fs = ip->i_lfs; 42 lbn = lblkno(fs, offset); 43 bsize = blksize(fs); 44 45 *bpp = NULL; 46 if (error = bread(vp, lbn, bsize, NOCRED, &bp)) { 47 brelse(bp); 48 return (error); 49 } 50 if (res) 51 *res = bp->b_un.b_addr + blkoff(fs, offset); 52 *bpp = bp; 53 return (0); 54 } 55 #undef vp 56 #undef offset 57 #undef res 58 #undef bpp 59