* Copyright (c) 1982, 1986, 1989 Regents of the University of California.
* %sccs.include.redist.c%
* @(#)lfs_inode.c 7.45 (Berkeley) %G%
#include <ufs/ufsmount.h>
#include <ufs/ufs_extern.h>
#include <lfs/lfs_extern.h>
extern int prtactive
; /* 1 => print out reclaim of active vnodes */
* Look up an LFS dinode number to find its incore vnode. If not already
* in core, read it in from the specified device. Return the inode locked.
* Detection and handling of mount points must be done by the calling routine.
register struct inode
*ip
;
register struct vnode
*vp
;
printf("lfs_iget ino %d\n", ino
);
if ((*ipp
= ufs_ihashget(dev
, ino
)) != NULL
)
/* Allocate new vnode/inode. */
mntp
= ITOV(pip
)->v_mount
;
error
= lfs_vcreate(mntp
, ino
, &nvp
);
* Put it onto its hash chain and lock it so that other requests for
* this inode will block if they arrive while we are sleeping waiting
* for old data structures to be purged or for the contents of the
* disk portion of this inode to be read.
/* Read in the disk contents for the inode, copy into the inode. */
fs
= VFSTOUFS(mntp
)->um_lfs
;
if (error
= bread(VFSTOUFS(mntp
)->um_devvp
, lfs_itod(fs
, ino
),
(int)fs
->lfs_bsize
, NOCRED
, &bp
)) {
* The inode does not contain anything useful, so it would
* be misleading to leave it on its hash chain. Iput() will
* take care of putting it back on the free list.
/* Unlock and discard unneeded inode. */
ip
->i_din
= *lfs_ifind(fs
, ino
, bp
->b_un
.b_dino
);
/* Initialize the vnode from the inode, check for aliases. */
if (error
= ufs_vinit(mntp
, ip
, &nip
)) {
lfs_iupdat(ip
, ta
, tm
, waitfor
)
register struct inode
*ip
;
* This isn't right, but ufs_iupdat() isn't either.
* Truncate the inode ip to at most length size.
* NB: triple indirect blocks are untested.
lfs_itrunc(oip
, length
, flags
)
register struct inode
*oip
;
vnode_pager_setsize(ITOV(oip
), length
);
/* If length is larger than the file, just update the times. */
if (oip
->i_size
<= length
) {
oip
->i_flag
|= ICHG
|IUPD
;
ITIMES(oip
, &time
, &time
);
* Update the size of the file. If the file is not being truncated to
* a block boundry, the contents of the partial block following the end
* of the file must be zero'ed in case it ever become accessable again
* because of subsequent file growth.
offset
= blkoff(fs
, length
);
lbn
= lblkno(fs
, length
);
if (error
= getinoquota(oip
))
if (error
= bread(ITOV(oip
), lbn
, fs
->lfs_bsize
, NOCRED
, &bp
))
size
= blksize(fs
); /* LFS */
(void) vnode_pager_uncache(ITOV(oip
));
bzero(bp
->b_un
.b_addr
+ offset
, (unsigned)(size
- offset
));
/* BZERO INODE BLOCK POINTERS HERE, FOR CONSISTENCY XXX */