Add possibility to set pre- and post callbacks which will be called

for all operations before or after executing the specific callback
(the api is not be final yet, though).
This commit is contained in:
pooka 2007-10-28 18:40:30 +00:00
parent 9b2fcb3d05
commit b40b63f077
4 changed files with 31 additions and 10 deletions

View File

@ -1,10 +1,10 @@
/* $NetBSD: dispatcher.c,v 1.17 2007/10/26 17:35:01 pooka Exp $ */
/* $NetBSD: dispatcher.c,v 1.18 2007/10/28 18:40:30 pooka Exp $ */
/*
* Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved.
*
* Development of this software was supported by the
* Ulla Tuominen Foundation.
* Ulla Tuominen Foundation and the Finnish Cultural Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: dispatcher.c,v 1.17 2007/10/26 17:35:01 pooka Exp $");
__RCSID("$NetBSD: dispatcher.c,v 1.18 2007/10/28 18:40:30 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
@ -177,11 +177,10 @@ puffs_dopreq(struct puffs_usermount *pu, struct puffs_req *preq,
* finishes. This prevents us from executing certain operations
* out-of-order (e.g. fsync and reclaim).
*
* Eqch preq will only remove its own pex from the tailq.
* See processresult() for the details on other-end removal
* Each preq will only remove its own pex from the tailq.
* See puffs_docc() for the details on other-end removal
* and dispatching.
*/
pex = malloc(sizeof(struct puffs_executor));
pex->pex_preq = preq;
/* mutex_enter */
@ -270,6 +269,9 @@ puffs_calldispatcher(struct puffs_cc *pcc)
buildpath = pu->pu_flags & PUFFS_FLAG_BUILDPATH;
preq->preq_setbacks = 0;
if (pu->pu_oppre)
pu->pu_oppre(pcc);
if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS) {
switch (preq->preq_optype) {
case PUFFS_VFS_UNMOUNT:
@ -1038,6 +1040,9 @@ puffs_calldispatcher(struct puffs_cc *pcc)
preq->preq_rv = error;
pcc->pcc_flags |= PCC_DONE;
if (pu->pu_oppost)
pu->pu_oppost(pcc);
/*
* Note, we are calling this from here so that we can run it
* off of the continuation stack. Otherwise puffs_goto() would

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs.c,v 1.70 2007/10/26 17:35:01 pooka Exp $ */
/* $NetBSD: puffs.c,v 1.71 2007/10/28 18:40:30 pooka Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: puffs.c,v 1.70 2007/10/26 17:35:01 pooka Exp $");
__RCSID("$NetBSD: puffs.c,v 1.71 2007/10/28 18:40:30 pooka Exp $");
#endif /* !lint */
#include <sys/param.h>
@ -311,6 +311,15 @@ puffs_ml_settimeout(struct puffs_usermount *pu, struct timespec *ts)
}
}
void
puffs_set_prepost(struct puffs_usermount *pu,
pu_prepost_fn pre, pu_prepost_fn pst)
{
pu->pu_oppre = pre;
pu->pu_oppost = pst;
}
void
puffs_setback(struct puffs_cc *pcc, int whatback)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs.h,v 1.90 2007/10/26 13:51:14 pooka Exp $ */
/* $NetBSD: puffs.h,v 1.91 2007/10/28 18:40:30 pooka Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@ -257,6 +257,8 @@ typedef int (*pu_namemod_fn)(struct puffs_usermount *,
typedef void (*pu_errnotify_fn)(struct puffs_usermount *,
uint8_t, int, const char *, void *);
typedef void (*pu_prepost_fn)(struct puffs_cc *);
enum {
PUFFS_STATE_BEFOREMOUNT, PUFFS_STATE_RUNNING,
PUFFS_STATE_UNMOUNTING, PUFFS_STATE_UNMOUNTED
@ -626,6 +628,8 @@ void puffs_set_pathfree(struct puffs_usermount *, pu_pathfree_fn);
void puffs_set_namemod(struct puffs_usermount *, pu_namemod_fn);
void puffs_set_errnotify(struct puffs_usermount *, pu_errnotify_fn);
void puffs_set_prepost(struct puffs_usermount *,
pu_prepost_fn, pu_prepost_fn);
/*
* Suspension

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_priv.h,v 1.28 2007/10/26 17:35:02 pooka Exp $ */
/* $NetBSD: puffs_priv.h,v 1.29 2007/10/28 18:40:31 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -130,6 +130,9 @@ struct puffs_usermount {
pu_errnotify_fn pu_errnotify;
pu_prepost_fn pu_oppre;
pu_prepost_fn pu_oppost;
struct puffs_framectrl pu_framectrl;
puffs_ml_loop_fn pu_ml_lfn;