ext2_inode.c (251658) | ext2_inode.c (254283) |
---|---|
1/*- 2 * modified for Lites 1.1 3 * 4 * Aug 1995, Godmar Back (gback@cs.utah.edu) 5 * University of Utah, Department of Computer Science 6 */ 7/*- 8 * Copyright (c) 1982, 1986, 1989, 1993 --- 19 unchanged lines hidden (view full) --- 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)ffs_inode.c 8.5 (Berkeley) 12/30/93 | 1/*- 2 * modified for Lites 1.1 3 * 4 * Aug 1995, Godmar Back (gback@cs.utah.edu) 5 * University of Utah, Department of Computer Science 6 */ 7/*- 8 * Copyright (c) 1982, 1986, 1989, 1993 --- 19 unchanged lines hidden (view full) --- 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)ffs_inode.c 8.5 (Berkeley) 12/30/93 |
36 * $FreeBSD: head/sys/fs/ext2fs/ext2_inode.c 251658 2013-06-12 15:24:48Z pfg $ | 36 * $FreeBSD: head/sys/fs/ext2fs/ext2_inode.c 254283 2013-08-13 15:40:43Z pfg $ |
37 */ 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/mount.h> 42#include <sys/bio.h> 43#include <sys/buf.h> 44#include <sys/vnode.h> --- 4 unchanged lines hidden (view full) --- 49#include <vm/vm_extern.h> 50 51#include <fs/ext2fs/inode.h> 52#include <fs/ext2fs/ext2_mount.h> 53#include <fs/ext2fs/ext2fs.h> 54#include <fs/ext2fs/fs.h> 55#include <fs/ext2fs/ext2_extern.h> 56 | 37 */ 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/mount.h> 42#include <sys/bio.h> 43#include <sys/buf.h> 44#include <sys/vnode.h> --- 4 unchanged lines hidden (view full) --- 49#include <vm/vm_extern.h> 50 51#include <fs/ext2fs/inode.h> 52#include <fs/ext2fs/ext2_mount.h> 53#include <fs/ext2fs/ext2fs.h> 54#include <fs/ext2fs/fs.h> 55#include <fs/ext2fs/ext2_extern.h> 56 |
57static int ext2_indirtrunc(struct inode *, int32_t, int32_t, int32_t, int, 58 long *); | 57static int ext2_indirtrunc(struct inode *, daddr_t, daddr_t, 58 daddr_t, int, e4fs_daddr_t *); |
59 60/* 61 * Update the access, modified, and inode change times as specified by the 62 * IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively. Write the inode 63 * to disk if the IN_MODIFIED flag is set (it may be set initially, or by 64 * the timestamp update). The IN_LAZYMOD flag is set to force a write 65 * later if not now. If we write now, then clear both IN_MODIFIED and 66 * IN_LAZYMOD to reflect the presumably successful write, and if waitfor is --- 47 unchanged lines hidden (view full) --- 114 int32_t lastblock; 115 struct inode *oip; 116 int32_t bn, lbn, lastiblock[NIADDR], indir_lbn[NIADDR]; 117 uint32_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR]; 118 struct bufobj *bo; 119 struct m_ext2fs *fs; 120 struct buf *bp; 121 int offset, size, level; | 59 60/* 61 * Update the access, modified, and inode change times as specified by the 62 * IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively. Write the inode 63 * to disk if the IN_MODIFIED flag is set (it may be set initially, or by 64 * the timestamp update). The IN_LAZYMOD flag is set to force a write 65 * later if not now. If we write now, then clear both IN_MODIFIED and 66 * IN_LAZYMOD to reflect the presumably successful write, and if waitfor is --- 47 unchanged lines hidden (view full) --- 114 int32_t lastblock; 115 struct inode *oip; 116 int32_t bn, lbn, lastiblock[NIADDR], indir_lbn[NIADDR]; 117 uint32_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR]; 118 struct bufobj *bo; 119 struct m_ext2fs *fs; 120 struct buf *bp; 121 int offset, size, level; |
122 long count, nblocks, blocksreleased = 0; | 122 e4fs_daddr_t count, nblocks, blocksreleased = 0; |
123 int error, i, allerror; 124 off_t osize; 125 126 oip = VTOI(ovp); 127 bo = &ovp->v_bufobj; 128 129 ASSERT_VOP_LOCKED(vp, "ext2_truncate"); 130 --- 220 unchanged lines hidden (view full) --- 351 * lastbn. If level is greater than SINGLE, the block is an indirect block 352 * and recursive calls to indirtrunc must be used to cleanse other indirect 353 * blocks. 354 * 355 * NB: triple indirect blocks are untested. 356 */ 357 358static int | 123 int error, i, allerror; 124 off_t osize; 125 126 oip = VTOI(ovp); 127 bo = &ovp->v_bufobj; 128 129 ASSERT_VOP_LOCKED(vp, "ext2_truncate"); 130 --- 220 unchanged lines hidden (view full) --- 351 * lastbn. If level is greater than SINGLE, the block is an indirect block 352 * and recursive calls to indirtrunc must be used to cleanse other indirect 353 * blocks. 354 * 355 * NB: triple indirect blocks are untested. 356 */ 357 358static int |
359ext2_indirtrunc(struct inode *ip, int32_t lbn, int32_t dbn, int32_t lastbn, 360 int level, long *countp) | 359ext2_indirtrunc(struct inode *ip, daddr_t lbn, daddr_t dbn, 360 daddr_t lastbn, int level, e4fs_daddr_t *countp) |
361{ 362 struct buf *bp; 363 struct m_ext2fs *fs = ip->i_e2fs; 364 struct vnode *vp; | 361{ 362 struct buf *bp; 363 struct m_ext2fs *fs = ip->i_e2fs; 364 struct vnode *vp; |
365 int32_t *bap, *copy, nb, nlbn, last; 366 long blkcount, factor; 367 int i, nblocks, blocksreleased = 0; 368 int error = 0, allerror = 0; | 365 e2fs_daddr_t *bap, *copy; 366 int i, nblocks, error = 0, allerror = 0; 367 e2fs_lbn_t nb, nlbn, last; 368 e4fs_daddr_t blkcount, factor, blocksreleased = 0; |
369 370 /* 371 * Calculate index in current block of last 372 * block to be kept. -1 indicates the entire 373 * block so we need not calculate the index. 374 */ 375 factor = 1; 376 for (i = SINGLE; i < level; i++) --- 23 unchanged lines hidden (view full) --- 400 error = bufwait(bp); 401 } 402 if (error) { 403 brelse(bp); 404 *countp = 0; 405 return (error); 406 } 407 | 369 370 /* 371 * Calculate index in current block of last 372 * block to be kept. -1 indicates the entire 373 * block so we need not calculate the index. 374 */ 375 factor = 1; 376 for (i = SINGLE; i < level; i++) --- 23 unchanged lines hidden (view full) --- 400 error = bufwait(bp); 401 } 402 if (error) { 403 brelse(bp); 404 *countp = 0; 405 return (error); 406 } 407 |
408 bap = (int32_t *)bp->b_data; | 408 bap = (e2fs_daddr_t *)bp->b_data; |
409 copy = malloc(fs->e2fs_bsize, M_TEMP, M_WAITOK); 410 bcopy((caddr_t)bap, (caddr_t)copy, (u_int)fs->e2fs_bsize); 411 bzero((caddr_t)&bap[last + 1], | 409 copy = malloc(fs->e2fs_bsize, M_TEMP, M_WAITOK); 410 bcopy((caddr_t)bap, (caddr_t)copy, (u_int)fs->e2fs_bsize); 411 bzero((caddr_t)&bap[last + 1], |
412 (u_int)(NINDIR(fs) - (last + 1)) * sizeof(int32_t)); | 412 (NINDIR(fs) - (last + 1)) * sizeof(e2fs_daddr_t)); |
413 if (last == -1) 414 bp->b_flags |= B_INVAL; 415 if (DOINGASYNC(vp)) { 416 bdwrite(bp); 417 } else { 418 error = bwrite(bp); 419 if (error) 420 allerror = error; --- 95 unchanged lines hidden --- | 413 if (last == -1) 414 bp->b_flags |= B_INVAL; 415 if (DOINGASYNC(vp)) { 416 bdwrite(bp); 417 } else { 418 error = bwrite(bp); 419 if (error) 420 allerror = error; --- 95 unchanged lines hidden --- |