9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: hiro <23hiro@gmail.com>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] fd and /srv filesystem
Date: Wed, 4 Oct 2023 14:25:22 +0200	[thread overview]
Message-ID: <CAFSF3XNvy-nCJX1qKrFJCx+guRWqiUEWSUSC1hnXmwQOuZHX0Q@mail.gmail.com> (raw)
In-Reply-To: <CAFSF3XNMyPj+cY8=_-vpcgtFHVoBERNxiJiFzqo_nLvU8y3KKg@mail.gmail.com>

btw it's very common on unix to share FDs in multi-threaded programs.
and all the pain resulting from un-synchronised FD access is available
as expected :)

On 10/4/23, hiro <23hiro@gmail.com> wrote:
> file descriptors describe to the kernel which of the files you
> previously open()'ed (a syscall) you want to operator on.
>
> it's not about security: if you want to operate on a file that another
> process might have opened before, you have to be careful that the
> other process isn't writing to the same location in the file at the
> same time. the kernel also keeps offsets for you.
>
> if you share FDs between multiple processes you might want some
> synchronisation like locking.
>
> On 10/4/23, Chris McGee <newton688@gmail.com> wrote:
>> Hi All,
>> 
>> I was thinking about file descriptors in the context of Plan 9. On Unix
>> an
>> fd is generally only usable by the current process, and child ones
>> through
>> a fork with some special incantation if one wants to communicate one over
>> a
>> domain socket. This is possibly for security reasons, avoiding other
>> users'
>> processes from trying to guess the fd of a critical file.
>> 
>> It's common practice in Plan 9 to post an fd (sometimes via a pipe) from
>> one process to the /srv filesystem so that others can discover it and
>> open
>> a comms channel. Does the kernel transform the fd into something when
>> posted to /srv so that it can be consumed by any other process in the
>> system?
>> 
>> Thanks,
>> Chris

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tfaa2554a9b74c479-Mcf0b3c1629feb1b852c3224d
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

  reply	other threads:[~2023-10-04 12:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 10:29 Chris McGee
2023-10-04 12:20 ` hiro
2023-10-04 12:25   ` hiro [this message]
2023-10-04 16:06 ` ori
2023-10-04 23:42   ` Chris McGee

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=CAFSF3XNvy-nCJX1qKrFJCx+guRWqiUEWSUSC1hnXmwQOuZHX0Q@mail.gmail.com \
    --to=23hiro@gmail.com \
    --cc=9fans@9fans.net \
    /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).