bug-hurd
[Top][All Lists]
Advanced

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

Patch to retrieve send rights for shared memory objects


From: Barry deFreese
Subject: Patch to retrieve send rights for shared memory objects
Date: Fri, 25 Feb 2005 20:10:36 -0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20050105 Debian/1.7.5-1

OK, I tied Marcus down here in Brussels and forced him to start on SYSV shm support. Tomorrow night when he falls asleep I will steal his laptop and commit it unless I hear too much bitching!! :-)

Here is our cool patch:

This patch adds a new interface io_get_refs which returns the number of
extant send rights to the shared memory object for the I/O object.

hurd/
2005-02-26  Marcus Brinkmann  <address@hidden>

      * io.defs (io_get_refs): New RPC.

boot/
2005-02-26  Marcus Brinkmann  <address@hidden>

        * boot.c (S_io_get_refs): New stub.

libdiskfs/
2005-02-26  Marcus Brinkmann  <address@hidden>

        * Makefile (IOSRCS): Add io-get-refs.c.
        * io-get-refs.c: New file.

libnetfs/
2005-02-26  Marcus Brinkmann  <address@hidden>

        * iostubs.c (netfs_S_io_get_refs): New stub.

libtrivfs/
2005-02-26  Marcus Brinkmann  <address@hidden>

        * io-stubs.c (trivfs_S_io_get_refs): New stub.

pflocal/
2005-02-26  Marcus Brinkmann  <address@hidden>

        * io.c (S_io_get_refs): New stub.

pfinet/
2005-02-26  Marcus Brinkmann  <address@hidden>

        * io-ops.c (S_io_get_refs): New stub.


Index: boot/boot.c
===================================================================
RCS file: /cvsroot/hurd/hurd/boot/boot.c,v
retrieving revision 1.108
diff -u -p -r1.108 boot.c
--- boot/boot.c 13 Jun 2002 20:57:45 -0000      1.108
+++ boot/boot.c 26 Feb 2005 02:53:58 -0000
@@ -1768,6 +1768,13 @@ S_io_revoke (mach_port_t obj,
  return EOPNOTSUPP;
}

+kern_return_t
+S_io_get_refs (mach_port_t obj,
+               mach_port_t reply, mach_msg_type_name_t replyPoly,
+               mach_port_urefs_t *refs)
+{
+  return EOPNOTSUPP;
+}


/* Implementation of the Hurd terminal driver interface, which we only
Index: hurd/io.defs
===================================================================
RCS file: /cvsroot/hurd/hurd/hurd/io.defs,v
retrieving revision 1.37
diff -u -p -r1.37 io.defs
--- hurd/io.defs        9 Nov 2004 14:38:03 -0000       1.37
+++ hurd/io.defs        26 Feb 2005 02:54:03 -0000
@@ -320,3 +320,10 @@ routine io_identity (
   on the specified object.  */
routine io_revoke (
        io_object: io_t RPTLAST);
+
+/* Return the number of extant send rights on the object.  This allows
+   you to peek at how many other users there might be.  */
+routine io_get_refs (
+       io_object: io_t;
+       RPT
+       out refs: mach_port_urefs_t);

Index: libdiskfs/Makefile
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/Makefile,v
retrieving revision 1.71
diff -u -p -r1.71 Makefile
--- libdiskfs/Makefile  27 Jun 2002 19:19:13 -0000      1.71
+++ libdiskfs/Makefile  26 Feb 2005 02:54:03 -0000
@@ -32,7 +32,8 @@ IOSRCS= io-async-icky.c io-async.c io-du
        io-modes-on.c io-modes-set.c io-owner-mod.c io-owner-get.c \
        io-pathconf.c io-prenotify.c io-read.c io-readable.c io-identity.c \
        io-reauthenticate.c io-rel-conch.c io-restrict-auth.c io-seek.c \
-       io-select.c io-stat.c io-stubs.c io-write.c io-version.c io-sigio.c
+       io-select.c io-stat.c io-stubs.c io-write.c io-version.c io-sigio.c \
+       io-get-refs.c
FSYSSRCS=fsys-getroot.c fsys-goaway.c fsys-startup.c fsys-getfile.c \
        fsys-options.c fsys-syncfs.c fsys-forward.c
IFSOCKSRCS=ifsock.c

Index: libnetfs/iostubs.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libnetfs/iostubs.c,v
retrieving revision 1.4
diff -u -p -r1.4 iostubs.c
--- libnetfs/iostubs.c  13 Sep 1999 06:33:54 -0000      1.4
+++ libnetfs/iostubs.c  26 Feb 2005 02:54:04 -0000
@@ -87,3 +87,9 @@ netfs_S_io_sigio (struct protid *user)
{
  return EOPNOTSUPP;
}
+
+error_t
+netfs_S_io_get_refs (struct protid *cred, mach_port_urefs_t *refs)
+{
+  return EOPNOTSUPP;
+}

Index: libtrivfs/io-stubs.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libtrivfs/io-stubs.c,v
retrieving revision 1.6
diff -u -p -r1.6 io-stubs.c
--- libtrivfs/io-stubs.c        13 Jun 2002 21:26:15 -0000      1.6
+++ libtrivfs/io-stubs.c        26 Feb 2005 02:54:06 -0000
@@ -98,3 +98,13 @@ trivfs_S_io_readnotify (struct trivfs_pr
{
  return EOPNOTSUPP;
}
+
+/* Implement io_get_refs as described in <hurd/io.defs>. */
+kern_return_t
+trivfs_S_io_get_refs (struct trivfs_protid *cred, mach_port_t reply,
+ mach_msg_type_name_t replytype, + mach_port_urefs_t *refs)
+{
+  return EOPNOTSUPP;
+}
+
Index: pfinet/io-ops.c
===================================================================
RCS file: /cvsroot/hurd/hurd/pfinet/io-ops.c,v
retrieving revision 1.28
diff -u -p -r1.28 io-ops.c
--- pfinet/io-ops.c     11 Jun 2002 21:40:25 -0000      1.28
+++ pfinet/io-ops.c     26 Feb 2005 02:54:06 -0000
@@ -606,3 +606,12 @@ S_io_sigio (struct sock_user *user)
{
  return EOPNOTSUPP;
}
+
+
+/* Implement io_get_refs as described in <hurd/io.defs>. */
+error_t
+S_io_get_refs (struct sock_user *cred, mach_port_urefs_t *refs)
+{
+  return EOPNOTSUPP;
+}
+
Index: pflocal/io.c
===================================================================
RCS file: /cvsroot/hurd/hurd/pflocal/io.c,v
retrieving revision 1.39
diff -u -p -r1.39 io.c
--- pflocal/io.c        11 Jun 2002 21:40:34 -0000      1.39
+++ pflocal/io.c        26 Feb 2005 02:54:07 -0000
@@ -619,3 +619,10 @@ S_io_server_version (struct sock_user *u
{
  return EOPNOTSUPP;
}
+
+/* Implement io_get_refs as described in <hurd/io.defs>. */
+error_t
+S_io_get_refs (struct sock_user *cred, mach_port_urefs_t *refs)
+{
+  return EOPNOTSUPP;
+}
--- /dev/null   2005-02-17 12:38:26.000000000 -0500
+++ libdiskfs/io-get-refs.c     2005-02-25 14:47:35.000000000 -0500
@@ -0,0 +1,55 @@
+/* io-get-refs.c - Get the number of extant send rights.
+   Copyright (C) 2005 Free Software Foundation
+   Written by Marcus Brinkmann <address@hidden>.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "priv.h"
+#include "io_S.h"
+
+/* Implement io_get_refs as described in <hurd/io.defs>. */
+error_t
+diskfs_S_io_get_refs (struct protid *cred, mach_port_urefs_t *refs)
+{
+  error_t err = 0;
+  struct node *node;
+  memory_object_t shared;
+
+  if (!cred)
+    return EOPNOTSUPP;
+
+  node = cred->po->np;
+
+  mutex_lock (&node->lock);
+
+  /* Mmmh.  We could use a flag that says "do not create an object if
+     it doesn't exist already.  */
+  shared = diskfs_get_filemap (cred->po->np, 0);
+  if (shared == MACH_PORT_NULL)
+    {
+      *refs = 0;
+      /* FIXME: What error?  diskfs_get_filemap should return it.  */
+      err = ENOMEM;
+    }
+  else
+    {
+      err = mach_port_get_refs (mach_task_self (),
+                             shared, MACH_PORT_RIGHT_SEND, refs);
+      mach_port_deallocate (mach_task_self (), shared);
+    }
+  mutex_unlock (&node->lock);
+
+  return err;
+}



--
Barry deFreese
Debian 3.0r1 "Woody"
GNU/Hurd
Registered Linux "Newbie" #302256 - Hurd H4XX0r wannabe

"Programming today is a race between software engineers striving
to build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots. So far, the Universe is
winning." Rich Cook.







reply via email to

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