commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 10/19: Do not make io_select return errors on unsupported READ/WR


From: Samuel Thibault
Subject: [hurd] 10/19: Do not make io_select return errors on unsupported READ/WRITE mode
Date: Wed, 10 Aug 2016 00:05:50 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit 4cb90fceb779dbf33cfd9bcf28c66ffc737537f2
Author: Samuel Thibault <address@hidden>
Date:   Sat Jun 4 23:14:46 2016 +0200

    Do not make io_select return errors on unsupported READ/WRITE mode
    
    The descriptor is valid, it is just the mode which is not available.
    
    * console-client/kbd-repeat.c (repeater_select): Drop SELECT_URG flag from
    `type'.  Return 0 instead of EINVAL if `type' contains SELECT_WRITE.
    * console-client/pc-mouse (repeater_select): Likewise.
    * trans/mtab.c (trivfs_S_io_select): Return 0 instead of EBADF when the
    openmodes do not match the requested modes in `type'.
    * trans/new-fifo.c (io_select_common): Likewise.
    * trans/fifo.c (io_select_common): Likewise.
    * trans/null.c (trivfs_S_io_select): Likewise.
    * trans/streamio.c (io_select_common): Likewise.
---
 console-client/kbd-repeat.c |  5 ++++-
 console-client/pc-mouse.c   |  5 ++++-
 trans/fifo.c                |  2 --
 trans/mtab.c                |  4 ----
 trans/new-fifo.c            |  2 --
 trans/null.c                |  6 +-----
 trans/streamio.c            | 12 ++++--------
 7 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/console-client/kbd-repeat.c b/console-client/kbd-repeat.c
index d3a39d0..8d8c9ee 100644
--- a/console-client/kbd-repeat.c
+++ b/console-client/kbd-repeat.c
@@ -94,8 +94,11 @@ repeater_select (struct protid *cred, mach_port_t reply,
   if (!cred)
     return EOPNOTSUPP;
 
+  *type &= ~SELECT_URG;
+
   if (*type & ~SELECT_READ)
-    return EINVAL;
+    /* Error immediately available...  */
+    return 0;
 
   if (*type == 0)
     return 0;
diff --git a/console-client/pc-mouse.c b/console-client/pc-mouse.c
index abdb602..40a569d 100644
--- a/console-client/pc-mouse.c
+++ b/console-client/pc-mouse.c
@@ -118,8 +118,11 @@ repeater_select (struct protid *cred, mach_port_t reply,
   if (!cred)
     return EOPNOTSUPP;
 
+  *type &= ~SELECT_URG;
+
   if (*type & ~SELECT_READ)
-    return EINVAL;
+    /* Error immediately available...  */
+    return 0;
 
   if (*type == 0)
     return 0;
diff --git a/trans/fifo.c b/trans/fifo.c
index f52baba..ac31f49 100644
--- a/trans/fifo.c
+++ b/trans/fifo.c
@@ -436,7 +436,6 @@ io_select_common (struct trivfs_protid *cred,
        }
       else
        {
-         err = EBADF;
          ready |= SELECT_READ; /* Error immediately available...  */
        }
       if (err)
@@ -458,7 +457,6 @@ io_select_common (struct trivfs_protid *cred,
        }
       else
        {
-         err = EBADF;
          ready |= SELECT_WRITE;        /* Error immediately available...  */
        }
     }
diff --git a/trans/mtab.c b/trans/mtab.c
index e0fcb46..c03749c 100644
--- a/trans/mtab.c
+++ b/trans/mtab.c
@@ -843,10 +843,6 @@ trivfs_S_io_select (struct trivfs_protid *cred,
   if (!cred)
     return EOPNOTSUPP;
 
-  if (((*type & SELECT_READ) && !(cred->po->openmodes & O_READ))
-      || ((*type & SELECT_WRITE) && !(cred->po->openmodes & O_WRITE)))
-    return EBADF;
-
   *type &= ~SELECT_URG;
   return 0;
 }
diff --git a/trans/new-fifo.c b/trans/new-fifo.c
index 0ceb842..f11ceca 100644
--- a/trans/new-fifo.c
+++ b/trans/new-fifo.c
@@ -623,7 +623,6 @@ io_select_common (struct trivfs_protid *cred,
        }
       else
        {
-         err = EBADF;
          ready |= SELECT_READ; /* Error immediately available...  */
        }
       if (err)
@@ -645,7 +644,6 @@ io_select_common (struct trivfs_protid *cred,
        }
       else
        {
-         err = EBADF;
          ready |= SELECT_WRITE;        /* Error immediately available...  */
        }
     }
diff --git a/trans/null.c b/trans/null.c
index bd082dc..92717ed 100644
--- a/trans/null.c
+++ b/trans/null.c
@@ -204,11 +204,7 @@ trivfs_S_io_select (struct trivfs_protid *cred,
 {
   if (!cred)
     return EOPNOTSUPP;
-  else if (((*type & SELECT_READ) && !(cred->po->openmodes & O_READ))
-          || ((*type & SELECT_WRITE) && !(cred->po->openmodes & O_WRITE)))
-    return EBADF;
-  else
-    *type &= ~SELECT_URG;
+  *type &= ~SELECT_URG;
   return 0;
 }
 
diff --git a/trans/streamio.c b/trans/streamio.c
index a80975f..5539c8e 100644
--- a/trans/streamio.c
+++ b/trans/streamio.c
@@ -560,9 +560,6 @@ io_select_common (struct trivfs_protid *cred,
   if (!cred)
     return EOPNOTSUPP;
 
-  if (!(cred->po->openmodes & O_WRITE) && (*type & SELECT_WRITE))
-    return EBADF;
-
   *type &= SELECT_READ | SELECT_WRITE;
 
   if (*type == 0)
@@ -575,11 +572,10 @@ io_select_common (struct trivfs_protid *cred,
       pthread_mutex_lock (&global_lock);
       if ((*type & SELECT_READ) && buffer_readable (input_buffer))
        available |= SELECT_READ;
-      if (output_buffer)
-       {
-         if ((*type & SELECT_WRITE) && buffer_writable (output_buffer))
-           available |= SELECT_WRITE;
-       }
+      if ((*type & SELECT_WRITE) &&
+         (!(cred->po->openmodes & O_WRITE) ||
+           (buffer_writable && buffer_writable (output_buffer))))
+       available |= SELECT_WRITE;
 
       if (available)
        {

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]