Home | History | Annotate | Line # | Download | only in libpuffs
dispatcher.c revision 1.11
      1  1.11  pooka /*	$NetBSD: dispatcher.c,v 1.11 2007/07/27 08:28:16 pooka Exp $	*/
      2   1.1  pooka 
      3   1.1  pooka /*
      4   1.2  pooka  * Copyright (c) 2006, 2007  Antti Kantee.  All Rights Reserved.
      5   1.1  pooka  *
      6   1.1  pooka  * Development of this software was supported by the
      7   1.2  pooka  * Ulla Tuominen Foundation.
      8   1.1  pooka  *
      9   1.1  pooka  * Redistribution and use in source and binary forms, with or without
     10   1.1  pooka  * modification, are permitted provided that the following conditions
     11   1.1  pooka  * are met:
     12   1.1  pooka  * 1. Redistributions of source code must retain the above copyright
     13   1.1  pooka  *    notice, this list of conditions and the following disclaimer.
     14   1.1  pooka  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1  pooka  *    notice, this list of conditions and the following disclaimer in the
     16   1.1  pooka  *    documentation and/or other materials provided with the distribution.
     17   1.1  pooka  *
     18   1.1  pooka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     19   1.1  pooka  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     20   1.1  pooka  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     21   1.1  pooka  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     22   1.1  pooka  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23   1.1  pooka  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     24   1.1  pooka  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25   1.1  pooka  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26   1.1  pooka  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27   1.1  pooka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28   1.1  pooka  * SUCH DAMAGE.
     29   1.1  pooka  */
     30   1.1  pooka 
     31   1.1  pooka #include <sys/cdefs.h>
     32   1.1  pooka #if !defined(lint)
     33  1.11  pooka __RCSID("$NetBSD: dispatcher.c,v 1.11 2007/07/27 08:28:16 pooka Exp $");
     34   1.1  pooka #endif /* !lint */
     35   1.1  pooka 
     36   1.1  pooka #include <sys/types.h>
     37   1.4  pooka #include <sys/poll.h>
     38   1.1  pooka 
     39   1.1  pooka #include <assert.h>
     40   1.1  pooka #include <errno.h>
     41   1.1  pooka #include <puffs.h>
     42   1.1  pooka #include <puffsdump.h>
     43   1.1  pooka #include <stdio.h>
     44   1.1  pooka #include <stdlib.h>
     45   1.1  pooka #include <unistd.h>
     46   1.1  pooka 
     47   1.1  pooka #include "puffs_priv.h"
     48   1.1  pooka 
     49   1.3  pooka static void processresult(struct puffs_cc *, struct puffs_putreq *, int);
     50   1.3  pooka 
     51   1.1  pooka /*
     52   1.1  pooka  * Set the following to 1 to not handle each request on a separate
     53   1.1  pooka  * stack.  This is highly volatile kludge, therefore no external
     54   1.1  pooka  * interface.
     55   1.1  pooka  */
     56   1.1  pooka int puffs_fakecc;
     57   1.1  pooka 
     58   1.3  pooka /* user-visible point to handle a request from */
     59   1.1  pooka int
     60   1.1  pooka puffs_dopreq(struct puffs_usermount *pu, struct puffs_req *preq,
     61   1.1  pooka 	struct puffs_putreq *ppr)
     62   1.1  pooka {
     63   1.1  pooka 	struct puffs_cc fakecc;
     64   1.1  pooka 	struct puffs_cc *pcc;
     65   1.1  pooka 
     66   1.1  pooka 	/*
     67   1.1  pooka 	 * XXX: the structure is currently a mess.  anyway, trap
     68   1.1  pooka 	 * the cacheops here already, since they don't need a cc.
     69   1.1  pooka 	 * I really should get around to revamping the operation
     70   1.1  pooka 	 * dispatching code one of these days.
     71   1.1  pooka 	 */
     72   1.1  pooka 	if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_CACHE) {
     73   1.1  pooka 		struct puffs_cacheinfo *pci = (void *)preq;
     74   1.1  pooka 
     75   1.1  pooka 		if (pu->pu_ops.puffs_cache_write == NULL)
     76   1.1  pooka 			return 0;
     77   1.1  pooka 
     78   1.1  pooka 		pu->pu_ops.puffs_cache_write(pu, preq->preq_cookie,
     79   1.1  pooka 		    pci->pcache_nruns, pci->pcache_runs);
     80   1.1  pooka 	}
     81   1.1  pooka 
     82   1.1  pooka 	if (pu->pu_flags & PUFFS_FLAG_OPDUMP)
     83   1.1  pooka 		puffsdump_req(preq);
     84   1.1  pooka 
     85   1.1  pooka 	if (puffs_fakecc) {
     86   1.1  pooka 		pcc = &fakecc;
     87   1.1  pooka 		pcc_init_local(pcc);
     88   1.1  pooka 
     89   1.1  pooka 		pcc->pcc_pu = pu;
     90   1.1  pooka 		pcc->pcc_preq = preq;
     91   1.1  pooka 		pcc->pcc_flags = PCC_FAKECC;
     92   1.1  pooka 	} else {
     93   1.1  pooka 		pcc = puffs_cc_create(pu);
     94   1.1  pooka 
     95   1.1  pooka 		/* XXX: temporary kludging */
     96   1.1  pooka 		pcc->pcc_preq = malloc(preq->preq_buflen);
     97   1.1  pooka 		if (pcc->pcc_preq == NULL)
     98   1.1  pooka 			return -1;
     99   1.1  pooka 		(void) memcpy(pcc->pcc_preq, preq, preq->preq_buflen);
    100   1.1  pooka 	}
    101   1.1  pooka 
    102   1.3  pooka 	puffs_docc(pcc, ppr);
    103   1.3  pooka 	return 0;
    104   1.1  pooka }
    105   1.1  pooka 
    106   1.1  pooka enum {PUFFCALL_ANSWER, PUFFCALL_IGNORE, PUFFCALL_AGAIN};
    107   1.1  pooka 
    108   1.3  pooka /* user-visible continuation point */
    109   1.3  pooka void
    110   1.1  pooka puffs_docc(struct puffs_cc *pcc, struct puffs_putreq *ppr)
    111   1.1  pooka {
    112   1.1  pooka 	struct puffs_usermount *pu = pcc->pcc_pu;
    113   1.3  pooka 	struct puffs_cc *pcc_iter;
    114   1.1  pooka 
    115   1.1  pooka 	assert((pcc->pcc_flags & PCC_DONE) == 0);
    116   1.3  pooka 	pcc->pcc_ppr = ppr;
    117   1.1  pooka 
    118   1.1  pooka 	if (pcc->pcc_flags & PCC_REALCC)
    119   1.1  pooka 		puffs_cc_continue(pcc);
    120   1.1  pooka 	else
    121   1.1  pooka 		puffs_calldispatcher(pcc);
    122   1.1  pooka 
    123   1.3  pooka 	/* can't do this above due to PCC_BORROWED */
    124   1.3  pooka 	while ((pcc_iter = LIST_FIRST(&pu->pu_ccnukelst)) != NULL) {
    125   1.3  pooka 		LIST_REMOVE(pcc_iter, nlst_entries);
    126   1.3  pooka 		puffs_cc_destroy(pcc_iter);
    127   1.1  pooka 	}
    128   1.1  pooka }
    129   1.1  pooka 
    130   1.1  pooka /* library private, but linked from callcontext.c */
    131   1.1  pooka 
    132   1.1  pooka void
    133   1.1  pooka puffs_calldispatcher(struct puffs_cc *pcc)
    134   1.1  pooka {
    135   1.1  pooka 	struct puffs_usermount *pu = pcc->pcc_pu;
    136   1.1  pooka 	struct puffs_ops *pops = &pu->pu_ops;
    137   1.1  pooka 	struct puffs_req *preq = pcc->pcc_preq;
    138   1.1  pooka 	void *auxbuf = preq; /* help with typecasting */
    139   1.1  pooka 	void *opcookie = preq->preq_cookie;
    140   1.1  pooka 	int error, rv, buildpath;
    141   1.1  pooka 
    142   1.1  pooka 	assert(pcc->pcc_flags & (PCC_FAKECC | PCC_REALCC));
    143   1.1  pooka 
    144   1.1  pooka 	if (PUFFSOP_WANTREPLY(preq->preq_opclass))
    145   1.1  pooka 		rv = PUFFCALL_ANSWER;
    146   1.1  pooka 	else
    147   1.1  pooka 		rv = PUFFCALL_IGNORE;
    148   1.1  pooka 
    149   1.1  pooka 	buildpath = pu->pu_flags & PUFFS_FLAG_BUILDPATH;
    150   1.1  pooka 	preq->preq_setbacks = 0;
    151   1.1  pooka 
    152   1.1  pooka 	if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS) {
    153   1.1  pooka 		switch (preq->preq_optype) {
    154   1.1  pooka 		case PUFFS_VFS_UNMOUNT:
    155   1.1  pooka 		{
    156   1.1  pooka 			struct puffs_vfsreq_unmount *auxt = auxbuf;
    157   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvfsr_cid);
    158   1.1  pooka 
    159   1.1  pooka 			PU_SETSTATE(pu, PUFFS_STATE_UNMOUNTING);
    160   1.1  pooka 			error = pops->puffs_fs_unmount(pcc,
    161   1.8  pooka 			    auxt->pvfsr_flags, pcid);
    162   1.1  pooka 			if (!error)
    163   1.1  pooka 				PU_SETSTATE(pu, PUFFS_STATE_UNMOUNTED);
    164   1.1  pooka 			else
    165   1.1  pooka 				PU_SETSTATE(pu, PUFFS_STATE_RUNNING);
    166   1.1  pooka 			break;
    167   1.1  pooka 		}
    168   1.1  pooka 
    169   1.1  pooka 		case PUFFS_VFS_STATVFS:
    170   1.1  pooka 		{
    171   1.1  pooka 			struct puffs_vfsreq_statvfs *auxt = auxbuf;
    172   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvfsr_cid);
    173   1.1  pooka 
    174   1.1  pooka 			error = pops->puffs_fs_statvfs(pcc,
    175   1.8  pooka 			    &auxt->pvfsr_sb, pcid);
    176   1.1  pooka 			break;
    177   1.1  pooka 		}
    178   1.1  pooka 
    179   1.1  pooka 		case PUFFS_VFS_SYNC:
    180   1.1  pooka 		{
    181   1.1  pooka 			struct puffs_vfsreq_sync *auxt = auxbuf;
    182   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvfsr_cred);
    183   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvfsr_cid);
    184   1.1  pooka 
    185   1.1  pooka 			error = pops->puffs_fs_sync(pcc,
    186   1.8  pooka 			    auxt->pvfsr_waitfor, pcr, pcid);
    187   1.1  pooka 			break;
    188   1.1  pooka 		}
    189   1.1  pooka 
    190   1.1  pooka 		case PUFFS_VFS_FHTOVP:
    191   1.1  pooka 		{
    192   1.1  pooka 			struct puffs_vfsreq_fhtonode *auxt = auxbuf;
    193   1.9  pooka 			struct puffs_newinfo pni;
    194   1.9  pooka 
    195   1.9  pooka 			pni.pni_cookie = &auxt->pvfsr_fhcookie;
    196   1.9  pooka 			pni.pni_vtype = &auxt->pvfsr_vtype;
    197   1.9  pooka 			pni.pni_size = &auxt->pvfsr_size;
    198   1.9  pooka 			pni.pni_rdev = &auxt->pvfsr_rdev;
    199   1.1  pooka 
    200   1.1  pooka 			error = pops->puffs_fs_fhtonode(pcc, auxt->pvfsr_data,
    201   1.9  pooka 			    auxt->pvfsr_dsize, &pni);
    202   1.1  pooka 
    203   1.1  pooka 			break;
    204   1.1  pooka 		}
    205   1.1  pooka 
    206   1.1  pooka 		case PUFFS_VFS_VPTOFH:
    207   1.1  pooka 		{
    208   1.1  pooka 			struct puffs_vfsreq_nodetofh *auxt = auxbuf;
    209   1.1  pooka 
    210   1.1  pooka 			error = pops->puffs_fs_nodetofh(pcc,
    211   1.1  pooka 			    auxt->pvfsr_fhcookie, auxt->pvfsr_data,
    212   1.1  pooka 			    &auxt->pvfsr_dsize);
    213   1.1  pooka 
    214   1.1  pooka 			break;
    215   1.1  pooka 		}
    216   1.1  pooka 
    217   1.1  pooka 		case PUFFS_VFS_SUSPEND:
    218   1.1  pooka 		{
    219   1.1  pooka 			struct puffs_vfsreq_suspend *auxt = auxbuf;
    220   1.1  pooka 
    221   1.1  pooka 			error = 0;
    222   1.1  pooka 			if (pops->puffs_fs_suspend == NULL)
    223   1.1  pooka 				break;
    224   1.1  pooka 
    225   1.1  pooka 			pops->puffs_fs_suspend(pcc, auxt->pvfsr_status);
    226   1.1  pooka 			break;
    227   1.1  pooka 		}
    228   1.1  pooka 
    229   1.1  pooka 		default:
    230   1.1  pooka 			/*
    231   1.1  pooka 			 * I guess the kernel sees this one coming
    232   1.1  pooka 			 */
    233   1.1  pooka 			error = EINVAL;
    234   1.1  pooka 			break;
    235   1.1  pooka 		}
    236   1.1  pooka 
    237   1.1  pooka 	/* XXX: audit return values */
    238   1.1  pooka 	/* XXX: sync with kernel */
    239   1.1  pooka 	} else if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) {
    240   1.1  pooka 		switch (preq->preq_optype) {
    241   1.1  pooka 		case PUFFS_VN_LOOKUP:
    242   1.1  pooka 		{
    243   1.1  pooka 			struct puffs_vnreq_lookup *auxt = auxbuf;
    244   1.9  pooka 			struct puffs_newinfo pni;
    245   1.1  pooka 			struct puffs_cn pcn;
    246   1.1  pooka 
    247   1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    248   1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    249   1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    250   1.9  pooka 			pni.pni_cookie = &auxt->pvnr_newnode;
    251   1.9  pooka 			pni.pni_vtype = &auxt->pvnr_vtype;
    252   1.9  pooka 			pni.pni_size = &auxt->pvnr_size;
    253   1.9  pooka 			pni.pni_rdev = &auxt->pvnr_rdev;
    254   1.7  pooka 
    255   1.1  pooka 			if (buildpath) {
    256   1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    257   1.1  pooka 				if (error)
    258   1.1  pooka 					break;
    259   1.1  pooka 			}
    260   1.1  pooka 
    261   1.1  pooka 			/* lookup *must* be present */
    262   1.1  pooka 			error = pops->puffs_node_lookup(pcc, opcookie,
    263   1.9  pooka 			    &pni, &pcn);
    264   1.1  pooka 
    265   1.1  pooka 			if (buildpath) {
    266   1.1  pooka 				if (error) {
    267   1.1  pooka 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
    268   1.1  pooka 				} else {
    269   1.1  pooka 					struct puffs_node *pn;
    270   1.1  pooka 
    271   1.1  pooka 					/*
    272   1.1  pooka 					 * did we get a new node or a
    273   1.1  pooka 					 * recycled node?
    274   1.1  pooka 					 */
    275   1.1  pooka 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
    276   1.1  pooka 					if (pn->pn_po.po_path == NULL)
    277   1.1  pooka 						pn->pn_po = pcn.pcn_po_full;
    278   1.1  pooka 					else
    279   1.1  pooka 						pu->pu_pathfree(pu,
    280   1.1  pooka 						    &pcn.pcn_po_full);
    281   1.1  pooka 				}
    282   1.1  pooka 			}
    283   1.1  pooka 
    284   1.1  pooka 			break;
    285   1.1  pooka 		}
    286   1.1  pooka 
    287   1.1  pooka 		case PUFFS_VN_CREATE:
    288   1.1  pooka 		{
    289   1.1  pooka 			struct puffs_vnreq_create *auxt = auxbuf;
    290   1.9  pooka 			struct puffs_newinfo pni;
    291   1.1  pooka 			struct puffs_cn pcn;
    292   1.9  pooka 
    293   1.1  pooka 			if (pops->puffs_node_create == NULL) {
    294   1.1  pooka 				error = 0;
    295   1.1  pooka 				break;
    296   1.1  pooka 			}
    297   1.1  pooka 
    298   1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    299   1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    300   1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    301   1.7  pooka 
    302   1.9  pooka 			memset(&pni, 0, sizeof(pni));
    303   1.9  pooka 			pni.pni_cookie = &auxt->pvnr_newnode;
    304   1.9  pooka 
    305   1.1  pooka 			if (buildpath) {
    306   1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    307   1.1  pooka 				if (error)
    308   1.1  pooka 					break;
    309   1.1  pooka 			}
    310   1.1  pooka 
    311   1.1  pooka 			error = pops->puffs_node_create(pcc,
    312   1.9  pooka 			    opcookie, &pni, &pcn, &auxt->pvnr_va);
    313   1.1  pooka 
    314   1.1  pooka 			if (buildpath) {
    315   1.1  pooka 				if (error) {
    316   1.1  pooka 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
    317   1.1  pooka 				} else {
    318   1.1  pooka 					struct puffs_node *pn;
    319   1.1  pooka 
    320   1.1  pooka 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
    321   1.1  pooka 					pn->pn_po = pcn.pcn_po_full;
    322   1.1  pooka 				}
    323   1.1  pooka 			}
    324   1.1  pooka 
    325   1.1  pooka 			break;
    326   1.1  pooka 		}
    327   1.1  pooka 
    328   1.1  pooka 		case PUFFS_VN_MKNOD:
    329   1.1  pooka 		{
    330   1.1  pooka 			struct puffs_vnreq_mknod *auxt = auxbuf;
    331   1.9  pooka 			struct puffs_newinfo pni;
    332   1.1  pooka 			struct puffs_cn pcn;
    333   1.9  pooka 
    334   1.1  pooka 			if (pops->puffs_node_mknod == NULL) {
    335   1.1  pooka 				error = 0;
    336   1.1  pooka 				break;
    337   1.1  pooka 			}
    338   1.1  pooka 
    339   1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    340   1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    341   1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    342   1.7  pooka 
    343   1.9  pooka 			memset(&pni, 0, sizeof(pni));
    344   1.9  pooka 			pni.pni_cookie = &auxt->pvnr_newnode;
    345   1.9  pooka 
    346   1.1  pooka 			if (buildpath) {
    347   1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    348   1.1  pooka 				if (error)
    349   1.1  pooka 					break;
    350   1.1  pooka 			}
    351   1.1  pooka 
    352   1.1  pooka 			error = pops->puffs_node_mknod(pcc,
    353   1.9  pooka 			    opcookie, &pni, &pcn, &auxt->pvnr_va);
    354   1.1  pooka 
    355   1.1  pooka 			if (buildpath) {
    356   1.1  pooka 				if (error) {
    357   1.1  pooka 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
    358   1.1  pooka 				} else {
    359   1.1  pooka 					struct puffs_node *pn;
    360   1.1  pooka 
    361   1.1  pooka 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
    362   1.1  pooka 					pn->pn_po = pcn.pcn_po_full;
    363   1.1  pooka 				}
    364   1.1  pooka 			}
    365   1.1  pooka 
    366   1.1  pooka 			break;
    367   1.1  pooka 		}
    368   1.1  pooka 
    369   1.1  pooka 		case PUFFS_VN_OPEN:
    370   1.1  pooka 		{
    371   1.1  pooka 			struct puffs_vnreq_open *auxt = auxbuf;
    372   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    373   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    374   1.7  pooka 
    375   1.1  pooka 			if (pops->puffs_node_open == NULL) {
    376   1.1  pooka 				error = 0;
    377   1.1  pooka 				break;
    378   1.1  pooka 			}
    379   1.1  pooka 
    380   1.1  pooka 			error = pops->puffs_node_open(pcc,
    381   1.8  pooka 			    opcookie, auxt->pvnr_mode, pcr, pcid);
    382   1.1  pooka 			break;
    383   1.1  pooka 		}
    384   1.1  pooka 
    385   1.1  pooka 		case PUFFS_VN_CLOSE:
    386   1.1  pooka 		{
    387   1.1  pooka 			struct puffs_vnreq_close *auxt = auxbuf;
    388   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    389   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    390   1.8  pooka 
    391   1.7  pooka 
    392   1.1  pooka 			if (pops->puffs_node_close == NULL) {
    393   1.1  pooka 				error = 0;
    394   1.1  pooka 				break;
    395   1.1  pooka 			}
    396   1.1  pooka 
    397   1.1  pooka 			error = pops->puffs_node_close(pcc,
    398   1.8  pooka 			    opcookie, auxt->pvnr_fflag, pcr, pcid);
    399   1.1  pooka 			break;
    400   1.1  pooka 		}
    401   1.1  pooka 
    402   1.1  pooka 		case PUFFS_VN_ACCESS:
    403   1.1  pooka 		{
    404   1.1  pooka 			struct puffs_vnreq_access *auxt = auxbuf;
    405   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    406   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    407   1.8  pooka 
    408   1.7  pooka 
    409   1.1  pooka 			if (pops->puffs_node_access == NULL) {
    410   1.1  pooka 				error = 0;
    411   1.1  pooka 				break;
    412   1.1  pooka 			}
    413   1.1  pooka 
    414   1.1  pooka 			error = pops->puffs_node_access(pcc,
    415   1.8  pooka 			    opcookie, auxt->pvnr_mode, pcr, pcid);
    416   1.1  pooka 			break;
    417   1.1  pooka 		}
    418   1.1  pooka 
    419   1.1  pooka 		case PUFFS_VN_GETATTR:
    420   1.1  pooka 		{
    421   1.1  pooka 			struct puffs_vnreq_getattr *auxt = auxbuf;
    422   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    423   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    424   1.8  pooka 
    425   1.7  pooka 
    426   1.1  pooka 			if (pops->puffs_node_getattr == NULL) {
    427   1.1  pooka 				error = EOPNOTSUPP;
    428   1.1  pooka 				break;
    429   1.1  pooka 			}
    430   1.1  pooka 
    431   1.1  pooka 			error = pops->puffs_node_getattr(pcc,
    432   1.8  pooka 			    opcookie, &auxt->pvnr_va, pcr, pcid);
    433   1.1  pooka 			break;
    434   1.1  pooka 		}
    435   1.1  pooka 
    436   1.1  pooka 		case PUFFS_VN_SETATTR:
    437   1.1  pooka 		{
    438   1.1  pooka 			struct puffs_vnreq_setattr *auxt = auxbuf;
    439   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    440   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    441   1.8  pooka 
    442   1.7  pooka 
    443   1.1  pooka 			if (pops->puffs_node_setattr == NULL) {
    444   1.1  pooka 				error = EOPNOTSUPP;
    445   1.1  pooka 				break;
    446   1.1  pooka 			}
    447   1.1  pooka 
    448   1.1  pooka 			error = pops->puffs_node_setattr(pcc,
    449   1.8  pooka 			    opcookie, &auxt->pvnr_va, pcr, pcid);
    450   1.1  pooka 			break;
    451   1.1  pooka 		}
    452   1.1  pooka 
    453   1.1  pooka 		case PUFFS_VN_MMAP:
    454   1.1  pooka 		{
    455   1.1  pooka 			struct puffs_vnreq_mmap *auxt = auxbuf;
    456   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    457   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    458   1.8  pooka 
    459   1.7  pooka 
    460   1.1  pooka 			if (pops->puffs_node_mmap == NULL) {
    461   1.1  pooka 				error = 0;
    462   1.1  pooka 				break;
    463   1.1  pooka 			}
    464   1.1  pooka 
    465   1.1  pooka 			error = pops->puffs_node_mmap(pcc,
    466  1.11  pooka 			    opcookie, auxt->pvnr_prot, pcr, pcid);
    467   1.1  pooka 			break;
    468   1.1  pooka 		}
    469   1.1  pooka 
    470   1.1  pooka 		case PUFFS_VN_FSYNC:
    471   1.1  pooka 		{
    472   1.1  pooka 			struct puffs_vnreq_fsync *auxt = auxbuf;
    473   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    474   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    475   1.8  pooka 
    476   1.7  pooka 
    477   1.1  pooka 			if (pops->puffs_node_fsync == NULL) {
    478   1.1  pooka 				error = 0;
    479   1.1  pooka 				break;
    480   1.1  pooka 			}
    481   1.1  pooka 
    482   1.7  pooka 			error = pops->puffs_node_fsync(pcc, opcookie, pcr,
    483   1.1  pooka 			    auxt->pvnr_flags, auxt->pvnr_offlo,
    484   1.8  pooka 			    auxt->pvnr_offhi, pcid);
    485   1.1  pooka 			break;
    486   1.1  pooka 		}
    487   1.1  pooka 
    488   1.1  pooka 		case PUFFS_VN_SEEK:
    489   1.1  pooka 		{
    490   1.1  pooka 			struct puffs_vnreq_seek *auxt = auxbuf;
    491   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    492   1.7  pooka 
    493   1.1  pooka 			if (pops->puffs_node_seek == NULL) {
    494   1.1  pooka 				error = 0;
    495   1.1  pooka 				break;
    496   1.1  pooka 			}
    497   1.1  pooka 
    498   1.1  pooka 			error = pops->puffs_node_seek(pcc,
    499   1.1  pooka 			    opcookie, auxt->pvnr_oldoff,
    500   1.7  pooka 			    auxt->pvnr_newoff, pcr);
    501   1.1  pooka 			break;
    502   1.1  pooka 		}
    503   1.1  pooka 
    504   1.1  pooka 		case PUFFS_VN_REMOVE:
    505   1.1  pooka 		{
    506   1.1  pooka 			struct puffs_vnreq_remove *auxt = auxbuf;
    507   1.1  pooka 			struct puffs_cn pcn;
    508   1.1  pooka 			if (pops->puffs_node_remove == NULL) {
    509   1.1  pooka 				error = 0;
    510   1.1  pooka 				break;
    511   1.1  pooka 			}
    512   1.1  pooka 
    513   1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    514   1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    515   1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    516   1.1  pooka 
    517   1.1  pooka 			error = pops->puffs_node_remove(pcc,
    518   1.1  pooka 			    opcookie, auxt->pvnr_cookie_targ, &pcn);
    519   1.1  pooka 			break;
    520   1.1  pooka 		}
    521   1.1  pooka 
    522   1.1  pooka 		case PUFFS_VN_LINK:
    523   1.1  pooka 		{
    524   1.1  pooka 			struct puffs_vnreq_link *auxt = auxbuf;
    525   1.1  pooka 			struct puffs_cn pcn;
    526   1.1  pooka 			if (pops->puffs_node_link == NULL) {
    527   1.1  pooka 				error = 0;
    528   1.1  pooka 				break;
    529   1.1  pooka 			}
    530   1.1  pooka 
    531   1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    532   1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    533   1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    534   1.7  pooka 
    535   1.1  pooka 			if (buildpath) {
    536   1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    537   1.1  pooka 				if (error)
    538   1.1  pooka 					break;
    539   1.1  pooka 			}
    540   1.1  pooka 
    541   1.1  pooka 			error = pops->puffs_node_link(pcc,
    542   1.1  pooka 			    opcookie, auxt->pvnr_cookie_targ, &pcn);
    543   1.1  pooka 			if (buildpath)
    544   1.1  pooka 				pu->pu_pathfree(pu, &pcn.pcn_po_full);
    545   1.1  pooka 
    546   1.1  pooka 			break;
    547   1.1  pooka 		}
    548   1.1  pooka 
    549   1.1  pooka 		case PUFFS_VN_RENAME:
    550   1.1  pooka 		{
    551   1.1  pooka 			struct puffs_vnreq_rename *auxt = auxbuf;
    552   1.1  pooka 			struct puffs_cn pcn_src, pcn_targ;
    553   1.1  pooka 			struct puffs_node *pn_src;
    554   1.1  pooka 
    555   1.1  pooka 			if (pops->puffs_node_rename == NULL) {
    556   1.1  pooka 				error = 0;
    557   1.1  pooka 				break;
    558   1.1  pooka 			}
    559   1.1  pooka 
    560   1.1  pooka 			pcn_src.pcn_pkcnp = &auxt->pvnr_cn_src;
    561   1.7  pooka 			PUFFS_KCREDTOCRED(pcn_src.pcn_cred,
    562   1.7  pooka 			    &auxt->pvnr_cn_src_cred);
    563   1.8  pooka 			PUFFS_KCIDTOCID(pcn_src.pcn_cid,
    564   1.8  pooka 			    &auxt->pvnr_cn_src_cid);
    565   1.8  pooka 
    566   1.1  pooka 			pcn_targ.pcn_pkcnp = &auxt->pvnr_cn_targ;
    567   1.7  pooka 			PUFFS_KCREDTOCRED(pcn_targ.pcn_cred,
    568   1.7  pooka 			    &auxt->pvnr_cn_targ_cred);
    569   1.8  pooka 			PUFFS_KCIDTOCID(pcn_targ.pcn_cid,
    570   1.8  pooka 			    &auxt->pvnr_cn_targ_cid);
    571   1.7  pooka 
    572   1.1  pooka 			if (buildpath) {
    573   1.1  pooka 				pn_src = auxt->pvnr_cookie_src;
    574   1.1  pooka 				pcn_src.pcn_po_full = pn_src->pn_po;
    575   1.1  pooka 
    576   1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn_targ,
    577   1.1  pooka 				    auxt->pvnr_cookie_targdir);
    578   1.1  pooka 				if (error)
    579   1.1  pooka 					break;
    580   1.1  pooka 			}
    581   1.1  pooka 
    582   1.1  pooka 			error = pops->puffs_node_rename(pcc,
    583   1.1  pooka 			    opcookie, auxt->pvnr_cookie_src,
    584   1.1  pooka 			    &pcn_src, auxt->pvnr_cookie_targdir,
    585   1.1  pooka 			    auxt->pvnr_cookie_targ, &pcn_targ);
    586   1.1  pooka 
    587   1.1  pooka 			if (buildpath) {
    588   1.1  pooka 				if (error) {
    589   1.1  pooka 					pu->pu_pathfree(pu,
    590   1.1  pooka 					    &pcn_targ.pcn_po_full);
    591   1.1  pooka 				} else {
    592   1.1  pooka 					struct puffs_pathinfo pi;
    593   1.1  pooka 					struct puffs_pathobj po_old;
    594   1.1  pooka 
    595   1.1  pooka 					/* handle this node */
    596   1.1  pooka 					po_old = pn_src->pn_po;
    597   1.1  pooka 					pn_src->pn_po = pcn_targ.pcn_po_full;
    598   1.1  pooka 
    599   1.1  pooka 					if (pn_src->pn_va.va_type != VDIR) {
    600   1.1  pooka 						pu->pu_pathfree(pu, &po_old);
    601   1.1  pooka 						break;
    602   1.1  pooka 					}
    603   1.1  pooka 
    604   1.1  pooka 					/* handle all child nodes for DIRs */
    605   1.1  pooka 					pi.pi_old = &pcn_src.pcn_po_full;
    606   1.1  pooka 					pi.pi_new = &pcn_targ.pcn_po_full;
    607   1.1  pooka 
    608   1.1  pooka 					if (puffs_pn_nodewalk(pu,
    609   1.1  pooka 					    puffs_path_prefixadj, &pi) != NULL)
    610   1.1  pooka 						error = ENOMEM;
    611   1.1  pooka 					pu->pu_pathfree(pu, &po_old);
    612   1.1  pooka 				}
    613   1.1  pooka 			}
    614   1.1  pooka 			break;
    615   1.1  pooka 		}
    616   1.1  pooka 
    617   1.1  pooka 		case PUFFS_VN_MKDIR:
    618   1.1  pooka 		{
    619   1.1  pooka 			struct puffs_vnreq_mkdir *auxt = auxbuf;
    620   1.9  pooka 			struct puffs_newinfo pni;
    621   1.1  pooka 			struct puffs_cn pcn;
    622   1.9  pooka 
    623   1.1  pooka 			if (pops->puffs_node_mkdir == NULL) {
    624   1.1  pooka 				error = 0;
    625   1.1  pooka 				break;
    626   1.1  pooka 			}
    627   1.1  pooka 
    628   1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    629   1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    630   1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    631   1.7  pooka 
    632   1.9  pooka 			memset(&pni, 0, sizeof(pni));
    633   1.9  pooka 			pni.pni_cookie = &auxt->pvnr_newnode;
    634   1.9  pooka 
    635   1.1  pooka 			if (buildpath) {
    636   1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    637   1.1  pooka 				if (error)
    638   1.1  pooka 					break;
    639   1.1  pooka 			}
    640   1.1  pooka 
    641   1.1  pooka 			error = pops->puffs_node_mkdir(pcc,
    642   1.9  pooka 			    opcookie, &pni, &pcn, &auxt->pvnr_va);
    643   1.1  pooka 
    644   1.1  pooka 			if (buildpath) {
    645   1.1  pooka 				if (error) {
    646   1.1  pooka 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
    647   1.1  pooka 				} else {
    648   1.1  pooka 					struct puffs_node *pn;
    649   1.1  pooka 
    650   1.1  pooka 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
    651   1.1  pooka 					pn->pn_po = pcn.pcn_po_full;
    652   1.1  pooka 				}
    653   1.1  pooka 			}
    654   1.1  pooka 
    655   1.1  pooka 			break;
    656   1.1  pooka 		}
    657   1.1  pooka 
    658   1.1  pooka 		case PUFFS_VN_RMDIR:
    659   1.1  pooka 		{
    660   1.1  pooka 			struct puffs_vnreq_rmdir *auxt = auxbuf;
    661   1.1  pooka 			struct puffs_cn pcn;
    662   1.1  pooka 			if (pops->puffs_node_rmdir == NULL) {
    663   1.1  pooka 				error = 0;
    664   1.1  pooka 				break;
    665   1.1  pooka 			}
    666   1.1  pooka 
    667   1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    668   1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    669   1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    670   1.1  pooka 
    671   1.1  pooka 			error = pops->puffs_node_rmdir(pcc,
    672   1.1  pooka 			    opcookie, auxt->pvnr_cookie_targ, &pcn);
    673   1.1  pooka 			break;
    674   1.1  pooka 		}
    675   1.1  pooka 
    676   1.1  pooka 		case PUFFS_VN_SYMLINK:
    677   1.1  pooka 		{
    678   1.1  pooka 			struct puffs_vnreq_symlink *auxt = auxbuf;
    679   1.9  pooka 			struct puffs_newinfo pni;
    680   1.1  pooka 			struct puffs_cn pcn;
    681   1.9  pooka 
    682   1.1  pooka 			if (pops->puffs_node_symlink == NULL) {
    683   1.1  pooka 				error = 0;
    684   1.1  pooka 				break;
    685   1.1  pooka 			}
    686   1.1  pooka 
    687   1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    688   1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    689   1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    690   1.7  pooka 
    691   1.9  pooka 			memset(&pni, 0, sizeof(pni));
    692   1.9  pooka 			pni.pni_cookie = &auxt->pvnr_newnode;
    693   1.9  pooka 
    694   1.1  pooka 			if (buildpath) {
    695   1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    696   1.1  pooka 				if (error)
    697   1.1  pooka 					break;
    698   1.1  pooka 			}
    699   1.1  pooka 
    700   1.1  pooka 			error = pops->puffs_node_symlink(pcc,
    701   1.9  pooka 			    opcookie, &pni, &pcn,
    702   1.9  pooka 			    &auxt->pvnr_va, auxt->pvnr_link);
    703   1.1  pooka 
    704   1.1  pooka 			if (buildpath) {
    705   1.1  pooka 				if (error) {
    706   1.1  pooka 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
    707   1.1  pooka 				} else {
    708   1.1  pooka 					struct puffs_node *pn;
    709   1.1  pooka 
    710   1.1  pooka 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
    711   1.1  pooka 					pn->pn_po = pcn.pcn_po_full;
    712   1.1  pooka 				}
    713   1.1  pooka 			}
    714   1.1  pooka 
    715   1.1  pooka 			break;
    716   1.1  pooka 		}
    717   1.1  pooka 
    718   1.1  pooka 		case PUFFS_VN_READDIR:
    719   1.1  pooka 		{
    720   1.1  pooka 			struct puffs_vnreq_readdir *auxt = auxbuf;
    721   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    722   1.1  pooka 			struct dirent *dent;
    723   1.1  pooka 			off_t *cookies;
    724   1.1  pooka 			size_t res, origcookies;
    725   1.1  pooka 
    726   1.1  pooka 			if (pops->puffs_node_readdir == NULL) {
    727   1.1  pooka 				error = 0;
    728   1.1  pooka 				break;
    729   1.1  pooka 			}
    730   1.1  pooka 
    731   1.1  pooka 			if (auxt->pvnr_ncookies) {
    732   1.1  pooka 				/* LINTED: pvnr_data is __aligned() */
    733   1.1  pooka 				cookies = (off_t *)auxt->pvnr_data;
    734   1.1  pooka 				origcookies = auxt->pvnr_ncookies;
    735   1.1  pooka 			} else {
    736   1.1  pooka 				cookies = NULL;
    737   1.1  pooka 				origcookies = 0;
    738   1.1  pooka 			}
    739   1.1  pooka 			/* LINTED: dentoff is aligned in the kernel */
    740   1.1  pooka 			dent = (struct dirent *)
    741   1.1  pooka 			    (auxt->pvnr_data + auxt->pvnr_dentoff);
    742   1.1  pooka 
    743   1.1  pooka 			res = auxt->pvnr_resid;
    744   1.1  pooka 			error = pops->puffs_node_readdir(pcc,
    745   1.1  pooka 			    opcookie, dent, &auxt->pvnr_offset,
    746   1.7  pooka 			    &auxt->pvnr_resid, pcr, &auxt->pvnr_eofflag,
    747   1.7  pooka 			    cookies, &auxt->pvnr_ncookies);
    748   1.1  pooka 
    749   1.1  pooka 			/* much easier to track non-working NFS */
    750   1.1  pooka 			assert(auxt->pvnr_ncookies <= origcookies);
    751   1.1  pooka 
    752   1.1  pooka 			/* need to move a bit more */
    753   1.1  pooka 			preq->preq_buflen = sizeof(struct puffs_vnreq_readdir)
    754   1.1  pooka 			    + auxt->pvnr_dentoff + (res - auxt->pvnr_resid);
    755   1.1  pooka 			break;
    756   1.1  pooka 		}
    757   1.1  pooka 
    758   1.1  pooka 		case PUFFS_VN_READLINK:
    759   1.1  pooka 		{
    760   1.1  pooka 			struct puffs_vnreq_readlink *auxt = auxbuf;
    761   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    762   1.7  pooka 
    763   1.1  pooka 			if (pops->puffs_node_readlink == NULL) {
    764   1.1  pooka 				error = EOPNOTSUPP;
    765   1.1  pooka 				break;
    766   1.1  pooka 			}
    767   1.1  pooka 
    768   1.7  pooka 			/*LINTED*/
    769   1.7  pooka 			error = pops->puffs_node_readlink(pcc, opcookie, pcr,
    770   1.1  pooka 			    auxt->pvnr_link, &auxt->pvnr_linklen);
    771   1.1  pooka 			break;
    772   1.1  pooka 		}
    773   1.1  pooka 
    774   1.1  pooka 		case PUFFS_VN_RECLAIM:
    775   1.1  pooka 		{
    776   1.1  pooka 			struct puffs_vnreq_reclaim *auxt = auxbuf;
    777   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    778   1.8  pooka 
    779   1.1  pooka 			if (pops->puffs_node_reclaim == NULL) {
    780   1.1  pooka 				error = 0;
    781   1.1  pooka 				break;
    782   1.1  pooka 			}
    783   1.1  pooka 
    784   1.8  pooka 			error = pops->puffs_node_reclaim(pcc, opcookie, pcid);
    785   1.1  pooka 			break;
    786   1.1  pooka 		}
    787   1.1  pooka 
    788   1.1  pooka 		case PUFFS_VN_INACTIVE:
    789   1.1  pooka 		{
    790   1.1  pooka 			struct puffs_vnreq_inactive *auxt = auxbuf;
    791   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    792   1.8  pooka 
    793   1.1  pooka 			if (pops->puffs_node_inactive == NULL) {
    794   1.1  pooka 				error = EOPNOTSUPP;
    795   1.1  pooka 				break;
    796   1.1  pooka 			}
    797   1.1  pooka 
    798  1.10  pooka 			error = pops->puffs_node_inactive(pcc, opcookie, pcid);
    799   1.1  pooka 			break;
    800   1.1  pooka 		}
    801   1.1  pooka 
    802   1.1  pooka 		case PUFFS_VN_PATHCONF:
    803   1.1  pooka 		{
    804   1.1  pooka 			struct puffs_vnreq_pathconf *auxt = auxbuf;
    805   1.1  pooka 			if (pops->puffs_node_pathconf == NULL) {
    806   1.1  pooka 				error = 0;
    807   1.1  pooka 				break;
    808   1.1  pooka 			}
    809   1.1  pooka 
    810   1.1  pooka 			error = pops->puffs_node_pathconf(pcc,
    811   1.1  pooka 			    opcookie, auxt->pvnr_name,
    812   1.1  pooka 			    &auxt->pvnr_retval);
    813   1.1  pooka 			break;
    814   1.1  pooka 		}
    815   1.1  pooka 
    816   1.1  pooka 		case PUFFS_VN_ADVLOCK:
    817   1.1  pooka 		{
    818   1.1  pooka 			struct puffs_vnreq_advlock *auxt = auxbuf;
    819   1.1  pooka 			if (pops->puffs_node_advlock == NULL) {
    820   1.1  pooka 				error = 0;
    821   1.1  pooka 				break;
    822   1.1  pooka 			}
    823   1.1  pooka 
    824   1.1  pooka 			error = pops->puffs_node_advlock(pcc,
    825   1.1  pooka 			    opcookie, auxt->pvnr_id, auxt->pvnr_op,
    826   1.1  pooka 			    &auxt->pvnr_fl, auxt->pvnr_flags);
    827   1.1  pooka 			break;
    828   1.1  pooka 		}
    829   1.1  pooka 
    830   1.1  pooka 		case PUFFS_VN_PRINT:
    831   1.1  pooka 		{
    832   1.1  pooka 			if (pops->puffs_node_print == NULL) {
    833   1.1  pooka 				error = 0;
    834   1.1  pooka 				break;
    835   1.1  pooka 			}
    836   1.1  pooka 
    837   1.1  pooka 			error = pops->puffs_node_print(pcc,
    838   1.1  pooka 			    opcookie);
    839   1.1  pooka 			break;
    840   1.1  pooka 		}
    841   1.1  pooka 
    842   1.1  pooka 		case PUFFS_VN_READ:
    843   1.1  pooka 		{
    844   1.1  pooka 			struct puffs_vnreq_read *auxt = auxbuf;
    845   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    846   1.1  pooka 			size_t res;
    847   1.1  pooka 
    848   1.1  pooka 			if (pops->puffs_node_read == NULL) {
    849   1.1  pooka 				error = EIO;
    850   1.1  pooka 				break;
    851   1.1  pooka 			}
    852   1.1  pooka 
    853   1.1  pooka 			res = auxt->pvnr_resid;
    854   1.1  pooka 			error = pops->puffs_node_read(pcc,
    855   1.1  pooka 			    opcookie, auxt->pvnr_data,
    856   1.1  pooka 			    auxt->pvnr_offset, &auxt->pvnr_resid,
    857   1.7  pooka 			    pcr, auxt->pvnr_ioflag);
    858   1.1  pooka 
    859   1.1  pooka 			/* need to move a bit more */
    860   1.1  pooka 			preq->preq_buflen = sizeof(struct puffs_vnreq_read)
    861   1.1  pooka 			    + (res - auxt->pvnr_resid);
    862   1.1  pooka 			break;
    863   1.1  pooka 		}
    864   1.1  pooka 
    865   1.1  pooka 		case PUFFS_VN_WRITE:
    866   1.1  pooka 		{
    867   1.1  pooka 			struct puffs_vnreq_write *auxt = auxbuf;
    868   1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    869   1.1  pooka 
    870   1.1  pooka 			if (pops->puffs_node_write == NULL) {
    871   1.1  pooka 				error = EIO;
    872   1.1  pooka 				break;
    873   1.1  pooka 			}
    874   1.1  pooka 
    875   1.1  pooka 			error = pops->puffs_node_write(pcc,
    876   1.1  pooka 			    opcookie, auxt->pvnr_data,
    877   1.1  pooka 			    auxt->pvnr_offset, &auxt->pvnr_resid,
    878   1.7  pooka 			    pcr, auxt->pvnr_ioflag);
    879   1.1  pooka 
    880   1.1  pooka 			/* don't need to move data back to the kernel */
    881   1.1  pooka 			preq->preq_buflen = sizeof(struct puffs_vnreq_write);
    882   1.1  pooka 			break;
    883   1.1  pooka 		}
    884   1.1  pooka 
    885   1.4  pooka 		case PUFFS_VN_POLL:
    886   1.4  pooka 		{
    887   1.4  pooka 			struct puffs_vnreq_poll *auxt = auxbuf;
    888   1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    889   1.8  pooka 
    890   1.4  pooka 			if (pops->puffs_node_poll == NULL) {
    891   1.4  pooka 				error = 0;
    892   1.4  pooka 
    893   1.4  pooka 				/* emulate genfs_poll() */
    894   1.4  pooka 				auxt->pvnr_events &= (POLLIN | POLLOUT
    895   1.4  pooka 						    | POLLRDNORM | POLLWRNORM);
    896   1.4  pooka 
    897   1.4  pooka 				break;
    898   1.4  pooka 			}
    899   1.4  pooka 
    900   1.4  pooka 			error = pops->puffs_node_poll(pcc,
    901   1.8  pooka 			    opcookie, &auxt->pvnr_events, pcid);
    902   1.4  pooka 			break;
    903   1.4  pooka 		}
    904   1.4  pooka 
    905   1.1  pooka /* holy bitrot, ryydman! */
    906   1.1  pooka #if 0
    907   1.1  pooka 		case PUFFS_VN_IOCTL:
    908   1.1  pooka 			error = pops->puffs_node_ioctl1(pcc, opcookie,
    909   1.1  pooka 			     (struct puffs_vnreq_ioctl *)auxbuf, &pop);
    910   1.1  pooka 			if (error != 0)
    911   1.1  pooka 				break;
    912   1.1  pooka 			pop.pso_reqid = preq->preq_id;
    913   1.1  pooka 
    914   1.1  pooka 			/* let the kernel do it's intermediate duty */
    915   1.1  pooka 			error = ioctl(pu->pu_kargs.pa_fd, PUFFSSIZEOP, &pop);
    916   1.1  pooka 			/*
    917   1.1  pooka 			 * XXX: I don't actually know what the correct
    918   1.1  pooka 			 * thing to do in case of an error is, so I'll
    919   1.1  pooka 			 * just ignore it for the time being.
    920   1.1  pooka 			 */
    921   1.1  pooka 			error = pops->puffs_node_ioctl2(pcc, opcookie,
    922   1.1  pooka 			    (struct puffs_vnreq_ioctl *)auxbuf, &pop);
    923   1.1  pooka 			break;
    924   1.1  pooka 
    925   1.1  pooka 		case PUFFS_VN_FCNTL:
    926   1.1  pooka 			error = pops->puffs_node_fcntl1(pcc, opcookie,
    927   1.1  pooka 			     (struct puffs_vnreq_fcntl *)auxbuf, &pop);
    928   1.1  pooka 			if (error != 0)
    929   1.1  pooka 				break;
    930   1.1  pooka 			pop.pso_reqid = preq->preq_id;
    931   1.1  pooka 
    932   1.1  pooka 			/* let the kernel do it's intermediate duty */
    933   1.1  pooka 			error = ioctl(pu->pu_kargs.pa_fd, PUFFSSIZEOP, &pop);
    934   1.1  pooka 			/*
    935   1.1  pooka 			 * XXX: I don't actually know what the correct
    936   1.1  pooka 			 * thing to do in case of an error is, so I'll
    937   1.1  pooka 			 * just ignore it for the time being.
    938   1.1  pooka 			 */
    939   1.1  pooka 			error = pops->puffs_node_fcntl2(pcc, opcookie,
    940   1.1  pooka 			    (struct puffs_vnreq_fcntl *)auxbuf, &pop);
    941   1.1  pooka 			break;
    942   1.1  pooka #endif
    943   1.1  pooka 
    944   1.1  pooka 		default:
    945   1.1  pooka 			printf("inval op %d\n", preq->preq_optype);
    946   1.1  pooka 			error = EINVAL;
    947   1.1  pooka 			break;
    948   1.1  pooka 		}
    949   1.1  pooka 	} else {
    950   1.1  pooka 		/*
    951   1.1  pooka 		 * this one also
    952   1.1  pooka 		 */
    953   1.1  pooka 		error = EINVAL;
    954   1.1  pooka 	}
    955   1.1  pooka 
    956   1.1  pooka 	preq->preq_rv = error;
    957   1.3  pooka 	pcc->pcc_flags |= PCC_DONE;
    958   1.1  pooka 
    959   1.3  pooka 	/*
    960   1.3  pooka 	 * Note, we are calling this from here so that we can run it
    961   1.3  pooka 	 * off of the continuation stack.  Otherwise puffs_goto() would
    962   1.3  pooka 	 * not work.
    963   1.3  pooka 	 */
    964   1.3  pooka 	processresult(pcc, pcc->pcc_ppr, rv);
    965   1.3  pooka }
    966   1.3  pooka 
    967   1.3  pooka static void
    968   1.3  pooka processresult(struct puffs_cc *pcc, struct puffs_putreq *ppr, int how)
    969   1.3  pooka {
    970   1.3  pooka 	struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
    971   1.3  pooka 
    972   1.3  pooka 	/* check if we need to store this reply */
    973   1.3  pooka 	switch (how) {
    974   1.3  pooka 	case PUFFCALL_ANSWER:
    975   1.3  pooka 		if (pu->pu_flags & PUFFS_FLAG_OPDUMP)
    976   1.3  pooka 			puffsdump_rv(pcc->pcc_preq);
    977   1.3  pooka 
    978   1.3  pooka 		if (pcc->pcc_flags & PCC_REALCC)
    979   1.3  pooka 			puffs_req_putcc(ppr, pcc);
    980   1.3  pooka 		else
    981   1.3  pooka 			puffs_req_put(ppr, pcc->pcc_preq);
    982   1.3  pooka 		break;
    983   1.3  pooka 	case PUFFCALL_IGNORE:
    984   1.3  pooka 		if (pcc->pcc_flags & PCC_REALCC)
    985   1.3  pooka 			LIST_INSERT_HEAD(&pu->pu_ccnukelst, pcc, nlst_entries);
    986   1.3  pooka 		break;
    987   1.3  pooka 	case PUFFCALL_AGAIN:
    988   1.3  pooka 		if (pcc->pcc_flags & PCC_FAKECC)
    989   1.3  pooka 			assert(pcc->pcc_flags & PCC_DONE);
    990   1.3  pooka 		break;
    991   1.3  pooka 	default:
    992   1.3  pooka 		assert(/*CONSTCOND*/0);
    993   1.3  pooka 	}
    994   1.3  pooka 
    995   1.3  pooka 	/* who needs information when you're living on borrowed time? */
    996   1.3  pooka 	if (pcc->pcc_flags & PCC_BORROWED)
    997   1.3  pooka 		puffs_cc_yield(pcc); /* back to borrow source */
    998   1.1  pooka }
    999   1.1  pooka 
   1000   1.1  pooka 
   1001   1.1  pooka #if 0
   1002   1.1  pooka 		case PUFFS_VN_KQFILTER:
   1003   1.1  pooka 		{
   1004   1.1  pooka 			struct puffs_vnreq_kqfilter *auxt = auxbuf;
   1005   1.1  pooka 			if (pops->puffs_node_kqfilter == NULL) {
   1006   1.1  pooka 				error = 0;
   1007   1.1  pooka 				break;
   1008   1.1  pooka 			}
   1009   1.1  pooka 
   1010   1.1  pooka 			error = pops->puffs_node_kqfilter(pcc,
   1011   1.1  pooka 			    opcookie, );
   1012   1.1  pooka 			break;
   1013   1.1  pooka 		}
   1014   1.1  pooka 
   1015   1.1  pooka 		case PUFFS_VN_CLOSEEXTATTR:
   1016   1.1  pooka 		{
   1017   1.1  pooka 			struct puffs_vnreq_closeextattr *auxt = auxbuf;
   1018   1.1  pooka 			if (pops->puffs_closeextattr == NULL) {
   1019   1.1  pooka 				error = 0;
   1020   1.1  pooka 				break;
   1021   1.1  pooka 			}
   1022   1.1  pooka 
   1023   1.1  pooka 			error = pops->puffs_closeextattr(pcc,
   1024   1.1  pooka 			    opcookie, );
   1025   1.1  pooka 			break;
   1026   1.1  pooka 		}
   1027   1.1  pooka 
   1028   1.1  pooka 		case PUFFS_VN_GETEXTATTR:
   1029   1.1  pooka 		{
   1030   1.1  pooka 			struct puffs_vnreq_getextattr *auxt = auxbuf;
   1031   1.1  pooka 			if (pops->puffs_getextattr == NULL) {
   1032   1.1  pooka 				error = 0;
   1033   1.1  pooka 				break;
   1034   1.1  pooka 			}
   1035   1.1  pooka 
   1036   1.1  pooka 			error = pops->puffs_getextattr(pcc,
   1037   1.1  pooka 			    opcookie, );
   1038   1.1  pooka 			break;
   1039   1.1  pooka 		}
   1040   1.1  pooka 
   1041   1.1  pooka 		case PUFFS_VN_LISTEXTATTR:
   1042   1.1  pooka 		{
   1043   1.1  pooka 			struct puffs_vnreq_listextattr *auxt = auxbuf;
   1044   1.1  pooka 			if (pops->puffs_listextattr == NULL) {
   1045   1.1  pooka 				error = 0;
   1046   1.1  pooka 				break;
   1047   1.1  pooka 			}
   1048   1.1  pooka 
   1049   1.1  pooka 			error = pops->puffs_listextattr(pcc,
   1050   1.1  pooka 			    opcookie, );
   1051   1.1  pooka 			break;
   1052   1.1  pooka 		}
   1053   1.1  pooka 
   1054   1.1  pooka 		case PUFFS_VN_OPENEXTATTR:
   1055   1.1  pooka 		{
   1056   1.1  pooka 			struct puffs_vnreq_openextattr *auxt = auxbuf;
   1057   1.1  pooka 			if (pops->puffs_openextattr == NULL) {
   1058   1.1  pooka 				error = 0;
   1059   1.1  pooka 				break;
   1060   1.1  pooka 			}
   1061   1.1  pooka 
   1062   1.1  pooka 			error = pops->puffs_openextattr(pcc,
   1063   1.1  pooka 			    opcookie, );
   1064   1.1  pooka 			break;
   1065   1.1  pooka 		}
   1066   1.1  pooka 
   1067   1.1  pooka 		case PUFFS_VN_DELETEEXTATTR:
   1068   1.1  pooka 		{
   1069   1.1  pooka 			struct puffs_vnreq_deleteextattr *auxt = auxbuf;
   1070   1.1  pooka 			if (pops->puffs_deleteextattr == NULL) {
   1071   1.1  pooka 				error = 0;
   1072   1.1  pooka 				break;
   1073   1.1  pooka 			}
   1074   1.1  pooka 
   1075   1.1  pooka 			error = pops->puffs_deleteextattr(pcc,
   1076   1.1  pooka 			    opcookie, );
   1077   1.1  pooka 			break;
   1078   1.1  pooka 		}
   1079   1.1  pooka 
   1080   1.1  pooka 		case PUFFS_VN_SETEXTATTR:
   1081   1.1  pooka 		{
   1082   1.1  pooka 			struct puffs_vnreq_setextattr *auxt = auxbuf;
   1083   1.1  pooka 			if (pops->puffs_setextattr == NULL) {
   1084   1.1  pooka 				error = 0;
   1085   1.1  pooka 				break;
   1086   1.1  pooka 			}
   1087   1.1  pooka 
   1088   1.1  pooka 			error = pops->puffs_setextattr(pcc,
   1089   1.1  pooka 			    opcookie, );
   1090   1.1  pooka 			break;
   1091   1.1  pooka 		}
   1092   1.1  pooka 
   1093   1.1  pooka #endif
   1094