summaryrefslogtreecommitdiff
path: root/libdiskfs
diff options
context:
space:
mode:
Diffstat (limited to 'libdiskfs')
-rw-r--r--libdiskfs/Makefile3
-rw-r--r--libdiskfs/boot-start.c20
-rw-r--r--libdiskfs/dead-name.c4
-rw-r--r--libdiskfs/dir-chg.c10
-rw-r--r--libdiskfs/dir-link.c28
-rw-r--r--libdiskfs/dir-lookup.c14
-rw-r--r--libdiskfs/dir-mkdir.c6
-rw-r--r--libdiskfs/dir-mkfile.c8
-rw-r--r--libdiskfs/dir-readdir.c8
-rw-r--r--libdiskfs/dir-rename.c52
-rw-r--r--libdiskfs/dir-renamed.c22
-rw-r--r--libdiskfs/dir-rmdir.c6
-rw-r--r--libdiskfs/dir-unlink.c10
-rw-r--r--libdiskfs/disk-pager.c25
-rw-r--r--libdiskfs/diskfs-pager.h12
-rw-r--r--libdiskfs/diskfs.h8
-rw-r--r--libdiskfs/file-access.c4
-rw-r--r--libdiskfs/file-chg.c6
-rw-r--r--libdiskfs/file-exec.c4
-rw-r--r--libdiskfs/file-get-fs-opts.c4
-rw-r--r--libdiskfs/file-get-trans.c4
-rw-r--r--libdiskfs/file-get-transcntl.c4
-rw-r--r--libdiskfs/file-getcontrol.c4
-rw-r--r--libdiskfs/file-getfh.c4
-rw-r--r--libdiskfs/file-lock-stat.c4
-rw-r--r--libdiskfs/file-lock.c4
-rw-r--r--libdiskfs/file-reparent.c4
-rw-r--r--libdiskfs/file-set-trans.c30
-rw-r--r--libdiskfs/file-sync.c4
-rw-r--r--libdiskfs/file-syncfs.c4
-rw-r--r--libdiskfs/fsys-getroot.c20
-rw-r--r--libdiskfs/fsys-options.c16
-rw-r--r--libdiskfs/fsys-syncfs.c8
-rw-r--r--libdiskfs/ifsock.c30
-rw-r--r--libdiskfs/init-first.c19
-rw-r--r--libdiskfs/init-init.c10
-rw-r--r--libdiskfs/init-startup.c12
-rw-r--r--libdiskfs/io-duplicate.c4
-rw-r--r--libdiskfs/io-get-conch.c6
-rw-r--r--libdiskfs/io-identity.c4
-rw-r--r--libdiskfs/io-map-cntl.c8
-rw-r--r--libdiskfs/io-map.c6
-rw-r--r--libdiskfs/io-modes-get.c4
-rw-r--r--libdiskfs/io-modes-off.c4
-rw-r--r--libdiskfs/io-modes-on.c4
-rw-r--r--libdiskfs/io-modes-set.c4
-rw-r--r--libdiskfs/io-owner-get.c4
-rw-r--r--libdiskfs/io-owner-mod.c4
-rw-r--r--libdiskfs/io-prenotify.c8
-rw-r--r--libdiskfs/io-read.c6
-rw-r--r--libdiskfs/io-readable.c4
-rw-r--r--libdiskfs/io-reauthenticate.c6
-rw-r--r--libdiskfs/io-rel-conch.c6
-rw-r--r--libdiskfs/io-restrict-auth.c4
-rw-r--r--libdiskfs/io-revoke.c4
-rw-r--r--libdiskfs/io-seek.c4
-rw-r--r--libdiskfs/io-sigio.c4
-rw-r--r--libdiskfs/io-stat.c4
-rw-r--r--libdiskfs/io-write.c4
-rw-r--r--libdiskfs/lookup.c6
-rw-r--r--libdiskfs/name-cache.c26
-rw-r--r--libdiskfs/node-drop.c4
-rw-r--r--libdiskfs/node-make.c2
-rw-r--r--libdiskfs/node-nput.c14
-rw-r--r--libdiskfs/node-nputl.c6
-rw-r--r--libdiskfs/node-nref.c8
-rw-r--r--libdiskfs/node-nrefl.c4
-rw-r--r--libdiskfs/node-nrele.c18
-rw-r--r--libdiskfs/node-nrelel.c6
-rw-r--r--libdiskfs/peropen-rele.c4
-rw-r--r--libdiskfs/priv.h6
-rw-r--r--libdiskfs/shutdown.c10
-rw-r--r--libdiskfs/sync-interval.c34
73 files changed, 358 insertions, 331 deletions
diff --git a/libdiskfs/Makefile b/libdiskfs/Makefile
index 606ed954..3c8de4c8 100644
--- a/libdiskfs/Makefile
+++ b/libdiskfs/Makefile
@@ -60,7 +60,8 @@ MIGSTUBS = fsServer.o ioServer.o fsysServer.o exec_startupServer.o \
startup_notifyServer.o
OBJS = $(sort $(SRCS:.c=.o) $(MIGSTUBS))
-HURDLIBS = fshelp iohelp store threads ports shouldbeinlibc pager
+HURDLIBS = fshelp iohelp store ports shouldbeinlibc pager
+LDLIBS += -lpthread
fsys-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h -DREPLY_PORTS
fs-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h
diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index 15563bdb..1e4a1c64 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -40,8 +40,8 @@ static mach_port_t diskfs_exec_ctl;
extern task_t diskfs_exec_server_task;
static task_t parent_task = MACH_PORT_NULL;
-static struct mutex execstartlock;
-static struct condition execstarted;
+static pthread_mutex_t execstartlock;
+static pthread_cond_t execstarted;
const char *diskfs_boot_init_program = _HURD_INIT;
@@ -155,12 +155,12 @@ diskfs_start_bootstrap ()
fflush (stdout);
/* Get the execserver going and wait for its fsys_startup */
- mutex_init (&execstartlock);
- condition_init (&execstarted);
- mutex_lock (&execstartlock);
+ pthread_mutex_init (&execstartlock, NULL);
+ pthread_cond_init (&execstarted, NULL);
+ pthread_mutex_lock (&execstartlock);
start_execserver ();
- condition_wait (&execstarted, &execstartlock);
- mutex_unlock (&execstartlock);
+ pthread_cond_wait (&execstarted, &execstartlock);
+ pthread_mutex_unlock (&execstartlock);
assert (diskfs_exec_ctl != MACH_PORT_NULL);
/* Contact the exec server. */
@@ -414,9 +414,9 @@ diskfs_execboot_fsys_startup (mach_port_t port, int flags,
diskfs_exec_ctl = ctl;
- mutex_lock (&execstartlock);
- condition_signal (&execstarted);
- mutex_unlock (&execstartlock);
+ pthread_mutex_lock (&execstartlock);
+ pthread_cond_signal (&execstarted);
+ pthread_mutex_unlock (&execstartlock);
ports_port_deref (pt);
return 0;
}
diff --git a/libdiskfs/dead-name.c b/libdiskfs/dead-name.c
index f5b641d2..760b36ff 100644
--- a/libdiskfs/dead-name.c
+++ b/libdiskfs/dead-name.c
@@ -30,7 +30,7 @@ ports_dead_name (void *notify, mach_port_t dead_name)
if (pi)
{
np = pi->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
if (dead_name == np->sockaddr)
{
mach_port_deallocate (mach_task_self (), np->sockaddr);
@@ -38,7 +38,7 @@ ports_dead_name (void *notify, mach_port_t dead_name)
diskfs_nput (np);
}
else
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
}
ports_interrupt_notified_rpcs (notify, dead_name, MACH_NOTIFY_DEAD_NAME);
diff --git a/libdiskfs/dir-chg.c b/libdiskfs/dir-chg.c
index 7ca34447..ed8f40c1 100644
--- a/libdiskfs/dir-chg.c
+++ b/libdiskfs/dir-chg.c
@@ -31,28 +31,28 @@ diskfs_S_dir_notice_changes (struct protid *cred,
return EOPNOTSUPP;
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
if (!S_ISDIR (np->dn_stat.st_mode))
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return ENOTDIR;
}
err = dir_changed (notify, np->dirmod_tick, DIR_CHANGED_NULL, "");
if (err)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return err;
}
req = malloc (sizeof (struct modreq));
if (! req)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return ENOMEM;
}
req->port = notify;
req->next = np->dirmod_reqs;
np->dirmod_reqs = req;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return 0;
}
diff --git a/libdiskfs/dir-link.c b/libdiskfs/dir-link.c
index 82f8aeec..45d88948 100644
--- a/libdiskfs/dir-link.c
+++ b/libdiskfs/dir-link.c
@@ -41,16 +41,16 @@ diskfs_S_dir_link (struct protid *dircred,
return EXDEV;
np = filecred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
if (S_ISDIR (np->dn_stat.st_mode))
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EPERM;
}
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
dnp = dircred->po->np;
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
/* Lookup new location */
error = diskfs_lookup (dnp, name, RENAME, &tnp, ds, dircred);
@@ -64,15 +64,15 @@ diskfs_S_dir_link (struct protid *dircred,
if (error == EAGAIN)
error = EINVAL;
diskfs_drop_dirstat (dnp, ds);
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
return error;
}
if (np == tnp)
{
diskfs_drop_dirstat (dnp, ds);
- mutex_unlock (&dnp->lock);
- mutex_unlock (&tnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&tnp->lock);
mach_port_deallocate (mach_task_self (), filecred->pi.port_right);
return 0;
}
@@ -80,8 +80,8 @@ diskfs_S_dir_link (struct protid *dircred,
if (tnp && S_ISDIR (tnp->dn_stat.st_mode))
{
diskfs_drop_dirstat (dnp, ds);
- mutex_unlock (&dnp->lock);
- mutex_unlock (&tnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&tnp->lock);
return EISDIR;
}
@@ -89,14 +89,14 @@ diskfs_S_dir_link (struct protid *dircred,
/* This is safe because NP is not a directory (thus not DNP) and
not TNP and is a leaf. */
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
/* Increment link count */
if (np->dn_stat.st_nlink == diskfs_link_max - 1)
{
diskfs_drop_dirstat (dnp, ds);
- mutex_unlock (&np->lock);
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&dnp->lock);
return EMLINK;
}
np->dn_stat.st_nlink++;
@@ -124,8 +124,8 @@ diskfs_S_dir_link (struct protid *dircred,
if (diskfs_synchronous)
diskfs_node_update (dnp, 1);
- mutex_unlock (&dnp->lock);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&np->lock);
if (!error)
/* MiG won't do this for us, which it ought to. */
mach_port_deallocate (mach_task_self (), filecred->pi.port_right);
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c
index 7e092908..1efdf75c 100644
--- a/libdiskfs/dir-lookup.c
+++ b/libdiskfs/dir-lookup.c
@@ -77,14 +77,14 @@ diskfs_S_dir_lookup (struct protid *dircred,
/* Set things up in the state expected by the code from gotit: on. */
dnp = 0;
np = dircred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
diskfs_nref (np);
goto gotit;
}
dnp = dircred->po->np;
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
np = 0;
diskfs_nref (dnp); /* acquire a reference for later diskfs_nput */
@@ -271,7 +271,7 @@ diskfs_S_dir_lookup (struct protid *dircred,
ports_port_deref (newpi);
newpi = 0;
if (np != dnp)
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
error = fshelp_fetch_root (&np->transbox, dircred->po,
dirport, dircred->user,
@@ -307,12 +307,12 @@ diskfs_S_dir_lookup (struct protid *dircred,
if (np != dnp)
{
if (!strcmp (path, ".."))
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
else
{
- mutex_unlock (&np->lock);
- mutex_lock (&dnp->lock);
- mutex_lock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
+ pthread_mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&np->lock);
}
}
}
diff --git a/libdiskfs/dir-mkdir.c b/libdiskfs/dir-mkdir.c
index 30d7a3b4..1ddb8087 100644
--- a/libdiskfs/dir-mkdir.c
+++ b/libdiskfs/dir-mkdir.c
@@ -36,7 +36,7 @@ diskfs_S_dir_mkdir (struct protid *dircred,
if (diskfs_check_readonly ())
return EROFS;
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
error = diskfs_lookup (dnp, name, CREATE, 0, ds, dircred);
if (error == EAGAIN)
@@ -47,7 +47,7 @@ diskfs_S_dir_mkdir (struct protid *dircred,
if (error != ENOENT)
{
diskfs_drop_dirstat (dnp, ds);
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
return error;
}
@@ -65,6 +65,6 @@ diskfs_S_dir_mkdir (struct protid *dircred,
if (!error)
diskfs_nput (np);
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
return error;
}
diff --git a/libdiskfs/dir-mkfile.c b/libdiskfs/dir-mkfile.c
index 914b18fe..a38d89a5 100644
--- a/libdiskfs/dir-mkfile.c
+++ b/libdiskfs/dir-mkfile.c
@@ -41,23 +41,23 @@ diskfs_S_dir_mkfile (struct protid *cred,
if (diskfs_check_readonly ())
return EROFS;
dnp = cred->po->np;
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
if (!S_ISDIR (dnp->dn_stat.st_mode))
{
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
return ENOTDIR;
}
err = fshelp_access (&dnp->dn_stat, S_IWRITE, cred->user);
if (err)
{
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
return err;
}
mode &= ~(S_IFMT | S_ISPARE | S_ISVTX | S_ITRANS);
mode |= S_IFREG;
err = diskfs_create_node (dnp, 0, mode, &np, cred, 0);
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
if (diskfs_synchronous)
{
diff --git a/libdiskfs/dir-readdir.c b/libdiskfs/dir-readdir.c
index d2f9d750..1393e26f 100644
--- a/libdiskfs/dir-readdir.c
+++ b/libdiskfs/dir-readdir.c
@@ -40,22 +40,22 @@ diskfs_S_dir_readdir (struct protid *cred,
return EOPNOTSUPP;
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
if ((cred->po->openstat & O_READ) == 0)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EBADF;
}
if ((np->dn_stat.st_mode & S_IFMT) != S_IFDIR)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return ENOTDIR;
}
err = diskfs_get_directs (np, entry, nentries, data, datacnt, bufsiz, amt);
*data_dealloc = 1; /* XXX */
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return err;
}
diff --git a/libdiskfs/dir-rename.c b/libdiskfs/dir-rename.c
index 298669be..ff9dead0 100644
--- a/libdiskfs/dir-rename.c
+++ b/libdiskfs/dir-rename.c
@@ -24,7 +24,7 @@
/* To avoid races in checkpath, and to prevent a directory from being
simultaneously renamed by two processes, we serialize all renames of
directores with this lock */
-static struct mutex renamedirlock = MUTEX_INITIALIZER;
+static pthread_mutex_t renamedirlock = PTHREAD_MUTEX_INITIALIZER;
/* Implement dir_rename as described in <hurd/fs.defs>. */
kern_return_t
@@ -63,9 +63,9 @@ diskfs_S_dir_rename (struct protid *fromcred,
/* Acquire the source; hold a reference to it. This
will prevent anyone from deleting it before we create
the new link. */
- mutex_lock (&fdp->lock);
+ pthread_mutex_lock (&fdp->lock);
err = diskfs_lookup (fdp, fromname, LOOKUP, &fnp, 0, fromcred);
- mutex_unlock (&fdp->lock);
+ pthread_mutex_unlock (&fdp->lock);
if (err == EAGAIN)
err = EINVAL;
if (err)
@@ -73,44 +73,44 @@ diskfs_S_dir_rename (struct protid *fromcred,
if (S_ISDIR (fnp->dn_stat.st_mode))
{
- mutex_unlock (&fnp->lock);
- if (!mutex_try_lock (&renamedirlock))
+ pthread_mutex_unlock (&fnp->lock);
+ if (pthread_mutex_trylock (&renamedirlock))
{
diskfs_nrele (fnp);
- mutex_lock (&renamedirlock);
+ pthread_mutex_lock (&renamedirlock);
goto try_again;
}
err = diskfs_rename_dir (fdp, fnp, fromname, tdp, toname, fromcred,
tocred);
if (diskfs_synchronous)
{
- mutex_lock (&fdp->lock);
+ pthread_mutex_lock (&fdp->lock);
diskfs_file_update (fdp, 1);
- mutex_unlock (&fdp->lock);
+ pthread_mutex_unlock (&fdp->lock);
- mutex_lock (&fnp->lock);
+ pthread_mutex_lock (&fnp->lock);
diskfs_file_update (fnp, 1);
- mutex_unlock (&fnp->lock);
+ pthread_mutex_unlock (&fnp->lock);
- mutex_lock (&tdp->lock);
+ pthread_mutex_lock (&tdp->lock);
diskfs_file_update (tdp, 1);
- mutex_unlock (&tdp->lock);
+ pthread_mutex_unlock (&tdp->lock);
}
diskfs_nrele (fnp);
- mutex_unlock (&renamedirlock);
+ pthread_mutex_unlock (&renamedirlock);
if (!err)
/* MiG won't do this for us, which it ought to. */
mach_port_deallocate (mach_task_self (), tocred->pi.port_right);
return err;
}
- mutex_unlock (&fnp->lock);
+ pthread_mutex_unlock (&fnp->lock);
/* We now hold no locks */
/* Link the node into the new directory. */
- mutex_lock (&tdp->lock);
+ pthread_mutex_lock (&tdp->lock);
err = diskfs_lookup (tdp, toname, RENAME, &tnp, ds, tocred);
if (err == EAGAIN)
@@ -124,7 +124,7 @@ diskfs_S_dir_rename (struct protid *fromcred,
{
diskfs_drop_dirstat (tdp, ds);
diskfs_nrele (fnp);
- mutex_unlock (&tdp->lock);
+ pthread_mutex_unlock (&tdp->lock);
return err;
}
@@ -135,7 +135,7 @@ diskfs_S_dir_rename (struct protid *fromcred,
diskfs_drop_dirstat (tdp, ds);
diskfs_nrele (fnp);
diskfs_nput (tnp);
- mutex_unlock (&tdp->lock);
+ pthread_mutex_unlock (&tdp->lock);
mach_port_deallocate (mach_task_self (), tocred->pi.port_right);
return 0;
}
@@ -146,11 +146,11 @@ diskfs_S_dir_rename (struct protid *fromcred,
diskfs_drop_dirstat (tdp, ds);
diskfs_nrele (fnp);
diskfs_nput (tnp);
- mutex_unlock (&tdp->lock);
+ pthread_mutex_unlock (&tdp->lock);
return EISDIR;
}
- mutex_lock (&fnp->lock);
+ pthread_mutex_lock (&fnp->lock);
/* Increment the link count for the upcoming link */
if (fnp->dn_stat.st_nlink == diskfs_link_max - 1)
@@ -159,7 +159,7 @@ diskfs_S_dir_rename (struct protid *fromcred,
diskfs_nput (fnp);
if (tnp)
diskfs_nput (tnp);
- mutex_unlock (&tdp->lock);
+ pthread_mutex_unlock (&tdp->lock);
return EMLINK;
}
fnp->dn_stat.st_nlink++;
@@ -184,8 +184,8 @@ diskfs_S_dir_rename (struct protid *fromcred,
if (diskfs_synchronous)
diskfs_node_update (tdp, 1);
- mutex_unlock (&tdp->lock);
- mutex_unlock (&fnp->lock);
+ pthread_mutex_unlock (&tdp->lock);
+ pthread_mutex_unlock (&fnp->lock);
if (err)
{
diskfs_nrele (fnp);
@@ -197,12 +197,12 @@ diskfs_S_dir_rename (struct protid *fromcred,
/* Now we remove the source. Unfortunately, we haven't held
fdp locked (nor could we), so someone else might have already
removed it. */
- mutex_lock (&fdp->lock);
+ pthread_mutex_lock (&fdp->lock);
err = diskfs_lookup (fdp, fromname, REMOVE, &tmpnp, ds, fromcred);
if (err)
{
diskfs_drop_dirstat (tdp, ds);
- mutex_unlock (&fdp->lock);
+ pthread_mutex_unlock (&fdp->lock);
diskfs_nrele (fnp);
return err;
}
@@ -213,7 +213,7 @@ diskfs_S_dir_rename (struct protid *fromcred,
diskfs_drop_dirstat (tdp, ds);
diskfs_nput (tmpnp);
diskfs_nrele (fnp);
- mutex_unlock (&fdp->lock);
+ pthread_mutex_unlock (&fdp->lock);
mach_port_deallocate (mach_task_self (), tocred->pi.port_right);
return 0;
}
@@ -231,7 +231,7 @@ diskfs_S_dir_rename (struct protid *fromcred,
diskfs_node_update (fnp, 1);
diskfs_nput (fnp);
- mutex_unlock (&fdp->lock);
+ pthread_mutex_unlock (&fdp->lock);
if (!err)
mach_port_deallocate (mach_task_self (), tocred->pi.port_right);
diff --git a/libdiskfs/dir-renamed.c b/libdiskfs/dir-renamed.c
index 3064dbaf..3990b138 100644
--- a/libdiskfs/dir-renamed.c
+++ b/libdiskfs/dir-renamed.c
@@ -76,7 +76,7 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname,
struct dirstat *ds;
struct dirstat *tmpds;
- mutex_lock (&tdp->lock);
+ pthread_mutex_lock (&tdp->lock);
diskfs_nref (tdp); /* reference and lock will get consumed by
checkpath */
err = checkpath (fnp, tdp, tocred);
@@ -86,9 +86,9 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname,
/* Now, lock the parent directories. This is legal because tdp is not
a child of fnp (guaranteed by checkpath above). */
- mutex_lock (&fdp->lock);
+ pthread_mutex_lock (&fdp->lock);
if (fdp != tdp)
- mutex_lock (&tdp->lock);
+ pthread_mutex_lock (&tdp->lock);
/* 1: Lookup target; if it exists, make sure it's an empty directory. */
ds = buf;
@@ -99,9 +99,9 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname,
{
diskfs_drop_dirstat (tdp, ds);
diskfs_nput (tnp);
- mutex_unlock (&tdp->lock);
+ pthread_mutex_unlock (&tdp->lock);
if (fdp != tdp)
- mutex_unlock (&fdp->lock);
+ pthread_mutex_unlock (&fdp->lock);
return 0;
}
@@ -167,9 +167,9 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname,
tdp. */
if (fnp->dn_stat.st_nlink == diskfs_link_max - 1)
{
- mutex_unlock (&fnp->lock);
+ pthread_mutex_unlock (&fnp->lock);
diskfs_drop_dirstat (tdp, ds);
- mutex_unlock (&tdp->lock);
+ pthread_mutex_unlock (&tdp->lock);
if (tnp)
diskfs_nput (tnp);
return EMLINK;
@@ -203,7 +203,7 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname,
/* 4: Remove the entry in fdp. */
ds = buf;
- mutex_unlock (&fnp->lock);
+ pthread_mutex_unlock (&fnp->lock);
err = diskfs_lookup (fdp, fromname, REMOVE, &tmpnp, ds, fromcred);
assert (!tmpnp || tmpnp == fnp);
if (tmpnp)
@@ -223,13 +223,13 @@ diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname,
out:
if (tdp)
- mutex_unlock (&tdp->lock);
+ pthread_mutex_unlock (&tdp->lock);
if (tnp)
diskfs_nput (tnp);
if (fdp && fdp != tdp)
- mutex_unlock (&fdp->lock);
+ pthread_mutex_unlock (&fdp->lock);
if (fnp)
- mutex_unlock (&fnp->lock);
+ pthread_mutex_unlock (&fnp->lock);
if (ds)
diskfs_drop_dirstat (tdp, ds);
return err;
diff --git a/libdiskfs/dir-rmdir.c b/libdiskfs/dir-rmdir.c
index a90ff07b..83ec37b3 100644
--- a/libdiskfs/dir-rmdir.c
+++ b/libdiskfs/dir-rmdir.c
@@ -38,7 +38,7 @@ diskfs_S_dir_rmdir (struct protid *dircred,
if (ds)
diskfs_drop_dirstat (dnp, ds);
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
return error;
}
@@ -50,7 +50,7 @@ diskfs_S_dir_rmdir (struct protid *dircred,
if (diskfs_check_readonly ())
return EROFS;
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
error = diskfs_lookup (dnp, name, REMOVE, &np, ds, dircred);
if (error)
@@ -61,7 +61,7 @@ diskfs_S_dir_rmdir (struct protid *dircred,
/* Attempt to rmdir(".") */
diskfs_nrele (np);
diskfs_drop_dirstat (dnp, ds);
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
return EINVAL;
}
diff --git a/libdiskfs/dir-unlink.c b/libdiskfs/dir-unlink.c
index e40aead5..f687a16e 100644
--- a/libdiskfs/dir-unlink.c
+++ b/libdiskfs/dir-unlink.c
@@ -37,7 +37,7 @@ diskfs_S_dir_unlink (struct protid *dircred,
if (diskfs_check_readonly ())
return EROFS;
- mutex_lock (&dnp->lock);
+ pthread_mutex_lock (&dnp->lock);
error = diskfs_lookup (dnp, name, REMOVE, &np, ds, dircred);
if (error == EAGAIN)
@@ -45,7 +45,7 @@ diskfs_S_dir_unlink (struct protid *dircred,
if (error)
{
diskfs_drop_dirstat (dnp, ds);
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
return error;
}
@@ -58,7 +58,7 @@ diskfs_S_dir_unlink (struct protid *dircred,
else
diskfs_nput (np);
diskfs_drop_dirstat (dnp, ds);
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
return EPERM; /* 1003.1-1996 5.5.1.4 */
}
@@ -68,7 +68,7 @@ diskfs_S_dir_unlink (struct protid *dircred,
if (error)
{
diskfs_nput (np);
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
return error;
}
@@ -86,7 +86,7 @@ diskfs_S_dir_unlink (struct protid *dircred,
diskfs_nrele (np);
else
diskfs_nput (np);
- mutex_unlock (&dnp->lock);
+ pthread_mutex_unlock (&dnp->lock);
if (control)
{
diff --git a/libdiskfs/disk-pager.c b/libdiskfs/disk-pager.c
index fefd2ef4..5795a281 100644
--- a/libdiskfs/disk-pager.c
+++ b/libdiskfs/disk-pager.c
@@ -21,6 +21,8 @@
#include <hurd/sigpreempt.h>
#include <error.h>
+__thread struct disk_image_user *diskfs_exception_diu;
+
struct pager *diskfs_disk_pager;
static void fault_handler (int sig, long int sigcode, struct sigcontext *scp);
@@ -33,8 +35,8 @@ static struct hurd_signal_preemptor preemptor =
/* A top-level function for the paging thread that just services paging
requests. */
-static void
-service_paging_requests (any_t arg)
+static void *
+service_paging_requests (void *arg)
{
struct port_bucket *pager_bucket = arg;
for (;;)
@@ -42,6 +44,7 @@ service_paging_requests (any_t arg)
pager_demuxer,
1000 * 60 * 2,
1000 * 60 * 10, 0);
+ return NULL;
}
void
@@ -49,12 +52,19 @@ diskfs_start_disk_pager (struct user_pager_info *upi,
struct port_bucket *pager_bucket, int may_cache,
size_t size, void **image)
{
+ pthread_t thread;
error_t err;
mach_port_t disk_pager_port;
/* Make a thread to service paging requests. */
- cthread_detach (cthread_fork ((cthread_fn_t) service_paging_requests,
- (any_t)pager_bucket));
+ err = pthread_create (&thread, NULL, service_paging_requests, pager_bucket);
+ if (!err)
+ pthread_detach (thread);
+ else
+ {
+ errno = err;
+ perror ("pthread_create");
+ }
/* Create the pager. */
diskfs_disk_pager = pager_create (upi, pager_bucket,
@@ -87,11 +97,10 @@ diskfs_start_disk_pager (struct user_pager_info *upi,
static void
fault_handler (int sig, long int sigcode, struct sigcontext *scp)
{
- jmp_buf *env = cthread_data (cthread_self ());
error_t err;
#ifndef NDEBUG
- if (!env)
+ if (diskfs_exception_diu == NULL)
{
error (0, 0,
"BUG: unexpected fault on disk image (%d, %#lx) in [%#lx,%#lx)"
@@ -107,7 +116,7 @@ fault_handler (int sig, long int sigcode, struct sigcontext *scp)
#endif
/* Clear the record, since the faulting thread will not. */
- cthread_set_data (cthread_self (), 0);
+ diskfs_exception_diu = NULL;
/* Fetch the error code from the pager. */
assert (scp->sc_error == EKERN_MEMORY_ERROR);
@@ -115,5 +124,5 @@ fault_handler (int sig, long int sigcode, struct sigcontext *scp)
assert (err);
/* Make `diskfault_catch' return the error code. */
- longjmp (*env, err);
+ longjmp (diskfs_exception_diu->env, err);
}
diff --git a/libdiskfs/diskfs-pager.h b/libdiskfs/diskfs-pager.h
index 4ec0b27b..bd0a050c 100644
--- a/libdiskfs/diskfs-pager.h
+++ b/libdiskfs/diskfs-pager.h
@@ -22,11 +22,13 @@
#include <hurd/pager.h>
#include <hurd/ports.h>
#include <setjmp.h>
-#include <cthreads.h>
+#include <pthread.h>
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
+extern __thread struct disk_image_user *diskfs_exception_diu;
+
/* Start a pager for the whole disk, and store it in DISKFS_DISK_PAGER,
preparing a signal preemptor so that the `diskfs_catch_exception' macro
below works. SIZE should be the size of the image to map, and the address
@@ -51,10 +53,10 @@ struct disk_image_user
({ \
struct disk_image_user *diu = alloca (sizeof *diu); \
error_t err; \
- diu->next = (void *) cthread_data (cthread_self ()); \
+ diu->next = diskfs_exception_diu; \
err = setjmp (diu->env); \
if (err == 0) \
- cthread_set_data (cthread_self (), diu); \
+ diskfs_exception_diu = diu; \
err; \
})
@@ -62,8 +64,8 @@ struct disk_image_user
Any unexpected fault hereafter will crash the program. */
#define diskfs_end_catch_exception() \
({ \
- struct disk_image_user *diu = (void *) cthread_data (cthread_self ()); \
- cthread_set_data (cthread_self (), diu->next); \
+ struct disk_image_user *diu = diskfs_exception_diu; \
+ diskfs_exception_diu = diu->next; \
})
diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
index 2051e41d..0f9c1d39 100644
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -22,7 +22,7 @@
#include <assert.h>
#include <unistd.h>
-#include <rwlock.h>
+#include <pthread.h>
#include <hurd/ports.h>
#include <hurd/fshelp.h>
#include <hurd/iohelp.h>
@@ -90,7 +90,7 @@ struct node
int dn_set_mtime;
int dn_stat_dirty;
- struct mutex lock;
+ pthread_mutex_t lock;
int references; /* hard references */
int light_references; /* light references */
@@ -174,7 +174,7 @@ extern const char *diskfs_boot_init_program;
/* Hold this lock while do fsys level operations. Innocuous users can just
hold a reader lock, and anyone who's going to do nasty things that would
screw anyone else should hold a writer lock. */
-extern struct rwlock diskfs_fsys_lock;
+extern pthread_rwlock_t diskfs_fsys_lock;
extern volatile struct mapped_time_value *diskfs_mtime;
@@ -184,7 +184,7 @@ extern volatile struct mapped_time_value *diskfs_mtime;
be done by format independent code. */
extern int diskfs_synchronous;
-extern spin_lock_t diskfs_node_refcnt_lock;
+extern pthread_spinlock_t diskfs_node_refcnt_lock;
extern int pager_port_type;
diff --git a/libdiskfs/file-access.c b/libdiskfs/file-access.c
index 4a5eb17d..f7e129aa 100644
--- a/libdiskfs/file-access.c
+++ b/libdiskfs/file-access.c
@@ -29,7 +29,7 @@ diskfs_S_file_check_access (struct protid *cred,
return EOPNOTSUPP;
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
*type = 0;
if (fshelp_access (&np->dn_stat, S_IREAD, cred->user) == 0)
*type |= O_READ;
@@ -38,7 +38,7 @@ diskfs_S_file_check_access (struct protid *cred,
if (fshelp_access (&np->dn_stat, S_IEXEC, cred->user) == 0)
*type |= O_EXEC;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return 0;
}
diff --git a/libdiskfs/file-chg.c b/libdiskfs/file-chg.c
index 22edc69c..2674398f 100644
--- a/libdiskfs/file-chg.c
+++ b/libdiskfs/file-chg.c
@@ -30,18 +30,18 @@ diskfs_S_file_notice_changes (struct protid *cred, mach_port_t notify)
return EOPNOTSUPP;
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
err = file_changed (notify, np->filemod_tick, FILE_CHANGED_NULL, 0, 0);
if (err)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return err;
}
req = malloc (sizeof (struct modreq));
req->port = notify;
req->next = np->filemod_reqs;
np->filemod_reqs = req;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return 0;
}
diff --git a/libdiskfs/file-exec.c b/libdiskfs/file-exec.c
index 452240c0..9572dbed 100644
--- a/libdiskfs/file-exec.c
+++ b/libdiskfs/file-exec.c
@@ -85,11 +85,11 @@ diskfs_S_file_exec (struct protid *cred,
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
mode = np->dn_stat.st_mode;
uid = np->dn_stat.st_uid;
gid = np->dn_stat.st_gid;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
if (_diskfs_noexec)
RETURN (EACCES);
diff --git a/libdiskfs/file-get-fs-opts.c b/libdiskfs/file-get-fs-opts.c
index b3bca821..1e70da23 100644
--- a/libdiskfs/file-get-fs-opts.c
+++ b/libdiskfs/file-get-fs-opts.c
@@ -39,9 +39,9 @@ diskfs_S_file_get_fs_options (struct protid *cred,
if (err)
return err;
- rwlock_reader_lock (&diskfs_fsys_lock);
+ pthread_rwlock_rdlock (&diskfs_fsys_lock);
err = diskfs_append_args (&argz, &argz_len);
- rwlock_reader_unlock (&diskfs_fsys_lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
if (! err)
/* Move ARGZ from a malloced buffer into a vm_alloced one. */
diff --git a/libdiskfs/file-get-trans.c b/libdiskfs/file-get-trans.c
index e77dba82..11ed439e 100644
--- a/libdiskfs/file-get-trans.c
+++ b/libdiskfs/file-get-trans.c
@@ -35,7 +35,7 @@ diskfs_S_file_get_translator (struct protid *cred,
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
/* First look for short-circuited translators. */
if (S_ISLNK (np->dn_stat.st_mode))
@@ -132,7 +132,7 @@ diskfs_S_file_get_translator (struct protid *cred,
}
}
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return error;
}
diff --git a/libdiskfs/file-get-transcntl.c b/libdiskfs/file-get-transcntl.c
index 528529fb..c7fad91a 100644
--- a/libdiskfs/file-get-transcntl.c
+++ b/libdiskfs/file-get-transcntl.c
@@ -32,7 +32,7 @@ diskfs_S_file_get_translator_cntl (struct protid *cred,
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
error = fshelp_isowner (&np->dn_stat, cred->user);
if (!error)
@@ -42,7 +42,7 @@ diskfs_S_file_get_translator_cntl (struct protid *cred,
if (!error)
*ctltype = MACH_MSG_TYPE_MOVE_SEND;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return error;
}
diff --git a/libdiskfs/file-getcontrol.c b/libdiskfs/file-getcontrol.c
index 23afb7cb..fc6f777e 100644
--- a/libdiskfs/file-getcontrol.c
+++ b/libdiskfs/file-getcontrol.c
@@ -40,9 +40,9 @@ diskfs_S_file_getcontrol (struct protid *cred,
if (error)
return error;
- spin_lock (&_diskfs_control_lock);
+ pthread_spin_lock (&_diskfs_control_lock);
_diskfs_ncontrol_ports++;
- spin_unlock (&_diskfs_control_lock);
+ pthread_spin_unlock (&_diskfs_control_lock);
*control = ports_get_right (newpi);
*controltype = MACH_MSG_TYPE_MAKE_SEND;
ports_port_deref (newpi);
diff --git a/libdiskfs/file-getfh.c b/libdiskfs/file-getfh.c
index 2dcf68e5..035705b5 100644
--- a/libdiskfs/file-getfh.c
+++ b/libdiskfs/file-getfh.c
@@ -41,7 +41,7 @@ diskfs_S_file_getfh (struct protid *cred, char **fh, size_t *fh_len)
node = cred->po->np;
- mutex_lock (&node->lock);
+ pthread_mutex_lock (&node->lock);
if (*fh_len < sizeof (union diskfs_fhandle))
*fh = mmap (0, sizeof (union diskfs_fhandle), PROT_READ|PROT_WRITE,
@@ -54,7 +54,7 @@ diskfs_S_file_getfh (struct protid *cred, char **fh, size_t *fh_len)
f->data.cache_id = node->cache_id;
f->data.gen = node->dn_stat.st_gen;
- mutex_unlock (&node->lock);
+ pthread_mutex_unlock (&node->lock);
return 0;
}
diff --git a/libdiskfs/file-lock-stat.c b/libdiskfs/file-lock-stat.c
index 75341617..4c371e29 100644
--- a/libdiskfs/file-lock-stat.c
+++ b/libdiskfs/file-lock-stat.c
@@ -30,9 +30,9 @@ diskfs_S_file_lock_stat (struct protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&cred->po->np->lock);
+ pthread_mutex_lock (&cred->po->np->lock);
*mystatus = cred->po->lock_status;
*otherstatus = cred->po->np->userlock.type;
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
return 0;
}
diff --git a/libdiskfs/file-lock.c b/libdiskfs/file-lock.c
index 4a348546..441daeb1 100644
--- a/libdiskfs/file-lock.c
+++ b/libdiskfs/file-lock.c
@@ -28,10 +28,10 @@ diskfs_S_file_lock (struct protid *cred, int flags)
error_t err;
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&cred->po->np->lock);
+ pthread_mutex_lock (&cred->po->np->lock);
err = fshelp_acquire_lock (&cred->po->np->userlock, &cred->po->lock_status,
&cred->po->np->lock, flags);
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
return err;
}
diff --git a/libdiskfs/file-reparent.c b/libdiskfs/file-reparent.c
index e659bcf0..da6a51d2 100644
--- a/libdiskfs/file-reparent.c
+++ b/libdiskfs/file-reparent.c
@@ -37,7 +37,7 @@ diskfs_S_file_reparent (struct protid *cred, mach_port_t parent,
node = cred->po->np;
- mutex_lock (&node->lock);
+ pthread_mutex_lock (&node->lock);
err = diskfs_make_peropen (node, cred->po->openstat, cred->po, &new_po);
if (! err)
{
@@ -45,7 +45,7 @@ diskfs_S_file_reparent (struct protid *cred, mach_port_t parent,
if (err)
diskfs_release_peropen (new_po);
}
- mutex_unlock (&node->lock);
+ pthread_mutex_unlock (&node->lock);
if (! err)
{
diff --git a/libdiskfs/file-set-trans.c b/libdiskfs/file-set-trans.c
index c9b2c613..37980015 100644
--- a/libdiskfs/file-set-trans.c
+++ b/libdiskfs/file-set-trans.c
@@ -48,12 +48,12 @@ diskfs_S_file_set_translator (struct protid *cred,
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
error = fshelp_isowner (&np->dn_stat, cred->user);
if (error)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return error;
}
@@ -63,20 +63,20 @@ diskfs_S_file_set_translator (struct protid *cred,
error = fshelp_fetch_control (&np->transbox, &control);
if (error)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return error;
}
if ((control != MACH_PORT_NULL) && ((active_flags & FS_TRANS_EXCL) == 0))
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
error = fsys_goaway (control, killtrans_flags);
mach_port_deallocate (mach_task_self (), control);
if (error && (error != MIG_SERVER_DIED)
&& (error != MACH_SEND_INVALID_DEST))
return error;
error = 0;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
}
else if (control != MACH_PORT_NULL)
mach_port_deallocate (mach_task_self (), control);
@@ -87,7 +87,7 @@ diskfs_S_file_set_translator (struct protid *cred,
&& (passive_flags & FS_TRANS_EXCL)
&& (np->dn_stat.st_mode & S_IPTRANS))
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EBUSY;
}
@@ -97,7 +97,7 @@ diskfs_S_file_set_translator (struct protid *cred,
active_flags & FS_TRANS_EXCL);
if (error)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return error;
}
}
@@ -129,7 +129,7 @@ diskfs_S_file_set_translator (struct protid *cred,
changes, the links will be lost. Perhaps it might be
allowed for empty directories, but that's too much of a
pain. */
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EISDIR;
}
if (newmode == S_IFBLK || newmode == S_IFCHR)
@@ -143,7 +143,7 @@ diskfs_S_file_set_translator (struct protid *cred,
assert (arg <= passive + passivelen);
if (arg == passive + passivelen)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EINVAL;
}
major = strtol (arg, 0, 0);
@@ -152,7 +152,7 @@ diskfs_S_file_set_translator (struct protid *cred,
assert (arg < passive + passivelen);
if (arg == passive + passivelen)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EINVAL;
}
minor = strtol (arg, 0, 0);
@@ -161,7 +161,7 @@ diskfs_S_file_set_translator (struct protid *cred,
makedev (major, minor));
if (error)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return error;
}
np->dn_stat.st_rdev = makedev (major, minor);
@@ -174,7 +174,7 @@ diskfs_S_file_set_translator (struct protid *cred,
assert (arg <= passive + passivelen);
if (arg == passive + passivelen)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EINVAL;
}
@@ -187,7 +187,7 @@ diskfs_S_file_set_translator (struct protid *cred,
1, cred, 0);
if (error)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return error;
}
}
@@ -198,13 +198,13 @@ diskfs_S_file_set_translator (struct protid *cred,
np->dn_stat.st_mode = newmode;
diskfs_node_update (np, diskfs_synchronous);
}
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return error;
}
}
error = diskfs_set_translator (np, passive, passivelen, cred);
}
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return error;
}
diff --git a/libdiskfs/file-sync.c b/libdiskfs/file-sync.c
index 94ffa9ac..20fa005c 100644
--- a/libdiskfs/file-sync.c
+++ b/libdiskfs/file-sync.c
@@ -34,9 +34,9 @@ diskfs_S_file_sync (struct protid *cred,
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
iohelp_get_conch (&np->conch);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
diskfs_file_update (np, wait);
return 0;
}
diff --git a/libdiskfs/file-syncfs.c b/libdiskfs/file-syncfs.c
index a3b7622e..b7d20a88 100644
--- a/libdiskfs/file-syncfs.c
+++ b/libdiskfs/file-syncfs.c
@@ -32,13 +32,13 @@ diskfs_S_file_syncfs (struct protid *cred,
mach_port_t control;
error = fshelp_fetch_control (&np->transbox, &control);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
if (!error && (control != MACH_PORT_NULL))
{
fsys_syncfs (control, wait, 1);
mach_port_deallocate (mach_task_self (), control);
}
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
return 0;
}
diff --git a/libdiskfs/fsys-getroot.c b/libdiskfs/fsys-getroot.c
index e083032e..2e11da4c 100644
--- a/libdiskfs/fsys-getroot.c
+++ b/libdiskfs/fsys-getroot.c
@@ -65,8 +65,8 @@ diskfs_S_fsys_getroot (fsys_t controlport,
idvec_set_ids (user.gids, gids, ngids);
#define drop_idvec() idvec_free (user.gids); idvec_free (user.uids)
- rwlock_reader_lock (&diskfs_fsys_lock);
- mutex_lock (&diskfs_root_node->lock);
+ pthread_rwlock_rdlock (&diskfs_fsys_lock);
+ pthread_mutex_lock (&diskfs_root_node->lock);
/* This code is similar (but not the same as) the code in
dir-lookup.c that does the same thing. Perhaps a way should
@@ -85,8 +85,8 @@ diskfs_S_fsys_getroot (fsys_t controlport,
retry, retryname, returned_port);
if (error != ENOENT)
{
- mutex_unlock (&diskfs_root_node->lock);
- rwlock_reader_unlock (&diskfs_fsys_lock);
+ pthread_mutex_unlock (&diskfs_root_node->lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
drop_idvec ();
if (!error)
*returned_port_poly = MACH_MSG_TYPE_MOVE_SEND;
@@ -111,8 +111,8 @@ diskfs_S_fsys_getroot (fsys_t controlport,
0, &amt);
pathbuf[amt] = '\0';
- mutex_unlock (&diskfs_root_node->lock);
- rwlock_reader_unlock (&diskfs_fsys_lock);
+ pthread_mutex_unlock (&diskfs_root_node->lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
if (error)
{
drop_idvec ();
@@ -164,8 +164,8 @@ diskfs_S_fsys_getroot (fsys_t controlport,
if (error)
{
- mutex_unlock (&diskfs_root_node->lock);
- rwlock_reader_unlock (&diskfs_fsys_lock);
+ pthread_mutex_unlock (&diskfs_root_node->lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
drop_idvec ();
return error;
}
@@ -196,8 +196,8 @@ diskfs_S_fsys_getroot (fsys_t controlport,
ports_port_deref (newpi);
}
- mutex_unlock (&diskfs_root_node->lock);
- rwlock_reader_unlock (&diskfs_fsys_lock);
+ pthread_mutex_unlock (&diskfs_root_node->lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
ports_port_deref (pt);
diff --git a/libdiskfs/fsys-options.c b/libdiskfs/fsys-options.c
index ea5ee8c5..bb183198 100644
--- a/libdiskfs/fsys-options.c
+++ b/libdiskfs/fsys-options.c
@@ -45,7 +45,7 @@ diskfs_S_fsys_set_options (fsys_t fsys,
mach_port_t control;
error = fshelp_fetch_control (&np->transbox, &control);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
if (!error && (control != MACH_PORT_NULL))
{
error = fsys_set_options (control, data, len, do_children);
@@ -53,7 +53,7 @@ diskfs_S_fsys_set_options (fsys_t fsys,
}
else
error = 0;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
if ((error == MIG_SERVER_DIED) || (error == MACH_SEND_INVALID_DEST))
error = 0;
@@ -65,16 +65,16 @@ diskfs_S_fsys_set_options (fsys_t fsys,
if (do_children)
{
- rwlock_writer_lock (&diskfs_fsys_lock);
+ pthread_rwlock_wrlock (&diskfs_fsys_lock);
err = diskfs_node_iterate (helper);
- rwlock_writer_unlock (&diskfs_fsys_lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
}
if (!err)
{
- rwlock_writer_lock (&diskfs_fsys_lock);
+ pthread_rwlock_wrlock (&diskfs_fsys_lock);
err = diskfs_set_options (data, len);
- rwlock_writer_unlock (&diskfs_fsys_lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
}
ports_port_deref (pt);
@@ -101,9 +101,9 @@ diskfs_S_fsys_get_options (fsys_t fsys,
if (err)
return err;
- rwlock_reader_lock (&diskfs_fsys_lock);
+ pthread_rwlock_rdlock (&diskfs_fsys_lock);
err = diskfs_append_args (&argz, &argz_len);
- rwlock_reader_unlock (&diskfs_fsys_lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
if (! err)
/* Move ARGZ from a malloced buffer into a vm_alloced one. */
diff --git a/libdiskfs/fsys-syncfs.c b/libdiskfs/fsys-syncfs.c
index 503eea4c..7d0c4849 100644
--- a/libdiskfs/fsys-syncfs.c
+++ b/libdiskfs/fsys-syncfs.c
@@ -39,20 +39,20 @@ diskfs_S_fsys_syncfs (fsys_t controlport,
mach_port_t control;
error = fshelp_fetch_control (&np->transbox, &control);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
if (!error && (control != MACH_PORT_NULL))
{
fsys_syncfs (control, wait, 1);
mach_port_deallocate (mach_task_self (), control);
}
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
return 0;
}
if (!pi)
return EOPNOTSUPP;
- rwlock_reader_lock (&diskfs_fsys_lock);
+ pthread_rwlock_rdlock (&diskfs_fsys_lock);
if (children)
diskfs_node_iterate (helper);
@@ -66,7 +66,7 @@ diskfs_S_fsys_syncfs (fsys_t controlport,
diskfs_set_hypermetadata (wait, 0);
}
- rwlock_reader_unlock (&diskfs_fsys_lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
ports_port_deref (pi);
diff --git a/libdiskfs/ifsock.c b/libdiskfs/ifsock.c
index 3e9b8325..1da81b85 100644
--- a/libdiskfs/ifsock.c
+++ b/libdiskfs/ifsock.c
@@ -22,7 +22,7 @@
#include <stdio.h>
#include <hurd/socket.h>
-static spin_lock_t pflocalserverlock = SPIN_LOCK_INITIALIZER;
+static pthread_spinlock_t pflocalserverlock = PTHREAD_SPINLOCK_INITIALIZER;
static mach_port_t pflocalserver = MACH_PORT_NULL;
kern_return_t
@@ -39,16 +39,16 @@ diskfs_S_ifsock_getsockaddr (struct protid *cred,
np = cred->po->np;
retry:
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
if ((np->dn_stat.st_mode & S_IFMT) != S_IFSOCK)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EOPNOTSUPP;
}
err = fshelp_access (&np->dn_stat, S_IWRITE, cred->user);
if (err)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return err;
}
@@ -58,17 +58,17 @@ diskfs_S_ifsock_getsockaddr (struct protid *cred,
mach_port_t sockaddr;
mach_port_t old;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
/* Fetch a port to the PF_LOCAL server, caching it. */
- spin_lock (&pflocalserverlock);
+ pthread_spin_lock (&pflocalserverlock);
if (pflocalserver == MACH_PORT_NULL)
{
/* Find out who the PF_LOCAL server is. */
char buf[100];
- spin_unlock (&pflocalserverlock);
+ pthread_spin_unlock (&pflocalserverlock);
/* Look it up */
sprintf (buf, "%s/%d", _SERVERS_SOCKET, PF_LOCAL);
@@ -77,17 +77,17 @@ diskfs_S_ifsock_getsockaddr (struct protid *cred,
return EIEIO;
/* Set it unless someone is already here */
- spin_lock (&pflocalserverlock);
+ pthread_spin_lock (&pflocalserverlock);
if (pflocalserver != MACH_PORT_NULL)
mach_port_deallocate (mach_task_self (), server);
else
pflocalserver = server;
- spin_unlock (&pflocalserverlock);
+ pthread_spin_unlock (&pflocalserverlock);
goto retry;
}
server = pflocalserver;
- spin_unlock (&pflocalserverlock);
+ pthread_spin_unlock (&pflocalserverlock);
/* Create an address for the node */
err = socket_fabricate_address (server, AF_LOCAL, &sockaddr);
@@ -95,19 +95,19 @@ diskfs_S_ifsock_getsockaddr (struct protid *cred,
&& restart_tries++ == 0)
/* The PF_LOCAL server died; try to restart it. */
{
- spin_lock (&pflocalserverlock);
+ pthread_spin_lock (&pflocalserverlock);
if (pflocalserver == server)
pflocalserver = MACH_PORT_NULL;
- spin_unlock (&pflocalserverlock);
+ pthread_spin_unlock (&pflocalserverlock);
goto retry;
}
if (err)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EIEIO;
}
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
if (np->sockaddr != MACH_PORT_NULL)
/* Someone beat us */
mach_port_deallocate (mach_task_self (), sockaddr);
@@ -129,7 +129,7 @@ diskfs_S_ifsock_getsockaddr (struct protid *cred,
}
*address = np->sockaddr;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return 0;
}
diff --git a/libdiskfs/init-first.c b/libdiskfs/init-first.c
index d91345be..6dd5fc4f 100644
--- a/libdiskfs/init-first.c
+++ b/libdiskfs/init-first.c
@@ -27,8 +27,8 @@ static int thread_timeout = 1000 * 60 * 2; /* two minutes */
static int server_timeout = 1000 * 60 * 10; /* ten minutes */
-static any_t
-master_thread_function (any_t demuxer)
+static void *
+master_thread_function (void *demuxer)
{
error_t err;
@@ -45,12 +45,21 @@ master_thread_function (any_t demuxer)
exit (0);
/* NOTREACHED */
- return (any_t) 0;
+ return NULL;
}
void
diskfs_spawn_first_thread (ports_demuxer_type demuxer)
{
- cthread_detach (cthread_fork ((cthread_fn_t) master_thread_function,
- (any_t) demuxer));
+ pthread_t thread;
+ error_t err;
+
+ err = pthread_create (&thread, NULL, master_thread_function, demuxer);
+ if (!err)
+ pthread_detach (thread);
+ else
+ {
+ errno = err;
+ perror ("pthread_create");
+ }
}
diff --git a/libdiskfs/init-init.c b/libdiskfs/init-init.c
index cd0c1b29..35be7edd 100644
--- a/libdiskfs/init-init.c
+++ b/libdiskfs/init-init.c
@@ -29,7 +29,7 @@ mach_port_t diskfs_default_pager;
mach_port_t diskfs_auth_server_port;
volatile struct mapped_time_value *diskfs_mtime;
-struct rwlock diskfs_fsys_lock = RWLOCK_INITIALIZER;
+pthread_rwlock_t diskfs_fsys_lock = PTHREAD_RWLOCK_INITIALIZER;
mach_port_t diskfs_fsys_identity;
int _diskfs_nosuid, _diskfs_noexec;
@@ -37,9 +37,9 @@ int _diskfs_noatime;
struct hurd_port _diskfs_exec_portcell;
-spin_lock_t diskfs_node_refcnt_lock = SPIN_LOCK_INITIALIZER;
+pthread_spinlock_t diskfs_node_refcnt_lock = PTHREAD_SPINLOCK_INITIALIZER;
-spin_lock_t _diskfs_control_lock = SPIN_LOCK_INITIALIZER;
+pthread_spinlock_t _diskfs_control_lock = PTHREAD_SPINLOCK_INITIALIZER;
int _diskfs_ncontrol_ports;
struct port_class *diskfs_protid_class;
@@ -101,7 +101,7 @@ diskfs_init_diskfs (void)
void
_diskfs_control_clean (void *arg __attribute__ ((unused)))
{
- spin_lock (&_diskfs_control_lock);
+ pthread_spin_lock (&_diskfs_control_lock);
_diskfs_ncontrol_ports--;
- spin_unlock (&_diskfs_control_lock);
+ pthread_spin_unlock (&_diskfs_control_lock);
}
diff --git a/libdiskfs/init-startup.c b/libdiskfs/init-startup.c
index ff57db38..2c0814fd 100644
--- a/libdiskfs/init-startup.c
+++ b/libdiskfs/init-startup.c
@@ -48,7 +48,7 @@ diskfs_startup_diskfs (mach_port_t bootstrap, int flags)
while (*_diskfs_chroot_directory == '/')
++_diskfs_chroot_directory;
- mutex_lock (&diskfs_root_node->lock);
+ pthread_mutex_lock (&diskfs_root_node->lock);
/* Create a protid we can use in diskfs_lookup. */
err = diskfs_make_peropen (diskfs_root_node, O_READ|O_EXEC,
@@ -60,7 +60,7 @@ diskfs_startup_diskfs (mach_port_t bootstrap, int flags)
/* Look up the directory name. */
err = diskfs_lookup (diskfs_root_node, _diskfs_chroot_directory,
LOOKUP, &np, NULL, rootpi);
- mutex_unlock (&diskfs_root_node->lock);
+ pthread_mutex_unlock (&diskfs_root_node->lock);
ports_port_deref (rootpi);
if (err == EAGAIN)
@@ -71,7 +71,7 @@ diskfs_startup_diskfs (mach_port_t bootstrap, int flags)
if (!S_ISDIR (np->dn_stat.st_mode))
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
error (1, ENOTDIR, "%s", _diskfs_chroot_directory);
}
@@ -81,7 +81,7 @@ diskfs_startup_diskfs (mach_port_t bootstrap, int flags)
if _diskfs_chroot_directory is non-null. */
old = diskfs_root_node;
diskfs_root_node = np;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
diskfs_nput (old);
}
@@ -138,7 +138,7 @@ diskfs_S_startup_dosync (mach_port_t handle)
diskfs_sync_everything (0);
diskfs_set_hypermetadata (0, 0);
- rwlock_writer_lock (&diskfs_fsys_lock);
+ pthread_rwlock_wrlock (&diskfs_fsys_lock);
/* Permit all the current RPC's to finish, and then suspend new ones */
err = ports_inhibit_class_rpcs (diskfs_protid_class);
@@ -158,7 +158,7 @@ diskfs_S_startup_dosync (mach_port_t handle)
ports_resume_class_rpcs (diskfs_protid_class);
}
- rwlock_writer_unlock (&diskfs_fsys_lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
}
ports_port_deref (pi);
diff --git a/libdiskfs/io-duplicate.c b/libdiskfs/io-duplicate.c
index 3cbf8f7b..45c4df5d 100644
--- a/libdiskfs/io-duplicate.c
+++ b/libdiskfs/io-duplicate.c
@@ -30,7 +30,7 @@ diskfs_S_io_duplicate (struct protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&cred->po->np->lock);
+ pthread_mutex_lock (&cred->po->np->lock);
err = diskfs_create_protid (cred->po, cred->user, &newpi);
if (! err)
@@ -40,7 +40,7 @@ diskfs_S_io_duplicate (struct protid *cred,
ports_port_deref (newpi);
}
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
return err;
}
diff --git a/libdiskfs/io-get-conch.c b/libdiskfs/io-get-conch.c
index 6be35f0b..fa63a398 100644
--- a/libdiskfs/io-get-conch.c
+++ b/libdiskfs/io-get-conch.c
@@ -29,16 +29,16 @@ diskfs_S_io_get_conch (struct protid *cred)
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
if (!cred->mapped)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EINVAL;
}
iohelp_handle_io_get_conch (&np->conch, cred, cred->mapped);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return 0;
}
diff --git a/libdiskfs/io-identity.c b/libdiskfs/io-identity.c
index 6f4e7546..0f3fce0f 100644
--- a/libdiskfs/io-identity.c
+++ b/libdiskfs/io-identity.c
@@ -38,9 +38,9 @@ diskfs_S_io_identity (struct protid *cred,
return EOPNOTSUPP;
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
inum = np->dn_stat.st_ino;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
err = fshelp_get_identity (diskfs_port_bucket, inum, id);
if (! err)
diff --git a/libdiskfs/io-map-cntl.c b/libdiskfs/io-map-cntl.c
index d615b046..2e9b9e98 100644
--- a/libdiskfs/io-map-cntl.c
+++ b/libdiskfs/io-map-cntl.c
@@ -29,7 +29,7 @@ diskfs_S_io_map_cntl (struct protid *cred,
return EOPNOTSUPP;
assert (__vm_page_size >= sizeof (struct shared_io));
- mutex_lock (&cred->po->np->lock);
+ pthread_mutex_lock (&cred->po->np->lock);
if (!cred->mapped)
{
default_pager_object_create (diskfs_default_pager, &cred->shared_object,
@@ -39,15 +39,15 @@ diskfs_S_io_map_cntl (struct protid *cred,
VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE, 0);
cred->mapped->shared_page_magic = SHARED_PAGE_MAGIC;
cred->mapped->conch_status = USER_HAS_NOT_CONCH;
- spin_lock_init (&cred->mapped->lock);
+ pthread_spin_init (&cred->mapped->lock, PTHREAD_PROCESS_PRIVATE);
*ctlobj = cred->shared_object;
*ctlobj_type = MACH_MSG_TYPE_COPY_SEND;
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
return 0;
}
else
{
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
return EBUSY;
}
}
diff --git a/libdiskfs/io-map.c b/libdiskfs/io-map.c
index 6268f2c5..3c1966dd 100644
--- a/libdiskfs/io-map.c
+++ b/libdiskfs/io-map.c
@@ -39,7 +39,7 @@ diskfs_S_io_map (struct protid *cred,
node = cred->po->np;
flags = cred->po->openstat & (O_READ | O_WRITE);
- mutex_lock (&node->lock);
+ pthread_mutex_lock (&node->lock);
switch (flags)
{
case O_READ | O_WRITE:
@@ -59,7 +59,7 @@ diskfs_S_io_map (struct protid *cred,
goto error;
break;
}
- mutex_unlock (&node->lock);
+ pthread_mutex_unlock (&node->lock);
*rdtype = MACH_MSG_TYPE_MOVE_SEND;
*wrtype = MACH_MSG_TYPE_MOVE_SEND;
@@ -67,7 +67,7 @@ diskfs_S_io_map (struct protid *cred,
return 0;
error:
- mutex_unlock (&node->lock);
+ pthread_mutex_unlock (&node->lock);
return errno;
}
diff --git a/libdiskfs/io-modes-get.c b/libdiskfs/io-modes-get.c
index a959881b..6bed408b 100644
--- a/libdiskfs/io-modes-get.c
+++ b/libdiskfs/io-modes-get.c
@@ -26,9 +26,9 @@ diskfs_S_io_get_openmodes (struct protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&cred->po->np->lock);
+ pthread_mutex_lock (&cred->po->np->lock);
*bits = cred->po->openstat;
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
return 0;
}
diff --git a/libdiskfs/io-modes-off.c b/libdiskfs/io-modes-off.c
index 25efcf22..b1e8f978 100644
--- a/libdiskfs/io-modes-off.c
+++ b/libdiskfs/io-modes-off.c
@@ -27,9 +27,9 @@ diskfs_S_io_clear_some_openmodes (struct protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&cred->po->np->lock);
+ pthread_mutex_lock (&cred->po->np->lock);
iohelp_get_conch (&cred->po->np->conch);
cred->po->openstat &= ~(offbits & HONORED_STATE_MODES);
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
return 0;
}
diff --git a/libdiskfs/io-modes-on.c b/libdiskfs/io-modes-on.c
index 3b7ff40c..c6ac3b12 100644
--- a/libdiskfs/io-modes-on.c
+++ b/libdiskfs/io-modes-on.c
@@ -27,9 +27,9 @@ diskfs_S_io_set_some_openmodes (struct protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&cred->po->np->lock);
+ pthread_mutex_lock (&cred->po->np->lock);
iohelp_get_conch (&cred->po->np->conch);
cred->po->openstat |= (newbits & HONORED_STATE_MODES);
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
return 0;
}
diff --git a/libdiskfs/io-modes-set.c b/libdiskfs/io-modes-set.c
index 2744a8f7..a8e2d7fa 100644
--- a/libdiskfs/io-modes-set.c
+++ b/libdiskfs/io-modes-set.c
@@ -27,10 +27,10 @@ diskfs_S_io_set_all_openmodes (struct protid *cred,
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&cred->po->np->lock);
+ pthread_mutex_lock (&cred->po->np->lock);
iohelp_get_conch (&cred->po->np->conch);
cred->po->openstat &= ~HONORED_STATE_MODES;
cred->po->openstat |= (newbits & HONORED_STATE_MODES);
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
return 0;
}
diff --git a/libdiskfs/io-owner-get.c b/libdiskfs/io-owner-get.c
index 057aa6e2..2f3e7e33 100644
--- a/libdiskfs/io-owner-get.c
+++ b/libdiskfs/io-owner-get.c
@@ -29,8 +29,8 @@ diskfs_S_io_get_owner (struct protid *cred,
return EOPNOTSUPP;
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
*owner = np->owner;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return 0;
}
diff --git a/libdiskfs/io-owner-mod.c b/libdiskfs/io-owner-mod.c
index c0977785..938c3d0d 100644
--- a/libdiskfs/io-owner-mod.c
+++ b/libdiskfs/io-owner-mod.c
@@ -29,8 +29,8 @@ diskfs_S_io_mod_owner (struct protid *cred,
return EOPNOTSUPP;
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
np->owner = owner;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return 0;
}
diff --git a/libdiskfs/io-prenotify.c b/libdiskfs/io-prenotify.c
index f193f52b..4eb1c657 100644
--- a/libdiskfs/io-prenotify.c
+++ b/libdiskfs/io-prenotify.c
@@ -37,7 +37,7 @@ diskfs_S_io_prenotify (struct protid *cred,
np = cred->po->np;
/* Clamp it down */
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
if (!cred->mapped)
{
@@ -55,9 +55,9 @@ diskfs_S_io_prenotify (struct protid *cred,
{
/* The user didn't need to do this, so we'll make sure they
have the right shared page info. */
- spin_lock (&cred->mapped->lock);
+ pthread_spin_lock (&cred->mapped->lock);
iohelp_put_shared_data (cred);
- spin_unlock (&cred->mapped->lock);
+ pthread_spin_unlock (&cred->mapped->lock);
goto out;
}
@@ -67,6 +67,6 @@ diskfs_S_io_prenotify (struct protid *cred,
if (!err && np->filemod_reqs)
diskfs_notice_filechange (np, FILE_CHANGED_EXTEND, 0, end);
out:
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return err;
}
diff --git a/libdiskfs/io-read.c b/libdiskfs/io-read.c
index 787c0eae..c849434b 100644
--- a/libdiskfs/io-read.c
+++ b/libdiskfs/io-read.c
@@ -40,7 +40,7 @@ diskfs_S_io_read (struct protid *cred,
if (!(cred->po->openstat & O_READ))
return EBADF;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
iohelp_get_conch (&np->conch);
@@ -48,7 +48,7 @@ diskfs_S_io_read (struct protid *cred,
off = cred->po->filepointer;
if (off < 0)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EINVAL;
}
@@ -104,6 +104,6 @@ diskfs_S_io_read (struct protid *cred,
if (err && ourbuf)
munmap (buf, maxread);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return err;
}
diff --git a/libdiskfs/io-readable.c b/libdiskfs/io-readable.c
index ccc241ef..c3debac3 100644
--- a/libdiskfs/io-readable.c
+++ b/libdiskfs/io-readable.c
@@ -34,13 +34,13 @@ diskfs_S_io_readable (struct protid *cred,
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
iohelp_get_conch (&np->conch);
if (np->dn_stat.st_size > cred->po->filepointer)
*amount = np->dn_stat.st_size - cred->po->filepointer;
else
*amount = 0;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return 0;
}
diff --git a/libdiskfs/io-reauthenticate.c b/libdiskfs/io-reauthenticate.c
index 3c5da52d..69d78bc5 100644
--- a/libdiskfs/io-reauthenticate.c
+++ b/libdiskfs/io-reauthenticate.c
@@ -34,13 +34,13 @@ diskfs_S_io_reauthenticate (struct protid *cred,
/* This routine must carefully ignore EINTR because we
are a simpleroutine, so callers won't know to restart. */
- mutex_lock (&cred->po->np->lock);
+ pthread_mutex_lock (&cred->po->np->lock);
do
err = diskfs_start_protid (cred->po, &newcred);
while (err == EINTR);
if (err)
{
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
return err;
}
@@ -58,7 +58,7 @@ diskfs_S_io_reauthenticate (struct protid *cred,
mach_port_deallocate (mach_task_self (), newright);
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
ports_port_deref (newcred);
diff --git a/libdiskfs/io-rel-conch.c b/libdiskfs/io-rel-conch.c
index c0257650..a42d1ba5 100644
--- a/libdiskfs/io-rel-conch.c
+++ b/libdiskfs/io-rel-conch.c
@@ -28,10 +28,10 @@ diskfs_S_io_release_conch (struct protid *cred)
return EOPNOTSUPP;
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
if (!cred->mapped)
{
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return EINVAL;
}
@@ -39,6 +39,6 @@ diskfs_S_io_release_conch (struct protid *cred)
iohelp_handle_io_release_conch (&np->conch, cred);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return 0;
}
diff --git a/libdiskfs/io-restrict-auth.c b/libdiskfs/io-restrict-auth.c
index c1560ac1..011aa19e 100644
--- a/libdiskfs/io-restrict-auth.c
+++ b/libdiskfs/io-restrict-auth.c
@@ -40,7 +40,7 @@ diskfs_S_io_restrict_auth (struct protid *cred,
if (err)
return err;
- mutex_lock (&cred->po->np->lock);
+ pthread_mutex_lock (&cred->po->np->lock);
err = diskfs_create_protid (cred->po, user, &newpi);
if (! err)
{
@@ -48,7 +48,7 @@ diskfs_S_io_restrict_auth (struct protid *cred,
*newportpoly = MACH_MSG_TYPE_MAKE_SEND;
ports_port_deref (newpi);
}
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
iohelp_free_iouser (user);
return err;
diff --git a/libdiskfs/io-revoke.c b/libdiskfs/io-revoke.c
index d42fb6c1..a07777e2 100644
--- a/libdiskfs/io-revoke.c
+++ b/libdiskfs/io-revoke.c
@@ -42,11 +42,11 @@ diskfs_S_io_revoke (struct protid *cred)
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
err = fshelp_isowner (&np->dn_stat, cred->user);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
if (err)
return err;
diff --git a/libdiskfs/io-seek.c b/libdiskfs/io-seek.c
index 71179816..9e3ff093 100644
--- a/libdiskfs/io-seek.c
+++ b/libdiskfs/io-seek.c
@@ -34,7 +34,7 @@ diskfs_S_io_seek (struct protid *cred,
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
iohelp_get_conch (&np->conch);
switch (whence)
@@ -56,6 +56,6 @@ diskfs_S_io_seek (struct protid *cred,
break;
}
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return err;
}
diff --git a/libdiskfs/io-sigio.c b/libdiskfs/io-sigio.c
index 229129bc..1e4c461b 100644
--- a/libdiskfs/io-sigio.c
+++ b/libdiskfs/io-sigio.c
@@ -28,9 +28,9 @@ diskfs_S_io_sigio (struct protid *cred)
if (!cred)
return EOPNOTSUPP;
- mutex_lock (&cred->po->np->lock);
+ pthread_mutex_lock (&cred->po->np->lock);
if ((cred->po->openstat & O_FSYNC) || diskfs_synchronous)
diskfs_file_update (cred->po->np, 1);
- mutex_unlock (&cred->po->np->lock);
+ pthread_mutex_unlock (&cred->po->np->lock);
return 0;
}
diff --git a/libdiskfs/io-stat.c b/libdiskfs/io-stat.c
index 59f3187e..211b53a8 100644
--- a/libdiskfs/io-stat.c
+++ b/libdiskfs/io-stat.c
@@ -30,7 +30,7 @@ diskfs_S_io_stat (struct protid *cred,
return EOPNOTSUPP;
np = cred->po->np;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
iohelp_get_conch (&np->conch);
if (diskfs_synchronous)
@@ -45,7 +45,7 @@ diskfs_S_io_stat (struct protid *cred,
if (cred->po->shadow_root == np || np == diskfs_root_node)
statbuf->st_mode |= S_IROOT;
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return 0;
}
diff --git a/libdiskfs/io-write.c b/libdiskfs/io-write.c
index a3c4199e..26e0be43 100644
--- a/libdiskfs/io-write.c
+++ b/libdiskfs/io-write.c
@@ -38,7 +38,7 @@ diskfs_S_io_write (struct protid *cred,
if (!(cred->po->openstat & O_WRITE))
return EBADF;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
assert (!S_ISDIR(np->dn_stat.st_mode));
@@ -89,6 +89,6 @@ diskfs_S_io_write (struct protid *cred,
if (!err && np->filemod_reqs)
diskfs_notice_filechange (np, FILE_CHANGED_WRITE, off, off + *amt);
out:
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return err;
}
diff --git a/libdiskfs/lookup.c b/libdiskfs/lookup.c
index 1f2a2588..bc2ad01e 100644
--- a/libdiskfs/lookup.c
+++ b/libdiskfs/lookup.c
@@ -29,7 +29,7 @@ static struct
int dot;
int dotdot;
} cache_misses;
-static spin_lock_t cm_lock = SPIN_LOCK_INITIALIZER;
+static pthread_spinlock_t cm_lock = PTHREAD_SPINLOCK_INITIALIZER;
/* Lookup in directory DP (which is locked) the name NAME. TYPE will
@@ -176,7 +176,7 @@ diskfs_lookup (struct node *dp, const char *name, enum lookup_type type,
{
err = diskfs_lookup_hard (dp, name, type, np, ds, cred);
- spin_lock (&cm_lock);
+ pthread_spin_lock (&cm_lock);
if (type == LOOKUP)
{
if (err == ENOENT)
@@ -193,7 +193,7 @@ diskfs_lookup (struct node *dp, const char *name, enum lookup_type type,
cache_misses.dotdot++;
}
}
- spin_unlock (&cm_lock);
+ pthread_spin_unlock (&cm_lock);
if (err && err != ENOENT)
return err;
diff --git a/libdiskfs/name-cache.c b/libdiskfs/name-cache.c
index f31482d4..8424ffee 100644
--- a/libdiskfs/name-cache.c
+++ b/libdiskfs/name-cache.c
@@ -53,7 +53,7 @@ struct lookup_cache
/* The contents of the cache in no particular order */
static struct cacheq lookup_cache = { sizeof (struct lookup_cache) };
-static spin_lock_t cache_lock = SPIN_LOCK_INITIALIZER;
+static pthread_spinlock_t cache_lock = PTHREAD_SPINLOCK_INITIALIZER;
/* Buffer to hold statistics */
static struct stats
@@ -104,7 +104,7 @@ diskfs_enter_lookup_cache (struct node *dir, struct node *np, const char *name)
if (name_len > CACHE_NAME_LEN - 1)
return;
- spin_lock (&cache_lock);
+ pthread_spin_lock (&cache_lock);
if (lookup_cache.length == 0)
/* There should always be an lru_cache; this being zero means that the
@@ -124,7 +124,7 @@ diskfs_enter_lookup_cache (struct node *dir, struct node *np, const char *name)
/* Now C becomes the MRU entry! */
cacheq_make_mru (&lookup_cache, c);
- spin_unlock (&cache_lock);
+ pthread_spin_unlock (&cache_lock);
}
/* Purge all references in the cache to NP as a node inside
@@ -134,7 +134,7 @@ diskfs_purge_lookup_cache (struct node *dp, struct node *np)
{
struct lookup_cache *c, *next;
- spin_lock (&cache_lock);
+ pthread_spin_lock (&cache_lock);
for (c = lookup_cache.mru; c; c = next)
{
/* Save C->hdr.next, since we may move C from this position. */
@@ -149,7 +149,7 @@ diskfs_purge_lookup_cache (struct node *dp, struct node *np)
entry. */
}
}
- spin_unlock (&cache_lock);
+ pthread_spin_unlock (&cache_lock);
}
/* Register a negative hit for an entry in the Nth stat class */
@@ -202,7 +202,7 @@ diskfs_check_lookup_cache (struct node *dir, const char *name)
{
struct lookup_cache *c;
- spin_lock (&cache_lock);
+ pthread_spin_lock (&cache_lock);
c = find_cache (dir, name, strlen (name));
if (c)
@@ -215,14 +215,14 @@ diskfs_check_lookup_cache (struct node *dir, const char *name)
/* A negative cache entry. */
{
register_neg_hit (c->stati);
- spin_unlock (&cache_lock);
+ pthread_spin_unlock (&cache_lock);
return (struct node *)-1;
}
else if (id == dir->cache_id)
/* The cached node is the same as DIR. */
{
register_pos_hit (c->stati);
- spin_unlock (&cache_lock);
+ pthread_spin_unlock (&cache_lock);
diskfs_nref (dir);
return dir;
}
@@ -233,13 +233,13 @@ diskfs_check_lookup_cache (struct node *dir, const char *name)
error_t err;
register_pos_hit (c->stati);
- spin_unlock (&cache_lock);
+ pthread_spin_unlock (&cache_lock);
if (name[0] == '.' && name[1] == '.' && name[2] == '\0')
{
- mutex_unlock (&dir->lock);
+ pthread_mutex_unlock (&dir->lock);
err = diskfs_cached_lookup (id, &np);
- mutex_lock (&dir->lock);
+ pthread_mutex_lock (&dir->lock);
/* In the window where DP was unlocked, we might
have lost. So check the cache again, and see
@@ -248,7 +248,7 @@ diskfs_check_lookup_cache (struct node *dir, const char *name)
if (!c || c->node_cache_id != id)
{
/* Lose */
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
return 0;
}
}
@@ -259,7 +259,7 @@ diskfs_check_lookup_cache (struct node *dir, const char *name)
}
register_miss ();
- spin_unlock (&cache_lock);
+ pthread_spin_unlock (&cache_lock);
return 0;
}
diff --git a/libdiskfs/node-drop.c b/libdiskfs/node-drop.c
index c3d32c96..8a097da5 100644
--- a/libdiskfs/node-drop.c
+++ b/libdiskfs/node-drop.c
@@ -61,7 +61,7 @@ diskfs_drop_node (struct node *np)
will notice that the size is zero, and not have to
do anything. */
np->references++;
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
diskfs_truncate (np, 0);
/* Force allocsize to zero; if truncate consistently fails this
@@ -94,7 +94,7 @@ diskfs_drop_node (struct node *np)
assert (!np->sockaddr);
diskfs_node_norefs (np);
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
}
diff --git a/libdiskfs/node-make.c b/libdiskfs/node-make.c
index 74fdda19..2b6ef2af 100644
--- a/libdiskfs/node-make.c
+++ b/libdiskfs/node-make.c
@@ -35,7 +35,7 @@ diskfs_make_node (struct disknode *dn)
np->dn_set_mtime = 0;
np->dn_stat_dirty = 0;
- mutex_init (&np->lock);
+ pthread_mutex_init (&np->lock, NULL);
np->references = 1;
np->light_references = 0;
np->owner = 0;
diff --git a/libdiskfs/node-nput.c b/libdiskfs/node-nput.c
index 2aad1b66..35f05b5d 100644
--- a/libdiskfs/node-nput.c
+++ b/libdiskfs/node-nput.c
@@ -29,14 +29,14 @@ diskfs_nput (struct node *np)
int tried_drop_softrefs = 0;
loop:
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
assert (np->references);
np->references--;
if (np->references + np->light_references == 0)
diskfs_drop_node (np);
else if (np->references == 0 && !tried_drop_softrefs)
{
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
/* This is our cue that something akin to "last process closes file"
in the POSIX.1 sense happened, so make sure any pending node time
@@ -52,9 +52,9 @@ diskfs_nput (struct node *np)
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_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
np->references++;
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
diskfs_try_dropping_softrefs (np);
@@ -65,11 +65,11 @@ diskfs_nput (struct node *np)
/* Now we can drop the reference back... */
goto loop;
}
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
}
else
{
- spin_unlock (&diskfs_node_refcnt_lock);
- mutex_unlock (&np->lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_mutex_unlock (&np->lock);
}
}
diff --git a/libdiskfs/node-nputl.c b/libdiskfs/node-nputl.c
index 45b109ea..19596654 100644
--- a/libdiskfs/node-nputl.c
+++ b/libdiskfs/node-nputl.c
@@ -25,14 +25,14 @@
void
diskfs_nput_light (struct node *np)
{
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
assert (np->light_references);
np->light_references--;
if (np->references + np->light_references == 0)
diskfs_drop_node (np);
else
{
- spin_unlock (&diskfs_node_refcnt_lock);
- mutex_unlock (&np->lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_mutex_unlock (&np->lock);
}
}
diff --git a/libdiskfs/node-nref.c b/libdiskfs/node-nref.c
index 753de65f..13cea056 100644
--- a/libdiskfs/node-nref.c
+++ b/libdiskfs/node-nref.c
@@ -27,14 +27,14 @@ void
diskfs_nref (struct node *np)
{
int new_hardref;
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
np->references++;
new_hardref = (np->references == 1);
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
if (new_hardref)
{
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
diskfs_new_hardrefs (np);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
}
}
diff --git a/libdiskfs/node-nrefl.c b/libdiskfs/node-nrefl.c
index ce3b39dd..96922471 100644
--- a/libdiskfs/node-nrefl.c
+++ b/libdiskfs/node-nrefl.c
@@ -24,7 +24,7 @@
void
diskfs_nref_light (struct node *np)
{
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
np->light_references++;
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
}
diff --git a/libdiskfs/node-nrele.c b/libdiskfs/node-nrele.c
index 9dbc5d8c..cc680893 100644
--- a/libdiskfs/node-nrele.c
+++ b/libdiskfs/node-nrele.c
@@ -31,35 +31,35 @@ diskfs_nrele (struct node *np)
int tried_drop_softrefs = 0;
loop:
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
assert (np->references);
np->references--;
if (np->references + np->light_references == 0)
{
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
diskfs_drop_node (np);
}
else if (np->references == 0)
{
- mutex_lock (&np->lock);
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_mutex_lock (&np->lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
diskfs_lost_hardrefs (np);
if (!np->dn_stat.st_nlink && !tried_drop_softrefs)
{
/* Same issue here as in nput; see that for explanation */
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
np->references++;
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
diskfs_try_dropping_softrefs (np);
tried_drop_softrefs = 1;
/* Now we can drop the reference back... */
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
goto loop;
}
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
}
else
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
}
diff --git a/libdiskfs/node-nrelel.c b/libdiskfs/node-nrelel.c
index e61f6378..ee53b227 100644
--- a/libdiskfs/node-nrelel.c
+++ b/libdiskfs/node-nrelel.c
@@ -26,14 +26,14 @@
void
diskfs_nrele_light (struct node *np)
{
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
assert (np->light_references);
np->light_references--;
if (np->references + np->light_references == 0)
{
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
diskfs_drop_node (np);
}
else
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
}
diff --git a/libdiskfs/peropen-rele.c b/libdiskfs/peropen-rele.c
index 6974e86a..08276ec3 100644
--- a/libdiskfs/peropen-rele.c
+++ b/libdiskfs/peropen-rele.c
@@ -22,11 +22,11 @@
void
diskfs_release_peropen (struct peropen *po)
{
- mutex_lock (&po->np->lock);
+ pthread_mutex_lock (&po->np->lock);
if (--po->refcnt)
{
- mutex_unlock (&po->np->lock);
+ pthread_mutex_unlock (&po->np->lock);
return;
}
diff --git a/libdiskfs/priv.h b/libdiskfs/priv.h
index 07464d56..bd23ab90 100644
--- a/libdiskfs/priv.h
+++ b/libdiskfs/priv.h
@@ -98,7 +98,7 @@ void _diskfs_control_clean (void *);
extern int _diskfs_ncontrol_ports;
/* Lock for _diskfs_ncontrol_ports. */
-extern spin_lock_t _diskfs_control_lock;
+extern pthread_spinlock_t _diskfs_control_lock;
/* Callback routines for active translator startup */
extern fshelp_fetch_root_callback1_t _diskfs_translator_callback1;
@@ -121,11 +121,11 @@ extern fshelp_fetch_root_callback2_t _diskfs_translator_callback2;
\
np = (PROTID)->po->np; \
\
- mutex_lock (&np->lock); \
+ pthread_mutex_lock (&np->lock); \
(OPERATION); \
if (diskfs_synchronous) \
diskfs_node_update (np, 1); \
- mutex_unlock (&np->lock); \
+ pthread_mutex_unlock (&np->lock); \
return err; \
})
diff --git a/libdiskfs/shutdown.c b/libdiskfs/shutdown.c
index f9bc4b57..66deb59a 100644
--- a/libdiskfs/shutdown.c
+++ b/libdiskfs/shutdown.c
@@ -36,7 +36,7 @@ diskfs_shutdown (int flags)
mach_port_t control;
error = fshelp_fetch_control (&np->transbox, &control);
- mutex_unlock (&np->lock);
+ pthread_mutex_unlock (&np->lock);
if (!error && (control != MACH_PORT_NULL))
{
error = fsys_goaway (control, flags);
@@ -44,7 +44,7 @@ diskfs_shutdown (int flags)
}
else
error = 0;
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
if ((error == MIG_SERVER_DIED) || (error == MACH_SEND_INVALID_DEST))
error = 0;
@@ -63,14 +63,14 @@ diskfs_shutdown (int flags)
return err;
}
- rwlock_writer_lock (&diskfs_fsys_lock);
+ pthread_rwlock_wrlock (&diskfs_fsys_lock);
/* Permit all the current RPC's to finish, and then
suspend new ones. */
err = ports_inhibit_class_rpcs (diskfs_protid_class);
if (err)
{
- rwlock_writer_unlock (&diskfs_fsys_lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
return err;
}
@@ -88,7 +88,7 @@ diskfs_shutdown (int flags)
{
ports_enable_class (diskfs_protid_class);
ports_resume_class_rpcs (diskfs_protid_class);
- rwlock_writer_unlock (&diskfs_fsys_lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
return EBUSY;
}
diff --git a/libdiskfs/sync-interval.c b/libdiskfs/sync-interval.c
index 20b9fbb4..14405f29 100644
--- a/libdiskfs/sync-interval.c
+++ b/libdiskfs/sync-interval.c
@@ -18,7 +18,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <errno.h>
-#include <cthreads.h>
+#include <pthread.h>
#include <unistd.h>
#include <hurd/fsys.h>
@@ -29,14 +29,14 @@
int diskfs_sync_interval = 0;
/* The thread that's doing the syncing. */
-static cthread_t periodic_sync_thread;
+static pthread_t periodic_sync_thread;
/* This port represents the periodic sync service as if it were
an RPC. We can use ports_inhibit_port_rpcs on this port to guarantee
that the periodic_sync_thread is quiescent. */
static struct port_info *pi;
-static void periodic_sync ();
+static void * periodic_sync (void *);
/* Establish a thread to sync the filesystem every INTERVAL seconds, or
never, if INTERVAL is zero. If an error occurs creating the thread, it is
@@ -66,12 +66,15 @@ diskfs_set_sync_interval (int interval)
periodic_sync_thread = 0;
else
{
- periodic_sync_thread =
- cthread_fork ((cthread_fn_t)periodic_sync, (any_t)(intptr_t)interval);
- if (periodic_sync_thread)
- cthread_detach (periodic_sync_thread);
+ err = pthread_create (&periodic_sync_thread, NULL, periodic_sync,
+ (void *)(intptr_t) interval);
+ if (!err)
+ pthread_detach (periodic_sync_thread);
else
- err = ENOMEM;
+ {
+ errno = err;
+ perror ("pthread_create");
+ }
}
if (!err)
@@ -87,9 +90,10 @@ diskfs_set_sync_interval (int interval)
/* Sync the filesystem (pointed to by the variable CONTROL_PORT above) every
INTERVAL seconds, as long as it's in the thread pointed to by the global
variable PERIODIC_SYNC_THREAD. */
-static void
-periodic_sync (int interval)
+static void *
+periodic_sync (void * arg)
{
+ int interval = (int) arg;
for (;;)
{
error_t err;
@@ -99,18 +103,18 @@ periodic_sync (int interval)
while we are in the process of syncing. */
err = ports_begin_rpc (pi, 0, &link);
- if (periodic_sync_thread != cthread_self ())
+ if (periodic_sync_thread != pthread_self ())
{
/* We've been superseded as the sync thread. Just die silently. */
ports_end_rpc (pi, &link);
- return;
+ return NULL;
}
if (! err)
{
if (! diskfs_readonly)
{
- rwlock_reader_lock (&diskfs_fsys_lock);
+ pthread_rwlock_rdlock (&diskfs_fsys_lock);
/* Only sync if we need to, to avoid clearing the clean flag
when it's just been set. Any other thread doing a sync
will have held the lock while it did its work. */
@@ -119,7 +123,7 @@ periodic_sync (int interval)
diskfs_sync_everything (0);
diskfs_set_hypermetadata (0, 0);
}
- rwlock_reader_unlock (&diskfs_fsys_lock);
+ pthread_rwlock_unlock (&diskfs_fsys_lock);
}
ports_end_rpc (pi, &link);
}
@@ -127,4 +131,6 @@ periodic_sync (int interval)
/* Wait until next time. */
sleep (interval);
}
+
+ return NULL;
}