[prev in list] [next in list] [prev in thread] [next in thread]
List: hurd-bug
Subject: [PATCH] unionfs: port to pthread, minor build fixes
From: Pino Toscano <toscano.pino () tiscali ! it>
Date: 2013-03-14 18:16:14
Message-ID: 201303141916.20118.toscano.pino () tiscali ! it
[Download RAW message or body]
[Attachment #2 (multipart/mixed)]
Hi,
attached there are few patches for unionfs, to port it to pthread and
fix small build-related issues/warnings.
Not that unionfs will work any better now that how it did before, but at
least can be compiled again now...
I guess unionfs is covered by the copyright assignment for "hurd", isn't
it?
Thanks,
--
Pino Toscano
["0001-Switch-from-cthreads-to-pthreads.patch" (text/x-patch)]
From 1d14864c9908ffa9fafdd7b281fe90236c294d8e Mon Sep 17 00:00:00 2001
From: Pino Toscano <toscano.pino@tiscali.i>
Date: Thu, 14 Mar 2013 17:32:04 +0100
Subject: [PATCH] Switch from cthreads to pthreads
Makefiles, headers, types, macros and function calls are renamed where
appropriate.
* Makefile: Switch from cthreads to pthreads.
* lib.c: Likewise.
* lib.h: Likewise.
* lnode.c: Likewise.
* lnode.h: Likewise.
* ncache.c: Likewise.
* ncache.h: Likewise.
* netfs.c: Likewise.
* node.c: Likewise.
* options.c: Likewise.
* pattern.c: Likewise.
* pattern.h: Likewise.
* stow.c: Likewise.
* ulfs.c: Likewise.
* ulfs.h: Likewise.
* update.c: Likewise.
---
Makefile | 2 +-
lib.c | 5 +++--
lib.h | 6 +++---
lnode.c | 10 +++++-----
lnode.h | 4 ++--
ncache.c | 12 ++++++------
ncache.h | 4 ++--
netfs.c | 52 ++++++++++++++++++++++++++--------------------------
node.c | 16 ++++++++--------
options.c | 2 +-
pattern.c | 16 ++++++++--------
pattern.h | 4 ++--
stow.c | 26 ++++++++++++++++----------
ulfs.c | 15 +++++++--------
ulfs.h | 8 +++++---
update.c | 43 +++++++++++++++++++++++++------------------
16 files changed, 120 insertions(+), 105 deletions(-)
diff --git a/Makefile b/Makefile
index 7ef2100..8f58759 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@ MIGCOM = mig -cc cat - /dev/null
CFLAGS += -Wall -g -O2 -D_FILE_OFFSET_BITS=64 -std=gnu99 \
-DDEBUG
-LDFLAGS += -lnetfs -lfshelp -liohelp -lthreads \
+LDFLAGS += -lnetfs -lfshelp -liohelp -lpthread \
-lports -lihash -lshouldbeinlibc -lhurdbugaddr
OBJS = main.o node.o lnode.o ulfs.o ncache.o netfs.o \
lib.o options.o pattern.o stow.o update.o
diff --git a/lib.c b/lib.c
index 0423c1b..05c2da0 100644
--- a/lib.c
+++ b/lib.c
@@ -19,18 +19,19 @@
#define _GNU_SOURCE
-#include <hurd/netfs.h>
+#include <pthread.h>
#include <error.h>
#include <dirent.h>
#include <errno.h>
#include <sys/mman.h>
#include <stddef.h>
+#include <string.h>
#include "lib.h"
/* Lock, which must be held, during printing of debugging
messages. */
-struct mutex debug_msg_lock = MUTEX_INITIALIZER;
+pthread_mutex_t debug_msg_lock = PTHREAD_MUTEX_INITIALIZER;
/* Returns no error if PATH points to a directory. */
error_t check_dir (char *path)
diff --git a/lib.h b/lib.h
index be9a219..095adaa 100644
--- a/lib.h
+++ b/lib.h
@@ -65,17 +65,17 @@ error_t file_lookup (file_t dir, char *name, int flags0, int flags1, int mode,
/* Returns no error if directory. */
error_t check_dir (char *path);
-extern struct mutex debug_msg_lock;
+extern pthread_mutex_t debug_msg_lock;
/* Support for debugging messages. */
#define debug_msg_send(fmt, args...) \
do \
{ \
- mutex_lock (&debug_msg_lock); \
+ pthread_mutex_lock (&debug_msg_lock); \
fprintf (stderr, "%s:%i: ", __FILE__, __LINE__); \
fprintf (stderr, fmt , ## args); \
putc ('\n', stderr); \
- mutex_unlock (&debug_msg_lock); \
+ pthread_mutex_unlock (&debug_msg_lock); \
} \
while (0)
diff --git a/lnode.c b/lnode.c
index 9b242bb..10d32ca 100644
--- a/lnode.c
+++ b/lnode.c
@@ -22,7 +22,7 @@
#define _GNU_SOURCE
-#include <hurd/netfs.h>
+#include <pthread.h>
#include <error.h>
#include <stdlib.h>
#include <string.h>
@@ -66,8 +66,8 @@ lnode_create (char *name, lnode_t **node)
node_new->dir = NULL;
node_new->entries = NULL;
node_new->references = 1;
- mutex_init (&node_new->lock);
- mutex_lock (&node_new->lock);
+ pthread_mutex_init (&node_new->lock, NULL);
+ pthread_mutex_lock (&node_new->lock);
*node = node_new;
}
}
@@ -127,7 +127,7 @@ lnode_ref_remove (lnode_t *node)
lnode_destroy (node);
}
else
- mutex_unlock (&node->lock);
+ pthread_mutex_unlock (&node->lock);
}
/* Get a light node by it's name. The looked up node is locked and
@@ -142,7 +142,7 @@ lnode_get (lnode_t *dir, char *name,
for (n = dir->entries; n && strcmp (n->name, name); n = n->next);
if (n)
{
- mutex_lock (&n->lock);
+ pthread_mutex_lock (&n->lock);
lnode_ref_add (n);
*node = n;
}
diff --git a/lnode.h b/lnode.h
index b43b7b2..f5a50f7 100644
--- a/lnode.h
+++ b/lnode.h
@@ -22,7 +22,7 @@
#ifndef INCLUDED_LNODE_H
#define INCLUDED_LNODE_H
-#include <hurd/netfs.h>
+#include <pthread.h>
#include <error.h>
struct lnode
@@ -40,7 +40,7 @@ struct lnode
contained int. */
struct lnode *entries; /* A reference to the list containing
the entries of this light node. */
- struct mutex lock; /* A lock. */
+ pthread_mutex_t lock; /* A lock. */
};
typedef struct lnode lnode_t;
diff --git a/ncache.c b/ncache.c
index 4c83ac0..2ebad57 100644
--- a/ncache.c
+++ b/ncache.c
@@ -43,7 +43,7 @@ ncache_init (int size_max)
ncache.lru = NULL;
ncache.size_max = size_max;
ncache.size_current = 0;
- mutex_init (&ncache.lock);
+ pthread_mutex_init (&ncache.lock, NULL);
}
/* Remove the given node NODE from the cache. */
@@ -70,10 +70,10 @@ ncache_reset (void)
{
node_t *node;
- mutex_lock (&ncache.lock);
+ pthread_mutex_lock (&ncache.lock);
while ((node = ncache.mru))
ncache_node_remove (node);
- mutex_unlock (&ncache.lock);
+ pthread_mutex_unlock (&ncache.lock);
}
/* Lookup the node for the light node LNODE. If it does not exist
@@ -101,7 +101,7 @@ ncache_node_lookup (lnode_t *lnode, node_t **node)
if (! err)
{
- mutex_lock (&n->lock);
+ pthread_mutex_lock (&n->lock);
*node = n;
}
return err;
@@ -112,7 +112,7 @@ ncache_node_lookup (lnode_t *lnode, node_t **node)
void
ncache_node_add (node_t *node)
{
- mutex_lock (&ncache.lock);
+ pthread_mutex_lock (&ncache.lock);
debug_msg ("adding node to cache: %s", node->nn->lnode->name);
@@ -147,5 +147,5 @@ ncache_node_add (node_t *node)
netfs_nrele (lru);
}
- mutex_unlock (&ncache.lock);
+ pthread_mutex_unlock (&ncache.lock);
}
diff --git a/ncache.h b/ncache.h
index 8fa7d10..dd9c330 100644
--- a/ncache.h
+++ b/ncache.h
@@ -21,7 +21,7 @@
#define INCLUDED_NCACHE_H
#include <error.h>
-#include <hurd/netfs.h>
+#include <pthread.h>
#include "node.h"
@@ -35,7 +35,7 @@ typedef struct ncache
cache. */
int size_current; /* Current number of nodes in the
cache. */
- struct mutex lock; /* A lock. */
+ pthread_mutex_t lock; /* A lock. */
} ncache_t;
/* Cache size, may be overwritten by the user. */
diff --git a/netfs.c b/netfs.c
index 9d24f06..d93f896 100644
--- a/netfs.c
+++ b/netfs.c
@@ -292,7 +292,7 @@ netfs_attempt_sync (struct iouser *cred, struct node *np,
/* The index of the currently analyzed filesystem. */
int i;
- mutex_lock (&ulfs_lock);
+ pthread_mutex_lock (&ulfs_lock);
/* Sync every directory associated with `np`.
@@ -320,7 +320,7 @@ netfs_attempt_sync (struct iouser *cred, struct node *np,
++i;
}
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
return final_err;
}
@@ -338,7 +338,7 @@ netfs_attempt_syncfs (struct iouser *cred, int wait)
/* The index of the currently analyzed filesystem. */
int i;
- mutex_lock (&ulfs_lock);
+ pthread_mutex_lock (&ulfs_lock);
/* Sync every unioned directory maintained by unionfs.
@@ -364,7 +364,7 @@ netfs_attempt_syncfs (struct iouser *cred, int wait)
++i;
}
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
return final_err;
}
@@ -507,7 +507,7 @@ error_t
netfs_attempt_mkfile (struct iouser *user, struct node *dir,
mode_t mode, struct node **np)
{
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
return EOPNOTSUPP;
}
@@ -519,7 +519,7 @@ error_t
netfs_attempt_create_file (struct iouser *user, struct node *dir,
char *name, mode_t mode, struct node **np)
{
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
return EOPNOTSUPP;
}
@@ -546,10 +546,10 @@ netfs_attempt_create_file_reduced (struct iouser *user, struct node *dir,
goto exit;
}
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
err = node_lookup_file (dir, name, flags | O_CREAT,
&p, &statbuf);
- mutex_lock (&dir->lock);
+ pthread_mutex_lock (&dir->lock);
if (err)
goto exit;
@@ -590,7 +590,7 @@ netfs_attempt_create_file_reduced (struct iouser *user, struct node *dir,
port_dealloc (p);
exit:
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
return err;
}
@@ -682,7 +682,7 @@ netfs_attempt_lookup_improved (struct iouser *user, struct node *dir,
mach_port_t p;
error_t err;
- mutex_lock (&dir->nn->lnode->lock);
+ pthread_mutex_lock (&dir->nn->lnode->lock);
err = fshelp_access (&dir->nn_stat, S_IEXEC, user);
if (err)
@@ -724,14 +724,14 @@ netfs_attempt_lookup_improved (struct iouser *user, struct node *dir,
err = node_update (dir);
/* We have to unlock this node while doing lookups. */
- mutex_unlock (&dir_lnode->lock);
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir_lnode->lock);
+ pthread_mutex_unlock (&dir->lock);
err = node_lookup_file (dir, name, flags & ~(O_NOLINK|O_CREAT),
&p, &statbuf);
- mutex_lock (&dir->lock);
- mutex_lock (&dir_lnode->lock);
+ pthread_mutex_lock (&dir->lock);
+ pthread_mutex_lock (&dir_lnode->lock);
if (err)
@@ -820,12 +820,12 @@ netfs_attempt_lookup_improved (struct iouser *user, struct node *dir,
*np = NULL;
else if (*np)
{
- mutex_unlock (&(*np)->lock);
+ pthread_mutex_unlock (&(*np)->lock);
ncache_node_add (*np);
}
- mutex_unlock (&dir->nn->lnode->lock);
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->nn->lnode->lock);
+ pthread_mutex_unlock (&dir->lock);
return err;
}
@@ -880,14 +880,14 @@ netfs_S_dir_lookup (struct protid *diruser,
/* Set things up in the state expected by the code from gotit: on. */
dnp = 0;
np = diruser->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
netfs_nref (np);
goto gotit;
}
dnp = diruser->po->np;
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
netfs_nref (dnp); /* acquire a reference for later netfs_nput */
@@ -932,7 +932,7 @@ netfs_S_dir_lookup (struct protid *diruser,
if (! lastcomp)
strcpy (retry_name, nextname);
error = 0;
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
goto out;
}
else if (diruser->po->root_parent != MACH_PORT_NULL)
@@ -946,7 +946,7 @@ netfs_S_dir_lookup (struct protid *diruser,
if (!lastcomp)
strcpy (retry_name, nextname);
error = 0;
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
goto out;
}
else
@@ -974,7 +974,7 @@ netfs_S_dir_lookup (struct protid *diruser,
{
mode &= ~(S_IFMT | S_ISPARE | S_ISVTX);
mode |= S_IFREG;
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
error = netfs_attempt_create_file_reduced (diruser->user, dnp,
filename, mode, flags);
@@ -986,7 +986,7 @@ netfs_S_dir_lookup (struct protid *diruser,
that's fine; otherwise, we have to retry the lookup. */
if ((!error) || (error == EEXIST && !excl))
{
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
goto retry_lookup;
}
@@ -999,9 +999,9 @@ netfs_S_dir_lookup (struct protid *diruser,
if (np)
{
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
error = netfs_validate_stat (np, diruser->user);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
if (error)
goto out;
}
@@ -1059,7 +1059,7 @@ netfs_S_dir_lookup (struct protid *diruser,
create = 0;
}
netfs_nput (np);
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
np = 0;
}
else
diff --git a/node.c b/node.c
index cf9a8b4..6e1b849 100644
--- a/node.c
+++ b/node.c
@@ -93,7 +93,7 @@ node_destroy (node_t *node)
debug_msg ("node destroy: %s", node->nn->lnode->name);
assert (! (node->nn->ncache_next || node->nn->ncache_prev));
node_ulfs_free (node);
- mutex_lock (&node->nn->lnode->lock);
+ pthread_mutex_lock (&node->nn->lnode->lock);
node->nn->lnode->node = NULL;
lnode_ref_remove (node->nn->lnode);
free (node->nn);
@@ -118,12 +118,12 @@ node_update (node_t *node)
if (node_is_root (node))
return err;
- mutex_lock (&netfs_root_node->lock);
+ pthread_mutex_lock (&netfs_root_node->lock);
err = lnode_path_construct (node->nn->lnode, &path);
if (err)
{
- mutex_unlock (&netfs_root_node->lock);
+ pthread_mutex_unlock (&netfs_root_node->lock);
return err;
}
@@ -178,7 +178,7 @@ node_update (node_t *node)
free (path);
node->nn->flags |= FLAG_NODE_ULFS_UPTODATE;
- mutex_unlock (&netfs_root_node->lock);
+ pthread_mutex_unlock (&netfs_root_node->lock);
return err;
}
@@ -500,7 +500,7 @@ node_create_root (node_t **root_node)
return err;
}
- mutex_unlock (&lnode->lock);
+ pthread_mutex_unlock (&lnode->lock);
*root_node = node;
return err;
}
@@ -515,12 +515,12 @@ node_init_root (node_t *node)
ulfs_t *ulfs;
int i = 0;
- mutex_lock (&ulfs_lock);
+ pthread_mutex_lock (&ulfs_lock);
err = node_ulfs_init (node);
if (err)
{
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
return err;
}
@@ -550,6 +550,6 @@ node_init_root (node_t *node)
i++;
}
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
return err;
}
diff --git a/options.c b/options.c
index 2d3a11f..37b5d4a 100644
--- a/options.c
+++ b/options.c
@@ -79,7 +79,7 @@ argp_parse_common_options (int key, char *arg, struct argp_state *state)
ulfs_match = 0, ulfs_priority = 0;
static struct patternlist ulfs_patternlist =
{
- .lock = MUTEX_INITIALIZER,
+ .lock = PTHREAD_MUTEX_INITIALIZER,
.head = NULL
};
error_t err = 0;
diff --git a/pattern.c b/pattern.c
index 68a0791..7ec94e1 100644
--- a/pattern.c
+++ b/pattern.c
@@ -58,7 +58,7 @@ patternlist_add (struct patternlist *list, char *pattern)
listentry->pattern = dup;
- mutex_lock (& (list->lock));
+ pthread_mutex_lock (& (list->lock));
if (list->head == NULL) /* List is empty. */
{
list->head = listentry;
@@ -69,7 +69,7 @@ patternlist_add (struct patternlist *list, char *pattern)
listentry->next = list->head;
list->head = listentry;
}
- mutex_unlock (& (list->lock));
+ pthread_mutex_unlock (& (list->lock));
return err;
}
@@ -84,7 +84,7 @@ patternlist_match (struct patternlist *list, char *string)
ptr = list->head;
- mutex_lock (&list->lock);
+ pthread_mutex_lock (&list->lock);
while (ptr != NULL)
{
err = fnmatch (ptr->pattern, string, FNM_FILE_NAME);
@@ -94,7 +94,7 @@ patternlist_match (struct patternlist *list, char *string)
ptr = ptr->next;
}
- mutex_unlock (&list->lock);
+ pthread_mutex_unlock (&list->lock);
return err;
}
@@ -105,7 +105,7 @@ patternlist_destroy (struct patternlist *list)
{
struct pattern *next, *ptr = list->head;
- mutex_lock (& (list->lock));
+ pthread_mutex_lock (& (list->lock));
while (ptr != NULL)
{
next = ptr->next;
@@ -114,7 +114,7 @@ patternlist_destroy (struct patternlist *list)
ptr = next;
}
- mutex_unlock (& (list->lock));
+ pthread_mutex_unlock (& (list->lock));
}
/* Return nonzero if *PATTERNLIST is empty. */
@@ -123,9 +123,9 @@ patternlist_isempty (struct patternlist *list)
{
int ret;
- mutex_lock (& (list->lock));
+ pthread_mutex_lock (& (list->lock));
ret = (list->head == NULL);
- mutex_unlock (& (list->lock));
+ pthread_mutex_unlock (& (list->lock));
return ret;
}
diff --git a/pattern.h b/pattern.h
index 1bab993..e5b1835 100644
--- a/pattern.h
+++ b/pattern.h
@@ -22,7 +22,7 @@
#ifndef _PATTERN_H
#define _PATTERN_H
-#include <hurd/netfs.h> /* For mutex stuff. */
+#include <pthread.h>
struct pattern
{
@@ -33,7 +33,7 @@ struct pattern
struct patternlist
{
- struct mutex lock;
+ pthread_mutex_t lock;
struct pattern *head;
};
diff --git a/stow.c b/stow.c
index fa99747..fa52e66 100644
--- a/stow.c
+++ b/stow.c
@@ -35,7 +35,7 @@ struct stow_privdata
struct patternlist *patternlist;
int flags;
int priority;
- struct mutex lock;
+ pthread_mutex_t lock;
};
static error_t
@@ -78,7 +78,7 @@ _stow_scanstowentry (char *arg, char *dirpath, void *priv)
free (tmp);
}
- mutex_lock (&privdata->lock);
+ pthread_mutex_lock (&privdata->lock);
if (patternlist_isempty (privdata->patternlist))
{
@@ -86,7 +86,7 @@ _stow_scanstowentry (char *arg, char *dirpath, void *priv)
err = ulfs_register (filepath, privdata->flags, privdata->priority);
if (err)
{
- mutex_unlock (&privdata->lock);
+ pthread_mutex_unlock (&privdata->lock);
return err;
}
@@ -96,21 +96,20 @@ _stow_scanstowentry (char *arg, char *dirpath, void *priv)
err = for_each_subdir_priv (filepath, _stow_registermatchingdirs, priv);
if (err)
{
- mutex_unlock (&privdata->lock);
+ pthread_mutex_unlock (&privdata->lock);
free (filepath);
return err;
}
}
free (filepath);
- mutex_unlock (&privdata->lock);
+ pthread_mutex_unlock (&privdata->lock);
return err;
}
/* Implement server for fs_notify. */
-#include <cthreads.h>
#include <hurd/port.h>
#include "stow-priv.h"
@@ -227,8 +226,8 @@ stow_S_dir_changed (stow_notify_t notify, natural_t tickno,
}
/* This is the server thread waiting for dir_changed messages. */
-static void
-_stow_notify_thread()
+static void *
+_stow_notify_thread(void *arg)
{
int stow_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
{
@@ -247,6 +246,8 @@ _stow_notify_thread()
0);
}
while (1);
+
+ return NULL;
}
@@ -294,7 +295,7 @@ stow_diradd (char *dir, int flags, struct patternlist *patternlist,
mypriv->patternlist = patternlist;
mypriv->flags = flags;
mypriv->priority = priority;
- mutex_init (&mypriv->lock);
+ pthread_mutex_init (&mypriv->lock, NULL);
err = for_each_subdir_priv (dir, _stow_scanstowentry, (void *)mypriv);
if (err)
@@ -313,6 +314,7 @@ error_t
stow_init (void)
{
error_t err = 0;
+ pthread_t thread;
stow_port_bucket = ports_create_bucket ();
if (!stow_port_bucket)
@@ -322,7 +324,11 @@ stow_init (void)
if (!stow_port_class)
return errno;
- cthread_detach (cthread_fork ( (cthread_fn_t)_stow_notify_thread, 0));
+ err = pthread_create (&thread, NULL, _stow_notify_thread, NULL);
+ if (err)
+ return err;
+
+ pthread_detach (thread);
return err;
}
diff --git a/ulfs.c b/ulfs.c
index 3c565a5..c0a1464 100644
--- a/ulfs.c
+++ b/ulfs.c
@@ -21,7 +21,6 @@
#define _GNU_SOURCE
-#include <hurd/netfs.h>
#include <stdlib.h>
#include <error.h>
#include <string.h>
@@ -43,7 +42,7 @@ ulfs_t *ulfs_chain_end;
unsigned int ulfs_num;
/* The lock protecting the ulfs data structures. */
-struct mutex ulfs_lock = MUTEX_INITIALIZER;
+pthread_mutex_t ulfs_lock = PTHREAD_MUTEX_INITIALIZER;
/* Create a new ulfs element. */
static error_t
@@ -226,7 +225,7 @@ ulfs_register (char *path, int flags, int priority)
return err;
}
- mutex_lock (&ulfs_lock);
+ pthread_mutex_lock (&ulfs_lock);
err = ulfs_create (path, &ulfs);
if (! err)
{
@@ -235,7 +234,7 @@ ulfs_register (char *path, int flags, int priority)
ulfs_install (ulfs);
ulfs_num++;
}
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
return err;
}
@@ -254,7 +253,7 @@ ulfs_check ()
struct ulfs_destroy *next;
} *ulfs_destroy_q = NULL;
- mutex_lock (&ulfs_lock);
+ pthread_mutex_lock (&ulfs_lock);
u = ulfs_chain_start;
while (u)
@@ -296,7 +295,7 @@ ulfs_check ()
free (ptr);
}
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
}
@@ -307,7 +306,7 @@ ulfs_unregister (char *path)
ulfs_t *ulfs;
error_t err;
- mutex_lock (&ulfs_lock);
+ pthread_mutex_lock (&ulfs_lock);
err = ulfs_get_path (path, &ulfs);
if (! err)
{
@@ -315,7 +314,7 @@ ulfs_unregister (char *path)
ulfs_destroy (ulfs);
ulfs_num--;
}
- mutex_unlock (&ulfs_lock);
+ pthread_mutex_unlock (&ulfs_lock);
return err;
}
diff --git a/ulfs.h b/ulfs.h
index 532e3c7..a39a7f7 100644
--- a/ulfs.h
+++ b/ulfs.h
@@ -22,6 +22,8 @@
#ifndef INCLUDED_ULFS_H
#define INCLUDED_ULFS_H
+#include <pthread.h>
+
/* The structure for each registered underlying filesystem. */
typedef struct ulfs
{
@@ -47,7 +49,7 @@ extern ulfs_t *ulfs_chain_end;
extern unsigned int ulfs_num;
/* The lock protecting the ulfs data structures. */
-extern struct mutex ulfs_lock;
+extern pthread_mutex_t ulfs_lock;
/* Register a new underlying filesystem. */
error_t ulfs_register (char *path, int flags, int priority);
@@ -62,9 +64,9 @@ error_t ulfs_get_num (int num, ulfs_t **ulfs);
void ulfs_check (void);
#define ulfs_iterate \
- for (ulfs_t *ulfs = (mutex_lock (&ulfs_lock), \
+ for (ulfs_t *ulfs = (pthread_mutex_lock (&ulfs_lock), \
ulfs_chain_start); \
- ulfs || (mutex_unlock (&ulfs_lock), 0); \
+ ulfs || (pthread_mutex_unlock (&ulfs_lock), 0); \
ulfs = ulfs->next)
#define ulfs_iterate_unlocked \
diff --git a/update.c b/update.c
index 8ec6688..cba9924 100644
--- a/update.c
+++ b/update.c
@@ -24,8 +24,6 @@
#include <errno.h>
#include <string.h>
-#include <cthreads.h>
-#include <rwlock.h>
#include "ncache.h"
#include "node.h"
@@ -34,21 +32,21 @@
/* Reader lock is used by threads that are going to
add/remove an ulfs; writer lock is hold by the
update thread. */
-static struct rwlock update_rwlock;
-static struct condition update_wakeup;
-static struct mutex update_lock;
+static pthread_rwlock_t update_rwlock;
+static pthread_cond_t update_wakeup;
+static pthread_mutex_t update_lock;
-static void
-_root_update_thread ()
+static void *
+_root_update_thread (void *arg)
{
error_t err;
while (1)
{
- if (hurd_condition_wait (&update_wakeup, &update_lock))
- mutex_unlock (&update_lock);
+ if (pthread_hurd_cond_wait_np (&update_wakeup, &update_lock))
+ pthread_mutex_unlock (&update_lock);
- rwlock_writer_lock (&update_rwlock);
+ pthread_rwlock_wrlock (&update_rwlock);
do
{
@@ -64,34 +62,43 @@ _root_update_thread ()
ncache_reset ();
- rwlock_writer_unlock (&update_rwlock);
+ pthread_rwlock_unlock (&update_rwlock);
}
+
+ return NULL;
}
void
root_update_schedule ()
{
- condition_signal (&update_wakeup);
+ pthread_cond_signal (&update_wakeup);
}
void
root_update_disable ()
{
- rwlock_reader_lock (&update_rwlock);
+ pthread_rwlock_rdlock (&update_rwlock);
}
void
root_update_enable ()
{
- rwlock_reader_unlock (&update_rwlock);
+ pthread_rwlock_unlock (&update_rwlock);
}
void
root_update_init()
{
- mutex_init (&update_lock);
- rwlock_init (&update_rwlock);
- condition_init (&update_wakeup);
+ pthread_t thread;
+ error_t err;
+
+ pthread_mutex_init (&update_lock, NULL);
+ pthread_rwlock_init (&update_rwlock, NULL);
+ pthread_cond_init (&update_wakeup, NULL);
- cthread_detach (cthread_fork ( (cthread_fn_t)_root_update_thread, 0));
+ err = pthread_create (&thread, NULL, _root_update_thread, NULL);
+ if (!err)
+ pthread_detach (thread);
+ else
+ perror ("root_update_init/pthread_create");
}
--
1.7.10.4
["0002-Fix-type-of-underlying_node_stat.patch" (text/x-patch)]
From e5344300cd4838e1e47d119a245b670d782cf862 Mon Sep 17 00:00:00 2001
From: Pino Toscano <toscano.pino@tiscali.i>
Date: Thu, 14 Mar 2013 17:42:24 +0100
Subject: [PATCH] Fix type of underlying_node_stat
* main.c (underlying_node_stat): Change type to io_statbuf_t.
* unionfs.h: (underlying_node_stat): Likewise.
---
main.c | 2 +-
unionfs.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
index c33b065..69a73df 100644
--- a/main.c
+++ b/main.c
@@ -53,7 +53,7 @@ pid_t fsid;
mach_port_t underlying_node;
/* stat information for the underlying node. */
-struct stat underlying_node_stat;
+io_statbuf_t underlying_node_stat;
/* Mapped time, used for updating node information. */
volatile struct mapped_time_value *maptime;
diff --git a/unionfs.h b/unionfs.h
index 8f5a087..6796752 100644
--- a/unionfs.h
+++ b/unionfs.h
@@ -76,7 +76,7 @@ extern volatile struct mapped_time_value *maptime;
extern mach_port_t underlying_node;
/* stat information for the underlying node. */
-extern struct stat underlying_node_stat;
+extern io_statbuf_t underlying_node_stat;
/* Send a debugging message, if unionfs is in debugging mode. */
#define debug_msg(fmt, args...) \
--
1.7.10.4
["0003-Fix-printf-format-for-priority.patch" (text/x-patch)]
From ec27c82e87ec8fadb6c28317a161c6d00785bb07 Mon Sep 17 00:00:00 2001
From: Pino Toscano <toscano.pino@tiscali.i>
Date: Thu, 14 Mar 2013 17:47:10 +0100
Subject: [PATCH] Fix printf format for priority
* netfs.c (netfs_append_args): Use %d as printf format for ULFS->PRIORITY.
---
netfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/netfs.c b/netfs.c
index d93f896..74fe8aa 100644
--- a/netfs.c
+++ b/netfs.c
@@ -60,7 +60,7 @@ netfs_append_args (char **argz, size_t *argz_len)
if (ulfs->priority)
{
char *buf = NULL;
- if ((err = asprintf (&buf, "%s=%s", OPT_LONG (OPT_LONG_PRIORITY),
+ if ((err = asprintf (&buf, "%s=%d", OPT_LONG (OPT_LONG_PRIORITY),
ulfs->priority)) != -1)
{
err = argz_add (argz, argz_len, buf);
--
1.7.10.4
["0004-Define-_GNU_SOURCE-at-Makefile-level.patch" (text/x-patch)]
From e75554c9ee5ac71327e2c6aec5772f4cb0ed3653 Mon Sep 17 00:00:00 2001
From: Pino Toscano <toscano.pino@tiscali.i>
Date: Thu, 14 Mar 2013 18:00:17 +0100
Subject: [PATCH] Define _GNU_SOURCE at Makefile level
Provide the _GNU_SOURCE define at the CFLAGS, instead of repeating it in every
source.
* Makefile (CFLAGS): Add -D_GNU_SOURCE.
* lib.c (_GNU_SOURCE): Remove define.
* lnode.c (_GNU_SOURCE): Likewise.
* main.c (_GNU_SOURCE): Likewise.
* ncache.c (_GNU_SOURCE): Likewise.
* netfs.c (_GNU_SOURCE): Likewise.
* node.c (_GNU_SOURCE): Likewise.
* options.c (_GNU_SOURCE): Likewise.
* pattern.c (_GNU_SOURCE): Likewise.
* stow.c (_GNU_SOURCE): Likewise.
* ulfs.c (_GNU_SOURCE): Likewise.
* update.c (_GNU_SOURCE): Likewise.
---
Makefile | 2 +-
lib.c | 2 --
lnode.c | 2 --
main.c | 2 --
ncache.c | 2 --
netfs.c | 2 --
node.c | 2 --
options.c | 2 --
pattern.c | 2 --
stow.c | 2 --
ulfs.c | 2 --
update.c | 2 --
12 files changed, 1 insertion(+), 23 deletions(-)
diff --git a/Makefile b/Makefile
index 8f58759..9801dbf 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@
CPP = gcc -E -x c
MIGCOM = mig -cc cat - /dev/null
-CFLAGS += -Wall -g -O2 -D_FILE_OFFSET_BITS=64 -std=gnu99 \
+CFLAGS += -Wall -g -O2 -D_FILE_OFFSET_BITS=64 -std=gnu99 -D_GNU_SOURCE \
-DDEBUG
LDFLAGS += -lnetfs -lfshelp -liohelp -lpthread \
-lports -lihash -lshouldbeinlibc -lhurdbugaddr
diff --git a/lib.c b/lib.c
index 05c2da0..e7f3aa9 100644
--- a/lib.c
+++ b/lib.c
@@ -17,8 +17,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA. */
-#define _GNU_SOURCE
-
#include <pthread.h>
#include <error.h>
#include <dirent.h>
diff --git a/lnode.c b/lnode.c
index 10d32ca..427bc3c 100644
--- a/lnode.c
+++ b/lnode.c
@@ -20,8 +20,6 @@
/* `light node' management. See unionfs.h for an explanation of light
nodes. */
-#define _GNU_SOURCE
-
#include <pthread.h>
#include <error.h>
#include <stdlib.h>
diff --git a/main.c b/main.c
index 69a73df..bd25e30 100644
--- a/main.c
+++ b/main.c
@@ -17,8 +17,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA. */
-#define _GNU_SOURCE
-
#include <hurd/netfs.h>
#include <argp.h>
#include <argz.h>
diff --git a/ncache.c b/ncache.c
index 2ebad57..32bdda9 100644
--- a/ncache.c
+++ b/ncache.c
@@ -17,8 +17,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA. */
-#define _GNU_SOURCE
-
#include <hurd/netfs.h>
#include <error.h>
#include <stdlib.h>
diff --git a/netfs.c b/netfs.c
index 74fe8aa..974d309 100644
--- a/netfs.c
+++ b/netfs.c
@@ -18,8 +18,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA. */
-#define _GNU_SOURCE
-
#include <hurd/netfs.h>
#include <error.h>
#include <argz.h>
diff --git a/node.c b/node.c
index 6e1b849..19228f6 100644
--- a/node.c
+++ b/node.c
@@ -19,8 +19,6 @@
/* node management. */
-#define _GNU_SOURCE
-
#include <hurd/netfs.h>
#include <stdlib.h>
#include <error.h>
diff --git a/options.c b/options.c
index 37b5d4a..b1f1620 100644
--- a/options.c
+++ b/options.c
@@ -19,8 +19,6 @@
/* Argument parsing. */
-#define _GNU_SOURCE
-
#include <argp.h>
#include <error.h>
diff --git a/pattern.c b/pattern.c
index 7ec94e1..409ed23 100644
--- a/pattern.c
+++ b/pattern.c
@@ -19,8 +19,6 @@
/* Pattern list management. */
-#define _GNU_SOURCE
-
#include <hurd/netfs.h>
#include <stdlib.h>
#include <fnmatch.h>
diff --git a/stow.c b/stow.c
index fa52e66..cf6366e 100644
--- a/stow.c
+++ b/stow.c
@@ -20,8 +20,6 @@
/* Stow mode for unionfs. */
-#define _GNU_SOURCE
-
#include <argp.h>
#include <error.h>
diff --git a/ulfs.c b/ulfs.c
index c0a1464..50affa6 100644
--- a/ulfs.c
+++ b/ulfs.c
@@ -19,8 +19,6 @@
/* Underlying filesystem management. */
-#define _GNU_SOURCE
-
#include <stdlib.h>
#include <error.h>
#include <string.h>
diff --git a/update.c b/update.c
index cba9924..113b25c 100644
--- a/update.c
+++ b/update.c
@@ -20,8 +20,6 @@
/* Update thread: A clean way to solve locking issues of
root node update. */
-#define _GNU_SOURCE
-
#include <errno.h>
#include <string.h>
--
1.7.10.4
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic