require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_UFS_UFS_UFSMOUNT_H_)) {
    eval 'sub _UFS_UFS_UFSMOUNT_H_ () {1;}' unless defined(&_UFS_UFS_UFSMOUNT_H_);
    require 'sys/mount.ph';
    if(defined(&_KERNEL)) {
	if(defined(&_KERNEL_OPT)) {
	    require './ufs/ufs/opt_ffs.ph';
	}
	require 'sys/mutex.ph';
	require 'ufs/ufs/extattr.ph';
	require 'ufs/ufs/quota.ph';
	eval 'sub um_fs () { ($ufsmount_u->{fs});}' unless defined(&um_fs);
	eval 'sub um_lfs () { ($ufsmount_u->{lfs});}' unless defined(&um_lfs);
	eval 'sub um_e2fs () { ($ufsmount_u->{e2fs});}' unless defined(&um_e2fs);
	eval 'sub um_e2fsb () { ($ufsmount_u->{e2fs}->{s_es});}' unless defined(&um_e2fsb);
	eval 'sub um_chfs () { ($ufsmount_u->{chfs});}' unless defined(&um_chfs);
	eval 'sub umq1_btime () { ($um_q->{um_q1}->{q1_btime});}' unless defined(&umq1_btime);
	eval 'sub umq1_itime () { ($um_q->{um_q1}->{q1_itime});}' unless defined(&umq1_itime);
	eval 'sub umq1_qflags () { ($um_q->{um_q1}->{q1_qflags});}' unless defined(&umq1_qflags);
	eval 'sub umq2_bsize () { ($um_q->{um_q2}->{q2_bsize});}' unless defined(&umq2_bsize);
	eval 'sub umq2_bmask () { ($um_q->{um_q2}->{q2_bmask});}' unless defined(&umq2_bmask);
	eval 'sub UFS_OPS {
	    my($vp) = @_;
    	    eval q(( &VFSTOUFS(($vp)-> &v_mount)-> &um_ops));
	}' unless defined(&UFS_OPS);
	eval 'sub UFS_ITIMES {
	    my($vp, $acc, $mod, $cre) = @_;
    	    eval q((* &UFS_OPS($vp)-> &uo_itimes)( &VTOI($vp), ($acc), ($mod), ($cre)));
	}' unless defined(&UFS_ITIMES);
	eval 'sub UFS_UPDATE {
	    my($vp, $acc, $mod, $flags) = @_;
    	    eval q((* &UFS_OPS($vp)-> &uo_update)(($vp), ($acc), ($mod), ($flags)));
	}' unless defined(&UFS_UPDATE);
	eval 'sub UFS_TRUNCATE {
	    my($vp, $off, $flags, $cr) = @_;
    	    eval q((* &UFS_OPS($vp)-> &uo_truncate)(($vp), ($off), ($flags), ($cr)));
	}' unless defined(&UFS_TRUNCATE);
	eval 'sub UFS_BALLOC {
	    my($vp, $off, $size, $cr, $flags, $bpp) = @_;
    	    eval q((* &UFS_OPS($vp)-> &uo_balloc)(($vp), ($off), ($size), ($cr), ($flags), ($bpp)));
	}' unless defined(&UFS_BALLOC);
	eval 'sub UFS_SNAPGONE {
	    my($vp) = @_;
    	    eval q((* &UFS_OPS($vp)-> &uo_snapgone)(($vp)));
	}' unless defined(&UFS_SNAPGONE);
	eval 'sub UFS_BUFRD {
	    my($vp, $uio, $ioflag, $cred) = @_;
    	    eval q((* &UFS_OPS($vp)-> &uo_bufrd)(($vp), ($uio), ($ioflag), ($cred)));
	}' unless defined(&UFS_BUFRD);
	eval 'sub UFS_BUFWR {
	    my($vp, $uio, $ioflag, $cred) = @_;
    	    eval q((* &UFS_OPS($vp)-> &uo_bufwr)(($vp), ($uio), ($ioflag), ($cred)));
	}' unless defined(&UFS_BUFWR);
	eval 'sub UFS_NEEDSWAP () {0x1;}' unless defined(&UFS_NEEDSWAP);
	eval 'sub UFS_ISAPPLEUFS () {0x2;}' unless defined(&UFS_ISAPPLEUFS);
	eval 'sub UFS_QUOTA () {0x4;}' unless defined(&UFS_QUOTA);
	eval 'sub UFS_QUOTA2 () {0x8;}' unless defined(&UFS_QUOTA2);
	eval 'sub UFS_EA () {0x10;}' unless defined(&UFS_EA);
	eval 'sub UFS1 () {1;}' unless defined(&UFS1);
	eval 'sub UFS2 () {2;}' unless defined(&UFS2);
	eval 'sub QTF_OPENING () {0x1;}' unless defined(&QTF_OPENING);
	eval 'sub QTF_CLOSING () {0x2;}' unless defined(&QTF_CLOSING);
	eval 'sub VFSTOUFS {
	    my($mp) = @_;
    	    eval q(((($mp)-> &mnt_data)));
	}' unless defined(&VFSTOUFS);
	if(defined(&APPLE_UFS)) {
	    eval 'sub UFS_MPISAPPLEUFS {
	        my($ump) = @_;
    		eval q((($ump)-> &um_flags &  &UFS_ISAPPLEUFS));
	    }' unless defined(&UFS_MPISAPPLEUFS);
	} else {
	    eval 'sub UFS_MPISAPPLEUFS {
	        my($ump) = @_;
    		eval q((0));
	    }' unless defined(&UFS_MPISAPPLEUFS);
	}
	eval 'sub MNINDIR {
	    my($ump) = @_;
    	    eval q((($ump)-> &um_nindir));
	}' unless defined(&MNINDIR);
	eval 'sub blkptrtodb {
	    my($ump, $b) = @_;
    	    eval q((($b) << ($ump)-> &um_bptrtodb));
	}' unless defined(&blkptrtodb);
	eval 'sub FSFMT {
	    my($vp) = @_;
    	    eval q(((($vp)-> ($v_mount->{mnt_iflag}) &  &IMNT_DTYPE) == 0));
	}' unless defined(&FSFMT);
    }
}
1;
