[Top][All Lists]

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

How to clone a port right

From: Sergiu Ivanov
Subject: How to clone a port right
Date: Tue, 7 Jul 2009 21:24:27 +0300
User-agent: Mutt/1.5.18 (2008-05-17)


In the latest working design unionmount creates a proxy node (by
cloning the netfs_root_node of unionfs translator) and sets the
mountee on this proxy.  I'm currently trying to implement cfhammar's
idea about having the mountee run in orphan mode.  To achieve this I
call only fshelp_start_translator, with no file_set_translator
following.  When calling fshelp_start_translator, I have to give a
pointer to a function, open_port, which in my case looks like this:

  /* Opens the port on which to set the mountee.  */
    open_port (int flags, mach_port_t * underlying,
               mach_msg_type_name_t * underlying_type, task_t task,
               void *cookie)
    err = 0;

    /* Create a port to `np`.  */
    newpi = netfs_make_protid
      (netfs_make_peropen (np, flags, NULL), user);
    if (!newpi)
        iohelp_free_iouser (user);
        return errno;

    *underlying = underlying_port = ports_get_send_right (newpi);
    *underlying_type = MACH_MSG_TYPE_COPY_SEND;

    ports_port_deref (newpi);

    return err;
  }                             /*open_port */

np is the pointer to the proxy node.  If I want to get rid of the
proxy node I must somehow avoid keeping references to it.  However, in
the above code I clearly add a reference to the proxy node by creating
a port which goes to the mountee and thus, does not get destroyed

I tried to set *underlying to MACH_PORT_NULL, but it (in a quite
expected way) refused to work.  I then tried to do
 *underlying = underlying_node;

where underlying_node is a port right describing a port to the
underlying node of the unionfs translator.  This led to the following

unionfs: /var/tmp/hurd-20090404/./libports/complete-deallocate.c:29:
_ports_complete_deallocate: Assertion `(pi->flags & 0x0001) == 0'
/hurd/filterfs: Translator startup failure: fsys_startup: (ipc/mig)
server died

(lines wrapped by MUA)

filterfs is the my own libnetfs-based translator which I use for
testing unionmount.

Now the question: can the reason for such failure be the fact that the
port right stored in underlying_node is used both in unionmount and in
the mountee?  If so, is there a way to clone the port right?


reply via email to

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