From f40f36c6a990bcc502cad4a343644f8354fec604 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 11 Feb 2013 23:30:17 +0000 Subject: Fix build against libpthread * configure.ac: Link against libpthread instead of libthreads. * fuse.pc.in: Likewise. * src/fuse_i.h (libfuse_ctx): Declare TLS variable. (netnode): Turn lock field from struct mutex to pthread_mutex_t. * src/main.c (libfuse_ctx): Define TLS variable. (fuse_get_context): Use libfuse_ctx instead of cthreads TSD. * src/netfs.c: Likewise. Use pthread functions instead of cthreads functions. Use fixed stat structure. * src/netnode.c: Likewise. * src/node.c: Likewise. --- src/netnode.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/netnode.c') diff --git a/src/netnode.c b/src/netnode.c index 092d03908..cfbd8cd01 100644 --- a/src/netnode.c +++ b/src/netnode.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include "fuse_i.h" @@ -35,7 +34,7 @@ static struct hash_element { /* rwlock needs to be held when touching either fuse_netnodes hash or * fuse_next_inode variable */ -struct rwlock fuse_netnodes_lock = RWLOCK_INITIALIZER; +pthread_rwlock_t fuse_netnodes_lock = PTHREAD_RWLOCK_INITIALIZER; /* next inode number that will be assigned * (fuse_netnodes_lock must be write locked, when touching this) @@ -69,8 +68,8 @@ fuse_make_netnode(struct netnode *parent, const char *path) unsigned int hash_value = fuse_netnode_hash_value(path); DEBUG("make_netnode", "hash for '%s' is %u\n", path, hash_value); - DEBUG("netnodes_lock", "aquiring rwlock_reader_lock for %s.\n", path); - rwlock_reader_lock(&fuse_netnodes_lock); + DEBUG("netnodes_lock", "aquiring pthread_rwlock_rdlock for %s.\n", path); + pthread_rwlock_rdlock(&fuse_netnodes_lock); hash_el = &fuse_netnodes[hash_value]; if(hash_el->nn) @@ -78,15 +77,15 @@ fuse_make_netnode(struct netnode *parent, const char *path) if(! strcmp(hash_el->nn->path, path)) { nn = hash_el->nn; - rwlock_reader_unlock(&fuse_netnodes_lock); - DEBUG("netnodes_lock", "releasing rwlock_reader_lock.\n"); + pthread_rwlock_unlock(&fuse_netnodes_lock); + DEBUG("netnodes_lock", "releasing pthread_rwlock_rdlock.\n"); return nn; } while((hash_el = hash_el->next)); - rwlock_reader_unlock(&fuse_netnodes_lock); - DEBUG("netnodes_lock", "releasing rwlock_reader_lock.\n"); + pthread_rwlock_unlock(&fuse_netnodes_lock); + DEBUG("netnodes_lock", "releasing pthread_rwlock_rdlock.\n"); nn = malloc(sizeof(*nn)); if(! nn) @@ -95,10 +94,10 @@ fuse_make_netnode(struct netnode *parent, const char *path) nn->path = strdup(path); nn->parent = parent; nn->node = NULL; - mutex_init(&nn->lock); + pthread_mutex_init(&nn->lock, NULL); - DEBUG("netnodes_lock", "aquiring rwlock_writer_lock for %s.\n", path); - rwlock_writer_lock(&fuse_netnodes_lock); + DEBUG("netnodes_lock", "aquiring pthread_rwlock_wrlock for %s.\n", path); + pthread_rwlock_wrlock(&fuse_netnodes_lock); nn->inode = fuse_next_inode ++; @@ -111,8 +110,8 @@ fuse_make_netnode(struct netnode *parent, const char *path) struct hash_element *new = malloc(sizeof(*new)); if(! new) { - rwlock_writer_unlock(&fuse_netnodes_lock); - DEBUG("netnodes_lock", "releasing rwlock_writer_lock.\n"); + pthread_rwlock_unlock(&fuse_netnodes_lock); + DEBUG("netnodes_lock", "releasing pthread_rwlock_wrlock.\n"); free(nn); return NULL; /* can't help, sorry. */ } @@ -126,8 +125,8 @@ fuse_make_netnode(struct netnode *parent, const char *path) hash_el->nn = nn; - rwlock_writer_unlock(&fuse_netnodes_lock); - DEBUG("netnodes_lock", "releasing rwlock_writer_lock.\n"); + pthread_rwlock_unlock(&fuse_netnodes_lock); + DEBUG("netnodes_lock", "releasing pthread_rwlock_wrlock.\n"); return nn; } @@ -145,7 +144,7 @@ fuse_sync_filesystem(void) return err; /* success */ /* make sure, nobody tries to confuse us */ - rwlock_writer_lock(&fuse_netnodes_lock); + pthread_rwlock_wrlock(&fuse_netnodes_lock); for(i = 0; i < HASH_BUCKETS; i ++) { @@ -175,6 +174,6 @@ fuse_sync_filesystem(void) } out: - rwlock_writer_unlock(&fuse_netnodes_lock); + pthread_rwlock_unlock(&fuse_netnodes_lock); return err; } -- cgit v1.2.3