summaryrefslogtreecommitdiff
path: root/libnetfs
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1995-11-13 21:33:24 +0000
committerMichael I. Bushnell <mib@gnu.org>1995-11-13 21:33:24 +0000
commit27ad04585de6312c81a4adf63f1d75c6bb322a15 (patch)
treefb3177b757b5d3dc59de9304b4a34c150d8029ab /libnetfs
parent0ec8fe4fe8c967c934566a4bf916744320a192aa (diff)
Formerly io-read.c.~2~
Diffstat (limited to 'libnetfs')
-rw-r--r--libnetfs/io-read.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libnetfs/io-read.c b/libnetfs/io-read.c
index 4a6b777c..dc19051e 100644
--- a/libnetfs/io-read.c
+++ b/libnetfs/io-read.c
@@ -19,6 +19,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
#include "netfs.h"
+#inlcude "io_S.h"
error_t
netfs_S_io_read (struct protid *user,
@@ -40,10 +41,22 @@ netfs_S_io_read (struct protid *user,
}
*datalen = amount;
+ mutex_lock (&user->po->np->lock);
err = netfs_attempt_read (user->credential, user->po->np,
- offset, datalen, *data);
+ offset == -1 ? user->po->filepointer : offset,
+ datalen, *data);
+ if (offset == -1 && !err)
+ user->po->filepointer += *datalen;
+ mutex_unlock (&user->po->np->lock);
+
if (err && alloced)
vm_deallocate (mach_task_self (), (vm_address_t) *data, amount);
+
+ if (!err && alloced && (round_page (*datalen) < round_page (amount)))
+ vm_deallocate (mach_task_self (),
+ (vm_address_t) *data + round_page (*datalen),
+ round_page (amount) - round_page (*datalen));
+
return err;
}