summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1999-07-11 05:27:55 +0000
committerThomas Bushnell <thomas@gnu.org>1999-07-11 05:27:55 +0000
commit8296fd7fe688a203d71c63bdd2fbc4cd098989c1 (patch)
tree3d2c4db6217702a2fbc39e187aa79b41b74f066f
parentb84e750c4abc10e5e1fb066abf1757b1ea42315e (diff)
1999-07-09 Thomas Bushnell, BSG <tb@mit.edu>
* ccache.c (ccache_read): Use mmap instead of vm_allocate. * netfs.c (get_dirents): Likewise.
-rw-r--r--ftpfs/ChangeLog5
-rw-r--r--ftpfs/ccache.c14
-rw-r--r--ftpfs/netfs.c4
3 files changed, 18 insertions, 5 deletions
diff --git a/ftpfs/ChangeLog b/ftpfs/ChangeLog
index 93c6db92..99527918 100644
--- a/ftpfs/ChangeLog
+++ b/ftpfs/ChangeLog
@@ -3,6 +3,11 @@
* netfs.c: Add #include <sys/mman.h> for munmap decl.
* ccache.c: Likewise.
+1999-07-09 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * ccache.c (ccache_read): Use mmap instead of vm_allocate.
+ * netfs.c (get_dirents): Likewise.
+
1999-07-03 Thomas Bushnell, BSG <tb@mit.edu>
* ccache.c (ccache_read): Use munmap instead of vm_deallocate.
diff --git a/ftpfs/ccache.c b/ftpfs/ccache.c
index c1e14a98..56f3bf1e 100644
--- a/ftpfs/ccache.c
+++ b/ftpfs/ccache.c
@@ -105,8 +105,10 @@ ccache_read (struct ccache *cc, off_t offs, size_t len, void *data)
if (cc->alloced == 0)
{
vm_address_t addr = 0;
- err = vm_allocate (mach_task_self (),
- &addr, alloc_end, 1);
+ addr = (vm_address_t) mmap (0, alloc_end,
+ PROT_READ|PROT_WRITE,
+ MAP_ANON, 0, 0);
+ err = (addr == -1) ? errno : 0;
if (! err)
cc->image = (char *)addr;
}
@@ -114,6 +116,8 @@ ccache_read (struct ccache *cc, off_t offs, size_t len, void *data)
{
vm_address_t addr =
(vm_address_t)cc->image + cc->alloced;
+ /* XXX. This can't be replaced with mmap until we
+ have MAP_EXCL. -tb */
err = vm_allocate (mach_task_self (),
&addr, alloc_end - cc->alloced,
0);
@@ -121,8 +125,10 @@ ccache_read (struct ccache *cc, off_t offs, size_t len, void *data)
/* Gack. We've goota move the whole splooge. */
{
addr = 0;
- err = vm_allocate (mach_task_self (),
- &addr, alloc_end, 1);
+ addr = (vm_address_t) mmap (0, alloc_end,
+ PROT_READ|PROT_WRITE,
+ MAP_ANON, 0, 0);
+ err = (addr == -1) ? errno : 0;
if (! err)
/* That worked; copy what's already-fetched. */
{
diff --git a/ftpfs/netfs.c b/ftpfs/netfs.c
index a7c8f7a0..ced7310a 100644
--- a/ftpfs/netfs.c
+++ b/ftpfs/netfs.c
@@ -180,7 +180,9 @@ get_dirents (struct ftpfs_dir *dir,
? DIRENTS_CHUNK_SIZE
: max_data_len);
- err = vm_allocate (mach_task_self (), (vm_address_t *) data, size, 1);
+ *data = mmap (0, size, PROT_READ|PROT_WRITE,
+ MAP_ANON, 0, 0);
+ err = ((void *) *data == (void *) -1) ? errno : 0;
if (! err)
{