9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Russ Cox <rsc@swtch.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] dup(3)
Date: Fri, 16 Oct 2009 09:52:52 -0700	[thread overview]
Message-ID: <dd6fe68a0910160952w6c36ff9ex1440beff75b921fc@mail.gmail.com> (raw)
In-Reply-To: <138575260910160858nfc9444fr73e3328d98eac98a@mail.gmail.com>

On Fri, Oct 16, 2009 at 8:58 AM, hugo rivera <uair00@gmail.com> wrote:
> I am having a hard time understanding the dircp script and the dup(3)
> device. What's exactly the purpose of writing
> @{builtin cd $1 && tar cf /fd/1 .} | @{builtin cd $2 && tar xTf /fd/0}
> instead of
> {builtin cd $1 && tar c .} | {builtin cd $2 && tar xT}

your version is fine except that you dropped the @.
the author of dircp either didn't realize that tar's default
was to use those files or wanted to be explicit since
older tar commands have other defaults (the tape device).

> What other uses dup(3) might have?

the same as any other file system: it gives a file name
for a resource, making that resource usable in any program
that wants to open a file.

on unix the same need is often met by the lame idiom that
the file name - means standard input or output depending
on context.  /fd is a real file system and more general.

it's not something you need every day, but it's often crucial
when you do need it.  for example, look at the way it gets
used in in exportfs or page.

russ


  reply	other threads:[~2009-10-16 16:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-16 15:58 hugo rivera
2009-10-16 16:52 ` Russ Cox [this message]
2009-10-16 17:25 ` Steve Simon
2009-10-19  9:10   ` hugo rivera
     [not found] <<138575260910160858nfc9444fr73e3328d98eac98a@mail.gmail.com>
2009-10-16 16:06 ` erik quanstrom

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=dd6fe68a0910160952w6c36ff9ex1440beff75b921fc@mail.gmail.com \
    --to=rsc@swtch.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).