From 4c92b3ea6ef88da50517e4fde36f3bbc05aeb740 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 4 Jan 1996 21:12:49 +0000 Subject: (_diskfs_rdwr_internal): Rewritten using pager_memcpy. Fix types of args: OFFSET to off_t, make AMT read/write size_t *. --- libdiskfs/rdwr-internal.c | 60 +++++++++-------------------------------------- 1 file changed, 11 insertions(+), 49 deletions(-) (limited to 'libdiskfs/rdwr-internal.c') diff --git a/libdiskfs/rdwr-internal.c b/libdiskfs/rdwr-internal.c index ecd5d8c7..a458810f 100644 --- a/libdiskfs/rdwr-internal.c +++ b/libdiskfs/rdwr-internal.c @@ -1,5 +1,5 @@ -/* - Copyright (C) 1994, 1995 Free Software Foundation +/* + Copyright (C) 1994, 1995, 1996 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -18,6 +18,7 @@ #include "priv.h" #include #include +#include /* Actually read or write a file. The file size must already permit the requested access. NP is the file to read/write. DATA is a buffer @@ -27,18 +28,14 @@ be locked. If NOTIME is set, then don't update the mtime or atime. */ error_t _diskfs_rdwr_internal (struct node *np, - char *volatile data, - volatile int offset, - volatile int amt, + char *data, + off_t offset, + size_t *amt, int dir, int notime) { - char *window; - int winoff; - volatile int cc; memory_object_t memobj; - volatile vm_prot_t prot - = dir ? (VM_PROT_READ | VM_PROT_WRITE) : VM_PROT_READ; + vm_prot_t prot = dir ? (VM_PROT_READ | VM_PROT_WRITE) : VM_PROT_READ; error_t err = 0; if (dir) @@ -51,46 +48,11 @@ _diskfs_rdwr_internal (struct node *np, else np->dn_set_atime = 1; } - - memobj = diskfs_get_filemap (np, prot); - - while (amt > 0) - { - winoff = trunc_page (offset); - window = 0; - /* We map in 8 pages at a time. Where'd that come from? Well, the - vax has a 1024 pagesize and with 8k blocks that seems like a - reasonable number. */ - err = vm_map (mach_task_self (), (u_int *)&window, 8 * __vm_page_size, - 0, 1, memobj, winoff, 0, prot, prot, VM_INHERIT_NONE); - assert_perror (err); - diskfs_register_memory_fault_area (diskfs_get_filemap_pager_struct (np), - winoff, window, 8 * __vm_page_size); - - if ((offset - winoff) + amt > 8 * (off_t) __vm_page_size) - cc = 8 * __vm_page_size - (offset - winoff); - else - cc = amt; - - if (!(err = diskfs_catch_exception ())) - { - if (dir) - bcopy (data, window + (offset - winoff), cc); - else - bcopy (window + (offset - winoff), data, cc); - diskfs_end_catch_exception (); - } + memobj = diskfs_get_filemap (np, prot); - vm_deallocate (mach_task_self (), (u_int) window, 8 * __vm_page_size); - diskfs_unregister_memory_fault_area (window, 8 * __vm_page_size); - if (err) - break; - amt -= cc; - offset += cc; - data += cc; - } - assert (amt == 0 || err); + err = pager_memcpy (diskfs_get_filemap_pager_struct (np), memobj, + offset, data, amt, prot); if (!diskfs_readonly && !notime) { @@ -99,7 +61,7 @@ _diskfs_rdwr_internal (struct node *np, else np->dn_set_atime = 1; } - + mach_port_deallocate (mach_task_self (), memobj); return err; } -- cgit v1.2.3