aboutsummaryrefslogtreecommitdiff
path: root/ftpfs
diff options
context:
space:
mode:
Diffstat (limited to 'ftpfs')
-rw-r--r--ftpfs/Makefile3
-rw-r--r--ftpfs/ccache.c24
-rw-r--r--ftpfs/ccache.h4
-rw-r--r--ftpfs/conn.c12
-rw-r--r--ftpfs/dir.c38
-rw-r--r--ftpfs/fs.c6
-rw-r--r--ftpfs/ftpfs.c18
-rw-r--r--ftpfs/ftpfs.h8
-rw-r--r--ftpfs/ncache.c4
-rw-r--r--ftpfs/netfs.c4
-rw-r--r--ftpfs/node.c12
11 files changed, 67 insertions, 66 deletions
diff --git a/ftpfs/Makefile b/ftpfs/Makefile
index 581c5da6..70398908 100644
--- a/ftpfs/Makefile
+++ b/ftpfs/Makefile
@@ -24,6 +24,7 @@ target = ftpfs
SRCS = ftpfs.c fs.c host.c netfs.c dir.c conn.c ccache.c node.c ncache.c
OBJS = $(SRCS:.c=.o)
-HURDLIBS = netfs fshelp iohelp threads ports ihash ftpconn shouldbeinlibc
+HURDLIBS = netfs fshelp iohelp ports ihash ftpconn shouldbeinlibc
+OTHERLIBS = -lpthread
include ../Makeconf
diff --git a/ftpfs/ccache.c b/ftpfs/ccache.c
index 56f3bf1e..fa63c687 100644
--- a/ftpfs/ccache.c
+++ b/ftpfs/ccache.c
@@ -37,7 +37,7 @@ ccache_read (struct ccache *cc, off_t offs, size_t len, void *data)
error_t err = 0;
size_t max = offs + len;
- mutex_lock (&cc->lock);
+ pthread_mutex_lock (&cc->lock);
if (max > cc->size)
max = cc->size;
@@ -48,7 +48,7 @@ ccache_read (struct ccache *cc, off_t offs, size_t len, void *data)
/* Some thread is fetching data, so just let it do its thing, but get
a wakeup call when it's done. */
{
- if (hurd_condition_wait (&cc->wakeup, &cc->lock))
+ if (pthread_hurd_cond_wait_np (&cc->wakeup, &cc->lock))
err = EINTR;
}
else
@@ -60,7 +60,7 @@ ccache_read (struct ccache *cc, off_t offs, size_t len, void *data)
while (cc->max < max && !err)
{
- mutex_unlock (&cc->lock);
+ pthread_mutex_unlock (&cc->lock);
if (! cc->conn)
/* We need to setup a connection to fetch data over. */
@@ -179,12 +179,12 @@ ccache_read (struct ccache *cc, off_t offs, size_t len, void *data)
err = EINTR;
}
- mutex_lock (&cc->lock);
+ pthread_mutex_lock (&cc->lock);
if (cc->max < max && !err)
/* If anyone's waiting for data, let them look (if we're done
fetching, this gets delayed until below). */
- condition_broadcast (&cc->wakeup);
+ pthread_cond_broadcast (&cc->wakeup);
}
if (!err && cc->conn && cc->max == cc->size)
@@ -200,14 +200,14 @@ ccache_read (struct ccache *cc, off_t offs, size_t len, void *data)
cc->fetching_active = 0;
/* Let others know something's going on. */
- condition_broadcast (&cc->wakeup);
+ pthread_cond_broadcast (&cc->wakeup);
}
}
if (! err)
bcopy (cc->image + offs, data, max - offs);
- mutex_unlock (&cc->lock);
+ pthread_mutex_unlock (&cc->lock);
return err;
}
@@ -218,13 +218,13 @@ ccache_invalidate (struct ccache *cc)
{
error_t err = 0;
- mutex_lock (&cc->lock);
+ pthread_mutex_lock (&cc->lock);
while (cc->fetching_active && !err)
/* Some thread is fetching data, so just let it do its thing, but get
a wakeup call when it's done. */
{
- if (hurd_condition_wait (&cc->wakeup, &cc->lock))
+ if (pthread_hurd_cond_wait_np (&cc->wakeup, &cc->lock))
err = EINTR;
}
@@ -246,7 +246,7 @@ ccache_invalidate (struct ccache *cc)
}
}
- mutex_unlock (&cc->lock);
+ pthread_mutex_unlock (&cc->lock);
return err;
}
@@ -265,8 +265,8 @@ ccache_create (struct node *node, struct ccache **cc)
new->size = node->nn_stat.st_size;
new->max = 0;
new->alloced = 0;
- mutex_init (&new->lock);
- condition_init (&new->wakeup);
+ pthread_mutex_init (&new->lock, NULL);
+ pthread_cond_init (&new->wakeup, NULL);
new->fetching_active = 0;
new->conn = 0;
new->data_conn = -1;
diff --git a/ftpfs/ccache.h b/ftpfs/ccache.h
index 410720c3..78f90bd2 100644
--- a/ftpfs/ccache.h
+++ b/ftpfs/ccache.h
@@ -40,10 +40,10 @@ struct ccache
/* Amount of IMAGE that has been allocated. */
size_t alloced;
- struct mutex lock;
+ pthread_mutex_t lock;
/* People can wait for a reading thread on this condition. */
- struct condition wakeup;
+ pthread_cond_t wakeup;
/* True if some thread is now fetching data. Only that thread should
modify the DATA_CONN, DATA_CONN_POS, and MAX fields. */
diff --git a/ftpfs/conn.c b/ftpfs/conn.c
index 9be7dd28..0f1b0973 100644
--- a/ftpfs/conn.c
+++ b/ftpfs/conn.c
@@ -39,11 +39,11 @@ ftpfs_get_ftp_conn (struct ftpfs *fs, struct ftp_conn **conn)
{
struct ftpfs_conn *fsc;
- spin_lock (&fs->conn_lock);
+ pthread_spin_lock (&fs->conn_lock);
fsc = fs->free_conns;
if (fsc)
fs->free_conns = fsc->next;
- spin_unlock (&fs->conn_lock);
+ pthread_spin_unlock (&fs->conn_lock);
if (! fsc)
{
@@ -73,10 +73,10 @@ ftpfs_get_ftp_conn (struct ftpfs *fs, struct ftp_conn **conn)
fsc->conn->hook = (void *)(uintptr_t)conn_id++;
}
- spin_lock (&fs->conn_lock);
+ pthread_spin_lock (&fs->conn_lock);
fsc->next = fs->conns;
fs->conns = fsc;
- spin_unlock (&fs->conn_lock);
+ pthread_spin_unlock (&fs->conn_lock);
*conn = fsc->conn;
@@ -89,7 +89,7 @@ ftpfs_release_ftp_conn (struct ftpfs *fs, struct ftp_conn *conn)
{
struct ftpfs_conn *fsc, *pfsc;
- spin_lock (&fs->conn_lock);
+ pthread_spin_lock (&fs->conn_lock);
for (pfsc = 0, fsc = fs->conns; fsc; pfsc = fsc, fsc = fsc->next)
if (fsc->conn == conn)
{
@@ -102,5 +102,5 @@ ftpfs_release_ftp_conn (struct ftpfs *fs, struct ftp_conn *conn)
break;
}
assert (fsc);
- spin_unlock (&fs->conn_lock);
+ pthread_spin_unlock (&fs->conn_lock);
}
diff --git a/ftpfs/dir.c b/ftpfs/dir.c
index 8ef719d8..da5ddbe5 100644
--- a/ftpfs/dir.c
+++ b/ftpfs/dir.c
@@ -460,7 +460,7 @@ ftpfs_refresh_node (struct node *node)
time_t timestamp = NOW;
struct ftpfs_dir *dir = entry->dir;
- mutex_lock (&dir->node->lock);
+ pthread_mutex_lock (&dir->node->lock);
if (! entry->self_p)
/* This is a deleted entry, just awaiting disposal; do so. */
@@ -545,7 +545,7 @@ ftpfs_refresh_node (struct node *node)
if (!nn->dir && S_ISDIR (entry->stat.st_mode))
ftpfs_dir_create (nn->fs, node, nn->rmt_path, &nn->dir);
- mutex_unlock (&dir->node->lock);
+ pthread_mutex_unlock (&dir->node->lock);
ftpfs_cache_node (node);
@@ -566,7 +566,7 @@ ftpfs_detach_node (struct node *node)
{
struct ftpfs_dir *dir = entry->dir;
- mutex_lock (&dir->node->lock);
+ pthread_mutex_lock (&dir->node->lock);
if (entry->self_p)
/* Just detach NODE from the still active entry. */
@@ -581,7 +581,7 @@ ftpfs_detach_node (struct node *node)
if (--dir->num_live_entries == 0)
netfs_nput (dir->node);
else
- mutex_unlock (&dir->node->lock);
+ pthread_mutex_unlock (&dir->node->lock);
}
return 0;
@@ -642,7 +642,7 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
if (dir->node->nn->dir_entry)
{
*node = dir->node->nn->dir_entry->dir->node;
- mutex_lock (&(*node)->lock);
+ pthread_mutex_lock (&(*node)->lock);
netfs_nref (*node);
}
else
@@ -651,7 +651,7 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
*node = 0;
}
- mutex_unlock (&dir->node->lock);
+ pthread_mutex_unlock (&dir->node->lock);
return err;
}
@@ -711,10 +711,10 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
{
/* If there's already a node, add a ref so that it doesn't go
away. */
- spin_lock (&netfs_node_refcnt_lock);
+ pthread_spin_lock (&netfs_node_refcnt_lock);
if (e->node)
e->node->references++;
- spin_unlock (&netfs_node_refcnt_lock);
+ pthread_spin_unlock (&netfs_node_refcnt_lock);
if (! e->node)
/* No node; make one and install it into E. */
@@ -740,9 +740,9 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
/* Keep a reference to dir's node corresponding to
children. */
{
- spin_lock (&netfs_node_refcnt_lock);
+ pthread_spin_lock (&netfs_node_refcnt_lock);
dir->node->references++;
- spin_unlock (&netfs_node_refcnt_lock);
+ pthread_spin_unlock (&netfs_node_refcnt_lock);
}
}
}
@@ -754,8 +754,8 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
because the locking order is always child-parent. We know
the child node won't go away because we already hold the
additional reference to it. */
- mutex_unlock (&dir->node->lock);
- mutex_lock (&e->node->lock);
+ pthread_mutex_unlock (&dir->node->lock);
+ pthread_mutex_lock (&e->node->lock);
}
}
else
@@ -765,7 +765,7 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
if (err)
{
*node = 0;
- mutex_unlock (&dir->node->lock);
+ pthread_mutex_unlock (&dir->node->lock);
}
if (rmt_path)
@@ -794,10 +794,10 @@ ftpfs_dir_null_lookup (struct ftpfs_dir *dir, struct node **node)
/* We've got a dir entry, get a node for it. */
{
/* If there's already a node, add a ref so that it doesn't go away. */
- spin_lock (&netfs_node_refcnt_lock);
+ pthread_spin_lock (&netfs_node_refcnt_lock);
if (e->node)
e->node->references++;
- spin_unlock (&netfs_node_refcnt_lock);
+ pthread_spin_unlock (&netfs_node_refcnt_lock);
if (! e->node)
/* No node; make one and install it into E. */
@@ -807,9 +807,9 @@ ftpfs_dir_null_lookup (struct ftpfs_dir *dir, struct node **node)
if (!err && dir->num_live_entries++ == 0)
/* Keep a reference to dir's node corresponding to children. */
{
- spin_lock (&netfs_node_refcnt_lock);
+ pthread_spin_lock (&netfs_node_refcnt_lock);
dir->node->references++;
- spin_unlock (&netfs_node_refcnt_lock);
+ pthread_spin_unlock (&netfs_node_refcnt_lock);
}
}
@@ -846,9 +846,9 @@ ftpfs_dir_create (struct ftpfs *fs, struct node *node, const char *rmt_path,
}
/* Hold a reference to the new dir's node. */
- spin_lock (&netfs_node_refcnt_lock);
+ pthread_spin_lock (&netfs_node_refcnt_lock);
node->references++;
- spin_unlock (&netfs_node_refcnt_lock);
+ pthread_spin_unlock (&netfs_node_refcnt_lock);
new->num_entries = 0;
new->num_live_entries = 0;
diff --git a/ftpfs/fs.c b/ftpfs/fs.c
index e4db3031..d3a93070 100644
--- a/ftpfs/fs.c
+++ b/ftpfs/fs.c
@@ -48,10 +48,10 @@ ftpfs_create (char *rmt_path, int fsid,
new->free_conns = 0;
new->conns = 0;
- spin_lock_init (&new->conn_lock);
+ pthread_spin_init (&new->conn_lock, PTHREAD_PROCESS_PRIVATE);
new->node_cache_mru = new->node_cache_lru = 0;
new->node_cache_len = 0;
- mutex_init (&new->node_cache_lock);
+ pthread_mutex_init (&new->node_cache_lock, NULL);
new->fsid = fsid;
new->next_inode = 2;
@@ -62,7 +62,7 @@ ftpfs_create (char *rmt_path, int fsid,
hurd_ihash_init (&new->inode_mappings,
offsetof (struct ftpfs_dir_entry, inode_locp));
- spin_lock_init (&new->inode_mappings_lock);
+ pthread_spin_init (&new->inode_mappings_lock, PTHREAD_PROCESS_PRIVATE);
super_root = netfs_make_node (0);
if (! super_root)
diff --git a/ftpfs/ftpfs.c b/ftpfs/ftpfs.c
index 393cc5ba..794439b4 100644
--- a/ftpfs/ftpfs.c
+++ b/ftpfs/ftpfs.c
@@ -72,7 +72,7 @@ extern error_t lookup_server (const char *server,
static FILE *debug_stream = 0;
static char *debug_stream_name = 0;
-static struct mutex debug_lock = MUTEX_INITIALIZER;
+static pthread_mutex_t debug_lock = PTHREAD_MUTEX_INITIALIZER;
/* Prints ftp connection log to DEBUG_STREAM. */
static void
@@ -87,14 +87,14 @@ cntl_debug (struct ftp_conn *conn, int type, const char *txt)
default: type_str = "?"; break;
}
- mutex_lock (&debug_lock);
+ pthread_mutex_lock (&debug_lock);
if (debug_stream)
{
fprintf (debug_stream, "%u.%s%s\n",
(unsigned)(uintptr_t)conn->hook, type_str, txt);
fflush (debug_stream);
}
- mutex_unlock (&debug_lock);
+ pthread_mutex_unlock (&debug_lock);
}
/* Various default parameters. */
@@ -154,7 +154,7 @@ parse_common_opt (int key, char *arg, struct argp_state *state)
switch (key)
{
case 'D':
- mutex_lock (&debug_lock);
+ pthread_mutex_lock (&debug_lock);
if (debug_stream && debug_stream != stderr)
fclose (debug_stream);
@@ -189,16 +189,16 @@ parse_common_opt (int key, char *arg, struct argp_state *state)
if (! err)
ftpfs_ftp_hooks.cntl_debug = cntl_debug;
- mutex_unlock (&debug_lock);
+ pthread_mutex_unlock (&debug_lock);
return err;
case OPT_NO_DEBUG:
- mutex_lock (&debug_lock);
+ pthread_mutex_lock (&debug_lock);
if (debug_stream && debug_stream != stderr)
fclose (debug_stream);
ftpfs_ftp_hooks.cntl_debug = 0;
- mutex_unlock (&debug_lock);
+ pthread_mutex_unlock (&debug_lock);
break;
case OPT_NODE_CACHE_MAX:
@@ -338,7 +338,7 @@ netfs_append_args (char **argz, size_t *argz_len)
} \
} while (0)
- mutex_lock (&debug_lock);
+ pthread_mutex_lock (&debug_lock);
if (ftpfs_ftp_hooks.cntl_debug && debug_stream)
{
if (debug_stream != stderr)
@@ -351,7 +351,7 @@ netfs_append_args (char **argz, size_t *argz_len)
else
err = argz_add (argz, argz_len, "--debug");
}
- mutex_unlock (&debug_lock);
+ pthread_mutex_unlock (&debug_lock);
if (ftpfs->params.name_timeout != DEFAULT_NAME_TIMEOUT)
FOPT ("--name-timeout=%ld", ftpfs->params.name_timeout);
diff --git a/ftpfs/ftpfs.h b/ftpfs/ftpfs.h
index 0eef5bde..206726f1 100644
--- a/ftpfs/ftpfs.h
+++ b/ftpfs/ftpfs.h
@@ -22,7 +22,7 @@
#define __FTPFS_H__
#include <stdlib.h>
-#include <cthreads.h>
+#include <pthread.h>
#include <ftpconn.h>
#include <maptime.h>
#include <hurd/ihash.h>
@@ -163,7 +163,7 @@ struct ftpfs
/* A pool of ftp connections for server threads to use. */
struct ftpfs_conn *free_conns;
struct ftpfs_conn *conns;
- spin_lock_t conn_lock;
+ pthread_spinlock_t conn_lock;
/* Parameters for making new ftp connections. */
struct ftp_conn_params *ftp_params;
@@ -175,14 +175,14 @@ struct ftpfs
/* A hash table mapping inode numbers to directory entries. */
struct hurd_ihash inode_mappings;
- spin_lock_t inode_mappings_lock;
+ pthread_spinlock_t inode_mappings_lock;
struct ftpfs_params params;
/* A cache that holds a reference to recently used nodes. */
struct node *node_cache_mru, *node_cache_lru;
size_t node_cache_len; /* Number of entries in it. */
- struct mutex node_cache_lock;
+ pthread_mutex_t node_cache_lock;
};
extern volatile struct mapped_time_value *ftpfs_maptime;
diff --git a/ftpfs/ncache.c b/ftpfs/ncache.c
index 27b868a7..612dc081 100644
--- a/ftpfs/ncache.c
+++ b/ftpfs/ncache.c
@@ -51,7 +51,7 @@ ftpfs_cache_node (struct node *node)
struct netnode *nn = node->nn;
struct ftpfs *fs = nn->fs;
- mutex_lock (&fs->node_cache_lock);
+ pthread_mutex_lock (&fs->node_cache_lock);
if (fs->params.node_cache_max > 0 || fs->node_cache_len > 0)
{
@@ -83,5 +83,5 @@ ftpfs_cache_node (struct node *node)
}
}
- mutex_unlock (&fs->node_cache_lock);
+ pthread_mutex_unlock (&fs->node_cache_lock);
}
diff --git a/ftpfs/netfs.c b/ftpfs/netfs.c
index 8922f3ab..5359acb9 100644
--- a/ftpfs/netfs.c
+++ b/ftpfs/netfs.c
@@ -41,7 +41,7 @@ netfs_attempt_create_file (struct iouser *user, struct node *dir,
char *name, mode_t mode, struct node **node)
{
*node = 0;
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
return EOPNOTSUPP;
}
@@ -413,7 +413,7 @@ error_t netfs_attempt_mkfile (struct iouser *user, struct node *dir,
mode_t mode, struct node **node)
{
*node = 0;
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
return EROFS;
}
diff --git a/ftpfs/node.c b/ftpfs/node.c
index d949016c..74cd402e 100644
--- a/ftpfs/node.c
+++ b/ftpfs/node.c
@@ -61,9 +61,9 @@ ftpfs_create_node (struct ftpfs_dir_entry *e, const char *rmt_path,
fshelp_touch (&new->nn_stat, TOUCH_ATIME|TOUCH_MTIME|TOUCH_CTIME,
ftpfs_maptime);
- spin_lock (&nn->fs->inode_mappings_lock);
+ pthread_spin_lock (&nn->fs->inode_mappings_lock);
err = hurd_ihash_add (&nn->fs->inode_mappings, e->stat.st_ino, e);
- spin_unlock (&nn->fs->inode_mappings_lock);
+ pthread_spin_unlock (&nn->fs->inode_mappings_lock);
if (err)
{
@@ -87,7 +87,7 @@ netfs_node_norefs (struct node *node)
/* Ftpfs_detach_node does ref count frobbing (of other nodes), so we have
to unlock NETFS_NODE_REFCNT_LOCK during it. */
node->references++;
- spin_unlock (&netfs_node_refcnt_lock);
+ pthread_spin_unlock (&netfs_node_refcnt_lock);
/* Remove NODE from any entry it is attached to. */
ftpfs_detach_node (node);
@@ -99,9 +99,9 @@ netfs_node_norefs (struct node *node)
}
/* Remove this entry from the set of known inodes. */
- spin_lock (&nn->fs->inode_mappings_lock);
+ pthread_spin_lock (&nn->fs->inode_mappings_lock);
hurd_ihash_locp_remove (&nn->fs->inode_mappings, nn->dir_entry->inode_locp);
- spin_unlock (&nn->fs->inode_mappings_lock);
+ pthread_spin_unlock (&nn->fs->inode_mappings_lock);
if (nn->contents)
ccache_free (nn->contents);
@@ -110,5 +110,5 @@ netfs_node_norefs (struct node *node)
free (node);
/* Caller expects us to leave this locked... */
- spin_lock (&netfs_node_refcnt_lock);
+ pthread_spin_lock (&netfs_node_refcnt_lock);
}