summaryrefslogtreecommitdiff
path: root/libdiskfs/io-read.c
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1994-02-03 19:21:35 +0000
committerMichael I. Bushnell <mib@gnu.org>1994-02-03 19:21:35 +0000
commit83a9bea887538c8c1adbefb66907deb87d61b19f (patch)
tree82ec9fb6e2aa00ac338aa1d15290db08d4117965 /libdiskfs/io-read.c
parent60f9217a9f1a5c092c4d263dc4333e2f82e1fb66 (diff)
Formerly io-read.c.~2~
Diffstat (limited to 'libdiskfs/io-read.c')
-rw-r--r--libdiskfs/io-read.c52
1 files changed, 22 insertions, 30 deletions
diff --git a/libdiskfs/io-read.c b/libdiskfs/io-read.c
index e6623457..1ee30836 100644
--- a/libdiskfs/io-read.c
+++ b/libdiskfs/io-read.c
@@ -42,44 +42,36 @@ diskfs_S_io_read (struct protid *cred,
mutex_lock (&np->i_toplock);
- if (err = ioserver_get_conch (&np->i_conch))
- {
- mutex_unlock (&np->i_toplock);
- return err;
- }
+ err = ioserver_get_conch (&np->i_conch);
+ if (err)
+ goto out;
if (off == -1)
off = cred->po->filepointer;
- if (!(err = catch_exception ()))
- {
- if (off + maxread > np->di->di_size)
- maxread = np->di->di_size - off;
- end_catch_exception ();
- }
+ if (off + maxread > np->dn_stat.st_size)
+ maxread = np->dn_stat.st_size - off;
- if (!err)
+ if (maxread > *datalen)
{
- if (maxread > *datalen)
- {
- ourbuf = 1;
- vm_allocate (mach_task_self (), (u_int *) &buf, maxread, 1);
- *data = buf;
- }
- else
- buf = *data;
-
- *datalen = maxread;
- if (maxread)
- err = io_rdwr (np, buf, off, maxread, 0);
- else
- err = 0;
- if (offset == -1 && !err)
- cred->po->filepointer += *datalen;
- if (err && ourbuf)
- vm_deallocate (mach_task_self (), (u_int) buf, maxread);
+ ourbuf = 1;
+ vm_allocate (mach_task_self (), (u_int *) &buf, maxread, 1);
+ *data = buf;
}
+ else
+ buf = *data;
+
+ *datalen = maxread;
+ if (maxread)
+ err = _diskfs_rdwr_internal (np, buf, off, maxread, 0);
+ else
+ err = 0;
+ if (offset == -1 && !err)
+ cred->po->filepointer += *datalen;
+ if (err && ourbuf)
+ vm_deallocate (mach_task_self (), (u_int) buf, maxread);
+ out:
mutex_unlock (&np->i_toplock);
return err;
}