summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2013-02-11 23:30:17 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-02-11 23:30:17 +0000
commitf40f36c6a990bcc502cad4a343644f8354fec604 (patch)
tree0dc49c079af3dac88a147d0754d2cf994767b3fb
parent9aad0ed8c52b517da4f16b167a9e8926bb5d08be (diff)
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.
-rw-r--r--configure.ac2
-rw-r--r--fuse.pc.in2
-rw-r--r--src/fuse_i.h5
-rw-r--r--src/main.c5
-rw-r--r--src/netfs.c54
-rw-r--r--src/netnode.c33
-rw-r--r--src/node.c8
7 files changed, 56 insertions, 53 deletions
diff --git a/configure.ac b/configure.ac
index 1f1676004..b1fa9afbd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ if test -z "$mkdir_p"; then
fi
# Checks for libraries.
-AC_CHECK_LIB([threads], [rwlock_init])
+AC_CHECK_LIB([pthread], [pthread_rwlock_init])
AC_CHECK_LIB([ports], [hurd_ihash_init])
AC_CHECK_LIB([fshelp], [fshelp_touch])
AC_CHECK_LIB([iohelp], [iohelp_initialize_conch])
diff --git a/fuse.pc.in b/fuse.pc.in
index f6f223a09..499b6ba24 100644
--- a/fuse.pc.in
+++ b/fuse.pc.in
@@ -6,5 +6,5 @@ includedir=@includedir@
Name: fuse
Description: Filesystem in Userspace
Version: 2.5.3
-Libs: -L${libdir} -lfuse -lthreads
+Libs: -L${libdir} -lfuse -lpthread
Cflags: -I${includedir}/fuse -D_FILE_OFFSET_BITS=64
diff --git a/src/fuse_i.h b/src/fuse_i.h
index 7694951f0..399b09437 100644
--- a/src/fuse_i.h
+++ b/src/fuse_i.h
@@ -64,6 +64,9 @@ extern const struct fuse_operations *fuse_ops25;
else (node)->nn->info.compat22.key; \
} while(0)
+
+extern __thread struct fuse_context *libfuse_ctx;
+
/*****************************************************************************
*** netnodes (in memory representation of libfuse's files or directories) ***
*****************************************************************************/
@@ -93,7 +96,7 @@ struct netnode {
struct node *node;
/* lock for *node pointer */
- struct mutex lock;
+ pthread_mutex_t lock;
/* whether this is an anonymous node, i.e. it has to be deleted,
* after the last node associated to it, was removed.
diff --git a/src/main.c b/src/main.c
index 923bc3dd7..e9a402f7d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -37,6 +37,8 @@ const struct fuse_operations_compat22 *fuse_ops_compat22 = NULL;
const struct fuse_operations_compat2 *fuse_ops_compat2 = NULL;
const struct fuse_operations *fuse_ops25 = NULL;
+__thread struct fuse_context *libfuse_ctx;
+
/* the port where to write out debug messages to, NULL to omit these */
FILE *debug_port = NULL;
@@ -598,6 +600,5 @@ fuse_exited(struct fuse *f)
struct fuse_context *
fuse_get_context(void)
{
- struct fuse_context *ctx = cthread_data(cthread_self());
- return ctx;
+ return libfuse_ctx;
}
diff --git a/src/netfs.c b/src/netfs.c
index a97b41b48..88ae22742 100644
--- a/src/netfs.c
+++ b/src/netfs.c
@@ -55,7 +55,7 @@ static inline void
refresh_context_struct(struct iouser *cred)
{
FUNC_PROLOGUE("refresh_context_struct");
- struct fuse_context *ctx = cthread_data(cthread_self());
+ struct fuse_context *ctx = libfuse_ctx;
if(! ctx)
{
@@ -66,7 +66,7 @@ refresh_context_struct(struct iouser *cred)
return;
}
- cthread_set_data(cthread_self(), ctx);
+ libfuse_ctx = ctx;
ctx->fuse = (void *) FUSE_MAGIC;
ctx->private_data = fsys_privdata;
@@ -259,9 +259,9 @@ netfs_attempt_create_file (struct iouser *user, struct node *dir,
free(path); /* fuse_make_netnode strdup'ed it. */
if(*node)
- mutex_lock(&(*node)->lock);
+ pthread_mutex_lock(&(*node)->lock);
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
FUNC_EPILOGUE(err);
}
@@ -507,7 +507,7 @@ error_t netfs_attempt_mkfile (struct iouser *user, struct node *dir,
if(err)
{
/* dir has to be unlocked no matter what ... */
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
goto out;
}
@@ -520,7 +520,7 @@ error_t netfs_attempt_mkfile (struct iouser *user, struct node *dir,
err = netfs_attempt_create_file(user, dir, name, mode, node);
if(err == EEXIST)
- mutex_lock(&dir->lock); /* netfs_attempt_create_file just unlocked
+ pthread_mutex_lock(&dir->lock); /* netfs_attempt_create_file just unlocked
* it for us, however we need to call it once
* more ...
*/
@@ -539,7 +539,7 @@ error_t netfs_attempt_mkfile (struct iouser *user, struct node *dir,
* netfs_attempt_create_file has already done that for us
*/
- /* mutex_unlock (&dir->lock);
+ /* pthread_mutex_unlock (&dir->lock);
* netfs_attempt_create_file already unlocked the node for us.
*/
FUNC_EPILOGUE(err);
@@ -620,13 +620,13 @@ error_t netfs_attempt_unlink (struct iouser *user, struct node *dir,
err = netfs_attempt_lookup(user, dir, name, &node);
assert(dir != node);
- mutex_lock(&dir->lock); /* re-lock directory, since netfs_attempt_lookup
+ pthread_mutex_lock(&dir->lock); /* re-lock directory, since netfs_attempt_lookup
* unlocked it for us
*/
if(err)
goto out;
- mutex_unlock(&node->lock);
+ pthread_mutex_unlock(&node->lock);
if((err = netfs_validate_stat(dir, user))
|| (err = netfs_validate_stat(node, user))
@@ -823,12 +823,12 @@ error_t netfs_attempt_lookup (struct iouser *user, struct node *dir,
}
out:
- mutex_unlock(&dir->lock);
+ pthread_mutex_unlock(&dir->lock);
if(err)
*node = NULL;
else
- mutex_lock(&(*node)->lock);
+ pthread_mutex_lock(&(*node)->lock);
FUNC_EPILOGUE(err);
}
@@ -846,13 +846,13 @@ error_t netfs_attempt_link (struct iouser *user, struct node *dir,
error_t err;
struct node *node = NULL;
- mutex_lock(&dir->lock);
+ pthread_mutex_lock(&dir->lock);
if((err = netfs_attempt_lookup(user, dir, name, &node)))
goto out_nounlock; /* netfs_attempt_lookup unlocked dir */
assert(dir != node);
- mutex_lock(&dir->lock);
+ pthread_mutex_lock(&dir->lock);
if((err = netfs_validate_stat(node, user))
|| (libfuse_params.deflt_perms
@@ -877,9 +877,9 @@ error_t netfs_attempt_link (struct iouser *user, struct node *dir,
* create a netnode with the may_need_sync flag set!! */
out:
- mutex_unlock(&dir->lock);
+ pthread_mutex_unlock(&dir->lock);
- mutex_unlock(&node->lock);
+ pthread_mutex_unlock(&node->lock);
netfs_nrele(node);
out_nounlock:
@@ -899,7 +899,7 @@ error_t netfs_attempt_rmdir (struct iouser *user,
err = netfs_attempt_lookup(user, dir, name, &node);
assert(dir != node);
- mutex_lock(&dir->lock); /* netfs_attempt_lookup unlocked dir */
+ pthread_mutex_lock(&dir->lock); /* netfs_attempt_lookup unlocked dir */
if(err)
goto out_nounlock;
@@ -919,7 +919,7 @@ error_t netfs_attempt_rmdir (struct iouser *user,
* FIXME, make sure nn->may_need_sync is set */
out:
- mutex_unlock(&node->lock);
+ pthread_mutex_unlock(&node->lock);
netfs_nrele(node);
out_nounlock:
@@ -1009,7 +1009,7 @@ error_t netfs_attempt_rename (struct iouser *user, struct node *fromdir,
goto out_nounlock;
}
- mutex_lock(&fromdir->lock);
+ pthread_mutex_lock(&fromdir->lock);
if(netfs_attempt_lookup(user, fromdir, fromname, &fromnode))
{
@@ -1019,7 +1019,7 @@ error_t netfs_attempt_rename (struct iouser *user, struct node *fromdir,
*/
}
- mutex_lock(&todir->lock);
+ pthread_mutex_lock(&todir->lock);
if((err = netfs_validate_stat(fromdir, user))
|| (libfuse_params.deflt_perms
@@ -1062,9 +1062,9 @@ error_t netfs_attempt_rename (struct iouser *user, struct node *fromdir,
out:
free(topath);
- mutex_unlock(&todir->lock);
+ pthread_mutex_unlock(&todir->lock);
- mutex_unlock(&fromnode->lock);
+ pthread_mutex_unlock(&fromnode->lock);
netfs_nrele(fromnode);
out_nounlock:
@@ -1185,11 +1185,11 @@ netfs_attempt_utimes (struct iouser *cred, struct node *node,
if (! err)
{
- node->nn_stat.st_mtime = utb.modtime;
- node->nn_stat.st_mtime_usec = 0;
+ node->nn_stat.st_mtim.tv_sec = utb.modtime;
+ node->nn_stat.st_mtim.tv_nsec = 0;
- node->nn_stat.st_atime = utb.actime;
- node->nn_stat.st_atime_usec = 0;
+ node->nn_stat.st_atim.tv_sec = utb.actime;
+ node->nn_stat.st_atim.tv_nsec = 0;
node->nn->may_need_sync = 1;
}
@@ -1695,7 +1695,7 @@ netfs_node_norefs (struct node *node)
assert(node);
DEBUG("netnode-lock", "locking netnode, path=%s\n", node->nn->path);
- mutex_lock(&node->nn->lock);
+ pthread_mutex_lock(&node->nn->lock);
if(node->nn->anonymous && FUSE_OP_HAVE(unlink))
{
@@ -1707,7 +1707,7 @@ netfs_node_norefs (struct node *node)
node->nn->node = NULL;
- mutex_unlock(&node->nn->lock);
+ pthread_mutex_unlock(&node->nn->lock);
DEBUG("netnode-lock", "netnode unlocked.\n"); /* no ref to node->nn av. */
FUNC_EPILOGUE_NORET();
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 <stdio.h>
#include <error.h>
#include <string.h>
-#include <rwlock.h>
#include <hurd/netfs.h>
#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;
}
diff --git a/src/node.c b/src/node.c
index a09cc5c6b..87f880640 100644
--- a/src/node.c
+++ b/src/node.c
@@ -32,13 +32,13 @@ fuse_make_node(struct netnode *nn)
DEBUG("fuse_make_node", "creating node for %s.\n", nn->path);
DEBUG("netnode-lock", "locking netnode, path=%s\n", nn->path);
- mutex_lock(&nn->lock);
+ pthread_mutex_lock(&nn->lock);
if((node = nn->node))
{
/* there already is a node, therefore return another reference to it */
netfs_nref(node);
- mutex_unlock(&nn->lock);
+ pthread_mutex_unlock(&nn->lock);
DEBUG("netnode-lock", "UNlocking netnode, path=%s\n", nn->path);
DEBUG("fuse_make_node", "reusing already existing node, %s\n", nn->path);
return node;
@@ -46,7 +46,7 @@ fuse_make_node(struct netnode *nn)
if(! (node = netfs_make_node(nn)))
{
- mutex_unlock(&nn->lock);
+ pthread_mutex_unlock(&nn->lock);
DEBUG("netnode-lock", "UNlocking netnode, path=%s\n", nn->path);
return NULL; /* doesn't look to good for us :-( */
}
@@ -62,7 +62,7 @@ fuse_make_node(struct netnode *nn)
/* add pointer to our new node structure to the netnode */
nn->node = node;
- mutex_unlock(&nn->lock);
+ pthread_mutex_unlock(&nn->lock);
DEBUG("netnode-lock", "UNlocking netnode, path=%s\n", nn->path);
DEBUG("fuse_make_node", "created a new node for %s.\n", nn->path);
return node;