summaryrefslogtreecommitdiff
path: root/libnetfs/io-read.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnetfs/io-read.c')
-rw-r--r--libnetfs/io-read.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libnetfs/io-read.c b/libnetfs/io-read.c
index 29b70a45..0cb257af 100644
--- a/libnetfs/io-read.c
+++ b/libnetfs/io-read.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -34,6 +34,14 @@ netfs_S_io_read (struct protid *user,
if (!user)
return EOPNOTSUPP;
+ mutex_lock (&user->po->np->lock);
+
+ if ((user->po->openstat & O_READ) == 0)
+ {
+ mutex_unlock (&user->po->np->lock);
+ return EBADF;
+ }
+
if (amount > *datalen)
{
alloced = 1;
@@ -41,7 +49,6 @@ 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 == -1 ? user->po->filepointer : offset,
datalen, *data);