]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - hurd/fopenport.c
contrib.texi: update
[thirdparty/glibc.git] / hurd / fopenport.c
index e0ab908dba9ee1cd668c833b0a24999780fd87a8..6fef2dbb2a45e01fb05eae566b66014574d1b192 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2024 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -13,7 +13,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #include <hurd.h>
 #include <stdio.h>
@@ -28,9 +28,10 @@ readio (void *cookie, char *buf, size_t n)
   mach_msg_type_number_t nread;
   error_t err;
   char *bufp = buf;
+  io_t io = (io_t) (uintptr_t) cookie;
 
   nread = n;
-  if (err = __io_read ((io_t) cookie, &bufp, &nread, -1, n))
+  if (err = __io_read (io, &bufp, &nread, -1, n))
     return __hurd_fail (err);
 
   if (bufp != buf)
@@ -48,10 +49,11 @@ readio (void *cookie, char *buf, size_t n)
 static ssize_t
 writeio (void *cookie, const char *buf, size_t n)
 {
-  mach_msg_type_number_t wrote;
+  vm_size_t wrote;
   error_t err;
+  io_t io = (io_t) (uintptr_t) cookie;
 
-  if (err = __io_write ((io_t) cookie, buf, n, -1, &wrote))
+  if (err = __io_write (io, buf, n, -1, &wrote))
     return __hurd_fail (err);
 
   return wrote;
@@ -62,10 +64,11 @@ writeio (void *cookie, const char *buf, size_t n)
    Returns zero if successful, nonzero if not.  */
 static int
 seekio (void *cookie,
-       _IO_off64_t *pos,
+       off64_t *pos,
        int whence)
 {
-  error_t err = __io_seek ((file_t) cookie, *pos, whence, pos);
+  io_t io = (io_t) (uintptr_t) cookie;
+  error_t err = __io_seek (io, *pos, whence, pos);
   return err ? __hurd_fail (err) : 0;
 }
 
@@ -74,8 +77,9 @@ seekio (void *cookie,
 static int
 closeio (void *cookie)
 {
+  io_t io = (io_t) (uintptr_t) cookie;
   error_t error = __mach_port_deallocate (__mach_task_self (),
-                                         (mach_port_t) cookie);
+                                         io);
   if (error)
     return __hurd_fail (error);
   return 0;
@@ -122,11 +126,9 @@ __fopenport (mach_port_t port, const char *mode)
 
   /* Check the access mode.  */
   if ((pflags & needflags) != needflags)
-    {
-      errno = EBADF;
-      return NULL;
-    }
+    return __hurd_fail (EBADF), NULL;
 
-  return fopencookie ((void *) port, mode, funcsio);
+  return fopencookie ((void *) (uintptr_t) port,
+                      mode, funcsio);
 }
 weak_alias (__fopenport, fopenport)