Deleted Added
full compact
ext2_vfsops.c (191990) ext2_vfsops.c (193377)
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/gnu/fs/ext2fs/ext2_vfsops.c 191990 2009-05-11 15:33:26Z attilio $
36 * $FreeBSD: head/sys/gnu/fs/ext2fs/ext2_vfsops.c 193377 2009-06-03 13:25:50Z stas $
37 */
38
39/*-
40 * COPYRIGHT.INFO says this has some GPL'd code from ext2_super.c in it
41 *
42 * This program is free software; you can redistribute it and/or modify
43 * it under the terms of the GNU General Public License as published by
44 * the Free Software Foundation; either version 2 of the License.

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

73#include <geom/geom.h>
74#include <geom/geom_vfs.h>
75
76#include <gnu/fs/ext2fs/ext2_mount.h>
77#include <gnu/fs/ext2fs/inode.h>
78
79#include <gnu/fs/ext2fs/fs.h>
80#include <gnu/fs/ext2fs/ext2_extern.h>
37 */
38
39/*-
40 * COPYRIGHT.INFO says this has some GPL'd code from ext2_super.c in it
41 *
42 * This program is free software; you can redistribute it and/or modify
43 * it under the terms of the GNU General Public License as published by
44 * the Free Software Foundation; either version 2 of the License.

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

73#include <geom/geom.h>
74#include <geom/geom_vfs.h>
75
76#include <gnu/fs/ext2fs/ext2_mount.h>
77#include <gnu/fs/ext2fs/inode.h>
78
79#include <gnu/fs/ext2fs/fs.h>
80#include <gnu/fs/ext2fs/ext2_extern.h>
81#include <gnu/fs/ext2fs/ext2_fs.h>
82#include <gnu/fs/ext2fs/ext2_fs_sb.h>
81#include <gnu/fs/ext2fs/ext2_fs_sb.h>
82#include <gnu/fs/ext2fs/ext2_fs.h>
83
84static int ext2_flushfiles(struct mount *mp, int flags, struct thread *td);
85static int ext2_mountfs(struct vnode *, struct mount *);
86static int ext2_reload(struct mount *mp, struct thread *td);
87static int ext2_sbupdate(struct ext2mount *, int);
88
89static vfs_unmount_t ext2_unmount;
90static vfs_root_t ext2_root;

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

407 fs->s_blocksize = EXT2_MIN_BLOCK_SIZE << es->s_log_block_size;
408 V(s_blocksize)
409 fs->s_bshift = EXT2_MIN_BLOCK_LOG_SIZE + es->s_log_block_size;
410 V(s_bshift)
411 fs->s_fsbtodb = es->s_log_block_size + 1;
412 V(s_fsbtodb)
413 fs->s_qbmask = fs->s_blocksize - 1;
414 V(s_qbmask)
83
84static int ext2_flushfiles(struct mount *mp, int flags, struct thread *td);
85static int ext2_mountfs(struct vnode *, struct mount *);
86static int ext2_reload(struct mount *mp, struct thread *td);
87static int ext2_sbupdate(struct ext2mount *, int);
88
89static vfs_unmount_t ext2_unmount;
90static vfs_root_t ext2_root;

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

407 fs->s_blocksize = EXT2_MIN_BLOCK_SIZE << es->s_log_block_size;
408 V(s_blocksize)
409 fs->s_bshift = EXT2_MIN_BLOCK_LOG_SIZE + es->s_log_block_size;
410 V(s_bshift)
411 fs->s_fsbtodb = es->s_log_block_size + 1;
412 V(s_fsbtodb)
413 fs->s_qbmask = fs->s_blocksize - 1;
414 V(s_qbmask)
415 fs->s_blocksize_bits = EXT2_BLOCK_SIZE_BITS(es);
415 fs->s_blocksize_bits = es->s_log_block_size + 10;
416 V(s_blocksize_bits)
417 fs->s_frag_size = EXT2_MIN_FRAG_SIZE << es->s_log_frag_size;
418 V(s_frag_size)
419 if (fs->s_frag_size)
420 fs->s_frags_per_block = fs->s_blocksize / fs->s_frag_size;
421 V(s_frags_per_block)
422 fs->s_blocks_per_group = es->s_blocks_per_group;
423 V(s_blocks_per_group)
424 fs->s_frags_per_group = es->s_frags_per_group;
425 V(s_frags_per_group)
426 fs->s_inodes_per_group = es->s_inodes_per_group;
427 V(s_inodes_per_group)
416 V(s_blocksize_bits)
417 fs->s_frag_size = EXT2_MIN_FRAG_SIZE << es->s_log_frag_size;
418 V(s_frag_size)
419 if (fs->s_frag_size)
420 fs->s_frags_per_block = fs->s_blocksize / fs->s_frag_size;
421 V(s_frags_per_block)
422 fs->s_blocks_per_group = es->s_blocks_per_group;
423 V(s_blocks_per_group)
424 fs->s_frags_per_group = es->s_frags_per_group;
425 V(s_frags_per_group)
426 fs->s_inodes_per_group = es->s_inodes_per_group;
427 V(s_inodes_per_group)
428 fs->s_inode_size = es->s_inode_size;
429 V(s_inode_size)
430 fs->s_first_inode = es->s_first_ino;
431 V(s_first_inode);
428 if (es->s_rev_level == EXT2_GOOD_OLD_REV) {
429 fs->s_first_ino = EXT2_GOOD_OLD_FIRST_INO;
430 fs->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
431 } else {
432 fs->s_first_ino = es->s_first_ino;
433 fs->s_inode_size = es->s_inode_size;
434
435 /*
436 * Simple sanity check for superblock inode size value.
437 */
438 if (fs->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE ||
439 fs->s_inode_size > fs->s_blocksize ||
440 (fs->s_inode_size & (fs->s_inode_size - 1)) != 0) {
441 printf("EXT2-fs: invalid inode size %d\n", fs->s_inode_size);
442 return (EIO);
443 }
444 }
432 fs->s_inodes_per_block = fs->s_blocksize / EXT2_INODE_SIZE(fs);
433 V(s_inodes_per_block)
434 fs->s_itb_per_group = fs->s_inodes_per_group /fs->s_inodes_per_block;
435 V(s_itb_per_group)
436 fs->s_desc_per_block = fs->s_blocksize / sizeof (struct ext2_group_desc);
437 V(s_desc_per_block)
438 /* s_resuid / s_resgid ? */
439 fs->s_groups_count = (es->s_blocks_count -
440 es->s_first_data_block +
441 EXT2_BLOCKS_PER_GROUP(fs) - 1) /
442 EXT2_BLOCKS_PER_GROUP(fs);
443 V(s_groups_count)
444 db_count = (fs->s_groups_count + EXT2_DESC_PER_BLOCK(fs) - 1) /
445 EXT2_DESC_PER_BLOCK(fs);
445 fs->s_inodes_per_block = fs->s_blocksize / EXT2_INODE_SIZE(fs);
446 V(s_inodes_per_block)
447 fs->s_itb_per_group = fs->s_inodes_per_group /fs->s_inodes_per_block;
448 V(s_itb_per_group)
449 fs->s_desc_per_block = fs->s_blocksize / sizeof (struct ext2_group_desc);
450 V(s_desc_per_block)
451 /* s_resuid / s_resgid ? */
452 fs->s_groups_count = (es->s_blocks_count -
453 es->s_first_data_block +
454 EXT2_BLOCKS_PER_GROUP(fs) - 1) /
455 EXT2_BLOCKS_PER_GROUP(fs);
456 V(s_groups_count)
457 db_count = (fs->s_groups_count + EXT2_DESC_PER_BLOCK(fs) - 1) /
458 EXT2_DESC_PER_BLOCK(fs);
446 fs->s_db_per_group = db_count;
447 V(s_db_per_group)
459 fs->s_gdb_count = db_count;
460 V(s_gdb_count)
448
449 fs->s_group_desc = bsd_malloc(db_count * sizeof (struct buf *),
450 M_EXT2MNT, M_WAITOK);
451
452 /* adjust logic_sb_block */
453 if(fs->s_blocksize > SBSIZE)
454 /* Godmar thinks: if the blocksize is greater than 1024, then
455 the superblock is logically part of block zero.

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

756 ronly = fs->s_rd_only;
757 if (ronly == 0) {
758 if (fs->s_wasvalid)
759 fs->s_es->s_state |= EXT2_VALID_FS;
760 ext2_sbupdate(ump, MNT_WAIT);
761 }
762
763 /* release buffers containing group descriptors */
461
462 fs->s_group_desc = bsd_malloc(db_count * sizeof (struct buf *),
463 M_EXT2MNT, M_WAITOK);
464
465 /* adjust logic_sb_block */
466 if(fs->s_blocksize > SBSIZE)
467 /* Godmar thinks: if the blocksize is greater than 1024, then
468 the superblock is logically part of block zero.

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

769 ronly = fs->s_rd_only;
770 if (ronly == 0) {
771 if (fs->s_wasvalid)
772 fs->s_es->s_state |= EXT2_VALID_FS;
773 ext2_sbupdate(ump, MNT_WAIT);
774 }
775
776 /* release buffers containing group descriptors */
764 for(i = 0; i < fs->s_db_per_group; i++)
777 for(i = 0; i < fs->s_gdb_count; i++)
765 ULCK_BUF(fs->s_group_desc[i])
766 bsd_free(fs->s_group_desc, M_EXT2MNT);
767
768 /* release cached inode/block bitmaps */
769 for (i = 0; i < EXT2_MAX_GROUP_LOADED; i++)
770 if (fs->s_inode_bitmap[i])
771 ULCK_BUF(fs->s_inode_bitmap[i])
772

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

834 nsb = 0;
835 for (i = 0 ; i < fs->s_groups_count; i++)
836 if (ext2_group_sparse(i))
837 nsb++;
838 } else
839 nsb = fs->s_groups_count;
840 overhead = es->s_first_data_block +
841 /* Superblocks and block group descriptors: */
778 ULCK_BUF(fs->s_group_desc[i])
779 bsd_free(fs->s_group_desc, M_EXT2MNT);
780
781 /* release cached inode/block bitmaps */
782 for (i = 0; i < EXT2_MAX_GROUP_LOADED; i++)
783 if (fs->s_inode_bitmap[i])
784 ULCK_BUF(fs->s_inode_bitmap[i])
785

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

847 nsb = 0;
848 for (i = 0 ; i < fs->s_groups_count; i++)
849 if (ext2_group_sparse(i))
850 nsb++;
851 } else
852 nsb = fs->s_groups_count;
853 overhead = es->s_first_data_block +
854 /* Superblocks and block group descriptors: */
842 nsb * (1 + fs->s_db_per_group) +
855 nsb * (1 + fs->s_gdb_count) +
843 /* Inode bitmap, block bitmap, and inode table: */
844 fs->s_groups_count * (1 + 1 + fs->s_itb_per_group);
845
846 sbp->f_bsize = EXT2_FRAG_SIZE(fs);
847 sbp->f_iosize = EXT2_BLOCK_SIZE(fs);
848 sbp->f_blocks = es->s_blocks_count - overhead;
849 sbp->f_bfree = es->s_free_blocks_count;
850 sbp->f_bavail = sbp->f_bfree - es->s_r_blocks_count;

--- 309 unchanged lines hidden ---
856 /* Inode bitmap, block bitmap, and inode table: */
857 fs->s_groups_count * (1 + 1 + fs->s_itb_per_group);
858
859 sbp->f_bsize = EXT2_FRAG_SIZE(fs);
860 sbp->f_iosize = EXT2_BLOCK_SIZE(fs);
861 sbp->f_blocks = es->s_blocks_count - overhead;
862 sbp->f_bfree = es->s_free_blocks_count;
863 sbp->f_bavail = sbp->f_bfree - es->s_r_blocks_count;

--- 309 unchanged lines hidden ---