Hello, On Mon, Jul 13, 2009 at 08:47:56PM +0300, Sergiu Ivanov wrote: > My current goal is to make unionmount go away when the mountee (the > union-mounted translator) goes away. From antrik's words (and from > personal remembering) I know that this could be achieved by listening > to the MACH_NOTIFY_NO_SENDERS notification on translator's control > port. However, I could not find sufficient (for me) information how > to properly request such a notification. > > I looked into hurd/boot/boot.c and libfshelp/start-translator-long.c > but, unfourtunately, both are handling rather specific cases, > considerably different from my situation. By analogy with boot.c, I > built up the following series of steps: > > mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, > &nosenders_listen_port); > mach_port_insert_right (mach_task_self (), nosenders_listen_port, > nosenders_listen_port, > MACH_MSG_TYPE_MAKE_SEND); > mach_port_request_notification (mach_task_self (), nosenders_listen_port, > MACH_NOTIFY_NO_SENDERS, 1, > nosenders_listen_port, > MACH_MSG_TYPE_MAKE_SEND_ONCE, &prev); > > However, this series of steps is pretty meaningless, since I never > specify the port to the mountee, to which I would like to listen for > notifications. I tried putting mountee_port and mountee_control (I > hope the names of the variables make their destination clear) instead > of nosenders_listen_port in different places, but I am constantly > receiving and ``invalid port right'' error. > > Could somebody point out an idea of a solution to this problem, > please?
The solution to this problem was kindly pointed out on the IRC by antrik and Fredrik. I was receiving ``invalid port right'' because I was listening to the wrong notification. The right notification is MACH_NOTIFY_DEAD_NAME. The first two function calls (mach_port_allocate and mach_port_insert_right) are okay. The third call, however, should be like as follows: mach_port_request_notification (mach_task_self (), mountee_control, MACH_NOTIFY_DEAD_NAME, 1, nosenders_listen_port, MACH_MSG_TYPE_MAKE_SEND_ONCE, &prev); (Of course, the name ``nosenders_listen_port'' is conceptually invalid, too) The problem with the ``no senders'' notification was that it should be (quite naturally) a receive right, while both mountee_{port,control} are *send* rights. According the GNU Mach reference manual, MACH_NOTIFY_DEAD_NAME is send exactly when the port itself is destroyed, while the right remains. It is not difficult to see that this is exactly the situation I am in. Great thanks to antrik and Fredrik! :-) Regards, scolobb