summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1996-04-02 14:18:49 +0000
committerMichael I. Bushnell <mib@gnu.org>1996-04-02 14:18:49 +0000
commit56cd00a8f29eef06941758fb07a27a42cbbfaca5 (patch)
treebde276fa582bd010641dd8a4ba105da3fff43d57
parent0c06d5bb0f5a4892b9076bdbef9b68923919b8d8 (diff)
(netfs_S_io_read): Verify that the user has the file open for reading.
-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);