Deleted Added
full compact
ext2_vfsops.c (228583) ext2_vfsops.c (232703)
1/*-
2 * modified for EXT2FS support in 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) 1989, 1991, 1993, 1994

--- 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_vfsops.c 8.8 (Berkeley) 4/18/94
1/*-
2 * modified for EXT2FS support in 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) 1989, 1991, 1993, 1994

--- 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_vfsops.c 8.8 (Berkeley) 4/18/94
36 * $FreeBSD: head/sys/fs/ext2fs/ext2_vfsops.c 228583 2011-12-16 15:47:43Z pfg $
36 * $FreeBSD: head/sys/fs/ext2fs/ext2_vfsops.c 232703 2012-03-08 21:06:05Z pfg $
37 */
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/namei.h>
42#include <sys/priv.h>
43#include <sys/proc.h>
44#include <sys/kernel.h>
45#include <sys/vnode.h>
46#include <sys/mount.h>
47#include <sys/bio.h>
48#include <sys/buf.h>
49#include <sys/conf.h>
37 */
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/namei.h>
42#include <sys/priv.h>
43#include <sys/proc.h>
44#include <sys/kernel.h>
45#include <sys/vnode.h>
46#include <sys/mount.h>
47#include <sys/bio.h>
48#include <sys/buf.h>
49#include <sys/conf.h>
50#include <sys/endian.h>
50#include <sys/fcntl.h>
51#include <sys/malloc.h>
52#include <sys/stat.h>
53#include <sys/mutex.h>
54
55#include <geom/geom.h>
56#include <geom/geom_vfs.h>
57

--- 276 unchanged lines hidden (view full) ---

334 fs->e2fs_isize = E2FS_REV0_INODE_SIZE ;
335 } else {
336 fs->e2fs_first_inode = es->e2fs_first_ino;
337 fs->e2fs_isize = es->e2fs_inode_size;
338
339 /*
340 * Simple sanity check for superblock inode size value.
341 */
51#include <sys/fcntl.h>
52#include <sys/malloc.h>
53#include <sys/stat.h>
54#include <sys/mutex.h>
55
56#include <geom/geom.h>
57#include <geom/geom_vfs.h>
58

--- 276 unchanged lines hidden (view full) ---

335 fs->e2fs_isize = E2FS_REV0_INODE_SIZE ;
336 } else {
337 fs->e2fs_first_inode = es->e2fs_first_ino;
338 fs->e2fs_isize = es->e2fs_inode_size;
339
340 /*
341 * Simple sanity check for superblock inode size value.
342 */
342 if (fs->e2fs_isize < E2FS_REV0_INODE_SIZE ||
343 fs->e2fs_isize > fs->e2fs_bsize ||
343 if (EXT2_INODE_SIZE(fs) < E2FS_REV0_INODE_SIZE ||
344 EXT2_INODE_SIZE(fs) > fs->e2fs_bsize ||
344 (fs->e2fs_isize & (fs->e2fs_isize - 1)) != 0) {
345 (fs->e2fs_isize & (fs->e2fs_isize - 1)) != 0) {
345 printf("EXT2-fs: invalid inode size %d\n",
346 printf("ext2fs: invalid inode size %d\n",
346 fs->e2fs_isize);
347 return (EIO);
348 }
349 }
347 fs->e2fs_isize);
348 return (EIO);
349 }
350 }
351 /* Check for extra isize in big inodes. */
352 if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT4F_ROCOMPAT_EXTRA_ISIZE) &&
353 EXT2_INODE_SIZE(fs) < sizeof(struct ext2fs_dinode)) {
354 printf("ext2fs: no space for extra inode timestamps\n");
355 return (EINVAL);
356 }
357
350 fs->e2fs_ipb = fs->e2fs_bsize / EXT2_INODE_SIZE(fs);
351 fs->e2fs_itpg = fs->e2fs_ipg /fs->e2fs_ipb;
352 fs->e2fs_descpb = fs->e2fs_bsize / sizeof(struct ext2_gd);
353 /* s_resuid / s_resgid ? */
354 fs->e2fs_gcount = (es->e2fs_bcount - es->e2fs_first_dblock +
355 EXT2_BLOCKS_PER_GROUP(fs) - 1) / EXT2_BLOCKS_PER_GROUP(fs);
356 db_count = (fs->e2fs_gcount + EXT2_DESC_PER_BLOCK(fs) - 1) /
357 EXT2_DESC_PER_BLOCK(fs);
358 fs->e2fs_gdbcount = db_count;
359 fs->e2fs_gd = malloc(db_count * fs->e2fs_bsize,
360 M_EXT2MNT, M_WAITOK);
358 fs->e2fs_ipb = fs->e2fs_bsize / EXT2_INODE_SIZE(fs);
359 fs->e2fs_itpg = fs->e2fs_ipg /fs->e2fs_ipb;
360 fs->e2fs_descpb = fs->e2fs_bsize / sizeof(struct ext2_gd);
361 /* s_resuid / s_resgid ? */
362 fs->e2fs_gcount = (es->e2fs_bcount - es->e2fs_first_dblock +
363 EXT2_BLOCKS_PER_GROUP(fs) - 1) / EXT2_BLOCKS_PER_GROUP(fs);
364 db_count = (fs->e2fs_gcount + EXT2_DESC_PER_BLOCK(fs) - 1) /
365 EXT2_DESC_PER_BLOCK(fs);
366 fs->e2fs_gdbcount = db_count;
367 fs->e2fs_gd = malloc(db_count * fs->e2fs_bsize,
368 M_EXT2MNT, M_WAITOK);
361 fs->e2fs_contigdirs = malloc(fs->e2fs_gcount * sizeof(*fs->e2fs_contigdirs),
362 M_EXT2MNT, M_WAITOK);
369 fs->e2fs_contigdirs = malloc(fs->e2fs_gcount *
370 sizeof(*fs->e2fs_contigdirs), M_EXT2MNT, M_WAITOK);
363
364 /*
365 * Adjust logic_sb_block.
366 * Godmar thinks: if the blocksize is greater than 1024, then
367 * the superblock is logically part of block zero.
368 */
369 if(fs->e2fs_bsize > SBSIZE)
370 logic_sb_block = 0;

--- 14 unchanged lines hidden (view full) ---

385 bp = NULL;
386 }
387 fs->e2fs_total_dir = 0;
388 for (i=0; i < fs->e2fs_gcount; i++){
389 fs->e2fs_total_dir += fs->e2fs_gd[i].ext2bgd_ndirs;
390 fs->e2fs_contigdirs[i] = 0;
391 }
392 if (es->e2fs_rev == E2FS_REV0 ||
371
372 /*
373 * Adjust logic_sb_block.
374 * Godmar thinks: if the blocksize is greater than 1024, then
375 * the superblock is logically part of block zero.
376 */
377 if(fs->e2fs_bsize > SBSIZE)
378 logic_sb_block = 0;

--- 14 unchanged lines hidden (view full) ---

393 bp = NULL;
394 }
395 fs->e2fs_total_dir = 0;
396 for (i=0; i < fs->e2fs_gcount; i++){
397 fs->e2fs_total_dir += fs->e2fs_gd[i].ext2bgd_ndirs;
398 fs->e2fs_contigdirs[i] = 0;
399 }
400 if (es->e2fs_rev == E2FS_REV0 ||
393 (es->e2fs_features_rocompat & EXT2F_ROCOMPAT_LARGEFILE) == 0)
401 !EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_LARGEFILE))
394 fs->e2fs_maxfilesize = 0x7fffffff;
395 else
396 fs->e2fs_maxfilesize = 0x7fffffffffffffff;
397 return (0);
398}
399
400/*
401 * Reload all incore data for a filesystem (used after running fsck on

--- 560 unchanged lines hidden (view full) ---

962 return (error);
963 }
964 /* convert ext2 inode to dinode */
965 ext2_ei2i((struct ext2fs_dinode *) ((char *)bp->b_data + EXT2_INODE_SIZE(fs) *
966 ino_to_fsbo(fs, ino)), ip);
967 ip->i_block_group = ino_to_cg(fs, ino);
968 ip->i_next_alloc_block = 0;
969 ip->i_next_alloc_goal = 0;
402 fs->e2fs_maxfilesize = 0x7fffffff;
403 else
404 fs->e2fs_maxfilesize = 0x7fffffffffffffff;
405 return (0);
406}
407
408/*
409 * Reload all incore data for a filesystem (used after running fsck on

--- 560 unchanged lines hidden (view full) ---

970 return (error);
971 }
972 /* convert ext2 inode to dinode */
973 ext2_ei2i((struct ext2fs_dinode *) ((char *)bp->b_data + EXT2_INODE_SIZE(fs) *
974 ino_to_fsbo(fs, ino)), ip);
975 ip->i_block_group = ino_to_cg(fs, ino);
976 ip->i_next_alloc_block = 0;
977 ip->i_next_alloc_goal = 0;
970 ip->i_prealloc_count = 0;
971 ip->i_prealloc_block = 0;
972
973 /*
974 * Now we want to make sure that block pointers for unused
975 * blocks are zeroed out - ext2_balloc depends on this
976 * although for regular files and directories only
977 */
978 if(S_ISDIR(ip->i_mode) || S_ISREG(ip->i_mode)) {
979 used_blocks = (ip->i_size+fs->e2fs_bsize-1) / fs->e2fs_bsize;

--- 142 unchanged lines hidden ---
978
979 /*
980 * Now we want to make sure that block pointers for unused
981 * blocks are zeroed out - ext2_balloc depends on this
982 * although for regular files and directories only
983 */
984 if(S_ISDIR(ip->i_mode) || S_ISREG(ip->i_mode)) {
985 used_blocks = (ip->i_size+fs->e2fs_bsize-1) / fs->e2fs_bsize;

--- 142 unchanged lines hidden ---