9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Jacob Moody <moody@mail.posixcafe.org>
To: 9front@9front.org
Subject: Re: [9front] srv(3) clone and srvid
Date: Wed, 29 Mar 2023 11:51:28 -0600	[thread overview]
Message-ID: <4d634a56-b533-6fd4-7010-142099f2464e@posixcafe.org> (raw)
In-Reply-To: <33F010865FC9B2A02D0352D79A362A33@smtp.pobox.com>

On 3/29/23 11:45, unobe@cpan.org wrote:
> I'm trying to run ndb/dns in a separate namespace so that I can use it
> to forward requests (in the namespace) to another DNS server.
> Recently, ndb/dns was updated to use /srv instead of '#s', which is
> necessary to keep it separate from the primary devsrv.  srv(3) states
> I can clone /srv and access that in two ways, via /srv/id or directly
> using srvspec:
> 
>           bind -c #s$srvspec /srv
> 
>           /srv/clone
>           /srv/id/...
>           /srv/service1
>           /srv/service2
> 
> The functionality is explained near the end of the man page:
>           Opening the clone file allocates a new service directory.
>           Reading clone returns the id of the new directory.  This new
>           service directory can then be accessed at /srv/id.  Directo-
>           ries are recursive; each new service directory contains its
>           own clone file and sub-directories.  Directories can be
>           walked from the root such as #s/id1/id2/id3 which makes them
>           globally addressable.  As a convention, /lib/namespace
>           accepts the path to the service directory from the environ-
>           ment variable $srvspec, making it possible to start a new
>           namespace using a specific service directory as a starting
>           point.
> 
> If I do:
> 	cpu% cat /srv/clone
> 	15cpu%
> 
> I get a new id.  I expected to be able to go to the clone using
> /srv/15, but that is not available:
> 	cpu% lc /srv/15
> 	ls: /srv/15: '/srv/15' file does not exist
> 
> I can, however, specify the srvspec to (supposedly) bind to a new
> service directtory:
> 	cpu% srvspec=`{cat /srv/clone} bind -c '#s'^$srvspec /srv
> 	cpu%
> 
> Yet I would have expected this cloned service directory to be
> disassociated from its parents so that manipulating it would not
> affect the parent.  Right now, that is not the case.  If I rm
> /srv/dns', after cloning the service directory, it is reflected across
> all namespaces.  Is this a feature that hasn't been implemented?  Am I
> misunderstanding how it's meant to work?
> 

Yes, clone works like how it does in /net, the board is only open for as long
as you have the fd open. So you cat'd it which opened it, read the new id, then closed
it deallocating the child srv. You need to keep the fd open for the length of time you
use the child srv, Or if you wish to 'pin' the child srv you can stash the clone fd itself
as a file in the child srv. This will keep the child srv around until you remove the pinned
clone fd.


  reply	other threads:[~2023-03-29 17:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 17:45 unobe
2023-03-29 17:51 ` Jacob Moody [this message]
2023-03-29 19:00   ` ori
2023-03-29 20:15     ` unobe
2023-03-29 20:31       ` Jacob Moody

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d634a56-b533-6fd4-7010-142099f2464e@posixcafe.org \
    --to=moody@mail.posixcafe.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).