Home | History | Annotate | Line # | Download | only in libpuffs
dispatcher.c revision 1.8
      1  1.8  pooka /*	$NetBSD: dispatcher.c,v 1.8 2007/07/01 17:22:18 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.8  pooka __RCSID("$NetBSD: dispatcher.c,v 1.8 2007/07/01 17:22:18 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.1  pooka 
    194  1.1  pooka 			error = pops->puffs_fs_fhtonode(pcc, auxt->pvfsr_data,
    195  1.1  pooka 			    auxt->pvfsr_dsize, &auxt->pvfsr_fhcookie,
    196  1.1  pooka 			    &auxt->pvfsr_vtype, &auxt->pvfsr_size,
    197  1.1  pooka 			    &auxt->pvfsr_rdev);
    198  1.1  pooka 
    199  1.1  pooka 			break;
    200  1.1  pooka 		}
    201  1.1  pooka 
    202  1.1  pooka 		case PUFFS_VFS_VPTOFH:
    203  1.1  pooka 		{
    204  1.1  pooka 			struct puffs_vfsreq_nodetofh *auxt = auxbuf;
    205  1.1  pooka 
    206  1.1  pooka 			error = pops->puffs_fs_nodetofh(pcc,
    207  1.1  pooka 			    auxt->pvfsr_fhcookie, auxt->pvfsr_data,
    208  1.1  pooka 			    &auxt->pvfsr_dsize);
    209  1.1  pooka 
    210  1.1  pooka 			break;
    211  1.1  pooka 		}
    212  1.1  pooka 
    213  1.1  pooka 		case PUFFS_VFS_SUSPEND:
    214  1.1  pooka 		{
    215  1.1  pooka 			struct puffs_vfsreq_suspend *auxt = auxbuf;
    216  1.1  pooka 
    217  1.1  pooka 			error = 0;
    218  1.1  pooka 			if (pops->puffs_fs_suspend == NULL)
    219  1.1  pooka 				break;
    220  1.1  pooka 
    221  1.1  pooka 			pops->puffs_fs_suspend(pcc, auxt->pvfsr_status);
    222  1.1  pooka 			break;
    223  1.1  pooka 		}
    224  1.1  pooka 
    225  1.1  pooka 		default:
    226  1.1  pooka 			/*
    227  1.1  pooka 			 * I guess the kernel sees this one coming
    228  1.1  pooka 			 */
    229  1.1  pooka 			error = EINVAL;
    230  1.1  pooka 			break;
    231  1.1  pooka 		}
    232  1.1  pooka 
    233  1.1  pooka 	/* XXX: audit return values */
    234  1.1  pooka 	/* XXX: sync with kernel */
    235  1.1  pooka 	} else if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) {
    236  1.1  pooka 		switch (preq->preq_optype) {
    237  1.1  pooka 		case PUFFS_VN_LOOKUP:
    238  1.1  pooka 		{
    239  1.1  pooka 			struct puffs_vnreq_lookup *auxt = auxbuf;
    240  1.1  pooka 			struct puffs_cn pcn;
    241  1.1  pooka 
    242  1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    243  1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    244  1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    245  1.7  pooka 
    246  1.1  pooka 			if (buildpath) {
    247  1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    248  1.1  pooka 				if (error)
    249  1.1  pooka 					break;
    250  1.1  pooka 			}
    251  1.1  pooka 
    252  1.1  pooka 			/* lookup *must* be present */
    253  1.1  pooka 			error = pops->puffs_node_lookup(pcc, opcookie,
    254  1.1  pooka 			    &auxt->pvnr_newnode, &auxt->pvnr_vtype,
    255  1.1  pooka 			    &auxt->pvnr_size, &auxt->pvnr_rdev, &pcn);
    256  1.1  pooka 
    257  1.1  pooka 			if (buildpath) {
    258  1.1  pooka 				if (error) {
    259  1.1  pooka 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
    260  1.1  pooka 				} else {
    261  1.1  pooka 					struct puffs_node *pn;
    262  1.1  pooka 
    263  1.1  pooka 					/*
    264  1.1  pooka 					 * did we get a new node or a
    265  1.1  pooka 					 * recycled node?
    266  1.1  pooka 					 */
    267  1.1  pooka 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
    268  1.1  pooka 					if (pn->pn_po.po_path == NULL)
    269  1.1  pooka 						pn->pn_po = pcn.pcn_po_full;
    270  1.1  pooka 					else
    271  1.1  pooka 						pu->pu_pathfree(pu,
    272  1.1  pooka 						    &pcn.pcn_po_full);
    273  1.1  pooka 				}
    274  1.1  pooka 			}
    275  1.1  pooka 
    276  1.1  pooka 			break;
    277  1.1  pooka 		}
    278  1.1  pooka 
    279  1.1  pooka 		case PUFFS_VN_CREATE:
    280  1.1  pooka 		{
    281  1.1  pooka 			struct puffs_vnreq_create *auxt = auxbuf;
    282  1.1  pooka 			struct puffs_cn pcn;
    283  1.1  pooka 			if (pops->puffs_node_create == NULL) {
    284  1.1  pooka 				error = 0;
    285  1.1  pooka 				break;
    286  1.1  pooka 			}
    287  1.1  pooka 
    288  1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    289  1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    290  1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    291  1.7  pooka 
    292  1.1  pooka 			if (buildpath) {
    293  1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    294  1.1  pooka 				if (error)
    295  1.1  pooka 					break;
    296  1.1  pooka 			}
    297  1.1  pooka 
    298  1.1  pooka 			error = pops->puffs_node_create(pcc,
    299  1.1  pooka 			    opcookie, &auxt->pvnr_newnode,
    300  1.1  pooka 			    &pcn, &auxt->pvnr_va);
    301  1.1  pooka 
    302  1.1  pooka 			if (buildpath) {
    303  1.1  pooka 				if (error) {
    304  1.1  pooka 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
    305  1.1  pooka 				} else {
    306  1.1  pooka 					struct puffs_node *pn;
    307  1.1  pooka 
    308  1.1  pooka 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
    309  1.1  pooka 					pn->pn_po = pcn.pcn_po_full;
    310  1.1  pooka 				}
    311  1.1  pooka 			}
    312  1.1  pooka 
    313  1.1  pooka 			break;
    314  1.1  pooka 		}
    315  1.1  pooka 
    316  1.1  pooka 		case PUFFS_VN_MKNOD:
    317  1.1  pooka 		{
    318  1.1  pooka 			struct puffs_vnreq_mknod *auxt = auxbuf;
    319  1.1  pooka 			struct puffs_cn pcn;
    320  1.1  pooka 			if (pops->puffs_node_mknod == NULL) {
    321  1.1  pooka 				error = 0;
    322  1.1  pooka 				break;
    323  1.1  pooka 			}
    324  1.1  pooka 
    325  1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    326  1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    327  1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    328  1.7  pooka 
    329  1.1  pooka 			if (buildpath) {
    330  1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    331  1.1  pooka 				if (error)
    332  1.1  pooka 					break;
    333  1.1  pooka 			}
    334  1.1  pooka 
    335  1.1  pooka 			error = pops->puffs_node_mknod(pcc,
    336  1.1  pooka 			    opcookie, &auxt->pvnr_newnode,
    337  1.1  pooka 			    &pcn, &auxt->pvnr_va);
    338  1.1  pooka 
    339  1.1  pooka 			if (buildpath) {
    340  1.1  pooka 				if (error) {
    341  1.1  pooka 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
    342  1.1  pooka 				} else {
    343  1.1  pooka 					struct puffs_node *pn;
    344  1.1  pooka 
    345  1.1  pooka 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
    346  1.1  pooka 					pn->pn_po = pcn.pcn_po_full;
    347  1.1  pooka 				}
    348  1.1  pooka 			}
    349  1.1  pooka 
    350  1.1  pooka 			break;
    351  1.1  pooka 		}
    352  1.1  pooka 
    353  1.1  pooka 		case PUFFS_VN_OPEN:
    354  1.1  pooka 		{
    355  1.1  pooka 			struct puffs_vnreq_open *auxt = auxbuf;
    356  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    357  1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    358  1.7  pooka 
    359  1.1  pooka 			if (pops->puffs_node_open == NULL) {
    360  1.1  pooka 				error = 0;
    361  1.1  pooka 				break;
    362  1.1  pooka 			}
    363  1.1  pooka 
    364  1.1  pooka 			error = pops->puffs_node_open(pcc,
    365  1.8  pooka 			    opcookie, auxt->pvnr_mode, pcr, pcid);
    366  1.1  pooka 			break;
    367  1.1  pooka 		}
    368  1.1  pooka 
    369  1.1  pooka 		case PUFFS_VN_CLOSE:
    370  1.1  pooka 		{
    371  1.1  pooka 			struct puffs_vnreq_close *auxt = auxbuf;
    372  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    373  1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    374  1.8  pooka 
    375  1.7  pooka 
    376  1.1  pooka 			if (pops->puffs_node_close == NULL) {
    377  1.1  pooka 				error = 0;
    378  1.1  pooka 				break;
    379  1.1  pooka 			}
    380  1.1  pooka 
    381  1.1  pooka 			error = pops->puffs_node_close(pcc,
    382  1.8  pooka 			    opcookie, auxt->pvnr_fflag, pcr, pcid);
    383  1.1  pooka 			break;
    384  1.1  pooka 		}
    385  1.1  pooka 
    386  1.1  pooka 		case PUFFS_VN_ACCESS:
    387  1.1  pooka 		{
    388  1.1  pooka 			struct puffs_vnreq_access *auxt = auxbuf;
    389  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    390  1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    391  1.8  pooka 
    392  1.7  pooka 
    393  1.1  pooka 			if (pops->puffs_node_access == NULL) {
    394  1.1  pooka 				error = 0;
    395  1.1  pooka 				break;
    396  1.1  pooka 			}
    397  1.1  pooka 
    398  1.1  pooka 			error = pops->puffs_node_access(pcc,
    399  1.8  pooka 			    opcookie, auxt->pvnr_mode, pcr, pcid);
    400  1.1  pooka 			break;
    401  1.1  pooka 		}
    402  1.1  pooka 
    403  1.1  pooka 		case PUFFS_VN_GETATTR:
    404  1.1  pooka 		{
    405  1.1  pooka 			struct puffs_vnreq_getattr *auxt = auxbuf;
    406  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    407  1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    408  1.8  pooka 
    409  1.7  pooka 
    410  1.1  pooka 			if (pops->puffs_node_getattr == NULL) {
    411  1.1  pooka 				error = EOPNOTSUPP;
    412  1.1  pooka 				break;
    413  1.1  pooka 			}
    414  1.1  pooka 
    415  1.1  pooka 			error = pops->puffs_node_getattr(pcc,
    416  1.8  pooka 			    opcookie, &auxt->pvnr_va, pcr, pcid);
    417  1.1  pooka 			break;
    418  1.1  pooka 		}
    419  1.1  pooka 
    420  1.1  pooka 		case PUFFS_VN_SETATTR:
    421  1.1  pooka 		{
    422  1.1  pooka 			struct puffs_vnreq_setattr *auxt = auxbuf;
    423  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    424  1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    425  1.8  pooka 
    426  1.7  pooka 
    427  1.1  pooka 			if (pops->puffs_node_setattr == NULL) {
    428  1.1  pooka 				error = EOPNOTSUPP;
    429  1.1  pooka 				break;
    430  1.1  pooka 			}
    431  1.1  pooka 
    432  1.1  pooka 			error = pops->puffs_node_setattr(pcc,
    433  1.8  pooka 			    opcookie, &auxt->pvnr_va, pcr, pcid);
    434  1.1  pooka 			break;
    435  1.1  pooka 		}
    436  1.1  pooka 
    437  1.1  pooka 		case PUFFS_VN_MMAP:
    438  1.1  pooka 		{
    439  1.1  pooka 			struct puffs_vnreq_mmap *auxt = auxbuf;
    440  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    441  1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    442  1.8  pooka 
    443  1.7  pooka 
    444  1.1  pooka 			if (pops->puffs_node_mmap == NULL) {
    445  1.1  pooka 				error = 0;
    446  1.1  pooka 				break;
    447  1.1  pooka 			}
    448  1.1  pooka 
    449  1.1  pooka 			error = pops->puffs_node_mmap(pcc,
    450  1.8  pooka 			    opcookie, auxt->pvnr_fflags, pcr, pcid);
    451  1.1  pooka 			break;
    452  1.1  pooka 		}
    453  1.1  pooka 
    454  1.1  pooka 		case PUFFS_VN_FSYNC:
    455  1.1  pooka 		{
    456  1.1  pooka 			struct puffs_vnreq_fsync *auxt = auxbuf;
    457  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    458  1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    459  1.8  pooka 
    460  1.7  pooka 
    461  1.1  pooka 			if (pops->puffs_node_fsync == NULL) {
    462  1.1  pooka 				error = 0;
    463  1.1  pooka 				break;
    464  1.1  pooka 			}
    465  1.1  pooka 
    466  1.7  pooka 			error = pops->puffs_node_fsync(pcc, opcookie, pcr,
    467  1.1  pooka 			    auxt->pvnr_flags, auxt->pvnr_offlo,
    468  1.8  pooka 			    auxt->pvnr_offhi, pcid);
    469  1.1  pooka 			break;
    470  1.1  pooka 		}
    471  1.1  pooka 
    472  1.1  pooka 		case PUFFS_VN_SEEK:
    473  1.1  pooka 		{
    474  1.1  pooka 			struct puffs_vnreq_seek *auxt = auxbuf;
    475  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    476  1.7  pooka 
    477  1.1  pooka 			if (pops->puffs_node_seek == NULL) {
    478  1.1  pooka 				error = 0;
    479  1.1  pooka 				break;
    480  1.1  pooka 			}
    481  1.1  pooka 
    482  1.1  pooka 			error = pops->puffs_node_seek(pcc,
    483  1.1  pooka 			    opcookie, auxt->pvnr_oldoff,
    484  1.7  pooka 			    auxt->pvnr_newoff, pcr);
    485  1.1  pooka 			break;
    486  1.1  pooka 		}
    487  1.1  pooka 
    488  1.1  pooka 		case PUFFS_VN_REMOVE:
    489  1.1  pooka 		{
    490  1.1  pooka 			struct puffs_vnreq_remove *auxt = auxbuf;
    491  1.1  pooka 			struct puffs_cn pcn;
    492  1.1  pooka 			if (pops->puffs_node_remove == NULL) {
    493  1.1  pooka 				error = 0;
    494  1.1  pooka 				break;
    495  1.1  pooka 			}
    496  1.1  pooka 
    497  1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    498  1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    499  1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    500  1.1  pooka 
    501  1.1  pooka 			error = pops->puffs_node_remove(pcc,
    502  1.1  pooka 			    opcookie, auxt->pvnr_cookie_targ, &pcn);
    503  1.1  pooka 			break;
    504  1.1  pooka 		}
    505  1.1  pooka 
    506  1.1  pooka 		case PUFFS_VN_LINK:
    507  1.1  pooka 		{
    508  1.1  pooka 			struct puffs_vnreq_link *auxt = auxbuf;
    509  1.1  pooka 			struct puffs_cn pcn;
    510  1.1  pooka 			if (pops->puffs_node_link == NULL) {
    511  1.1  pooka 				error = 0;
    512  1.1  pooka 				break;
    513  1.1  pooka 			}
    514  1.1  pooka 
    515  1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    516  1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    517  1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    518  1.7  pooka 
    519  1.1  pooka 			if (buildpath) {
    520  1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    521  1.1  pooka 				if (error)
    522  1.1  pooka 					break;
    523  1.1  pooka 			}
    524  1.1  pooka 
    525  1.1  pooka 			error = pops->puffs_node_link(pcc,
    526  1.1  pooka 			    opcookie, auxt->pvnr_cookie_targ, &pcn);
    527  1.1  pooka 			if (buildpath)
    528  1.1  pooka 				pu->pu_pathfree(pu, &pcn.pcn_po_full);
    529  1.1  pooka 
    530  1.1  pooka 			break;
    531  1.1  pooka 		}
    532  1.1  pooka 
    533  1.1  pooka 		case PUFFS_VN_RENAME:
    534  1.1  pooka 		{
    535  1.1  pooka 			struct puffs_vnreq_rename *auxt = auxbuf;
    536  1.1  pooka 			struct puffs_cn pcn_src, pcn_targ;
    537  1.1  pooka 			struct puffs_node *pn_src;
    538  1.1  pooka 
    539  1.1  pooka 			if (pops->puffs_node_rename == NULL) {
    540  1.1  pooka 				error = 0;
    541  1.1  pooka 				break;
    542  1.1  pooka 			}
    543  1.1  pooka 
    544  1.1  pooka 			pcn_src.pcn_pkcnp = &auxt->pvnr_cn_src;
    545  1.7  pooka 			PUFFS_KCREDTOCRED(pcn_src.pcn_cred,
    546  1.7  pooka 			    &auxt->pvnr_cn_src_cred);
    547  1.8  pooka 			PUFFS_KCIDTOCID(pcn_src.pcn_cid,
    548  1.8  pooka 			    &auxt->pvnr_cn_src_cid);
    549  1.8  pooka 
    550  1.1  pooka 			pcn_targ.pcn_pkcnp = &auxt->pvnr_cn_targ;
    551  1.7  pooka 			PUFFS_KCREDTOCRED(pcn_targ.pcn_cred,
    552  1.7  pooka 			    &auxt->pvnr_cn_targ_cred);
    553  1.8  pooka 			PUFFS_KCIDTOCID(pcn_targ.pcn_cid,
    554  1.8  pooka 			    &auxt->pvnr_cn_targ_cid);
    555  1.7  pooka 
    556  1.1  pooka 			if (buildpath) {
    557  1.1  pooka 				pn_src = auxt->pvnr_cookie_src;
    558  1.1  pooka 				pcn_src.pcn_po_full = pn_src->pn_po;
    559  1.1  pooka 
    560  1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn_targ,
    561  1.1  pooka 				    auxt->pvnr_cookie_targdir);
    562  1.1  pooka 				if (error)
    563  1.1  pooka 					break;
    564  1.1  pooka 			}
    565  1.1  pooka 
    566  1.1  pooka 			error = pops->puffs_node_rename(pcc,
    567  1.1  pooka 			    opcookie, auxt->pvnr_cookie_src,
    568  1.1  pooka 			    &pcn_src, auxt->pvnr_cookie_targdir,
    569  1.1  pooka 			    auxt->pvnr_cookie_targ, &pcn_targ);
    570  1.1  pooka 
    571  1.1  pooka 			if (buildpath) {
    572  1.1  pooka 				if (error) {
    573  1.1  pooka 					pu->pu_pathfree(pu,
    574  1.1  pooka 					    &pcn_targ.pcn_po_full);
    575  1.1  pooka 				} else {
    576  1.1  pooka 					struct puffs_pathinfo pi;
    577  1.1  pooka 					struct puffs_pathobj po_old;
    578  1.1  pooka 
    579  1.1  pooka 					/* handle this node */
    580  1.1  pooka 					po_old = pn_src->pn_po;
    581  1.1  pooka 					pn_src->pn_po = pcn_targ.pcn_po_full;
    582  1.1  pooka 
    583  1.1  pooka 					if (pn_src->pn_va.va_type != VDIR) {
    584  1.1  pooka 						pu->pu_pathfree(pu, &po_old);
    585  1.1  pooka 						break;
    586  1.1  pooka 					}
    587  1.1  pooka 
    588  1.1  pooka 					/* handle all child nodes for DIRs */
    589  1.1  pooka 					pi.pi_old = &pcn_src.pcn_po_full;
    590  1.1  pooka 					pi.pi_new = &pcn_targ.pcn_po_full;
    591  1.1  pooka 
    592  1.1  pooka 					if (puffs_pn_nodewalk(pu,
    593  1.1  pooka 					    puffs_path_prefixadj, &pi) != NULL)
    594  1.1  pooka 						error = ENOMEM;
    595  1.1  pooka 					pu->pu_pathfree(pu, &po_old);
    596  1.1  pooka 				}
    597  1.1  pooka 			}
    598  1.1  pooka 			break;
    599  1.1  pooka 		}
    600  1.1  pooka 
    601  1.1  pooka 		case PUFFS_VN_MKDIR:
    602  1.1  pooka 		{
    603  1.1  pooka 			struct puffs_vnreq_mkdir *auxt = auxbuf;
    604  1.1  pooka 			struct puffs_cn pcn;
    605  1.1  pooka 			if (pops->puffs_node_mkdir == NULL) {
    606  1.1  pooka 				error = 0;
    607  1.1  pooka 				break;
    608  1.1  pooka 			}
    609  1.1  pooka 
    610  1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    611  1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    612  1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    613  1.7  pooka 
    614  1.1  pooka 			if (buildpath) {
    615  1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    616  1.1  pooka 				if (error)
    617  1.1  pooka 					break;
    618  1.1  pooka 			}
    619  1.1  pooka 
    620  1.1  pooka 			error = pops->puffs_node_mkdir(pcc,
    621  1.1  pooka 			    opcookie, &auxt->pvnr_newnode,
    622  1.1  pooka 			    &pcn, &auxt->pvnr_va);
    623  1.1  pooka 
    624  1.1  pooka 			if (buildpath) {
    625  1.1  pooka 				if (error) {
    626  1.1  pooka 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
    627  1.1  pooka 				} else {
    628  1.1  pooka 					struct puffs_node *pn;
    629  1.1  pooka 
    630  1.1  pooka 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
    631  1.1  pooka 					pn->pn_po = pcn.pcn_po_full;
    632  1.1  pooka 				}
    633  1.1  pooka 			}
    634  1.1  pooka 
    635  1.1  pooka 			break;
    636  1.1  pooka 		}
    637  1.1  pooka 
    638  1.1  pooka 		case PUFFS_VN_RMDIR:
    639  1.1  pooka 		{
    640  1.1  pooka 			struct puffs_vnreq_rmdir *auxt = auxbuf;
    641  1.1  pooka 			struct puffs_cn pcn;
    642  1.1  pooka 			if (pops->puffs_node_rmdir == NULL) {
    643  1.1  pooka 				error = 0;
    644  1.1  pooka 				break;
    645  1.1  pooka 			}
    646  1.1  pooka 
    647  1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    648  1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    649  1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    650  1.1  pooka 
    651  1.1  pooka 			error = pops->puffs_node_rmdir(pcc,
    652  1.1  pooka 			    opcookie, auxt->pvnr_cookie_targ, &pcn);
    653  1.1  pooka 			break;
    654  1.1  pooka 		}
    655  1.1  pooka 
    656  1.1  pooka 		case PUFFS_VN_SYMLINK:
    657  1.1  pooka 		{
    658  1.1  pooka 			struct puffs_vnreq_symlink *auxt = auxbuf;
    659  1.1  pooka 			struct puffs_cn pcn;
    660  1.1  pooka 			if (pops->puffs_node_symlink == NULL) {
    661  1.1  pooka 				error = 0;
    662  1.1  pooka 				break;
    663  1.1  pooka 			}
    664  1.1  pooka 
    665  1.1  pooka 			pcn.pcn_pkcnp = &auxt->pvnr_cn;
    666  1.7  pooka 			PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
    667  1.8  pooka 			PUFFS_KCIDTOCID(pcn.pcn_cid, &auxt->pvnr_cn_cid);
    668  1.7  pooka 
    669  1.1  pooka 			if (buildpath) {
    670  1.1  pooka 				error = puffs_path_pcnbuild(pu, &pcn, opcookie);
    671  1.1  pooka 				if (error)
    672  1.1  pooka 					break;
    673  1.1  pooka 			}
    674  1.1  pooka 
    675  1.1  pooka 			error = pops->puffs_node_symlink(pcc,
    676  1.1  pooka 			    opcookie, &auxt->pvnr_newnode,
    677  1.1  pooka 			    &pcn, &auxt->pvnr_va, auxt->pvnr_link);
    678  1.1  pooka 
    679  1.1  pooka 			if (buildpath) {
    680  1.1  pooka 				if (error) {
    681  1.1  pooka 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
    682  1.1  pooka 				} else {
    683  1.1  pooka 					struct puffs_node *pn;
    684  1.1  pooka 
    685  1.1  pooka 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
    686  1.1  pooka 					pn->pn_po = pcn.pcn_po_full;
    687  1.1  pooka 				}
    688  1.1  pooka 			}
    689  1.1  pooka 
    690  1.1  pooka 			break;
    691  1.1  pooka 		}
    692  1.1  pooka 
    693  1.1  pooka 		case PUFFS_VN_READDIR:
    694  1.1  pooka 		{
    695  1.1  pooka 			struct puffs_vnreq_readdir *auxt = auxbuf;
    696  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    697  1.1  pooka 			struct dirent *dent;
    698  1.1  pooka 			off_t *cookies;
    699  1.1  pooka 			size_t res, origcookies;
    700  1.1  pooka 
    701  1.1  pooka 			if (pops->puffs_node_readdir == NULL) {
    702  1.1  pooka 				error = 0;
    703  1.1  pooka 				break;
    704  1.1  pooka 			}
    705  1.1  pooka 
    706  1.1  pooka 			if (auxt->pvnr_ncookies) {
    707  1.1  pooka 				/* LINTED: pvnr_data is __aligned() */
    708  1.1  pooka 				cookies = (off_t *)auxt->pvnr_data;
    709  1.1  pooka 				origcookies = auxt->pvnr_ncookies;
    710  1.1  pooka 			} else {
    711  1.1  pooka 				cookies = NULL;
    712  1.1  pooka 				origcookies = 0;
    713  1.1  pooka 			}
    714  1.1  pooka 			/* LINTED: dentoff is aligned in the kernel */
    715  1.1  pooka 			dent = (struct dirent *)
    716  1.1  pooka 			    (auxt->pvnr_data + auxt->pvnr_dentoff);
    717  1.1  pooka 
    718  1.1  pooka 			res = auxt->pvnr_resid;
    719  1.1  pooka 			error = pops->puffs_node_readdir(pcc,
    720  1.1  pooka 			    opcookie, dent, &auxt->pvnr_offset,
    721  1.7  pooka 			    &auxt->pvnr_resid, pcr, &auxt->pvnr_eofflag,
    722  1.7  pooka 			    cookies, &auxt->pvnr_ncookies);
    723  1.1  pooka 
    724  1.1  pooka 			/* much easier to track non-working NFS */
    725  1.1  pooka 			assert(auxt->pvnr_ncookies <= origcookies);
    726  1.1  pooka 
    727  1.1  pooka 			/* need to move a bit more */
    728  1.1  pooka 			preq->preq_buflen = sizeof(struct puffs_vnreq_readdir)
    729  1.1  pooka 			    + auxt->pvnr_dentoff + (res - auxt->pvnr_resid);
    730  1.1  pooka 			break;
    731  1.1  pooka 		}
    732  1.1  pooka 
    733  1.1  pooka 		case PUFFS_VN_READLINK:
    734  1.1  pooka 		{
    735  1.1  pooka 			struct puffs_vnreq_readlink *auxt = auxbuf;
    736  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    737  1.7  pooka 
    738  1.1  pooka 			if (pops->puffs_node_readlink == NULL) {
    739  1.1  pooka 				error = EOPNOTSUPP;
    740  1.1  pooka 				break;
    741  1.1  pooka 			}
    742  1.1  pooka 
    743  1.7  pooka 			/*LINTED*/
    744  1.7  pooka 			error = pops->puffs_node_readlink(pcc, opcookie, pcr,
    745  1.1  pooka 			    auxt->pvnr_link, &auxt->pvnr_linklen);
    746  1.1  pooka 			break;
    747  1.1  pooka 		}
    748  1.1  pooka 
    749  1.1  pooka 		case PUFFS_VN_RECLAIM:
    750  1.1  pooka 		{
    751  1.1  pooka 			struct puffs_vnreq_reclaim *auxt = auxbuf;
    752  1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    753  1.8  pooka 
    754  1.1  pooka 			if (pops->puffs_node_reclaim == NULL) {
    755  1.1  pooka 				error = 0;
    756  1.1  pooka 				break;
    757  1.1  pooka 			}
    758  1.1  pooka 
    759  1.8  pooka 			error = pops->puffs_node_reclaim(pcc, opcookie, pcid);
    760  1.1  pooka 			break;
    761  1.1  pooka 		}
    762  1.1  pooka 
    763  1.1  pooka 		case PUFFS_VN_INACTIVE:
    764  1.1  pooka 		{
    765  1.1  pooka 			struct puffs_vnreq_inactive *auxt = auxbuf;
    766  1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    767  1.8  pooka 
    768  1.1  pooka 			if (pops->puffs_node_inactive == NULL) {
    769  1.1  pooka 				error = EOPNOTSUPP;
    770  1.1  pooka 				break;
    771  1.1  pooka 			}
    772  1.1  pooka 
    773  1.5  pooka 			auxt->pvnr_backendrefs = 1; /* safe default */
    774  1.1  pooka 			error = pops->puffs_node_inactive(pcc,
    775  1.8  pooka 			    opcookie, pcid, &auxt->pvnr_backendrefs);
    776  1.1  pooka 			break;
    777  1.1  pooka 		}
    778  1.1  pooka 
    779  1.1  pooka 		case PUFFS_VN_PATHCONF:
    780  1.1  pooka 		{
    781  1.1  pooka 			struct puffs_vnreq_pathconf *auxt = auxbuf;
    782  1.1  pooka 			if (pops->puffs_node_pathconf == NULL) {
    783  1.1  pooka 				error = 0;
    784  1.1  pooka 				break;
    785  1.1  pooka 			}
    786  1.1  pooka 
    787  1.1  pooka 			error = pops->puffs_node_pathconf(pcc,
    788  1.1  pooka 			    opcookie, auxt->pvnr_name,
    789  1.1  pooka 			    &auxt->pvnr_retval);
    790  1.1  pooka 			break;
    791  1.1  pooka 		}
    792  1.1  pooka 
    793  1.1  pooka 		case PUFFS_VN_ADVLOCK:
    794  1.1  pooka 		{
    795  1.1  pooka 			struct puffs_vnreq_advlock *auxt = auxbuf;
    796  1.1  pooka 			if (pops->puffs_node_advlock == NULL) {
    797  1.1  pooka 				error = 0;
    798  1.1  pooka 				break;
    799  1.1  pooka 			}
    800  1.1  pooka 
    801  1.1  pooka 			error = pops->puffs_node_advlock(pcc,
    802  1.1  pooka 			    opcookie, auxt->pvnr_id, auxt->pvnr_op,
    803  1.1  pooka 			    &auxt->pvnr_fl, auxt->pvnr_flags);
    804  1.1  pooka 			break;
    805  1.1  pooka 		}
    806  1.1  pooka 
    807  1.1  pooka 		case PUFFS_VN_PRINT:
    808  1.1  pooka 		{
    809  1.1  pooka 			if (pops->puffs_node_print == NULL) {
    810  1.1  pooka 				error = 0;
    811  1.1  pooka 				break;
    812  1.1  pooka 			}
    813  1.1  pooka 
    814  1.1  pooka 			error = pops->puffs_node_print(pcc,
    815  1.1  pooka 			    opcookie);
    816  1.1  pooka 			break;
    817  1.1  pooka 		}
    818  1.1  pooka 
    819  1.1  pooka 		case PUFFS_VN_READ:
    820  1.1  pooka 		{
    821  1.1  pooka 			struct puffs_vnreq_read *auxt = auxbuf;
    822  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    823  1.1  pooka 			size_t res;
    824  1.1  pooka 
    825  1.1  pooka 			if (pops->puffs_node_read == NULL) {
    826  1.1  pooka 				error = EIO;
    827  1.1  pooka 				break;
    828  1.1  pooka 			}
    829  1.1  pooka 
    830  1.1  pooka 			res = auxt->pvnr_resid;
    831  1.1  pooka 			error = pops->puffs_node_read(pcc,
    832  1.1  pooka 			    opcookie, auxt->pvnr_data,
    833  1.1  pooka 			    auxt->pvnr_offset, &auxt->pvnr_resid,
    834  1.7  pooka 			    pcr, auxt->pvnr_ioflag);
    835  1.1  pooka 
    836  1.1  pooka 			/* need to move a bit more */
    837  1.1  pooka 			preq->preq_buflen = sizeof(struct puffs_vnreq_read)
    838  1.1  pooka 			    + (res - auxt->pvnr_resid);
    839  1.1  pooka 			break;
    840  1.1  pooka 		}
    841  1.1  pooka 
    842  1.1  pooka 		case PUFFS_VN_WRITE:
    843  1.1  pooka 		{
    844  1.1  pooka 			struct puffs_vnreq_write *auxt = auxbuf;
    845  1.7  pooka 			PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
    846  1.1  pooka 
    847  1.1  pooka 			if (pops->puffs_node_write == NULL) {
    848  1.1  pooka 				error = EIO;
    849  1.1  pooka 				break;
    850  1.1  pooka 			}
    851  1.1  pooka 
    852  1.1  pooka 			error = pops->puffs_node_write(pcc,
    853  1.1  pooka 			    opcookie, auxt->pvnr_data,
    854  1.1  pooka 			    auxt->pvnr_offset, &auxt->pvnr_resid,
    855  1.7  pooka 			    pcr, auxt->pvnr_ioflag);
    856  1.1  pooka 
    857  1.1  pooka 			/* don't need to move data back to the kernel */
    858  1.1  pooka 			preq->preq_buflen = sizeof(struct puffs_vnreq_write);
    859  1.1  pooka 			break;
    860  1.1  pooka 		}
    861  1.1  pooka 
    862  1.4  pooka 		case PUFFS_VN_POLL:
    863  1.4  pooka 		{
    864  1.4  pooka 			struct puffs_vnreq_poll *auxt = auxbuf;
    865  1.8  pooka 			PUFFS_MAKECID(pcid, &auxt->pvnr_cid);
    866  1.8  pooka 
    867  1.4  pooka 			if (pops->puffs_node_poll == NULL) {
    868  1.4  pooka 				error = 0;
    869  1.4  pooka 
    870  1.4  pooka 				/* emulate genfs_poll() */
    871  1.4  pooka 				auxt->pvnr_events &= (POLLIN | POLLOUT
    872  1.4  pooka 						    | POLLRDNORM | POLLWRNORM);
    873  1.4  pooka 
    874  1.4  pooka 				break;
    875  1.4  pooka 			}
    876  1.4  pooka 
    877  1.4  pooka 			error = pops->puffs_node_poll(pcc,
    878  1.8  pooka 			    opcookie, &auxt->pvnr_events, pcid);
    879  1.4  pooka 			break;
    880  1.4  pooka 		}
    881  1.4  pooka 
    882  1.1  pooka /* holy bitrot, ryydman! */
    883  1.1  pooka #if 0
    884  1.1  pooka 		case PUFFS_VN_IOCTL:
    885  1.1  pooka 			error = pops->puffs_node_ioctl1(pcc, opcookie,
    886  1.1  pooka 			     (struct puffs_vnreq_ioctl *)auxbuf, &pop);
    887  1.1  pooka 			if (error != 0)
    888  1.1  pooka 				break;
    889  1.1  pooka 			pop.pso_reqid = preq->preq_id;
    890  1.1  pooka 
    891  1.1  pooka 			/* let the kernel do it's intermediate duty */
    892  1.1  pooka 			error = ioctl(pu->pu_kargs.pa_fd, PUFFSSIZEOP, &pop);
    893  1.1  pooka 			/*
    894  1.1  pooka 			 * XXX: I don't actually know what the correct
    895  1.1  pooka 			 * thing to do in case of an error is, so I'll
    896  1.1  pooka 			 * just ignore it for the time being.
    897  1.1  pooka 			 */
    898  1.1  pooka 			error = pops->puffs_node_ioctl2(pcc, opcookie,
    899  1.1  pooka 			    (struct puffs_vnreq_ioctl *)auxbuf, &pop);
    900  1.1  pooka 			break;
    901  1.1  pooka 
    902  1.1  pooka 		case PUFFS_VN_FCNTL:
    903  1.1  pooka 			error = pops->puffs_node_fcntl1(pcc, opcookie,
    904  1.1  pooka 			     (struct puffs_vnreq_fcntl *)auxbuf, &pop);
    905  1.1  pooka 			if (error != 0)
    906  1.1  pooka 				break;
    907  1.1  pooka 			pop.pso_reqid = preq->preq_id;
    908  1.1  pooka 
    909  1.1  pooka 			/* let the kernel do it's intermediate duty */
    910  1.1  pooka 			error = ioctl(pu->pu_kargs.pa_fd, PUFFSSIZEOP, &pop);
    911  1.1  pooka 			/*
    912  1.1  pooka 			 * XXX: I don't actually know what the correct
    913  1.1  pooka 			 * thing to do in case of an error is, so I'll
    914  1.1  pooka 			 * just ignore it for the time being.
    915  1.1  pooka 			 */
    916  1.1  pooka 			error = pops->puffs_node_fcntl2(pcc, opcookie,
    917  1.1  pooka 			    (struct puffs_vnreq_fcntl *)auxbuf, &pop);
    918  1.1  pooka 			break;
    919  1.1  pooka #endif
    920  1.1  pooka 
    921  1.1  pooka 		default:
    922  1.1  pooka 			printf("inval op %d\n", preq->preq_optype);
    923  1.1  pooka 			error = EINVAL;
    924  1.1  pooka 			break;
    925  1.1  pooka 		}
    926  1.1  pooka 	} else {
    927  1.1  pooka 		/*
    928  1.1  pooka 		 * this one also
    929  1.1  pooka 		 */
    930  1.1  pooka 		error = EINVAL;
    931  1.1  pooka 	}
    932  1.1  pooka 
    933  1.1  pooka 	preq->preq_rv = error;
    934  1.3  pooka 	pcc->pcc_flags |= PCC_DONE;
    935  1.1  pooka 
    936  1.3  pooka 	/*
    937  1.3  pooka 	 * Note, we are calling this from here so that we can run it
    938  1.3  pooka 	 * off of the continuation stack.  Otherwise puffs_goto() would
    939  1.3  pooka 	 * not work.
    940  1.3  pooka 	 */
    941  1.3  pooka 	processresult(pcc, pcc->pcc_ppr, rv);
    942  1.3  pooka }
    943  1.3  pooka 
    944  1.3  pooka static void
    945  1.3  pooka processresult(struct puffs_cc *pcc, struct puffs_putreq *ppr, int how)
    946  1.3  pooka {
    947  1.3  pooka 	struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
    948  1.3  pooka 
    949  1.3  pooka 	/* check if we need to store this reply */
    950  1.3  pooka 	switch (how) {
    951  1.3  pooka 	case PUFFCALL_ANSWER:
    952  1.3  pooka 		if (pu->pu_flags & PUFFS_FLAG_OPDUMP)
    953  1.3  pooka 			puffsdump_rv(pcc->pcc_preq);
    954  1.3  pooka 
    955  1.3  pooka 		if (pcc->pcc_flags & PCC_REALCC)
    956  1.3  pooka 			puffs_req_putcc(ppr, pcc);
    957  1.3  pooka 		else
    958  1.3  pooka 			puffs_req_put(ppr, pcc->pcc_preq);
    959  1.3  pooka 		break;
    960  1.3  pooka 	case PUFFCALL_IGNORE:
    961  1.3  pooka 		if (pcc->pcc_flags & PCC_REALCC)
    962  1.3  pooka 			LIST_INSERT_HEAD(&pu->pu_ccnukelst, pcc, nlst_entries);
    963  1.3  pooka 		break;
    964  1.3  pooka 	case PUFFCALL_AGAIN:
    965  1.3  pooka 		if (pcc->pcc_flags & PCC_FAKECC)
    966  1.3  pooka 			assert(pcc->pcc_flags & PCC_DONE);
    967  1.3  pooka 		break;
    968  1.3  pooka 	default:
    969  1.3  pooka 		assert(/*CONSTCOND*/0);
    970  1.3  pooka 	}
    971  1.3  pooka 
    972  1.3  pooka 	/* who needs information when you're living on borrowed time? */
    973  1.3  pooka 	if (pcc->pcc_flags & PCC_BORROWED)
    974  1.3  pooka 		puffs_cc_yield(pcc); /* back to borrow source */
    975  1.1  pooka }
    976  1.1  pooka 
    977  1.1  pooka 
    978  1.1  pooka #if 0
    979  1.1  pooka 		case PUFFS_VN_KQFILTER:
    980  1.1  pooka 		{
    981  1.1  pooka 			struct puffs_vnreq_kqfilter *auxt = auxbuf;
    982  1.1  pooka 			if (pops->puffs_node_kqfilter == NULL) {
    983  1.1  pooka 				error = 0;
    984  1.1  pooka 				break;
    985  1.1  pooka 			}
    986  1.1  pooka 
    987  1.1  pooka 			error = pops->puffs_node_kqfilter(pcc,
    988  1.1  pooka 			    opcookie, );
    989  1.1  pooka 			break;
    990  1.1  pooka 		}
    991  1.1  pooka 
    992  1.1  pooka 		case PUFFS_VN_CLOSEEXTATTR:
    993  1.1  pooka 		{
    994  1.1  pooka 			struct puffs_vnreq_closeextattr *auxt = auxbuf;
    995  1.1  pooka 			if (pops->puffs_closeextattr == NULL) {
    996  1.1  pooka 				error = 0;
    997  1.1  pooka 				break;
    998  1.1  pooka 			}
    999  1.1  pooka 
   1000  1.1  pooka 			error = pops->puffs_closeextattr(pcc,
   1001  1.1  pooka 			    opcookie, );
   1002  1.1  pooka 			break;
   1003  1.1  pooka 		}
   1004  1.1  pooka 
   1005  1.1  pooka 		case PUFFS_VN_GETEXTATTR:
   1006  1.1  pooka 		{
   1007  1.1  pooka 			struct puffs_vnreq_getextattr *auxt = auxbuf;
   1008  1.1  pooka 			if (pops->puffs_getextattr == NULL) {
   1009  1.1  pooka 				error = 0;
   1010  1.1  pooka 				break;
   1011  1.1  pooka 			}
   1012  1.1  pooka 
   1013  1.1  pooka 			error = pops->puffs_getextattr(pcc,
   1014  1.1  pooka 			    opcookie, );
   1015  1.1  pooka 			break;
   1016  1.1  pooka 		}
   1017  1.1  pooka 
   1018  1.1  pooka 		case PUFFS_VN_LISTEXTATTR:
   1019  1.1  pooka 		{
   1020  1.1  pooka 			struct puffs_vnreq_listextattr *auxt = auxbuf;
   1021  1.1  pooka 			if (pops->puffs_listextattr == NULL) {
   1022  1.1  pooka 				error = 0;
   1023  1.1  pooka 				break;
   1024  1.1  pooka 			}
   1025  1.1  pooka 
   1026  1.1  pooka 			error = pops->puffs_listextattr(pcc,
   1027  1.1  pooka 			    opcookie, );
   1028  1.1  pooka 			break;
   1029  1.1  pooka 		}
   1030  1.1  pooka 
   1031  1.1  pooka 		case PUFFS_VN_OPENEXTATTR:
   1032  1.1  pooka 		{
   1033  1.1  pooka 			struct puffs_vnreq_openextattr *auxt = auxbuf;
   1034  1.1  pooka 			if (pops->puffs_openextattr == NULL) {
   1035  1.1  pooka 				error = 0;
   1036  1.1  pooka 				break;
   1037  1.1  pooka 			}
   1038  1.1  pooka 
   1039  1.1  pooka 			error = pops->puffs_openextattr(pcc,
   1040  1.1  pooka 			    opcookie, );
   1041  1.1  pooka 			break;
   1042  1.1  pooka 		}
   1043  1.1  pooka 
   1044  1.1  pooka 		case PUFFS_VN_DELETEEXTATTR:
   1045  1.1  pooka 		{
   1046  1.1  pooka 			struct puffs_vnreq_deleteextattr *auxt = auxbuf;
   1047  1.1  pooka 			if (pops->puffs_deleteextattr == NULL) {
   1048  1.1  pooka 				error = 0;
   1049  1.1  pooka 				break;
   1050  1.1  pooka 			}
   1051  1.1  pooka 
   1052  1.1  pooka 			error = pops->puffs_deleteextattr(pcc,
   1053  1.1  pooka 			    opcookie, );
   1054  1.1  pooka 			break;
   1055  1.1  pooka 		}
   1056  1.1  pooka 
   1057  1.1  pooka 		case PUFFS_VN_SETEXTATTR:
   1058  1.1  pooka 		{
   1059  1.1  pooka 			struct puffs_vnreq_setextattr *auxt = auxbuf;
   1060  1.1  pooka 			if (pops->puffs_setextattr == NULL) {
   1061  1.1  pooka 				error = 0;
   1062  1.1  pooka 				break;
   1063  1.1  pooka 			}
   1064  1.1  pooka 
   1065  1.1  pooka 			error = pops->puffs_setextattr(pcc,
   1066  1.1  pooka 			    opcookie, );
   1067  1.1  pooka 			break;
   1068  1.1  pooka 		}
   1069  1.1  pooka 
   1070  1.1  pooka #endif
   1071