diff options
Diffstat (limited to 'libtreefs')
-rw-r--r-- | libtreefs/dir-lookup.c | 16 | ||||
-rw-r--r-- | libtreefs/fsys-getroot.c | 2 | ||||
-rw-r--r-- | libtreefs/fsys-hooks.c | 4 | ||||
-rw-r--r-- | libtreefs/fsys.c | 4 | ||||
-rw-r--r-- | libtreefs/trans-help.c | 22 | ||||
-rw-r--r-- | libtreefs/trans-start.c | 2 | ||||
-rw-r--r-- | libtreefs/treefs.h | 62 |
7 files changed, 56 insertions, 56 deletions
diff --git a/libtreefs/dir-lookup.c b/libtreefs/dir-lookup.c index 336ce8fd..ce2acafd 100644 --- a/libtreefs/dir-lookup.c +++ b/libtreefs/dir-lookup.c @@ -58,13 +58,13 @@ _treefs_s_dir_lookup (struct treefs_handle *h, /* Set things up in the state expected by the code from gotit: on. */ dir = 0; node = h->po->node; - mutex_lock (&node->lock); + pthread_mutex_lock (&node->lock); treefs_node_ref (node); goto gotit; } dir = h->po->node; - mutex_lock (&dir->lock); + pthread_mutex_lock (&dir->lock); node = 0; treefs_node_ref (dir); /* acquire a ref for later node_release */ @@ -147,8 +147,8 @@ _treefs_s_dir_lookup (struct treefs_handle *h, /* Be very careful not to hold an inode lock while fetching a translator lock and vice versa. */ - mutex_unlock (&node->lock); - mutex_unlock (&dir->lock); + pthread_mutex_unlock (&node->lock); + pthread_mutex_unlock (&dir->lock); do { @@ -199,12 +199,12 @@ _treefs_s_dir_lookup (struct treefs_handle *h, in the right order. */ if (strcmp (path, "..") != 0) { - mutex_unlock (&node->lock); - mutex_lock (&dir->lock); - mutex_lock (&node->lock); + pthread_mutex_unlock (&node->lock); + pthread_mutex_lock (&dir->lock); + pthread_mutex_lock (&node->lock); } else - mutex_lock (&dir->lock); + pthread_mutex_lock (&dir->lock); } if (treefs_node_type (node) == S_IFLNK diff --git a/libtreefs/fsys-getroot.c b/libtreefs/fsys-getroot.c index 986938cf..cd735bfe 100644 --- a/libtreefs/fsys-getroot.c +++ b/libtreefs/fsys-getroot.c @@ -86,7 +86,7 @@ _treefs_s_fsys_getroot (struct treefs_fsys *fsys, } } - mutex_lock (&root->lock); + pthread_mutex_lock (&root->lock); type = treefs_node_type (root); if (type == S_IFLNK && !(flags & (O_NOLINK | O_NOTRANS))) diff --git a/libtreefs/fsys-hooks.c b/libtreefs/fsys-hooks.c index cb7fcfc6..ecff092b 100644 --- a/libtreefs/fsys-hooks.c +++ b/libtreefs/fsys-hooks.c @@ -30,11 +30,11 @@ error_t _treefs_fsys_get_root (struct treefs_fsys *fsys, struct treefs_node **root) { - mutex_lock (&fsys->lock); + pthread_mutex_lock (&fsys->lock); *root = fsys->root; if (*root != NULL) treefs_node_ref (*root); - mutex_unlock (&fsys->lock); + pthread_mutex_unlock (&fsys->lock); return *root ? 0 : EOPNOTSUPP; } diff --git a/libtreefs/fsys.c b/libtreefs/fsys.c index 459d0d3b..d6565bb9 100644 --- a/libtreefs/fsys.c +++ b/libtreefs/fsys.c @@ -40,7 +40,7 @@ treefs_create_node (struct treefs_fsys *fsys, struct treefs_node **node) n->hooks = fsys->hooks; n->children = NULL; n->u = NULL; - mutex_init (&n->lock); + pthread_mutex_init (&n->lock, NULL); fshelp_init_trans_link (&n->active_trans); fshelp_lock_init (&n->lock_box); @@ -77,7 +77,7 @@ treefs_create_fsys (struct port_bucket *port_bucket, if (*fsys == NULL) return ENOMEM; - mutex_init (&(*fsys)->lock); + pthread_mutex_init (&(*fsys)->lock, NULL); (*fsys)->root = NULL; (*fsys)->underlying_port = MACH_PORT_NULL; diff --git a/libtreefs/trans-help.c b/libtreefs/trans-help.c index b28e93e1..7d3841c0 100644 --- a/libtreefs/trans-help.c +++ b/libtreefs/trans-help.c @@ -40,21 +40,21 @@ treefs_node_get_active_trans (struct treefs_node *node, /* Fill in dir_port */ void make_dir_port () { - mutex_lock (&dir->lock); + pthread_mutex_lock (&dir->lock); *dir_port = treefs_node_make_right (dir, 0, parent_port, 0); mach_port_insert_right (mach_task_self (), *dir_port, *dir_port, MACH_MSG_TYPE_MAKE_SEND); - mutex_unlock (&dir->lock); + pthread_mutex_unlock (&dir->lock); } - mutex_lock (&node->active_trans.lock); + pthread_mutex_lock (&node->active_trans.lock); if (node->active_trans.control != MACH_PORT_NULL) { mach_port_t control = node->active_trans.control; mach_port_mod_refs (mach_task_self (), control, MACH_PORT_RIGHT_SEND, 1); - mutex_unlock (&node->active_trans.lock); + pthread_mutex_unlock (&node->active_trans.lock); /* Now we have a copy of the translator port that isn't dependent on the translator lock itself. Relock @@ -69,12 +69,12 @@ treefs_node_get_active_trans (struct treefs_node *node, return 0; } - mutex_unlock (&node->active_trans.lock); + pthread_mutex_unlock (&node->active_trans.lock); /* If we get here, then we have no active control port. Check to see if there is a passive translator, and if so repeat the translator check. */ - mutex_lock (&node->lock); + pthread_mutex_lock (&node->lock); if (!node->istranslated) { *control_port = MACH_PORT_NULL; @@ -89,15 +89,15 @@ treefs_node_get_active_trans (struct treefs_node *node, } if (err) { - mutex_unlock (&node->lock); + pthread_mutex_unlock (&node->lock); return err; } if (*dir_port == MACH_PORT_NULL) { - mutex_unlock (&node->lock); + pthread_mutex_unlock (&node->lock); make_dir_port (); - mutex_lock (&node->lock); + pthread_mutex_lock (&node->lock); } /* Try starting the translator (this unlocks NODE). */ @@ -118,11 +118,11 @@ void treefs_node_drop_active_trans (struct treefs_node *node, mach_port_t control_port) { - mutex_lock (&node->active_trans.lock); + pthread_mutex_lock (&node->active_trans.lock); /* Only zero the control port if it hasn't changed. */ if (node->active_trans.control == control) fshelp_translator_drop (&node->active_trans); - mutex_unlock (&node->active_trans.lock); + pthread_mutex_unlock (&node->active_trans.lock); /* And we're done with this port. */ mach_port_deallocate (mach_task_self (), control_port); diff --git a/libtreefs/trans-start.c b/libtreefs/trans-start.c index 2196a8dc..b27c38f4 100644 --- a/libtreefs/trans-start.c +++ b/libtreefs/trans-start.c @@ -49,7 +49,7 @@ _treefs_node_start_translator (struct treefs_node *node, MACH_MSG_TYPE_MAKE_SEND); - mutex_unlock (&node->lock); + pthread_mutex_unlock (&node->lock); /* XXXX Change libfshelp so that it take more than 1 uid/gid? */ uid = auth->nuids > 0 ? auth->uids[0] : -1; diff --git a/libtreefs/treefs.h b/libtreefs/treefs.h index d8f30e4e..0e49ef51 100644 --- a/libtreefs/treefs.h +++ b/libtreefs/treefs.h @@ -24,7 +24,7 @@ #define __TREEFS_H__ #include <errno.h> -#include <cthreads.h> +#include <pthread.h> #include <assert.h> #include <features.h> @@ -100,7 +100,7 @@ struct treefs_node char *passive_trans; struct lock_box user_lock; - struct mutex lock; + pthread_mutex_t lock; unsigned refs, weak_refs; /* Node ops */ @@ -123,7 +123,7 @@ struct treefs_node_list struct treefs_fsys { struct port_info pi; - struct mutex lock; + pthread_mutex_t lock; /* The root node in this filesystem. */ struct treefs_node *root; @@ -242,7 +242,7 @@ void treefs_hooks_set (treefs_hook_vector_t hooks, /* ---------------------------------------------------------------- */ /* Reference counting function (largely stolen from diskfs). */ -extern spin_lock_t treefs_node_refcnt_lock; +extern pthread_spinlock_t treefs_node_refcnt_lock; extern void treefs_node_ref (struct treefs_node *node); extern void treefs_node_release (struct treefs_node *node); @@ -259,15 +259,15 @@ TREEFS_EI void treefs_node_ref (struct treefs_node *node) { int new_ref; - spin_lock (&treefs_node_refcnt_lock); + pthread_spin_lock (&treefs_node_refcnt_lock); node->refs++; new_ref = (node->refs == 1); - spin_unlock (&treefs_node_refcnt_lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); if (new_ref) { - mutex_lock (&node->lock); + pthread_mutex_lock (&node->lock); treefs_node_new_refs (node); - mutex_unlock (&node->lock); + pthread_mutex_unlock (&node->lock); } } @@ -280,14 +280,14 @@ treefs_node_release (struct treefs_node *node) int tried_drop_weak_refs = 0; loop: - spin_lock (&treefs_node_refcnt_lock); + pthread_spin_lock (&treefs_node_refcnt_lock); assert (node->refs); node->refs--; if (node->refs + node->weak_refs == 0) treefs_node_drop (node); else if (node->refs == 0 && !tried_drop_weak_refs) { - spin_unlock (&treefs_node_refcnt_lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); treefs_node_lost_refs (node); if (treefs_node_unlinked (node)) { @@ -297,9 +297,9 @@ treefs_node_release (struct treefs_node *node) routine, which might result in further recursive calls to the ref-counting system. So we have to reacquire our reference around the call to forestall disaster. */ - spin_unlock (&treefs_node_refcnt_lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); node->refs++; - spin_unlock (&treefs_node_refcnt_lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); treefs_node_try_dropping_weak_refs (node); @@ -312,8 +312,8 @@ treefs_node_release (struct treefs_node *node) } } else - spin_unlock (&treefs_node_refcnt_lock); - mutex_unlock (&node->lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); + pthread_mutex_unlock (&node->lock); } /* Release a hard reference on NODE. If NODE is locked by anyone, then @@ -327,61 +327,61 @@ treefs_node_unref (struct treefs_node *node) int tried_drop_weak_refs = 0; loop: - spin_lock (&treefs_node_refcnt_lock); + pthread_spin_lock (&treefs_node_refcnt_lock); assert (node->refs); node->refs--; if (node->refs + node->weak_refs == 0) { - mutex_lock (&node->lock); + pthread_mutex_lock (&node->lock); treefs_node_drop (node); } else if (node->refs == 0) { - mutex_lock (&node->lock); - spin_unlock (&treefs_node_refcnt_lock); + pthread_mutex_lock (&node->lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); treefs_node_lost_refs (node); if (treefs_node_unlinked(node) && !tried_drop_weak_refs) { /* Same issue here as in nodeut; see that for explanation */ - spin_unlock (&treefs_node_refcnt_lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); node->refs++; - spin_unlock (&treefs_node_refcnt_lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); treefs_node_try_dropping_weak_refs (node); tried_drop_weak_refs = 1; /* Now we can drop the reference back... */ - mutex_unlock (&node->lock); + pthread_mutex_unlock (&node->lock); goto loop; } - mutex_unlock (&node->lock); + pthread_mutex_unlock (&node->lock); } else - spin_unlock (&treefs_node_refcnt_lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); } /* Add a weak reference to a node. */ TREEFS_EI void treefs_node_ref_weak (struct treefs_node *node) { - spin_lock (&treefs_node_refcnt_lock); + pthread_spin_lock (&treefs_node_refcnt_lock); node->weak_refs++; - spin_unlock (&treefs_node_refcnt_lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); } /* Unlock node NODE and release a weak reference */ TREEFS_EI void treefs_node_release_weak (struct treefs_node *node) { - spin_lock (&treefs_node_refcnt_lock); + pthread_spin_lock (&treefs_node_refcnt_lock); assert (node->weak_refs); node->weak_refs--; if (node->refs + node->weak_refs == 0) treefs_node_drop (node); else { - spin_unlock (&treefs_node_refcnt_lock); - mutex_unlock (&node->lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); + pthread_mutex_unlock (&node->lock); } } @@ -391,16 +391,16 @@ treefs_node_release_weak (struct treefs_node *node) TREEFS_EI void treefs_node_unref_weak (struct treefs_node *node) { - spin_lock (&treefs_node_refcnt_lock); + pthread_spin_lock (&treefs_node_refcnt_lock); assert (node->weak_refs); node->weak_refs--; if (node->refs + node->weak_refs == 0) { - mutex_lock (&node->lock); + pthread_mutex_lock (&node->lock); treefs_node_drop (node); } else - spin_unlock (&treefs_node_refcnt_lock); + pthread_spin_unlock (&treefs_node_refcnt_lock); } #endif /* Use extern inlines. */ |