bug-hurd
[Top][All Lists]
Advanced

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

Re: pread()


From: Manuel Menal
Subject: Re: pread()
Date: Sun, 31 Oct 2010 23:13:18 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100918 Icedove/3.0.8

On 14/10/2010 19:10, Roland McGrath wrote:
>> Shouldn't we change io_write() too? 
 > Yes, they are exact parallels.
 
Here is a patch that should make io_read() and io_write() return ESPIPE
when called with offset != -1 for non-seekable objects. I've tested all 
the components affected by this patch, and AFAICS everything is working
fine (and now pread() behaves as expected).

I've included a change for the documentation as well. As I'm not a
native speaker, my wording might not be elegant: someone might
want to proofread it.


diff --git a/boot/boot.c b/boot/boot.c
index 1a4e1b1..cc62b60 100644
--- a/boot/boot.c
+++ b/boot/boot.c
@@ -1421,6 +1421,8 @@ S_io_write (mach_port_t object,
 {
   if (object != pseudo_console)
     return EOPNOTSUPP;
+  else if (offset != (off_t) -1)
+    return ESPIPE;
 
 #if 0
   if (console_send_rights)
@@ -1448,6 +1450,8 @@ S_io_read (mach_port_t object,
 
   if (object != pseudo_console)
     return EOPNOTSUPP;
+  if (offset != (off_t) -1)
+    return ESPIPE;
 
 #if 0
   if (console_send_rights)
diff --git a/console-client/kbd-repeat.c b/console-client/kbd-repeat.c
index 4bf9268..75b773f 100644
--- a/console-client/kbd-repeat.c
+++ b/console-client/kbd-repeat.c
@@ -131,6 +131,8 @@ repeater_read (struct protid *cred, char **data,
     return EOPNOTSUPP;
   else if (! (cred->po->openstat & O_READ))
     return EBADF;
+  else if (offset != (off_t) -1)
+    return ESPIPE;
   
   mutex_lock (&global_lock);
   while (amount > kbdbuf.size)
diff --git a/console-client/pc-mouse.c b/console-client/pc-mouse.c
index cf8987b..426817d 100644
--- a/console-client/pc-mouse.c
+++ b/console-client/pc-mouse.c
@@ -174,7 +174,9 @@ repeater_read (struct protid *cred, char **data,
     return EOPNOTSUPP;
   else if (! (cred->po->openstat & O_READ))
     return EBADF;
-  
+  else if (offset != (off_t) -1)
+    return ESPIPE;
+
   mutex_lock (&global_lock);
   while (!mousebuf.size)
     {
diff --git a/console/console.c b/console/console.c
index dad7516..606f646 100644
--- a/console/console.c
+++ b/console/console.c
@@ -1114,13 +1114,18 @@ netfs_attempt_read (struct iouser *cred, struct node 
*np,
   mutex_unlock (&np->lock);
   if (np == vcons->cons_node)
     {
-      ssize_t amt = input_dequeue (vcons->input,
-                                  /* cred->po->openstat & O_NONBLOCK */ 0,
-                                  data, *len);
-      if (amt == -1)
-       err = errno;
-      else
-       *len = amt;
+      if (offset != (off_t) -1)
+       err = ESPIPE;
+      else 
+       {
+         ssize_t amt = input_dequeue (vcons->input,
+                                      /* cred->po->openstat & O_NONBLOCK */ 0,
+                                      data, *len);
+         if (amt == -1)
+           err = errno;
+         else
+           *len = amt;
+       }
     }
   else
     {
diff --git a/doc/hurd.texi b/doc/hurd.texi
index 098bebf..5a60d78 100644
--- a/doc/hurd.texi
+++ b/doc/hurd.texi
@@ -1649,17 +1649,18 @@ ID's.
 @subsection Simple Operations
 
 @findex io_write
-Users write to I/O ports by calling the @code{io_write} RPC.  They
-specify an @var{offset} parameter; if the object supports writing at
-arbitrary offsets, the server should honour this parameter.  If @math{-1}
-is passed as the offset, then the server should use the default file
-pointer.  The server should return the amount of data which was
-successfully written.  If the operation was interrupted after some but
-not all of the data was written, then it is considered to have succeeded
-and the server should return the amount written.  If the port is not an
-I/O port at all, the server should reply with the error
address@hidden  If the port is an I/O port, but does not happen to
-support writing, then the correct error is @code{EBADF}.
+Users write to I/O ports by calling the @code{io_write} RPC. They specify an
address@hidden parameter; if the object supports writing at arbitrary offsets, 
the
+server should honour this parameter. If @math{-1} is passed as the offset, then
+the server should use the default file pointer. For objects that don't support
+writing at arbitrary offsets, the offset should always be @math{-1}, or the
+server should reply with the error @code{ESPIPE}. The server should return the
+amount of data which was successfully written. If the operation was interrupted
+after some but not all of the data was written, then it is considered to have
+succeeded and the server should return the amount written. If the port is not 
an
+I/O port at all, the server should reply with the error @code{EOPNOTSUPP}. If
+the port is an I/O port, but does not happen to support writing, then the
+correct error is @code{EBADF}.
 
 @findex io_read
 Users read from I/O ports by calling the @code{io_read} RPC.  They
@@ -1677,12 +1678,12 @@ then the server may return @code{EINTR} rather than 
actually filling the
 buffer (taking care that any modifications of the default file pointer
 have been reversed).  Preferably, however, servers should return data.
 
-There are two categories of objects: seekable and non-seekable.
-Seekable objects must accept arbitrary offset parameters in the
address@hidden and @code{io_write} calls, and must implement the
address@hidden call.  Non-seekable objects must ignore the offset
-parameters to @code{io_read} and @code{io_write}, and should return
address@hidden to the @code{io_seek} call.
+There are two categories of objects: seekable and non-seekable. Seekable 
objects
+must accept arbitrary offset parameters in the @code{io_read} and
address@hidden calls, and must implement the @code{io_seek} call. For
+non-seekable objects, the offset parameter to @code{io_read} and 
@code{io_write}
+should always be @math{-1}, or @code{ESPIPE} should be returned; they should
+also return @code{ESPIPE} to the @code{io_seek} call.
 
 @c FIXME: should that last `should' be replaced with `must'?
 @c  tb: maybe, but perhaps not.  There might be a reason to implement a
diff --git a/hurd/io.defs b/hurd/io.defs
index d30233e..06855ce 100644
--- a/hurd/io.defs
+++ b/hurd/io.defs
@@ -32,13 +32,13 @@ IO_IMPORTS
 INTR_INTERFACE
 
 
-/* Write data to an IO object.  If offset is -1, write at the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount successfully written is returned in AMOUNT.  A
-   given user should not have more than one outstanding io_write on an
-   object at a time; servers implement congestion control by delaying
-   responses to io_write.  Servers may drop data (returning ENOBUFS)
-   if they recevie more than one write when not prepared for it.  */
+/* Write data to an IO object. If offset is -1, write at the object maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount successfully written is returned in AMOUNT. A given 
user
+   should not have more than one outstanding io_write on an object at a time;
+   servers implement congestion control by delaying responses to io_write.
+   Servers may drop data (returning ENOBUFS) if they recevie more than one 
write
+   when not prepared for it. */
 routine io_write (
        io_object: io_t;
        RPT
@@ -46,9 +46,9 @@ routine io_write (
        offset: loff_t;
        out amount: vm_size_t);
 
-/* Read data from an IO object.  If offset if -1, read from the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount desired to be read is in AMOUNT.  */
+/* Read data from an IO object. If offset if -1, read from the object 
maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount desired to be read is in AMOUNT. */
 routine io_read (
        io_object: io_t;
        RPT
diff --git a/pfinet/io-ops.c b/pfinet/io-ops.c
index ef8d851..554025b 100644
--- a/pfinet/io-ops.c
+++ b/pfinet/io-ops.c
@@ -47,6 +47,8 @@ S_io_write (struct sock_user *user,
 
   if (!user)
     return EOPNOTSUPP;
+  else if (offset != (off_t) -1)
+    return ESPIPE;
 
   __mutex_lock (&global_lock);
   become_task (user);
@@ -81,6 +83,8 @@ S_io_read (struct sock_user *user,
 
   if (!user)
     return EOPNOTSUPP;
+  if (offset != (off_t) -1)
+    return ESPIPE;
 
   /* Instead of this, we should peek and the socket and only
      allocate as much as necessary. */
diff --git a/pfinet/tunnel.c b/pfinet/tunnel.c
index c4f9580..a4a69f8 100644
--- a/pfinet/tunnel.c
+++ b/pfinet/tunnel.c
@@ -271,9 +271,9 @@ error_t (*trivfs_check_open_hook)(struct trivfs_control *,
    is about to be destroyed. */
 void (*trivfs_protid_destroy_hook) (struct trivfs_protid *) = pi_destroy_hook;
 
-/* Read data from an IO object.  If offset is -1, read from the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount desired to be read is in AMOUNT.  */
+/* Read data from an IO object. If offset is -1, read from the object 
maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount desired to be read is in AMOUNT.  */
 error_t
 trivfs_S_io_read (struct trivfs_protid *cred,
                   mach_port_t reply, mach_msg_type_name_t reply_type,
@@ -288,6 +288,8 @@ trivfs_S_io_read (struct trivfs_protid *cred,
     return EOPNOTSUPP;
   else if (! (cred->po->openmodes & O_READ))
     return EBADF;
+  else if (offs != (off_t) -1)
+    return ESPIPE;
 
   if (cred->pi.class != tunnel_class)
     return EOPNOTSUPP;
@@ -345,13 +347,13 @@ trivfs_S_io_read (struct trivfs_protid *cred,
   return 0;
 }
 
-/* Write data to an IO object.  If offset is -1, write at the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount successfully written is returned in amount.  A
-   given user should not have more than one outstanding io_write on an
-   object at a time; servers implement congestion control by delaying
-   responses to io_write.  Servers may drop data (returning ENOBUFS)
-   if they receive more than one write when not prepared for it.  */
+/* Write data to an IO object. If offset is -1, write at the object maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount successfully written is returned in amount. A given 
user
+   should not have more than one outstanding io_write on an object at a time;
+   servers implement congestion control by delaying responses to io_write.
+   Servers may drop data (returning ENOBUFS) if they receive more than one 
write
+   when not prepared for it.  */
 error_t
 trivfs_S_io_write (struct trivfs_protid *cred,
                    mach_port_t reply,
@@ -369,6 +371,8 @@ trivfs_S_io_write (struct trivfs_protid *cred,
     return EOPNOTSUPP;
   else if (! (cred->po->openmodes & O_WRITE))
     return EBADF;
+  else if (offset != (off_t) -1)
+    return ESPIPE;
 
   if (cred->pi.class != tunnel_class)
     return EOPNOTSUPP;
diff --git a/pflocal/io.c b/pflocal/io.c
index 74c2f97..d02697d 100644
--- a/pflocal/io.c
+++ b/pflocal/io.c
@@ -39,9 +39,9 @@
 #include "io_S.h"
 #include "interrupt_S.h"
 
-/* Read data from an IO object.  If offset if -1, read from the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount desired to be read is in amount.  */
+/* Read data from an IO object. If offset if -1, read from the object 
maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount desired to be read is in amount.  */
 error_t
 S_io_read (struct sock_user *user,
           char **data, mach_msg_type_number_t *data_len,
@@ -52,6 +52,8 @@ S_io_read (struct sock_user *user,
 
   if (!user)
     return EOPNOTSUPP;
+  if (offset != (off_t) -1)
+    return ESPIPE;
 
   err = sock_acquire_read_pipe (user->sock, &pipe);
   if (err == EPIPE)
@@ -71,13 +73,13 @@ S_io_read (struct sock_user *user,
   return err;
 }
 
-/* Write data to an IO object.  If offset is -1, write at the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount successfully written is returned in amount.  A
-   given user should not have more than one outstanding io_write on an
-   object at a time; servers implement congestion control by delaying
-   responses to io_write.  Servers may drop data (returning ENOBUFS)
-   if they recevie more than one write when not prepared for it.  */
+/* Write data to an IO object. If offset is -1, write at the object maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount successfully written is returned in amount. A given 
user
+   should not have more than one outstanding io_write on an object at a time;
+   servers implement congestion control by delaying responses to io_write.
+   Servers may drop data (returning ENOBUFS) if they recevie more than one 
write
+   when not prepared for it.  */
 error_t
 S_io_write (struct sock_user *user,
            char *data, mach_msg_type_number_t data_len,
@@ -88,6 +90,8 @@ S_io_write (struct sock_user *user,
 
   if (!user)
     return EOPNOTSUPP;
+  else if (offset != (off_t) -1)
+    return ESPIPE;
 
   err = sock_acquire_write_pipe (user->sock, &pipe);
   if (!err)
diff --git a/storeio/io.c b/storeio/io.c
index 508df77..89626b2 100644
--- a/storeio/io.c
+++ b/storeio/io.c
@@ -75,9 +75,9 @@ trivfs_S_io_map (struct trivfs_protid *cred,
     }
 }
 
-/* Read data from an IO object.  If offset if -1, read from the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount desired to be read is in AMOUNT.  */
+/* Read data from an IO object. If offset if -1, read from the object 
maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount desired to be read is in AMOUNT.  */
 error_t
 trivfs_S_io_read (struct trivfs_protid *cred,
                  mach_port_t reply, mach_msg_type_name_t reply_type,
@@ -113,13 +113,13 @@ trivfs_S_io_readable (struct trivfs_protid *cred,
     }
 }
 
-/* Write data to an IO object.  If offset is -1, write at the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount successfully written is returned in amount.  A
-   given user should not have more than one outstanding io_write on an
-   object at a time; servers implement congestion control by delaying
-   responses to io_write.  Servers may drop data (returning ENOBUFS)
-   if they recevie more than one write when not prepared for it.  */
+/* Write data to an IO object. If offset is -1, write at the object maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount successfully written is returned in amount. A given 
user
+   should not have more than one outstanding io_write on an object at a time;
+   servers implement congestion control by delaying responses to io_write.
+   Servers may drop data (returning ENOBUFS) if they recevie more than one 
write
+   when not prepared for it.  */
 error_t
 trivfs_S_io_write (struct trivfs_protid *cred,
                   mach_port_t reply, mach_msg_type_name_t reply_type,
diff --git a/term/users.c b/term/users.c
index a4e110b..67c2446 100644
--- a/term/users.c
+++ b/term/users.c
@@ -580,6 +580,8 @@ trivfs_S_io_write (struct trivfs_protid *cred,
 
   if (!cred)
     return EOPNOTSUPP;
+  else if (offset != (off_t) -1)
+    return ESPIPE;
 
   if (cred->pi.class == pty_class)
     return pty_io_write (cred, data, datalen, amt);
@@ -658,6 +660,8 @@ trivfs_S_io_read (struct trivfs_protid *cred,
 
   if (!cred)
     return EOPNOTSUPP;
+  if (offset != (off_t) -1)
+    return ESPIPE;
 
   if (cred->pi.class == pty_class)
     return pty_io_read (cred, data, datalen, amount);
diff --git a/trans/fifo.c b/trans/fifo.c
index 39043ac..e49e57b 100644
--- a/trans/fifo.c
+++ b/trans/fifo.c
@@ -329,9 +329,9 @@ trivfs_S_io_map (struct trivfs_protid *cred,
 
 /* ---------------------------------------------------------------- */
 
-/* Read data from an IO object.  If offset if -1, read from the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount desired to be read is in AMT.  */
+/* Read data from an IO object. If offset if -1, read from the object 
maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount desired to be read is in AMT.  */
 error_t
 trivfs_S_io_read (struct trivfs_protid *cred,
                  mach_port_t reply, mach_msg_type_name_t reply_type,
@@ -344,6 +344,8 @@ trivfs_S_io_read (struct trivfs_protid *cred,
     err = EOPNOTSUPP;
   else if (!(cred->po->openmodes & O_READ))
     err = EBADF;
+  else if (offs != (off_t) -1)
+    err = ESPIPE;
   else
     {
       struct pipe *pipe = cred->po->hook;
@@ -458,13 +460,13 @@ trivfs_S_io_select (struct trivfs_protid *cred,
 
 /* ---------------------------------------------------------------- */
 
-/* Write data to an IO object.  If offset is -1, write at the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount successfully written is returned in amount.  A
-   given user should not have more than one outstanding io_write on an
-   object at a time; servers implement congestion control by delaying
-   responses to io_write.  Servers may drop data (returning ENOBUFS)
-   if they recevie more than one write when not prepared for it.  */
+/* Write data to an IO object. If offset is -1, write at the object maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount successfully written is returned in amount. A given 
user
+   should not have more than one outstanding io_write on an object at a time;
+   servers implement congestion control by delaying responses to io_write.
+   Servers may drop data (returning ENOBUFS) if they recevie more than one 
write
+   when not prepared for it.  */
 error_t
 trivfs_S_io_write (struct trivfs_protid *cred,
                   mach_port_t reply, mach_msg_type_name_t reply_type,
@@ -475,6 +477,8 @@ trivfs_S_io_write (struct trivfs_protid *cred,
 
   if (!cred)
     err = EOPNOTSUPP;
+  else if (offs != (off_t) -1)
+    err = ESPIPE;
   else
     {
       int flags = cred->po->openmodes;
diff --git a/trans/firmlink.c b/trans/firmlink.c
index 087e19d..551caba 100644
--- a/trans/firmlink.c
+++ b/trans/firmlink.c
@@ -197,9 +197,9 @@ trivfs_goaway (struct trivfs_control *cntl, int flags)
 
 /* We store the file offset in po->hook (ick!) */
 
-/* Read data from an IO object.  If offset if -1, read from the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount desired to be read is in AMT.  */
+/* Read data from an IO object. If offset if -1, read from the object 
maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount desired to be read is in AMT.  */
 error_t
 trivfs_S_io_read (struct trivfs_protid *cred,
                  mach_port_t reply, mach_msg_type_name_t reply_type,
diff --git a/trans/hello-mt.c b/trans/hello-mt.c
index b933cfd..e80272c 100644
--- a/trans/hello-mt.c
+++ b/trans/hello-mt.c
@@ -117,9 +117,9 @@ close_hook (struct trivfs_peropen *peropen)
 }
 
 
-/* Read data from an IO object.  If offset is -1, read from the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount desired to be read is in AMOUNT.  */
+/* Read data from an IO object. If offset is -1, read from the object 
maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount desired to be read is in AMOUNT.  */
 error_t
 trivfs_S_io_read (struct trivfs_protid *cred,
                  mach_port_t reply, mach_msg_type_name_t reply_type,
diff --git a/trans/hello.c b/trans/hello.c
index c49feeb..b6a49dd 100644
--- a/trans/hello.c
+++ b/trans/hello.c
@@ -107,9 +107,9 @@ close_hook (struct trivfs_peropen *peropen)
 }
 
 
-/* Read data from an IO object.  If offset is -1, read from the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount desired to be read is in AMOUNT.  */
+/* Read data from an IO object. If offset is -1, read from the object 
maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount desired to be read is in AMOUNT.  */
 error_t
 trivfs_S_io_read (struct trivfs_protid *cred,
                  mach_port_t reply, mach_msg_type_name_t reply_type,
diff --git a/trans/new-fifo.c b/trans/new-fifo.c
index 5306dee..7ab9e6a 100644
--- a/trans/new-fifo.c
+++ b/trans/new-fifo.c
@@ -514,9 +514,9 @@ trivfs_S_io_map (struct trivfs_protid *cred,
 
 /* ---------------------------------------------------------------- */
 
-/* Read data from an IO object.  If offset if -1, read from the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount desired to be read is in AMT.  */
+/* Read data from an IO object. If offset if -1, read from the object 
maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount desired to be read is in AMT.  */
 error_t
 trivfs_S_io_read (struct trivfs_protid *cred,
                  mach_port_t reply, mach_msg_type_name_t reply_type,
@@ -529,6 +529,8 @@ trivfs_S_io_read (struct trivfs_protid *cred,
     err = EOPNOTSUPP;
   else if (!(cred->po->openmodes & O_READ))
     err = EBADF;
+  else if (offs != (off_t) -1)
+    err = ESPIPE;
   else
     {
       struct pipe *pipe = cred->po->hook;
@@ -645,13 +647,13 @@ trivfs_S_io_select (struct trivfs_protid *cred,
 
 /* ---------------------------------------------------------------- */
 
-/* Write data to an IO object.  If offset is -1, write at the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount successfully written is returned in amount.  A
-   given user should not have more than one outstanding io_write on an
-   object at a time; servers implement congestion control by delaying
-   responses to io_write.  Servers may drop data (returning ENOBUFS)
-   if they recevie more than one write when not prepared for it.  */
+/* Write data to an IO object. If offset is -1, write at the object maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount successfully written is returned in amount. A given 
user
+   should not have more than one outstanding io_write on an object at a time;
+   servers implement congestion control by delaying responses to io_write.
+   Servers may drop data (returning ENOBUFS) if they recevie more than one 
write
+   when not prepared for it.  */
 error_t
 trivfs_S_io_write (struct trivfs_protid *cred,
                   mach_port_t reply, mach_msg_type_name_t reply_type,
@@ -664,6 +666,8 @@ trivfs_S_io_write (struct trivfs_protid *cred,
     err = EOPNOTSUPP;
   else if (!(cred->po->openmodes & O_WRITE))
     err = EBADF;
+  else if (offs != (off_t) -1)
+    err = ESPIPE;
   else
     {
       struct pipe *pipe = cred->po->hook;
diff --git a/trans/null.c b/trans/null.c
index 9673a75..440c196 100644
--- a/trans/null.c
+++ b/trans/null.c
@@ -133,9 +133,9 @@ trivfs_S_io_map (struct trivfs_protid *cred,
   return EOPNOTSUPP;           /* XXX should work! */
 }
 
-/* Read data from an IO object.  If offset if -1, read from the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount desired to be read is in AMT.  */
+/* Read data from an IO object. If offset if -1, read from the object 
maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE 
is
+   returned. The amount desired to be read is in AMT.  */
 kern_return_t
 trivfs_S_io_read(struct trivfs_protid *cred,
                 mach_port_t reply, mach_msg_type_name_t replytype,
@@ -204,13 +204,13 @@ trivfs_S_io_select (struct trivfs_protid *cred,
   return 0;
 }
 
-/* Write data to an IO object.  If offset is -1, write at the object
-   maintained file pointer.  If the object is not seekable, offset is
-   ignored.  The amount successfully written is returned in amount.  A
-   given user should not have more than one outstanding io_write on an
-   object at a time; servers implement congestion control by delaying
-   responses to io_write.  Servers may drop data (returning ENOBUFS)
-   if they recevie more than one write when not prepared for it.  */
+/* Write data to an IO object. If offset is -1, write at the object maintained
+   file pointer. If the object is not seekable, offset should be -1 or ESPIPE
+   would be returned. The amount successfully written is returned in amount. A
+   given user should not have more than one outstanding io_write on an object 
at
+   a time; servers implement congestion control by delaying responses to
+   io_write. Servers may drop data (returning ENOBUFS) if they recevie more 
than
+   one write when not prepared for it.  */
 kern_return_t
 trivfs_S_io_write (struct trivfs_protid *cred,
                   mach_port_t reply, mach_msg_type_name_t replytype,
diff --git a/trans/streamio.c b/trans/streamio.c
index 0faa8a3..07a0d12 100644
--- a/trans/streamio.c
+++ b/trans/streamio.c
@@ -485,6 +485,9 @@ trivfs_S_io_read (struct trivfs_protid *cred,
   if (!(cred->po->openmodes & O_READ))
     return EBADF;
 
+  if (offs != (off_t) -1)
+    return ESPIPE;
+
   mutex_lock (&global_lock);
   err = dev_read (amount, (void **)data, data_len, cred->po->openmodes & 
O_NONBLOCK);
   mutex_unlock (&global_lock);
@@ -524,6 +527,9 @@ trivfs_S_io_write (struct trivfs_protid *cred,
   if (!(cred->po->openmodes & O_WRITE))
     return EBADF;
 
+  if (offs == (off_t) -1)
+    return ESPIPE;
+
   mutex_lock (&global_lock);
   err = dev_write ((void *)data, data_len, amount, cred->po->openmodes & 
O_NONBLOCK);
   mutex_unlock (&global_lock);

HTH,

-- 
Manuel Menal

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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