require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_PUFFS_H_)) {
    eval 'sub _PUFFS_H_ () {1;}' unless defined(&_PUFFS_H_);
    require 'sys/param.ph';
    require 'sys/types.ph';
    require 'sys/mount.ph';
    require 'sys/namei.ph';
    require 'sys/stat.ph';
    require 'sys/statvfs.ph';
    require 'sys/time.ph';
    require 'sys/vnode.ph';
    require 'fs/puffs/puffs_msgif.ph';
    require 'mntopts.ph';
    require 'stdbool.ph';
    require 'string.ph';
    eval 'sub PUFFS_NODE_REMOVED () {0x1;}' unless defined(&PUFFS_NODE_REMOVED);
    eval 'sub PUFFS_VNOVAL () {(-1);}' unless defined(&PUFFS_VNOVAL);
    eval 'sub PUFFS_IO_APPEND () {0x20;}' unless defined(&PUFFS_IO_APPEND);
    eval 'sub PUFFS_IO_NDELAY () {0x100;}' unless defined(&PUFFS_IO_NDELAY);
    eval 'sub PUFFS_VEXEC () {01;}' unless defined(&PUFFS_VEXEC);
    eval 'sub PUFFS_VWRITE () {02;}' unless defined(&PUFFS_VWRITE);
    eval 'sub PUFFS_VREAD () {04;}' unless defined(&PUFFS_VREAD);
    eval 'sub PUFFS_FSYNC_DATAONLY () {0x2;}' unless defined(&PUFFS_FSYNC_DATAONLY);
    eval 'sub PUFFS_FSYNC_CACHE () {0x100;}' unless defined(&PUFFS_FSYNC_CACHE);
    eval 'sub PUFFS_SETATTR_FAF () {0x1;}' unless defined(&PUFFS_SETATTR_FAF);
    eval 'sub PUFFS_WRITE_FAF () {0x1;}' unless defined(&PUFFS_WRITE_FAF);
    eval 'sub PUFFS_EXTATTR_LIST_LENPREFIX () {1;}' unless defined(&PUFFS_EXTATTR_LIST_LENPREFIX);
    eval 'sub PUFFS_CC_STACKSHIFT_DEFAULT () {18;}' unless defined(&PUFFS_CC_STACKSHIFT_DEFAULT);
    eval 'sub pcn_nameiop () { ($pcn_pkcnp->{pkcn_nameiop});}' unless defined(&pcn_nameiop);
    eval 'sub pcn_flags () { ($pcn_pkcnp->{pkcn_flags});}' unless defined(&pcn_flags);
    eval 'sub pcn_name () { ($pcn_pkcnp->{pkcn_name});}' unless defined(&pcn_name);
    eval 'sub pcn_namelen () { ($pcn_pkcnp->{pkcn_namelen});}' unless defined(&pcn_namelen);
    eval 'sub pcn_consume () { ($pcn_pkcnp->{pkcn_consume});}' unless defined(&pcn_consume);
    eval 'sub PUFFSMOPT_NAMECACHE () {{ "namecache", 1,  &PUFFS_KFLAG_NOCACHE_NAME, 1};}' unless defined(&PUFFSMOPT_NAMECACHE);
    eval 'sub PUFFSMOPT_PAGECACHE () {{ "pagecache", 1,  &PUFFS_KFLAG_NOCACHE_PAGE, 1};}' unless defined(&PUFFSMOPT_PAGECACHE);
    eval 'sub PUFFSMOPT_ATTRCACHE () {{ "attrcache", 1,  &PUFFS_KFLAG_NOCACHE_ATTR, 1};}' unless defined(&PUFFSMOPT_ATTRCACHE);
    eval 'sub PUFFSMOPT_CACHE () {{ "cache", 1,  &PUFFS_KFLAG_NOCACHE, 1};}' unless defined(&PUFFSMOPT_CACHE);
    eval 'sub PUFFSMOPT_ALLOPS () {{ "allops", 0,  &PUFFS_KFLAG_ALLOPS, 1};}' unless defined(&PUFFSMOPT_ALLOPS);
    eval 'sub PUFFSMOPT_DUMP () {{ "dump", 0,  &PUFFS_FLAG_OPDUMP, 1};}' unless defined(&PUFFSMOPT_DUMP);
    eval 'sub PUFFSMOPT_STD () { &PUFFSMOPT_NAMECACHE,  &PUFFSMOPT_PAGECACHE,  &PUFFSMOPT_ATTRCACHE,  &PUFFSMOPT_CACHE,  &PUFFSMOPT_ALLOPS,  &PUFFSMOPT_DUMP;}' unless defined(&PUFFSMOPT_STD);
    eval("sub PUFFS_STATE_BEFOREMOUNT () { 0; }") unless defined(&PUFFS_STATE_BEFOREMOUNT);
    eval("sub PUFFS_STATE_RUNNING () { 1; }") unless defined(&PUFFS_STATE_RUNNING);
    eval("sub PUFFS_STATE_UNMOUNTING () { 2; }") unless defined(&PUFFS_STATE_UNMOUNTING);
    eval("sub PUFFS_STATE_UNMOUNTED () { 3; }") unless defined(&PUFFS_STATE_UNMOUNTED);
    eval 'sub PUFFS_FLAG_BUILDPATH () {0x80000000;}' unless defined(&PUFFS_FLAG_BUILDPATH);
    eval 'sub PUFFS_FLAG_OPDUMP () {0x40000000;}' unless defined(&PUFFS_FLAG_OPDUMP);
    eval 'sub PUFFS_FLAG_HASHPATH () {0x20000000;}' unless defined(&PUFFS_FLAG_HASHPATH);
    eval 'sub PUFFS_FLAG_PNCOOKIE () {0x10000000;}' unless defined(&PUFFS_FLAG_PNCOOKIE);
    eval 'sub PUFFS_FLAG_MASK () {0xf0000000;}' unless defined(&PUFFS_FLAG_MASK);
    eval 'sub PUFFS_FLAG_KERN {
        my($a) = @_;
	    eval q((($a) &  &PUFFS_KFLAG_MASK));
    }' unless defined(&PUFFS_FLAG_KERN);
    eval 'sub PUFFS_FLAG_LIB {
        my($a) = @_;
	    eval q((($a) &  &PUFFS_FLAG_MASK));
    }' unless defined(&PUFFS_FLAG_LIB);
    eval 'sub PUFFSDEV_BLOCK () {0;}' unless defined(&PUFFSDEV_BLOCK);
    eval 'sub PUFFSDEV_NONBLOCK () {1;}' unless defined(&PUFFSDEV_NONBLOCK);
    eval 'sub PUFFS_STACKSIZE_DEFAULT () {(1<< &PUFFS_CC_STACKSHIFT_DEFAULT);}' unless defined(&PUFFS_STACKSIZE_DEFAULT);
    eval 'sub PUFFS_STACKSIZE_MIN () {(-1);}' unless defined(&PUFFS_STACKSIZE_MIN);
    eval 'sub DENT_DOT () {0;}' unless defined(&DENT_DOT);
    eval 'sub DENT_DOTDOT () {1;}' unless defined(&DENT_DOTDOT);
    eval 'sub DENT_ADJ {
        my($a) = @_;
	    eval q((($a)-2));
    }' unless defined(&DENT_ADJ);
    eval 'sub PUFFSOP_PROTOS {
        my($fsname) = @_;
	    eval q(\'int\' $fsname &_fs_unmount(\'struct puffs_usermount\' *, \'int\'); \'int\' $fsname &_fs_statvfs(\'struct puffs_usermount\' *, \'struct puffs_statvfs\' *); \'int\' $fsname &_fs_sync(\'struct puffs_usermount\' *, \'int\',  &const \'struct puffs_cred\' * &cred); \'int\' $fsname &_fs_fhtonode(\'struct puffs_usermount\' *,  &void *, \'size_t\', \'struct puffs_newinfo\' *); \'int\' $fsname &_fs_nodetofh(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &void *, \'size_t\' *); \'int\' $fsname &_fs_extattrctl(\'struct puffs_usermount\' *, \'int\',  &puffs_cookie_t, \'int\', \'int\',  &const \'char\' *); \'int\' $fsname &_node_lookup(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'struct puffs_newinfo\' *,  &const \'struct puffs_cn\' *); \'int\' $fsname &_node_create(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'struct puffs_newinfo\' *,  &const \'struct puffs_cn\' *,  &const \'struct vattr\' *); \'int\' $fsname &_node_mknod(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'struct puffs_newinfo\' *,  &const \'struct puffs_cn\' *,  &const \'struct vattr\' *); \'int\' $fsname &_node_open(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'int\',  &const \'struct puffs_cred\' *); \'int\' $fsname &_node_close(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'int\',  &const \'struct puffs_cred\' *); \'int\' $fsname &_node_access(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'int\',  &const \'struct puffs_cred\' *); \'int\' $fsname &_node_getattr(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'struct vattr\' *,  &const \'struct puffs_cred\' *); \'int\' $fsname &_node_setattr(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &const \'struct vattr\' *,  &const \'struct puffs_cred\' *); \'int\' $fsname &_node_poll(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'int\' *); \'int\' $fsname &_node_mmap(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &vm_prot_t,  &const \'struct puffs_cred\' *); \'int\' $fsname &_node_fsync(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &const \'struct puffs_cred\' *, \'int\',  &off_t,  &off_t); \'int\' $fsname &_node_seek(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &off_t,  &off_t,  &const \'struct puffs_cred\' *); \'int\' $fsname &_node_remove(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &puffs_cookie_t,  &const \'struct puffs_cn\' *); \'int\' $fsname &_node_link(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &puffs_cookie_t,  &const \'struct puffs_cn\' *); \'int\' $fsname &_node_rename(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &puffs_cookie_t,  &const \'struct puffs_cn\' *,  &puffs_cookie_t,  &puffs_cookie_t,  &const \'struct puffs_cn\' *); \'int\' $fsname &_node_mkdir(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'struct puffs_newinfo\' *,  &const \'struct puffs_cn\' *,  &const \'struct vattr\' *); \'int\' $fsname &_node_rmdir(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &puffs_cookie_t,  &const \'struct puffs_cn\' *); \'int\' $fsname &_node_symlink(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'struct puffs_newinfo\' *,  &const \'struct puffs_cn\' *,  &const \'struct vattr\' *,  &const \'char\' *); \'int\' $fsname &_node_readdir(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'struct dirent\' *,  &off_t *, \'size_t\' *,  &const \'struct puffs_cred\' *, \'int\' *,  &off_t *, \'size_t\' *); \'int\' $fsname &_node_readlink(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &const \'struct puffs_cred\' *, \'char\' *, \'size_t\' *); \'int\' $fsname &_node_reclaim(\'struct puffs_usermount\' *,  &puffs_cookie_t); \'int\' $fsname &_node_inactive(\'struct puffs_usermount\' *,  &puffs_cookie_t); \'int\' $fsname &_node_print(\'struct puffs_usermount\' *,  &puffs_cookie_t); \'int\' $fsname &_node_pathconf(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'int\',  &__register_t *); \'int\' $fsname &_node_advlock(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &void *, \'int\', \'struct flock\' *, \'int\'); \'int\' $fsname &_node_read(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &uint8_t *,  &off_t, \'size_t\' *,  &const \'struct puffs_cred\' *, \'int\'); \'int\' $fsname &_node_write(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &uint8_t *,  &off_t, \'size_t\' *,  &const \'struct puffs_cred\' *, \'int\'); \'int\' $fsname &_node_abortop(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &const \'struct puffs_cn\' *); \'int\' $fsname &_node_getextattr(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'int\',  &const \'char\' *, \'size_t\' *,  &uint8_t *, \'size_t\' *,  &const \'struct puffs_cred\' *); \'int\' $fsname &_node_setextattr(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'int\',  &const \'char\' *,  &uint8_t *, \'size_t\' *,  &const \'struct puffs_cred\' *); \'int\' $fsname &_node_listextattr(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'int\', \'size_t\' *,  &uint8_t *, \'size_t\' *, \'int\',  &const \'struct puffs_cred\' *); \'int\' $fsname &_node_deleteextattr(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'int\',  &const \'char\' *,  &const \'struct puffs_cred\' *); \'int\' $fsname &_node_getattr_ttl(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'struct vattr\' *,  &const \'struct puffs_cred\' *, \'struct timespec\' *); \'int\' $fsname &_node_setattr_ttl(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'struct vattr\' *,  &const \'struct puffs_cred\' *, \'struct timespec\' *, \'int\'); \'int\' $fsname &_node_write2(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &uint8_t *,  &off_t, \'size_t\' *,  &const \'struct puffs_cred\' *, \'int\', \'int\'); \'int\' $fsname &_node_reclaim2(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'int\'); \'int\' $fsname &_node_open2(\'struct puffs_usermount\' *,  &puffs_cookie_t, \'int\',  &const \'struct puffs_cred\' *, \'int\' *); \'int\' $fsname &_node_fallocate(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &off_t,  &off_t); \'int\' $fsname &_node_fdiscard(\'struct puffs_usermount\' *,  &puffs_cookie_t,  &off_t,  &off_t););
    }' unless defined(&PUFFSOP_PROTOS);
    eval 'sub PUFFSOP_INIT {
        my($ops) = @_;
	    eval q($ops =  &malloc($sizeof{\'struct puffs_ops\'});  &memset($ops, 0, $sizeof{\'struct puffs_ops\'}));
    }' unless defined(&PUFFSOP_INIT);
    eval 'sub PUFFSOP_SET {
        my($ops, $fsname, $fsornode, $opname) = @_;
	    eval q(($ops)-> &puffs_$fsornode &_$opname = $fsname &_$fsornode &_$opname);
    }' unless defined(&PUFFSOP_SET);
    eval 'sub PUFFSOP_SETFSNOP {
        my($ops, $opname) = @_;
	    eval q(($ops)-> &puffs_fs_$opname =  &puffs_fsnop_$opname);
    }' unless defined(&PUFFSOP_SETFSNOP);
    eval 'sub PNPATH {
        my($pnode) = @_;
	    eval q((($pnode)-> ($pn_po->{po_path})));
    }' unless defined(&PNPATH);
    eval 'sub PNPLEN {
        my($pnode) = @_;
	    eval q((($pnode)-> ($pn_po->{po_len})));
    }' unless defined(&PNPLEN);
    eval 'sub PCNPATH {
        my($pcnode) = @_;
	    eval q((($pcnode)-> ($pcn_po_full->{po_path})));
    }' unless defined(&PCNPATH);
    eval 'sub PCNPLEN {
        my($pcnode) = @_;
	    eval q((($pcnode)-> ($pcn_po_full->{po_len})));
    }' unless defined(&PCNPLEN);
    eval 'sub PCNISDOTDOT {
        my($pcnode) = @_;
	    eval q((($pcnode)-> &pcn_namelen == 2 &&  &strcmp(($pcnode)-> &pcn_name, \\"..\\") == 0));
    }' unless defined(&PCNISDOTDOT);
    eval 'sub PUFFS_STORE_DCOOKIE {
        my($cp, $ncp, $off) = @_;
	    eval q( &if ($cp) { *(($cp)++) = $off; (*($ncp))++; });
    }' unless defined(&PUFFS_STORE_DCOOKIE);
    eval 'sub PUFFS_FBIO_READ () {0x1;}' unless defined(&PUFFS_FBIO_READ);
    eval 'sub PUFFS_FBIO_WRITE () {0x2;}' unless defined(&PUFFS_FBIO_WRITE);
    eval 'sub PUFFS_FBIO_ERROR () {0x4;}' unless defined(&PUFFS_FBIO_ERROR);
    eval 'sub PUFFS_FBQUEUE_URGENT () {0x1;}' unless defined(&PUFFS_FBQUEUE_URGENT);
    eval 'sub PUFFS_DEFER () {(( &void *)-1);}' unless defined(&PUFFS_DEFER);
}
1;
