diff --git a/lib/libpuffs/puffs.c b/lib/libpuffs/puffs.c index d0b168982a57..2e5f8be5cc49 100644 --- a/lib/libpuffs/puffs.c +++ b/lib/libpuffs/puffs.c @@ -1,4 +1,4 @@ -/* $NetBSD: puffs.c,v 1.25 2007/01/16 22:37:17 pooka Exp $ */ +/* $NetBSD: puffs.c,v 1.26 2007/01/20 13:52:14 pooka Exp $ */ /* * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved. @@ -34,7 +34,7 @@ #include #if !defined(lint) -__RCSID("$NetBSD: puffs.c,v 1.25 2007/01/16 22:37:17 pooka Exp $"); +__RCSID("$NetBSD: puffs.c,v 1.26 2007/01/20 13:52:14 pooka Exp $"); #endif /* !lint */ #include @@ -305,13 +305,13 @@ puffs_mainloop(struct puffs_usermount *pu, int flags) int rv; rv = -1; - pgr = puffs_makegetreq(pu, pu->pu_maxreqlen, 0); + pgr = puffs_req_makeget(pu, pu->pu_maxreqlen, 0); if (pgr == NULL) return -1; - ppr = puffs_makeputreq(pu); + ppr = puffs_req_makeput(pu); if (ppr == NULL) { - puffs_destroygetreq(pgr); + puffs_req_destroyget(pgr); return -1; } @@ -322,47 +322,24 @@ puffs_mainloop(struct puffs_usermount *pu, int flags) /* XXX: should be a bit more robust with errors here */ while (puffs_getstate(pu) == PUFFS_STATE_RUNNING || puffs_getstate(pu) == PUFFS_STATE_UNMOUNTING) { - puffs_resetputreq(ppr); + puffs_req_resetput(ppr); - if (puffs_handlereqs(pu, pgr, ppr, 0) == -1) { + if (puffs_req_handle(pu, pgr, ppr, 0) == -1) { rv = -1; break; } - if (puffs_putputreq(ppr) == -1) { + if (puffs_req_putput(ppr) == -1) { rv = -1; break; } } out: - puffs_destroyputreq(ppr); - puffs_destroygetreq(pgr); + puffs_req_destroyput(ppr); + puffs_req_destroyget(pgr); return rv; } -int -puffs_handlereqs(struct puffs_usermount *pu, struct puffs_getreq *pgr, - struct puffs_putreq *ppr, int maxops) -{ - struct puffs_req *preq; - int pval; - - puffs_setmaxgetreq(pgr, maxops); - if (puffs_loadgetreq(pgr) == -1) - return -1; - - /* interlink pgr and ppr for diagnostic asserts */ - pgr->pgr_nppr++; - ppr->ppr_pgr = pgr; - - pval = 0; - while ((preq = puffs_getreq(pgr)) != NULL - && pu->pu_state != PUFFS_STATE_UNMOUNTED) - pval = puffs_dopreq(pu, ppr, preq); - - return pval; -} - int puffs_dopreq(struct puffs_usermount *pu, struct puffs_putreq *ppr, struct puffs_req *preq) @@ -405,7 +382,7 @@ puffs_docc(struct puffs_putreq *ppr, struct puffs_cc *pcc) /* check if we need to store this reply */ switch (rv) { case PUFFCALL_ANSWER: - puffs_putreq_cc(ppr, pcc); + puffs_req_putcc(ppr, pcc); break; case PUFFCALL_IGNORE: puffs_cc_destroy(pcc); diff --git a/lib/libpuffs/puffs.h b/lib/libpuffs/puffs.h index 50534c7e6bf1..9a1e3ad536de 100644 --- a/lib/libpuffs/puffs.h +++ b/lib/libpuffs/puffs.h @@ -1,4 +1,4 @@ -/* $NetBSD: puffs.h,v 1.26 2007/01/16 22:37:17 pooka Exp $ */ +/* $NetBSD: puffs.h,v 1.27 2007/01/20 13:52:14 pooka Exp $ */ /* * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved. @@ -378,7 +378,7 @@ int puffs_cred_isjuggernaut(const struct puffs_cred *pcr); #define PUFFSOP_SETFSNOP(ops, opname) \ (ops)->puffs_fs_##opname = puffs_fsnop_##opname -#define PUFFS_DEVEL_LIBVERSION 4 +#define PUFFS_DEVEL_LIBVERSION 5 #define puffs_mount(a,b,c,d,e,f,g) \ _puffs_mount(PUFFS_DEVEL_LIBVERSION,a,b,c,d,e,f,g) @@ -430,20 +430,24 @@ void puffs_stat2vattr(struct vattr *va, const struct stat *); * Requests */ -struct puffs_getreq *puffs_makegetreq(struct puffs_usermount *, - size_t, int); -int puffs_loadgetreq(struct puffs_getreq *); -struct puffs_req *puffs_getreq(struct puffs_getreq *); -int puffs_remaininggetreq(struct puffs_getreq *); -void puffs_setmaxgetreq(struct puffs_getreq *, int); -void puffs_destroygetreq(struct puffs_getreq *); +struct puffs_getreq *puffs_req_makeget(struct puffs_usermount *, + size_t, int); +int puffs_req_loadget(struct puffs_getreq *); +struct puffs_req *puffs_req_get(struct puffs_getreq *); +int puffs_req_remainingget(struct puffs_getreq *); +void puffs_req_setmaxget(struct puffs_getreq *, int); +void puffs_req_destroyget(struct puffs_getreq *); -struct puffs_putreq *puffs_makeputreq(struct puffs_usermount *); -void puffs_putreq(struct puffs_putreq *, struct puffs_req *); -void puffs_putreq_cc(struct puffs_putreq *,struct puffs_cc*); -int puffs_putputreq(struct puffs_putreq *); -void puffs_resetputreq(struct puffs_putreq *); -void puffs_destroyputreq(struct puffs_putreq *); +struct puffs_putreq *puffs_req_makeput(struct puffs_usermount *); +void puffs_req_put(struct puffs_putreq *,struct puffs_req *); +void puffs_req_putcc(struct puffs_putreq *,struct puffs_cc*); +int puffs_req_putput(struct puffs_putreq *); +void puffs_req_resetput(struct puffs_putreq *); +void puffs_req_destroyput(struct puffs_putreq *); + +int puffs_req_handle(struct puffs_usermount *, + struct puffs_getreq *, + struct puffs_putreq *, int); /* * Call Context interfaces relevant for user. @@ -459,9 +463,6 @@ void puffs_cc_destroy(struct puffs_cc *); * Execute or continue a request */ -int puffs_handlereqs(struct puffs_usermount *, struct puffs_getreq *, - struct puffs_putreq *, int); - int puffs_dopreq(struct puffs_usermount *, struct puffs_putreq *, struct puffs_req *); int puffs_docc(struct puffs_putreq *, struct puffs_cc *); diff --git a/lib/libpuffs/requests.c b/lib/libpuffs/requests.c index 8577e6bdce2f..56c0b3c22775 100644 --- a/lib/libpuffs/requests.c +++ b/lib/libpuffs/requests.c @@ -1,4 +1,4 @@ -/* $NetBSD: requests.c,v 1.2 2006/12/29 15:28:11 pooka Exp $ */ +/* $NetBSD: requests.c,v 1.3 2007/01/20 13:52:14 pooka Exp $ */ /* * Copyright (c) 2006 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ #include #if !defined(lint) -__RCSID("$NetBSD: requests.c,v 1.2 2006/12/29 15:28:11 pooka Exp $"); +__RCSID("$NetBSD: requests.c,v 1.3 2007/01/20 13:52:14 pooka Exp $"); #endif /* !lint */ #include @@ -45,7 +45,7 @@ __RCSID("$NetBSD: requests.c,v 1.2 2006/12/29 15:28:11 pooka Exp $"); #include "puffs_priv.h" struct puffs_getreq * -puffs_makegetreq(struct puffs_usermount *pu, size_t buflen, int maxops) +puffs_req_makeget(struct puffs_usermount *pu, size_t buflen, int maxops) { struct puffs_getreq *pgr; uint8_t *buf; @@ -71,7 +71,7 @@ puffs_makegetreq(struct puffs_usermount *pu, size_t buflen, int maxops) } int -puffs_loadgetreq(struct puffs_getreq *pgr) +puffs_req_loadget(struct puffs_getreq *pgr) { assert(pgr->pgr_nppr == 0); @@ -89,7 +89,7 @@ puffs_loadgetreq(struct puffs_getreq *pgr) } struct puffs_req * -puffs_getreq(struct puffs_getreq *pgr) +puffs_req_get(struct puffs_getreq *pgr) { struct puffs_req *preq; @@ -107,14 +107,14 @@ puffs_getreq(struct puffs_getreq *pgr) } int -puffs_remaininggetreq(struct puffs_getreq *pgr) +puffs_req_remainingget(struct puffs_getreq *pgr) { return pgr->pgr_phg.phg_nops; } void -puffs_setmaxgetreq(struct puffs_getreq *pgr, int maxops) +puffs_req_setmaxget(struct puffs_getreq *pgr, int maxops) { pgr->pgr_phg.phg_nops = maxops; @@ -122,7 +122,7 @@ puffs_setmaxgetreq(struct puffs_getreq *pgr, int maxops) } void -puffs_destroygetreq(struct puffs_getreq *pgr) +puffs_req_destroyget(struct puffs_getreq *pgr) { assert(pgr->pgr_nppr == 0); @@ -133,7 +133,7 @@ puffs_destroygetreq(struct puffs_getreq *pgr) struct puffs_putreq * -puffs_makeputreq(struct puffs_usermount *pu) +puffs_req_makeput(struct puffs_usermount *pu) { struct puffs_putreq *ppr; @@ -147,13 +147,13 @@ puffs_makeputreq(struct puffs_usermount *pu) ppr->ppr_pu = pu; ppr->ppr_pgr = NULL; - puffs_resetputreq(ppr); + puffs_req_resetput(ppr); return ppr; } void -puffs_putreq(struct puffs_putreq *ppr, struct puffs_req *preq) +puffs_req_put(struct puffs_putreq *ppr, struct puffs_req *preq) { ppr->ppr_php.php_nops++; @@ -173,15 +173,15 @@ puffs_putreq(struct puffs_putreq *ppr, struct puffs_req *preq) * instead of a direct preq, put a cc onto the push queue */ void -puffs_putreq_cc(struct puffs_putreq *ppr, struct puffs_cc *pcc) +puffs_req_putcc(struct puffs_putreq *ppr, struct puffs_cc *pcc) { TAILQ_INSERT_TAIL(&ppr->ppr_pccq, pcc, entries); - puffs_putreq(ppr, pcc->pcc_preq); + puffs_req_put(ppr, pcc->pcc_preq); } int -puffs_putputreq(struct puffs_putreq *ppr) +puffs_req_putput(struct puffs_putreq *ppr) { if (ppr->ppr_php.php_nops) @@ -192,7 +192,7 @@ puffs_putputreq(struct puffs_putreq *ppr) } void -puffs_resetputreq(struct puffs_putreq *ppr) +puffs_req_resetput(struct puffs_putreq *ppr) { struct puffs_cc *pcc; @@ -212,9 +212,32 @@ puffs_resetputreq(struct puffs_putreq *ppr) } void -puffs_destroyputreq(struct puffs_putreq *ppr) +puffs_req_destroyput(struct puffs_putreq *ppr) { - puffs_resetputreq(ppr); + puffs_req_resetput(ppr); free(ppr); } + +int +puffs_req_handle(struct puffs_usermount *pu, struct puffs_getreq *pgr, + struct puffs_putreq *ppr, int maxops) +{ + struct puffs_req *preq; + int pval; + + puffs_req_setmaxget(pgr, maxops); + if (puffs_req_loadget(pgr) == -1) + return -1; + + /* interlink pgr and ppr for diagnostic asserts */ + pgr->pgr_nppr++; + ppr->ppr_pgr = pgr; + + pval = 0; + while ((preq = puffs_req_get(pgr)) != NULL + && pu->pu_state != PUFFS_STATE_UNMOUNTED) + pval = puffs_dopreq(pu, ppr, preq); + + return pval; +}