diff options
Diffstat (limited to 'tmpfs')
-rw-r--r-- | tmpfs/Makefile | 3 | ||||
-rw-r--r-- | tmpfs/dir.c | 4 | ||||
-rw-r--r-- | tmpfs/node.c | 20 | ||||
-rw-r--r-- | tmpfs/tmpfs.c | 26 | ||||
-rw-r--r-- | tmpfs/tmpfs.h | 4 |
5 files changed, 33 insertions, 24 deletions
diff --git a/tmpfs/Makefile b/tmpfs/Makefile index 7730949c..fdcae349 100644 --- a/tmpfs/Makefile +++ b/tmpfs/Makefile @@ -23,6 +23,7 @@ target = tmpfs SRCS = tmpfs.c node.c dir.c pager-stubs.c OBJS = $(SRCS:.c=.o) default_pagerUser.o # XXX The shared libdiskfs requires libstore even though we don't use it here. -HURDLIBS = diskfs pager iohelp fshelp store threads ports ihash shouldbeinlibc +HURDLIBS = diskfs pager iohelp fshelp store ports ihash shouldbeinlibc +OTHERLIBS = -lpthread include ../Makeconf diff --git a/tmpfs/dir.c b/tmpfs/dir.c index c0ae9785..45a07521 100644 --- a/tmpfs/dir.c +++ b/tmpfs/dir.c @@ -210,13 +210,13 @@ diskfs_lookup_hard (struct node *dp, } else { - mutex_unlock (&dp->lock); + pthread_mutex_unlock (&dp->lock); err = diskfs_cached_lookup ((ino_t) (intptr_t) dddn, np); if (type == (LOOKUP|SPEC_DOTDOT)) diskfs_nrele (dp); else - mutex_lock (&dp->lock); + pthread_mutex_lock (&dp->lock); if (err) *np = 0; diff --git a/tmpfs/node.c b/tmpfs/node.c index bce15370..9d5f9b75 100644 --- a/tmpfs/node.c +++ b/tmpfs/node.c @@ -38,18 +38,18 @@ diskfs_alloc_node (struct node *dp, mode_t mode, struct node **npp) dn = calloc (1, sizeof *dn); if (dn == 0) return ENOSPC; - spin_lock (&diskfs_node_refcnt_lock); + pthread_spin_lock (&diskfs_node_refcnt_lock); if (round_page (tmpfs_space_used + sizeof *dn) / vm_page_size > tmpfs_page_limit) { - spin_unlock (&diskfs_node_refcnt_lock); + pthread_spin_unlock (&diskfs_node_refcnt_lock); free (dn); return ENOSPC; } dn->gen = gen++; ++num_files; tmpfs_space_used += sizeof *dn; - spin_unlock (&diskfs_node_refcnt_lock); + pthread_spin_unlock (&diskfs_node_refcnt_lock); dn->type = IFTODT (mode & S_IFMT); return diskfs_cached_lookup ((ino_t) (uintptr_t) dn, npp); @@ -179,13 +179,13 @@ diskfs_cached_lookup (ino_t inum, struct node **npp) np = diskfs_make_node (dn); np->cache_id = (ino_t) (uintptr_t) dn; - spin_lock (&diskfs_node_refcnt_lock); + pthread_spin_lock (&diskfs_node_refcnt_lock); dn->hnext = all_nodes; if (dn->hnext) dn->hnext->dn->hprevp = &dn->hnext; dn->hprevp = &all_nodes; all_nodes = np; - spin_unlock (&diskfs_node_refcnt_lock); + pthread_spin_unlock (&diskfs_node_refcnt_lock); st = &np->dn_stat; memset (st, 0, sizeof *st); @@ -212,7 +212,7 @@ diskfs_cached_lookup (ino_t inum, struct node **npp) recompute_blocks (np); } - mutex_lock (&np->lock); + pthread_mutex_lock (&np->lock); *npp = np; return 0; } @@ -224,7 +224,7 @@ diskfs_node_iterate (error_t (*fun) (struct node *)) unsigned int num_nodes = 0; struct node *node, **node_list, **p; - spin_lock (&diskfs_node_refcnt_lock); + pthread_spin_lock (&diskfs_node_refcnt_lock); /* We must copy everything from the hash table into another data structure to avoid running into any problems with the hash-table being modified @@ -242,7 +242,7 @@ diskfs_node_iterate (error_t (*fun) (struct node *)) node->references++; } - spin_unlock (&diskfs_node_refcnt_lock); + pthread_spin_unlock (&diskfs_node_refcnt_lock); p = node_list; while (num_nodes-- > 0) @@ -250,9 +250,9 @@ diskfs_node_iterate (error_t (*fun) (struct node *)) node = *p++; if (!err) { - mutex_lock (&node->lock); + pthread_mutex_lock (&node->lock); err = (*fun) (node); - mutex_unlock (&node->lock); + pthread_mutex_unlock (&node->lock); } diskfs_nrele (node); } diff --git a/tmpfs/tmpfs.c b/tmpfs/tmpfs.c index 83795289..36fa1338 100644 --- a/tmpfs/tmpfs.c +++ b/tmpfs/tmpfs.c @@ -67,10 +67,10 @@ diskfs_set_statfs (struct statfs *st) st->f_bsize = vm_page_size; st->f_blocks = tmpfs_page_limit; - spin_lock (&diskfs_node_refcnt_lock); + pthread_spin_lock (&diskfs_node_refcnt_lock); st->f_files = num_files; pages = round_page (tmpfs_space_used) / vm_page_size; - spin_unlock (&diskfs_node_refcnt_lock); + pthread_spin_unlock (&diskfs_node_refcnt_lock); st->f_bfree = pages < tmpfs_page_limit ? tmpfs_page_limit - pages : 0; st->f_bavail = st->f_bfree; @@ -293,8 +293,8 @@ diskfs_append_args (char **argz, size_t *argz_len) /* Handling of operations for the ports in diskfs_port_bucket, calling * demuxer for each incoming message */ -static any_t -diskfs_thread_function (any_t demuxer) +static void * +diskfs_thread_function (void *demuxer) { error_t err; @@ -311,7 +311,7 @@ diskfs_thread_function (any_t demuxer) exit (0); /* NOTREACHED */ - return (any_t) 0; + return NULL; } @@ -338,6 +338,7 @@ main (int argc, char **argv) { error_t err; mach_port_t bootstrap, realnode, host_priv; + pthread_t pthread_id; struct stat st; err = argp_parse (&startup_argp, argc, argv, ARGP_IN_ORDER, NULL, NULL); @@ -378,8 +379,15 @@ main (int argc, char **argv) error (4, err, "cannot create root directory"); /* Like diskfs_spawn_first_thread. But do it manually, without timeout */ - cthread_detach (cthread_fork ((cthread_fn_t) diskfs_thread_function, - (any_t) diskfs_demuxer)); + err = pthread_create (&pthread_id, NULL, diskfs_thread_function, + diskfs_demuxer); + if (!err) + pthread_detach (pthread_id); + else + { + errno = err; + perror ("pthread_create"); + } /* Now that we are all set up to handle requests, and diskfs_root_node is set properly, it is safe to export our fsys control port to the @@ -429,10 +437,10 @@ main (int argc, char **argv) /* We must keep the REALNODE send right to remain the active translator for the underlying node. */ - mutex_unlock (&diskfs_root_node->lock); + pthread_mutex_unlock (&diskfs_root_node->lock); /* and so we die, leaving others to do the real work. */ - cthread_exit (0); + pthread_exit (NULL); /* NOTREACHED */ return 0; } diff --git a/tmpfs/tmpfs.h b/tmpfs/tmpfs.h index 3cb31e6b..b3c636d0 100644 --- a/tmpfs/tmpfs.h +++ b/tmpfs/tmpfs.h @@ -77,9 +77,9 @@ extern mach_port_t default_pager; static inline void adjust_used (off_t change) { - spin_lock (&diskfs_node_refcnt_lock); + pthread_spin_lock (&diskfs_node_refcnt_lock); tmpfs_space_used += change; - spin_unlock (&diskfs_node_refcnt_lock); + pthread_spin_unlock (&diskfs_node_refcnt_lock); } #endif |