require '_h2ph_pre.ph';

no warnings 'redefine';

require 'sys/buf.ph';
require 'sys/lock.ph';
require 'ufs/ufs/dinode.ph';
require 'ufs/ufs/dir.ph';
require 'ufs/ext2fs/ext2fs_dinode.ph';
unless(defined(&i_fs)) {
    sub i_fs () {	 ($inode_u->{fs});}
}
unless(defined(&i_e2fs)) {
    sub i_e2fs () {	 ($inode_u->{e2fs});}
}
unless(defined(&i_e2fs_last_lblk)) {
    sub i_e2fs_last_lblk () {	 ($inode_ext->{e2fs}->{ext2fs_last_lblk});}
}
unless(defined(&i_e2fs_last_blk)) {
    sub i_e2fs_last_blk () {	 ($inode_ext->{e2fs}->{ext2fs_last_blk});}
}
unless(defined(&i_e2fs_uid)) {
    sub i_e2fs_uid () {	 ($inode_ext->{e2fs}->{ext2fs_effective_uid});}
}
unless(defined(&i_e2fs_gid)) {
    sub i_e2fs_gid () {	 ($inode_ext->{e2fs}->{ext2fs_effective_gid});}
}
unless(defined(&i_dirhash)) {
    sub i_dirhash () {	 ($inode_ext->{dirhash});}
}
unless(defined(&i_din1)) {
    sub i_din1 () {	 ($dinode_u->{ffs1_din});}
}
unless(defined(&i_din2)) {
    sub i_din2 () {	 ($dinode_u->{ffs2_din});}
}
unless(defined(&i_e2din)) {
    sub i_e2din () {	 ($dinode_u->{e2fs_din});}
}
unless(defined(&UFS_TRUNCATE)) {
    sub UFS_TRUNCATE {
	my($ip, $off, $flags, $cred) = @_;
	eval q((($ip)-> ($i_vtbl->{iv_truncate}))(($ip), ($off), ($flags), ($cred)));
    }
}
unless(defined(&UFS_UPDATE)) {
    sub UFS_UPDATE {
	my($ip, $sync) = @_;
	eval q((($ip)-> ($i_vtbl->{iv_update}))(($ip),  &NULL,  &NULL, ($sync)));
    }
}
unless(defined(&UFS_UPDATE2)) {
    sub UFS_UPDATE2 {
	my($ip, $atime, $mtime, $sync) = @_;
	eval q((($ip)-> ($i_vtbl->{iv_update}))(($ip), ($atime), ($mtime), ($sync)));
    }
}
unless(defined(&UFS_INODE_ALLOC)) {
    sub UFS_INODE_ALLOC {
	my($pip, $mode, $cred, $vpp) = @_;
	eval q((($pip)-> ($i_vtbl->{iv_inode_alloc}))(($pip), ($mode), ($cred), ($vpp)));
    }
}
unless(defined(&UFS_INODE_FREE)) {
    sub UFS_INODE_FREE {
	my($pip, $ino, $mode) = @_;
	eval q((($pip)-> ($i_vtbl->{iv_inode_free}))(($pip), ($ino), ($mode)));
    }
}
unless(defined(&UFS_BUF_ALLOC)) {
    sub UFS_BUF_ALLOC {
	my($ip, $startoffset, $size, $cred, $flags, $bpp) = @_;
	eval q((($ip)-> ($i_vtbl->{iv_buf_alloc}))(($ip), ($startoffset), ($size), ($cred), ($flags), ($bpp)));
    }
}
unless(defined(&UFS_BUFATOFF)) {
    sub UFS_BUFATOFF {
	my($ip, $offset, $res, $bpp) = @_;
	eval q((($ip)-> ($i_vtbl->{iv_bufatoff}))(($ip), ($offset), ($res), ($bpp)));
    }
}
unless(defined(&i_ffs1_atime)) {
    sub i_ffs1_atime () {	 ($i_din1->{di_atime});}
}
unless(defined(&i_ffs1_atimensec)) {
    sub i_ffs1_atimensec () {	 ($i_din1->{di_atimensec});}
}
unless(defined(&i_ffs1_blocks)) {
    sub i_ffs1_blocks () {	 ($i_din1->{di_blocks});}
}
unless(defined(&i_ffs1_ctime)) {
    sub i_ffs1_ctime () {	 ($i_din1->{di_ctime});}
}
unless(defined(&i_ffs1_ctimensec)) {
    sub i_ffs1_ctimensec () {	 ($i_din1->{di_ctimensec});}
}
unless(defined(&i_ffs1_db)) {
    sub i_ffs1_db () {	 ($i_din1->{di_db});}
}
unless(defined(&i_ffs1_flags)) {
    sub i_ffs1_flags () {	 ($i_din1->{di_flags});}
}
unless(defined(&i_ffs1_gen)) {
    sub i_ffs1_gen () {	 ($i_din1->{di_gen});}
}
unless(defined(&i_ffs1_gid)) {
    sub i_ffs1_gid () {	 ($i_din1->{di_gid});}
}
unless(defined(&i_ffs1_ib)) {
    sub i_ffs1_ib () {	 ($i_din1->{di_ib});}
}
unless(defined(&i_ffs1_mode)) {
    sub i_ffs1_mode () {	 ($i_din1->{di_mode});}
}
unless(defined(&i_ffs1_mtime)) {
    sub i_ffs1_mtime () {	 ($i_din1->{di_mtime});}
}
unless(defined(&i_ffs1_mtimensec)) {
    sub i_ffs1_mtimensec () {	 ($i_din1->{di_mtimensec});}
}
unless(defined(&i_ffs1_nlink)) {
    sub i_ffs1_nlink () {	 ($i_din1->{di_nlink});}
}
unless(defined(&i_ffs1_rdev)) {
    sub i_ffs1_rdev () {	 ($i_din1->{di_rdev});}
}
unless(defined(&i_ffs1_shortlink)) {
    sub i_ffs1_shortlink () {	 ($i_din1->{di_shortlink});}
}
unless(defined(&i_ffs1_size)) {
    sub i_ffs1_size () {	 ($i_din1->{di_size});}
}
unless(defined(&i_ffs1_uid)) {
    sub i_ffs1_uid () {	 ($i_din1->{di_uid});}
}
unless(defined(&i_ffs2_atime)) {
    sub i_ffs2_atime () {	 ($i_din2->{di_atime});}
}
unless(defined(&i_ffs2_atimensec)) {
    sub i_ffs2_atimensec () {	 ($i_din2->{di_atimensec});}
}
unless(defined(&i_ffs2_blocks)) {
    sub i_ffs2_blocks () {	 ($i_din2->{di_blocks});}
}
unless(defined(&i_ffs2_blksize)) {
    sub i_ffs2_blksize () {	 ($i_din2->{di_blksize});}
}
unless(defined(&i_ffs2_ctime)) {
    sub i_ffs2_ctime () {	 ($i_din2->{di_ctime});}
}
unless(defined(&i_ffs2_ctimensec)) {
    sub i_ffs2_ctimensec () {	 ($i_din2->{di_ctimensec});}
}
unless(defined(&i_ffs2_db)) {
    sub i_ffs2_db () {	 ($i_din2->{di_db});}
}
unless(defined(&i_ffs2_flags)) {
    sub i_ffs2_flags () {	 ($i_din2->{di_flags});}
}
unless(defined(&i_ffs2_gen)) {
    sub i_ffs2_gen () {	 ($i_din2->{di_gen});}
}
unless(defined(&i_ffs2_gid)) {
    sub i_ffs2_gid () {	 ($i_din2->{di_gid});}
}
unless(defined(&i_ffs2_ib)) {
    sub i_ffs2_ib () {	 ($i_din2->{di_ib});}
}
unless(defined(&i_ffs2_mode)) {
    sub i_ffs2_mode () {	 ($i_din2->{di_mode});}
}
unless(defined(&i_ffs2_mtime)) {
    sub i_ffs2_mtime () {	 ($i_din2->{di_mtime});}
}
unless(defined(&i_ffs2_mtimensec)) {
    sub i_ffs2_mtimensec () {	 ($i_din2->{di_mtimensec});}
}
unless(defined(&i_ffs2_nlink)) {
    sub i_ffs2_nlink () {	 ($i_din2->{di_nlink});}
}
unless(defined(&i_ffs2_rdev)) {
    sub i_ffs2_rdev () {	 ($i_din2->{di_rdev});}
}
unless(defined(&i_ffs2_size)) {
    sub i_ffs2_size () {	 ($i_din2->{di_size});}
}
unless(defined(&i_ffs2_uid)) {
    sub i_ffs2_uid () {	 ($i_din2->{di_uid});}
}
unless(defined(&_KERNEL)) {
    eval 'sub i_atime () { ($i_din1->{di_atime});}' unless defined(&i_atime);
    eval 'sub i_atimensec () { ($i_din1->{di_atimensec});}' unless defined(&i_atimensec);
    eval 'sub i_blocks () { ($i_din1->{di_blocks});}' unless defined(&i_blocks);
    eval 'sub i_ctime () { ($i_din1->{di_ctime});}' unless defined(&i_ctime);
    eval 'sub i_ctimensec () { ($i_din1->{di_ctimensec});}' unless defined(&i_ctimensec);
    eval 'sub i_db () { ($i_din1->{di_db});}' unless defined(&i_db);
    eval 'sub i_flags () { ($i_din1->{di_flags});}' unless defined(&i_flags);
    eval 'sub i_gen () { ($i_din1->{di_gen});}' unless defined(&i_gen);
    eval 'sub i_gid () { ($i_din1->{di_gid});}' unless defined(&i_gid);
    eval 'sub i_ib () { ($i_din1->{di_ib});}' unless defined(&i_ib);
    eval 'sub i_mode () { ($i_din1->{di_mode});}' unless defined(&i_mode);
    eval 'sub i_mtime () { ($i_din1->{di_mtime});}' unless defined(&i_mtime);
    eval 'sub i_mtimensec () { ($i_din1->{di_mtimensec});}' unless defined(&i_mtimensec);
    eval 'sub i_nlink () { ($i_din1->{di_nlink});}' unless defined(&i_nlink);
    eval 'sub i_rdev () { ($i_din1->{di_rdev});}' unless defined(&i_rdev);
    eval 'sub i_shortlink () { ($i_din1->{di_shortlink});}' unless defined(&i_shortlink);
    eval 'sub i_size () { ($i_din1->{di_size});}' unless defined(&i_size);
    eval 'sub i_uid () { ($i_din1->{di_uid});}' unless defined(&i_uid);
}
unless(defined(&i_e2fs_mode)) {
    sub i_e2fs_mode () {	 ($i_e2din->{e2di_mode});}
}
unless(defined(&i_e2fs_size)) {
    sub i_e2fs_size () {	 ($i_e2din->{e2di_size});}
}
unless(defined(&i_e2fs_atime)) {
    sub i_e2fs_atime () {	 ($i_e2din->{e2di_atime});}
}
unless(defined(&i_e2fs_ctime)) {
    sub i_e2fs_ctime () {	 ($i_e2din->{e2di_ctime});}
}
unless(defined(&i_e2fs_mtime)) {
    sub i_e2fs_mtime () {	 ($i_e2din->{e2di_mtime});}
}
unless(defined(&i_e2fs_dtime)) {
    sub i_e2fs_dtime () {	 ($i_e2din->{e2di_dtime});}
}
unless(defined(&i_e2fs_nlink)) {
    sub i_e2fs_nlink () {	 ($i_e2din->{e2di_nlink});}
}
unless(defined(&i_e2fs_nblock)) {
    sub i_e2fs_nblock () {	 ($i_e2din->{e2di_nblock});}
}
unless(defined(&i_e2fs_flags)) {
    sub i_e2fs_flags () {	 ($i_e2din->{e2di_flags});}
}
unless(defined(&i_e2fs_blocks)) {
    sub i_e2fs_blocks () {	 ($i_e2din->{e2di_blocks});}
}
unless(defined(&i_e2fs_gen)) {
    sub i_e2fs_gen () {	 ($i_e2din->{e2di_gen});}
}
unless(defined(&i_e2fs_facl)) {
    sub i_e2fs_facl () {	 ($i_e2din->{e2di_facl});}
}
unless(defined(&i_e2fs_dacl)) {
    sub i_e2fs_dacl () {	 ($i_e2din->{e2di_dacl});}
}
unless(defined(&i_e2fs_faddr)) {
    sub i_e2fs_faddr () {	 ($i_e2din->{e2di_faddr});}
}
unless(defined(&i_e2fs_nfrag)) {
    sub i_e2fs_nfrag () {	 ($i_e2din->{e2di_nfrag});}
}
unless(defined(&i_e2fs_fsize)) {
    sub i_e2fs_fsize () {	 ($i_e2din->{e2di_fsize});}
}
unless(defined(&i_e2fs_uid_low)) {
    sub i_e2fs_uid_low () {	 ($i_e2din->{e2di_uid_low});}
}
unless(defined(&i_e2fs_gid_low)) {
    sub i_e2fs_gid_low () {	 ($i_e2din->{e2di_gid_low});}
}
unless(defined(&i_e2fs_uid_high)) {
    sub i_e2fs_uid_high () {	 ($i_e2din->{e2di_uid_high});}
}
unless(defined(&i_e2fs_gid_high)) {
    sub i_e2fs_gid_high () {	 ($i_e2din->{e2di_gid_high});}
}
unless(defined(&IN_ACCESS)) {
    sub IN_ACCESS () {	0x1;}
}
unless(defined(&IN_CHANGE)) {
    sub IN_CHANGE () {	0x2;}
}
unless(defined(&IN_UPDATE)) {
    sub IN_UPDATE () {	0x4;}
}
unless(defined(&IN_MODIFIED)) {
    sub IN_MODIFIED () {	0x8;}
}
unless(defined(&IN_RENAME)) {
    sub IN_RENAME () {	0x10;}
}
unless(defined(&IN_SHLOCK)) {
    sub IN_SHLOCK () {	0x20;}
}
unless(defined(&IN_EXLOCK)) {
    sub IN_EXLOCK () {	0x40;}
}
unless(defined(&i_devvp)) {
    sub i_devvp () {	 ($i_ump->{um_devvp});}
}
if(defined(&_KERNEL)) {
    eval 'sub DIP {
        my($ip, $field) = @_;
	    eval q(((($ip)-> ($i_ump->{um_fstype}) ==  &UM_UFS1) ? ($ip)-> &i_ffs1_$field : ($ip)-> &i_ffs2_$field));
    }' unless defined(&DIP);
    eval 'sub DIP_ASSIGN {
        my($ip, $field, $value) = @_;
	    eval q( &do {  &if (($ip)-> ($i_ump->{um_fstype}) ==  &UM_UFS1) ($ip)-> &i_ffs1_$field = ($value);  &else ($ip)-> &i_ffs2_$field = ($value); }  &while (0));
    }' unless defined(&DIP_ASSIGN);
    eval 'sub DIP_ADD {
        my($ip, $field, $value) = @_;
	    eval q( &do {  &if (($ip)-> ($i_ump->{um_fstype}) ==  &UM_UFS1) ($ip)-> &i_ffs1_$field += ($value);  &else ($ip)-> &i_ffs2_$field += ($value); }  &while (0));
    }' unless defined(&DIP_ADD);
    eval 'sub SHORTLINK {
        my($ip) = @_;
	    eval q(((-> ($i_ump->{um_fstype}) ==  &UM_UFS1) ? -> &i_ffs1_db : ($ip)-> &i_ffs2_db));
    }' unless defined(&SHORTLINK);
    eval 'sub VTOI {
        my($vp) = @_;
	    eval q((($vp)-> &v_data));
    }' unless defined(&VTOI);
    eval 'sub ITOV {
        my($ip) = @_;
	    eval q((($ip)-> &i_vnode));
    }' unless defined(&ITOV);
    eval 'sub FFS_ITIMES {
        my($ip, $t1, $t2) = @_;
	    eval q({  &if (($ip)-> &i_flag & ( &IN_ACCESS |  &IN_CHANGE |  &IN_UPDATE)) { ($ip)-> &i_flag |=  &IN_MODIFIED;  &if (($ip)-> &i_flag &  &IN_ACCESS)  &DIP_ASSIGN(($ip),  &atime, ($t1)-> &tv_sec);  &if (($ip)-> &i_flag &  &IN_UPDATE) {  &DIP_ASSIGN(($ip),  &mtime, ($t2)-> &tv_sec); ($ip)-> &i_modrev++; }  &if (($ip)-> &i_flag &  &IN_CHANGE)  &DIP_ASSIGN(($ip),  &ctime,  &time_second); ($ip)-> &i_flag &= ~( &IN_ACCESS |  &IN_CHANGE |  &IN_UPDATE); } });
    }' unless defined(&FFS_ITIMES);
    eval 'sub EXT2FS_ITIMES {
        my($ip, $t1, $t2) = @_;
	    eval q({  &if (($ip)-> &i_flag & ( &IN_ACCESS |  &IN_CHANGE |  &IN_UPDATE)) { ($ip)-> &i_flag |=  &IN_MODIFIED;  &if (($ip)-> &i_flag &  &IN_ACCESS) ($ip)-> &i_e2fs_atime = ($t1)-> &tv_sec;  &if (($ip)-> &i_flag &  &IN_UPDATE) { ($ip)-> &i_e2fs_mtime = ($t2)-> &tv_sec; ($ip)-> &i_modrev++; }  &if (($ip)-> &i_flag &  &IN_CHANGE) ($ip)-> &i_e2fs_ctime =  &time_second; ($ip)-> &i_flag &= ~( &IN_ACCESS |  &IN_CHANGE |  &IN_UPDATE); } });
    }' unless defined(&EXT2FS_ITIMES);
    eval 'sub ITIMES {
        my($ip, $t1, $t2) = @_;
	    eval q({  &if ( &IS_EXT2_VNODE(($ip)-> &i_vnode)) {  &EXT2FS_ITIMES($ip, $t1, $t2); }  &else {  &FFS_ITIMES($ip, $t1, $t2); } });
    }' unless defined(&ITIMES);
    if(defined(&FFS_SOFTUPDATES)) {
	eval 'sub DOINGSOFTDEP {
	    my($vp) = @_;
    	    eval q((($vp)-> ($v_mount->{mnt_flag}) &  &MNT_SOFTDEP));
	}' unless defined(&DOINGSOFTDEP);
    } else {
	eval 'sub DOINGSOFTDEP {
	    my($vp) = @_;
    	    eval q((0));
	}' unless defined(&DOINGSOFTDEP);
    }
    eval 'sub DOINGASYNC {
        my($vp) = @_;
	    eval q((($vp)-> ($v_mount->{mnt_flag}) &  &MNT_ASYNC));
    }' unless defined(&DOINGASYNC);
}
1;
