ext2_alloc.c (229200) | ext2_alloc.c (232703) |
---|---|
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_alloc.c 8.8 (Berkeley) 2/21/94 | 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_alloc.c 8.8 (Berkeley) 2/21/94 |
36 * $FreeBSD: head/sys/fs/ext2fs/ext2_alloc.c 229200 2012-01-01 20:47:33Z ed $ | 36 * $FreeBSD: head/sys/fs/ext2fs/ext2_alloc.c 232703 2012-03-08 21:06:05Z pfg $ |
37 */ 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/conf.h> 42#include <sys/vnode.h> 43#include <sys/stat.h> 44#include <sys/mount.h> --- 294 unchanged lines hidden (view full) --- 339 */ 340int 341ext2_valloc(pvp, mode, cred, vpp) 342 struct vnode *pvp; 343 int mode; 344 struct ucred *cred; 345 struct vnode **vpp; 346{ | 37 */ 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/conf.h> 42#include <sys/vnode.h> 43#include <sys/stat.h> 44#include <sys/mount.h> --- 294 unchanged lines hidden (view full) --- 339 */ 340int 341ext2_valloc(pvp, mode, cred, vpp) 342 struct vnode *pvp; 343 int mode; 344 struct ucred *cred; 345 struct vnode **vpp; 346{ |
347 struct timespec ts; |
|
347 struct inode *pip; 348 struct m_ext2fs *fs; 349 struct inode *ip; 350 struct ext2mount *ump; 351 ino_t ino, ipref; 352 int i, error, cg; 353 354 *vpp = NULL; --- 25 unchanged lines hidden (view full) --- 380 goto noinodes; 381 error = VFS_VGET(pvp->v_mount, ino, LK_EXCLUSIVE, vpp); 382 if (error) { 383 ext2_vfree(pvp, ino, mode); 384 return (error); 385 } 386 ip = VTOI(*vpp); 387 | 348 struct inode *pip; 349 struct m_ext2fs *fs; 350 struct inode *ip; 351 struct ext2mount *ump; 352 ino_t ino, ipref; 353 int i, error, cg; 354 355 *vpp = NULL; --- 25 unchanged lines hidden (view full) --- 381 goto noinodes; 382 error = VFS_VGET(pvp->v_mount, ino, LK_EXCLUSIVE, vpp); 383 if (error) { 384 ext2_vfree(pvp, ino, mode); 385 return (error); 386 } 387 ip = VTOI(*vpp); 388 |
388 /* 389 the question is whether using VGET was such good idea at all - 390 Linux doesn't read the old inode in when it's allocating a 391 new one. I will set at least i_size & i_blocks the zero. 392 */ 393 ip->i_mode = 0; | 389 /* 390 * The question is whether using VGET was such good idea at all: 391 * Linux doesn't read the old inode in when it is allocating a 392 * new one. I will set at least i_size and i_blocks to zero. 393 */ |
394 ip->i_size = 0; 395 ip->i_blocks = 0; | 394 ip->i_size = 0; 395 ip->i_blocks = 0; |
396 ip->i_mode = 0; |
|
396 ip->i_flags = 0; 397 /* now we want to make sure that the block pointers are zeroed out */ 398 for (i = 0; i < NDADDR; i++) 399 ip->i_db[i] = 0; 400 for (i = 0; i < NIADDR; i++) 401 ip->i_ib[i] = 0; 402 403 /* 404 * Set up a new generation number for this inode. 405 * XXX check if this makes sense in ext2 406 */ 407 if (ip->i_gen == 0 || ++ip->i_gen == 0) 408 ip->i_gen = random() / 2 + 1; | 397 ip->i_flags = 0; 398 /* now we want to make sure that the block pointers are zeroed out */ 399 for (i = 0; i < NDADDR; i++) 400 ip->i_db[i] = 0; 401 for (i = 0; i < NIADDR; i++) 402 ip->i_ib[i] = 0; 403 404 /* 405 * Set up a new generation number for this inode. 406 * XXX check if this makes sense in ext2 407 */ 408 if (ip->i_gen == 0 || ++ip->i_gen == 0) 409 ip->i_gen = random() / 2 + 1; |
410 411 vfs_timestamp(&ts); 412 ip->i_birthtime = ts.tv_sec; 413 ip->i_birthnsec = ts.tv_nsec; 414 |
|
409/* 410printf("ext2_valloc: allocated inode %d\n", ino); 411*/ 412 return (0); 413noinodes: 414 EXT2_UNLOCK(ump); 415 ext2_fserr(fs, cred->cr_uid, "out of inodes"); 416 uprintf("\n%s: create/symlink failed, no inodes free\n", fs->e2fs_fsmnt); --- 705 unchanged lines hidden --- | 415/* 416printf("ext2_valloc: allocated inode %d\n", ino); 417*/ 418 return (0); 419noinodes: 420 EXT2_UNLOCK(ump); 421 ext2_fserr(fs, cred->cr_uid, "out of inodes"); 422 uprintf("\n%s: create/symlink failed, no inodes free\n", fs->e2fs_fsmnt); --- 705 unchanged lines hidden --- |