summaryrefslogtreecommitdiff
path: root/fatfs
diff options
context:
space:
mode:
Diffstat (limited to 'fatfs')
-rw-r--r--fatfs/Makefile3
-rw-r--r--fatfs/dir.c8
-rw-r--r--fatfs/fat.c18
-rw-r--r--fatfs/fatfs.h6
-rw-r--r--fatfs/inode.c74
-rw-r--r--fatfs/main.c4
-rw-r--r--fatfs/pager.c78
-rw-r--r--fatfs/virt-inode.c20
8 files changed, 106 insertions, 105 deletions
diff --git a/fatfs/Makefile b/fatfs/Makefile
index 24dcab12..c673b1ba 100644
--- a/fatfs/Makefile
+++ b/fatfs/Makefile
@@ -22,7 +22,8 @@ target = fatfs
SRCS = inode.c main.c dir.c pager.c fat.c virt-inode.c node-create.c
OBJS = $(SRCS:.c=.o)
-HURDLIBS = diskfs iohelp fshelp store pager threads ports ihash shouldbeinlibc
+HURDLIBS = diskfs iohelp fshelp store pager ports ihash shouldbeinlibc
+OTHERLIBS = -lpthread
include ../Makeconf
diff --git a/fatfs/dir.c b/fatfs/dir.c
index 762320f8..b2b7d7e4 100644
--- a/fatfs/dir.c
+++ b/fatfs/dir.c
@@ -314,9 +314,9 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type,
/* Drop what we *thought* was .. (but isn't any more) and
try *again*. */
diskfs_nput (np);
- mutex_unlock (&dp->lock);
+ pthread_mutex_unlock (&dp->lock);
err = diskfs_cached_lookup_in_dirbuf (inum, &np, buf);
- mutex_lock (&dp->lock);
+ pthread_mutex_lock (&dp->lock);
if (err)
goto out;
retry_dotdot = inum;
@@ -329,9 +329,9 @@ diskfs_lookup_hard (struct node *dp, const char *name, enum lookup_type type,
/* Lock them in the proper order, and then
repeat the directory scan to see if this is still
right. */
- mutex_unlock (&dp->lock);
+ pthread_mutex_unlock (&dp->lock);
err = diskfs_cached_lookup_in_dirbuf (inum, &np, buf);
- mutex_lock (&dp->lock);
+ pthread_mutex_lock (&dp->lock);
if (err)
goto out;
retry_dotdot = inum;
diff --git a/fatfs/fat.c b/fatfs/fat.c
index 1d110c40..14926ff3 100644
--- a/fatfs/fat.c
+++ b/fatfs/fat.c
@@ -51,10 +51,10 @@ size_t first_fat_sector;
cluster_t nr_of_clusters;
/* Hold this lock while converting times using gmtime. */
-spin_lock_t epoch_to_time_lock = SPIN_LOCK_INITIALIZER;
+pthread_spinlock_t epoch_to_time_lock = PTHREAD_SPINLOCK_INITIALIZER;
/* Hold this lock while allocating a new cluster in the FAT. */
-spin_lock_t allocate_free_cluster_lock = SPIN_LOCK_INITIALIZER;
+pthread_spinlock_t allocate_free_cluster_lock = PTHREAD_SPINLOCK_INITIALIZER;
/* Where to look for the next free cluster. This is meant to avoid
searching through a nearly full file system from the beginning at
@@ -323,7 +323,7 @@ fat_allocate_cluster (cluster_t content, cluster_t *cluster)
assert (content != FAT_FREE_CLUSTER);
- spin_lock (&allocate_free_cluster_lock);
+ pthread_spin_lock (&allocate_free_cluster_lock);
old_next_free_cluster = next_free_cluster;
/* Loop over all clusters, starting from next_free_cluster and
@@ -356,7 +356,7 @@ fat_allocate_cluster (cluster_t content, cluster_t *cluster)
else
err = ENOSPC;
- spin_unlock(&allocate_free_cluster_lock);
+ pthread_spin_unlock (&allocate_free_cluster_lock);
return err;
}
@@ -390,14 +390,14 @@ fat_extend_chain (struct node *node, cluster_t new_last_cluster, int create)
return 0;
}
- spin_lock(&dn->chain_extension_lock);
+ pthread_spin_lock (&dn->chain_extension_lock);
/* If we already have what we need, or we have all clusters that are
available without allocating new ones, go out. */
if (new_last_cluster < dn->length_of_chain
|| (!create && dn->chain_complete))
{
- spin_unlock(&dn->chain_extension_lock);
+ pthread_spin_unlock (&dn->chain_extension_lock);
return 0;
}
@@ -460,7 +460,7 @@ fat_extend_chain (struct node *node, cluster_t new_last_cluster, int create)
if (dn->length_of_chain << log2_bytes_per_cluster > node->allocsize)
node->allocsize = dn->length_of_chain << log2_bytes_per_cluster;
- spin_unlock(&dn->chain_extension_lock);
+ pthread_spin_unlock (&dn->chain_extension_lock);
return err;
}
@@ -739,7 +739,7 @@ fat_from_epoch (char *date, char *time, time_t *tp)
{
struct tm *tm;
- spin_lock(&epoch_to_time_lock);
+ pthread_spin_lock (&epoch_to_time_lock);
tm = gmtime (tp);
/* Date format:
@@ -757,5 +757,5 @@ fat_from_epoch (char *date, char *time, time_t *tp)
| ((tm->tm_year - 80) << 9));
write_word(time, (tm->tm_hour << 11) | (tm->tm_min << 5)
| (tm->tm_sec >> 1));
- spin_unlock(&epoch_to_time_lock);
+ pthread_spin_unlock (&epoch_to_time_lock);
}
diff --git a/fatfs/fatfs.h b/fatfs/fatfs.h
index 16b058a8..06955a4a 100644
--- a/fatfs/fatfs.h
+++ b/fatfs/fatfs.h
@@ -45,7 +45,7 @@ struct disknode
/* The directory that hold this file, always hold a reference. */
struct node *dirnode;
- struct rwlock dirent_lock;
+ pthread_rwlock_t dirent_lock;
char *link_target; /* For S_ISLNK. */
@@ -54,11 +54,11 @@ struct disknode
/* Lock to hold while fiddling with this inode's block allocation
info. */
- struct rwlock alloc_lock;
+ pthread_rwlock_t alloc_lock;
/* Lock to hold while extending this inode's block allocation info.
Hold only if you hold readers alloc_lock, then you don't need to
hold it if you hold writers alloc_lock already. */
- spin_lock_t chain_extension_lock;
+ pthread_spinlock_t chain_extension_lock;
struct cluster_chain *first;
struct cluster_chain *last;
cluster_t length_of_chain;
diff --git a/fatfs/inode.c b/fatfs/inode.c
index 2a427933..e3ca09d5 100644
--- a/fatfs/inode.c
+++ b/fatfs/inode.c
@@ -65,13 +65,13 @@ diskfs_cached_lookup (ino64_t inum, struct node **npp)
struct node *np;
struct disknode *dn;
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
for (np = nodehash[INOHASH(inum)]; np; np = np->dn->hnext)
if (np->cache_id == inum)
{
np->references++;
- spin_unlock (&diskfs_node_refcnt_lock);
- mutex_lock (&np->lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_mutex_lock (&np->lock);
*npp = np;
return 0;
}
@@ -80,7 +80,7 @@ diskfs_cached_lookup (ino64_t inum, struct node **npp)
dn = malloc (sizeof (struct disknode));
if (! dn)
{
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
return ENOMEM;
}
dn->pager = 0;
@@ -88,16 +88,16 @@ diskfs_cached_lookup (ino64_t inum, struct node **npp)
dn->last = 0;
dn->length_of_chain = 0;
dn->chain_complete = 0;
- dn->chain_extension_lock = SPIN_LOCK_INITIALIZER;
- rwlock_init (&dn->alloc_lock);
- rwlock_init (&dn->dirent_lock);
+ dn->chain_extension_lock = PTHREAD_SPINLOCK_INITIALIZER;
+ pthread_rwlock_init (&dn->alloc_lock, NULL);
+ pthread_rwlock_init (&dn->dirent_lock, NULL);
/* Create the new node. */
np = diskfs_make_node (dn);
np->cache_id = inum;
np->dn->inode = vi_lookup(inum);
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
/* Put NP in NODEHASH. */
dn->hnext = nodehash[INOHASH(inum)];
@@ -106,7 +106,7 @@ diskfs_cached_lookup (ino64_t inum, struct node **npp)
dn->hprevp = &nodehash[INOHASH(inum)];
nodehash[INOHASH(inum)] = np;
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
/* Get the contents of NP off disk. */
err = read_node (np, 0);
@@ -130,13 +130,13 @@ diskfs_cached_lookup_in_dirbuf (int inum, struct node **npp, vm_address_t buf)
struct node *np;
struct disknode *dn;
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
for (np = nodehash[INOHASH(inum)]; np; np = np->dn->hnext)
if (np->cache_id == inum)
{
np->references++;
- spin_unlock (&diskfs_node_refcnt_lock);
- mutex_lock (&np->lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_mutex_lock (&np->lock);
*npp = np;
return 0;
}
@@ -145,7 +145,7 @@ diskfs_cached_lookup_in_dirbuf (int inum, struct node **npp, vm_address_t buf)
dn = malloc (sizeof (struct disknode));
if (! dn)
{
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
return ENOMEM;
}
dn->pager = 0;
@@ -153,16 +153,16 @@ diskfs_cached_lookup_in_dirbuf (int inum, struct node **npp, vm_address_t buf)
dn->last = 0;
dn->length_of_chain = 0;
dn->chain_complete = 0;
- dn->chain_extension_lock = SPIN_LOCK_INITIALIZER;
- rwlock_init (&dn->alloc_lock);
- rwlock_init (&dn->dirent_lock);
+ dn->chain_extension_lock = PTHREAD_SPINLOCK_INITIALIZER;
+ pthread_rwlock_init (&dn->alloc_lock, NULL);
+ pthread_rwlock_init (&dn->dirent_lock, NULL);
/* Create the new node. */
np = diskfs_make_node (dn);
np->cache_id = inum;
np->dn->inode = vi_lookup(inum);
- mutex_lock (&np->lock);
+ pthread_mutex_lock (&np->lock);
/* Put NP in NODEHASH. */
dn->hnext = nodehash[INOHASH(inum)];
@@ -171,7 +171,7 @@ diskfs_cached_lookup_in_dirbuf (int inum, struct node **npp, vm_address_t buf)
dn->hprevp = &nodehash[INOHASH(inum)];
nodehash[INOHASH(inum)] = np;
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
/* Get the contents of NP off disk. */
err = read_node (np, buf);
@@ -192,14 +192,14 @@ ifind (ino_t inum)
{
struct node *np;
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
for (np = nodehash[INOHASH(inum)]; np; np = np->dn->hnext)
{
if (np->cache_id != inum)
continue;
assert (np->references);
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
return np;
}
assert (0);
@@ -230,9 +230,9 @@ diskfs_node_norefs (struct node *np)
all references to the node have been deleted. */
if (np->dn->dirnode)
{
- spin_unlock (&diskfs_node_refcnt_lock);
+ pthread_spin_unlock (&diskfs_node_refcnt_lock);
diskfs_nrele (np->dn->dirnode);
- spin_lock (&diskfs_node_refcnt_lock);
+ pthread_spin_lock (&diskfs_node_refcnt_lock);
}
assert (!np->dn->pager);
@@ -336,7 +336,7 @@ read_node (struct node *np, vm_address_t buf)
if (dp)
dp->references++;
- rwlock_reader_lock(&np->dn->dirent_lock);
+ pthread_rwlock_rdlock (&np->dn->dirent_lock);
dn->start_cluster = (read_word (dr->first_cluster_high) << 16)
+ read_word (dr->first_cluster_low);
@@ -355,9 +355,9 @@ read_node (struct node *np, vm_address_t buf)
else
{
np->allocsize = 0;
- rwlock_reader_lock(&dn->alloc_lock);
+ pthread_rwlock_rdlock (&dn->alloc_lock);
err = fat_extend_chain (np, FAT_EOC, 0);
- rwlock_reader_unlock(&dn->alloc_lock);
+ pthread_rwlock_unlock (&dn->alloc_lock);
if (err)
{
if (our_buf && buf)
@@ -391,7 +391,7 @@ read_node (struct node *np, vm_address_t buf)
st->st_blksize = bytes_per_sector;
st->st_blocks = (st->st_size - 1) / bytes_per_sector + 1;
- rwlock_reader_unlock(&np->dn->dirent_lock);
+ pthread_rwlock_unlock (&np->dn->dirent_lock);
if (our_buf && buf)
munmap ((caddr_t) buf, buflen);
@@ -482,14 +482,14 @@ write_node (struct node *np)
dp = np->dn->dirnode;
assert (dp);
- mutex_lock (&dp->lock);
+ pthread_mutex_lock (&dp->lock);
/* Map in the directory contents. */
memobj = diskfs_get_filemap (dp, prot);
if (memobj == MACH_PORT_NULL)
{
- mutex_unlock (&dp->lock);
+ pthread_mutex_unlock (&dp->lock);
/* FIXME: We shouldn't ignore this error. */
return;
}
@@ -501,7 +501,7 @@ write_node (struct node *np)
dr = (struct dirrect *) (buf + vk.dir_offset);
- rwlock_writer_lock(&np->dn->dirent_lock);
+ pthread_rwlock_wrlock (&np->dn->dirent_lock);
write_word (dr->first_cluster_low, np->dn->start_cluster & 0xffff);
write_word (dr->first_cluster_high, np->dn->start_cluster >> 16);
@@ -511,11 +511,11 @@ write_node (struct node *np)
fat_from_epoch ((unsigned char *) &dr->write_date,
(unsigned char *) &dr->write_time, &st->st_mtime);
- rwlock_writer_unlock(&np->dn->dirent_lock);
+ pthread_rwlock_unlock (&np->dn->dirent_lock);
np->dn_stat_dirty = 0;
munmap ((caddr_t) buf, buflen);
- mutex_unlock (&dp->lock);
+ pthread_mutex_unlock (&dp->lock);
}
}
@@ -548,7 +548,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *))
int n, 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
@@ -569,7 +569,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)
@@ -577,9 +577,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);
}
@@ -700,7 +700,7 @@ diskfs_truncate (struct node *node, loff_t length)
diskfs_file_update (node, 1);
}
- rwlock_writer_lock (&node->dn->alloc_lock);
+ pthread_rwlock_wrlock (&node->dn->alloc_lock);
/* Update the size on disk; if we crash, we'll loose. */
node->dn_stat.st_size = length;
@@ -720,7 +720,7 @@ diskfs_truncate (struct node *node, loff_t length)
node->dn_set_ctime = 1;
node->dn_stat_dirty = 1;
- rwlock_writer_unlock (&node->dn->alloc_lock);
+ pthread_rwlock_unlock (&node->dn->alloc_lock);
return err;
}
diff --git a/fatfs/main.c b/fatfs/main.c
index b85d7fe7..b34f8dae 100644
--- a/fatfs/main.c
+++ b/fatfs/main.c
@@ -205,7 +205,7 @@ fetch_root ()
assert_perror (err);
- mutex_unlock (&diskfs_root_node->lock);
+ pthread_mutex_unlock (&diskfs_root_node->lock);
}
@@ -239,7 +239,7 @@ main (int argc, char **argv)
diskfs_startup_diskfs (bootstrap, 0);
- cthread_exit (0);
+ pthread_exit (NULL);
return 0;
}
diff --git a/fatfs/pager.c b/fatfs/pager.c
index e617af03..f892c88f 100644
--- a/fatfs/pager.c
+++ b/fatfs/pager.c
@@ -28,7 +28,7 @@ struct port_bucket *pager_bucket;
/* Mapped image of the FAT. */
void *fat_image;
-spin_lock_t node_to_page_lock = SPIN_LOCK_INITIALIZER;
+pthread_spinlock_t node_to_page_lock = PTHREAD_SPINLOCK_INITIALIZER;
#ifdef DONT_CACHE_MEMORY_OBJECTS
#define MAY_CACHE 0
@@ -40,7 +40,7 @@ spin_lock_t node_to_page_lock = SPIN_LOCK_INITIALIZER;
#define MAX_FREE_PAGE_BUFS 32
-static spin_lock_t free_page_bufs_lock = SPIN_LOCK_INITIALIZER;
+static pthread_spinlock_t free_page_bufs_lock = PTHREAD_SPINLOCK_INITIALIZER;
static void *free_page_bufs = 0;
static int num_free_page_bufs = 0;
@@ -50,12 +50,12 @@ get_page_buf ()
{
void *buf;
- spin_lock (&free_page_bufs_lock);
+ pthread_spin_lock (&free_page_bufs_lock);
buf = free_page_bufs;
if (buf == 0)
{
- spin_unlock (&free_page_bufs_lock);
+ pthread_spin_unlock (&free_page_bufs_lock);
buf = mmap (0, vm_page_size, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
if (buf == (void *) -1)
buf = 0;
@@ -64,7 +64,7 @@ get_page_buf ()
{
free_page_bufs = *(void **)buf;
num_free_page_bufs--;
- spin_unlock (&free_page_bufs_lock);
+ pthread_spin_unlock (&free_page_bufs_lock);
}
return buf;
@@ -74,17 +74,17 @@ get_page_buf ()
static void
free_page_buf (void *buf)
{
- spin_lock (&free_page_bufs_lock);
+ pthread_spin_lock (&free_page_bufs_lock);
if (num_free_page_bufs < MAX_FREE_PAGE_BUFS)
{
*(void **)buf = free_page_bufs;
free_page_bufs = buf;
num_free_page_bufs++;
- spin_unlock (&free_page_bufs_lock);
+ pthread_spin_unlock (&free_page_bufs_lock);
}
else
{
- spin_unlock (&free_page_bufs_lock);
+ pthread_spin_unlock (&free_page_bufs_lock);
munmap (buf, vm_page_size);
}
}
@@ -96,14 +96,14 @@ free_page_buf (void *buf)
error code otherwise is returned. */
static error_t
find_cluster (struct node *node, vm_offset_t offset,
- cluster_t *cluster, struct rwlock **lock)
+ cluster_t *cluster, pthread_rwlock_t **lock)
{
error_t err;
if (!*lock)
{
*lock = &node->dn->alloc_lock;
- rwlock_reader_lock (*lock);
+ pthread_rwlock_rdlock (*lock);
}
if (round_cluster (offset) > node->allocsize)
@@ -134,7 +134,7 @@ root_dir_pager_read_page (vm_offset_t page, void **buf, int *writelock)
return EIO;
}
- rwlock_reader_lock(&diskfs_root_node->dn->alloc_lock);
+ pthread_rwlock_rdlock (&diskfs_root_node->dn->alloc_lock);
addr = first_root_dir_byte + page;
if (page + vm_page_size > diskfs_root_node->allocsize)
@@ -145,7 +145,7 @@ root_dir_pager_read_page (vm_offset_t page, void **buf, int *writelock)
if (!err && read != vm_page_size)
err = EIO;
- rwlock_reader_unlock (&diskfs_root_node->dn->alloc_lock);
+ pthread_rwlock_unlock (&diskfs_root_node->dn->alloc_lock);
if (overrun)
bzero ((void *) *buf + vm_page_size - overrun, overrun);
@@ -162,7 +162,7 @@ file_pager_read_small_page (struct node *node, vm_offset_t page,
void **buf, int *writelock)
{
error_t err;
- struct rwlock *lock = NULL;
+ pthread_rwlock_t *lock = NULL;
cluster_t cluster;
size_t read = 0;
@@ -188,7 +188,7 @@ file_pager_read_small_page (struct node *node, vm_offset_t page,
}
if (lock)
- rwlock_reader_unlock (lock);
+ pthread_rwlock_unlock (lock);
return err;
}
@@ -204,7 +204,7 @@ file_pager_read_huge_page (struct node *node, vm_offset_t page,
{
error_t err;
int offs = 0;
- struct rwlock *lock = NULL;
+ pthread_rwlock_t *lock = NULL;
int left = vm_page_size;
cluster_t pending_clusters = 0;
int num_pending_clusters = 0;
@@ -295,7 +295,7 @@ file_pager_read_huge_page (struct node *node, vm_offset_t page,
err = do_pending_reads();
if (lock)
- rwlock_reader_unlock (lock);
+ pthread_rwlock_unlock (lock);
return err;
}
@@ -380,7 +380,7 @@ file_pager_write_huge_page (struct node *node, vm_offset_t offset, void *buf)
{
error_t err = 0;
struct pending_clusters pc;
- struct rwlock *lock = &node->dn->alloc_lock;
+ pthread_rwlock_t *lock = &node->dn->alloc_lock;
cluster_t cluster;
int left = vm_page_size;
@@ -389,7 +389,7 @@ file_pager_write_huge_page (struct node *node, vm_offset_t offset, void *buf)
/* Holding NODE->dn->alloc_lock effectively locks NODE->allocsize,
at least for the cases we care about: pager_unlock_page,
diskfs_grow and diskfs_truncate. */
- rwlock_reader_lock (&node->dn->alloc_lock);
+ pthread_rwlock_rdlock (&node->dn->alloc_lock);
if (offset >= node->allocsize)
left = 0;
@@ -411,7 +411,7 @@ file_pager_write_huge_page (struct node *node, vm_offset_t offset, void *buf)
if (!err)
pending_clusters_write (&pc);
- rwlock_reader_unlock (&node->dn->alloc_lock);
+ pthread_rwlock_unlock (&node->dn->alloc_lock);
return err;
}
@@ -436,7 +436,7 @@ root_dir_pager_write_page (vm_offset_t offset, void *buf)
/* Holding NODE->dn->alloc_lock effectively locks NODE->allocsize,
at least for the cases we care about: pager_unlock_page,
diskfs_grow and diskfs_truncate. */
- rwlock_reader_lock (&diskfs_root_node->dn->alloc_lock);
+ pthread_rwlock_rdlock (&diskfs_root_node->dn->alloc_lock);
addr = first_root_dir_byte + offset;
@@ -450,7 +450,7 @@ root_dir_pager_write_page (vm_offset_t offset, void *buf)
if (!err && write != length)
err = EIO;
- rwlock_reader_unlock (&diskfs_root_node->dn->alloc_lock);
+ pthread_rwlock_unlock (&diskfs_root_node->dn->alloc_lock);
return err;
}
@@ -464,7 +464,7 @@ static error_t
file_pager_write_small_page (struct node *node, vm_offset_t offset, void *buf)
{
error_t err;
- struct rwlock *lock = NULL;
+ pthread_rwlock_t *lock = NULL;
cluster_t cluster;
size_t write = 0;
@@ -474,7 +474,7 @@ file_pager_write_small_page (struct node *node, vm_offset_t offset, void *buf)
/* Holding NODE->dn->alloc_lock effectively locks NODE->allocsize,
at least for the cases we care about: pager_unlock_page,
diskfs_grow and diskfs_truncate. */
- rwlock_reader_lock (&node->dn->alloc_lock);
+ pthread_rwlock_rdlock (&node->dn->alloc_lock);
err = find_cluster (node, offset, &cluster, &lock);
@@ -489,7 +489,7 @@ file_pager_write_small_page (struct node *node, vm_offset_t offset, void *buf)
}
if (lock)
- rwlock_reader_unlock (lock);
+ pthread_rwlock_unlock (lock);
return err;
}
@@ -617,7 +617,7 @@ diskfs_grow (struct node *node, loff_t size, struct protid *cred)
cluster_t new_end_cluster;
struct disknode *dn = node->dn;
- rwlock_writer_lock (&dn->alloc_lock);
+ pthread_rwlock_wrlock (&dn->alloc_lock);
old_size = node->allocsize;
new_size = ((size + bytes_per_cluster - 1) >> log2_bytes_per_cluster)
@@ -647,7 +647,7 @@ diskfs_grow (struct node *node, loff_t size, struct protid *cred)
node->allocsize = new_size;
- rwlock_writer_unlock (&dn->alloc_lock);
+ pthread_rwlock_unlock (&dn->alloc_lock);
return err;
}
@@ -662,11 +662,11 @@ diskfs_file_update (struct node *node, int wait)
{
struct pager *pager;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = node->dn->pager;
if (pager)
ports_port_ref (pager);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
if (pager)
{
@@ -684,11 +684,11 @@ flush_node_pager (struct node *node)
struct pager *pager;
struct disknode *dn = node->dn;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = dn->pager;
if (pager)
ports_port_ref (pager);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
if (pager)
{
@@ -724,11 +724,11 @@ pager_clear_user_data (struct user_pager_info *upi)
{
struct pager *pager;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = upi->node->dn->pager;
if (pager && pager_get_upi (pager) == upi)
upi->node->dn->pager = 0;
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
diskfs_nrele_light (upi->node);
}
@@ -768,7 +768,7 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot)
|| S_ISREG (node->dn_stat.st_mode)
|| (S_ISLNK (node->dn_stat.st_mode)));
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
do
{
struct pager *pager = node->dn->pager;
@@ -799,7 +799,7 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot)
{
diskfs_nrele_light (node);
free (upi);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
return MACH_PORT_NULL;
}
@@ -808,7 +808,7 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot)
}
}
while (right == MACH_PORT_NULL);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
mach_port_insert_right (mach_task_self (), right, right,
MACH_MSG_TYPE_MAKE_SEND);
@@ -823,11 +823,11 @@ drop_pager_softrefs (struct node *node)
{
struct pager *pager;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = node->dn->pager;
if (pager)
ports_port_ref (pager);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
if (MAY_CACHE && pager)
pager_change_attributes (pager, 0, MEMORY_OBJECT_COPY_DELAY, 0);
@@ -842,11 +842,11 @@ allow_pager_softrefs (struct node *node)
{
struct pager *pager;
- spin_lock (&node_to_page_lock);
+ pthread_spin_lock (&node_to_page_lock);
pager = node->dn->pager;
if (pager)
ports_port_ref (pager);
- spin_unlock (&node_to_page_lock);
+ pthread_spin_unlock (&node_to_page_lock);
if (MAY_CACHE && pager)
pager_change_attributes (pager, 1, MEMORY_OBJECT_COPY_DELAY, 0);
diff --git a/fatfs/virt-inode.c b/fatfs/virt-inode.c
index d7c990d6..5d134b00 100644
--- a/fatfs/virt-inode.c
+++ b/fatfs/virt-inode.c
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <assert.h>
#include <string.h>
-#include <spin-lock.h>
+#include <pthread.h>
#include "virt-inode.h"
/* Each virtual inode contains the UNIQUE key it belongs to,
@@ -56,7 +56,7 @@ struct table_page
struct table_page *inode_table;
-spin_lock_t inode_table_lock = SPIN_LOCK_INITIALIZER;
+pthread_spinlock_t inode_table_lock = PTHREAD_SPINLOCK_INITIALIZER;
/* See vi_new and vi_rlookup. */
error_t
@@ -119,9 +119,9 @@ vi_new(vi_key_t key, ino_t *inode, inode_t *v_inode)
assert (memcmp(&vi_zero_key, &key, sizeof (vi_key_t)));
- spin_lock (&inode_table_lock);
+ pthread_spin_lock (&inode_table_lock);
err = _vi_new(key, inode, v_inode);
- spin_unlock (&inode_table_lock);
+ pthread_spin_unlock (&inode_table_lock);
return err;
}
@@ -144,7 +144,7 @@ vi_lookup(ino_t inode)
int offset = (inode - 1) & (TABLE_PAGE_SIZE - 1);
inode_t v_inode = 0;
- spin_lock (&inode_table_lock);
+ pthread_spin_lock (&inode_table_lock);
while (table && page > 0)
{
@@ -155,7 +155,7 @@ vi_lookup(ino_t inode)
if (table)
v_inode = &table->vi[offset];
- spin_unlock (&inode_table_lock);
+ pthread_spin_unlock (&inode_table_lock);
return v_inode;
}
@@ -173,7 +173,7 @@ vi_rlookup(vi_key_t key, ino_t *inode, inode_t *v_inode, int create)
assert (memcmp(&vi_zero_key, &key, sizeof (vi_key_t)));
- spin_lock (&inode_table_lock);
+ pthread_spin_lock (&inode_table_lock);
while (table && memcmp(&table->vi[offset].key, &key, sizeof (vi_key_t)))
{
@@ -200,7 +200,7 @@ vi_rlookup(vi_key_t key, ino_t *inode, inode_t *v_inode, int create)
err = EINVAL;
}
- spin_unlock (&inode_table_lock);
+ pthread_spin_unlock (&inode_table_lock);
return err;
}
@@ -221,10 +221,10 @@ vi_key_t vi_change(inode_t v_inode, vi_key_t key)
vi_key_t vi_free(inode_t v_inode)
{
vi_key_t key;
- spin_lock (&inode_table_lock);
+ pthread_spin_lock (&inode_table_lock);
key = v_inode->key;
v_inode->key = vi_zero_key;
- spin_unlock (&inode_table_lock);
+ pthread_spin_unlock (&inode_table_lock);
return key;
}