9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: ron minnich <rminnich@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] replica under 9vx
Date: Sun,  4 Oct 2009 23:39:58 -0700	[thread overview]
Message-ID: <13426df10910042339j2e1889em728f6f103a535529@mail.gmail.com> (raw)
In-Reply-To: <13426df10910042142p1392b6b8m8b05ece8c9b05353@mail.gmail.com>

OK, it's an incompatibility between Posix world and Plan 9 world. It's
because mkdir doesn't open the directory, and
create on Plan 9 does.

Here is what I think is the relevant code from applylog.


			if(rd.mode&DMDIR){
				fd = create(local, OREAD, DMDIR); <========= creates d--------- --
but it's open.
				if(fd < 0 && isdir(local))
					fd = open(local, OREAD);
				if(fd  < 0){
					error("mkdir %q: %r", name);
					skip = 1;
					continue;
				}

This sequence works fine on Plan 9.

In devfs-posix.c we have this:

                if(mkdir(path, perm & 0777) < 0)
                        oserror();
                if((fd = open(path, 0)) < 0)
                        oserror();

Which fails very badly on linux if perm is 0, as it is from replica.

This works on Plan 9 because create is one operation, even for
directories. Chalk it up to another Posix botch. I can't recall how
many times this one has bitten me.

I can special-case the code in devfs-posix.c:

if (perm&0400 == 0) then do a mkdir, an open, and an fchmod. Tomorrow,
that is. I think the work-around is pretty easy.
I figure the 0400 might work because mode has to be OREAD at this point anyway.

or, simpler: take this code:
                // Be like Plan 9 file servers: inherit mode bits
                // and group from parent.
                fchmod(fd, perm & st.st_mode & 0777);

which happens AFTER the mkdir, and instead compute the perms first and
do the mkdir with those perms.

Russ, any reason to make the d--------- perm directory and then change
it with the fchmod later? Can we just do the mkdir with the final
permissions? Or is this d--------- guarding against some race
condition in the linux vfs?

ron



  reply	other threads:[~2009-10-05  6:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<13426df10910032308j1c9aac90k51dd2400db23f79f@mail.gmail.com>
2009-10-04 15:22 ` erik quanstrom
2009-10-04 16:30   ` ron minnich
2009-10-04 17:20     ` Steve Simon
2009-10-04 21:15       ` ron minnich
2009-10-05  0:55         ` Fernan Bolando
2009-10-05  4:42           ` ron minnich
2009-10-05  6:39             ` ron minnich [this message]
2009-10-05  6:41               ` ron minnich
     [not found] <<13426df10910042341k73b0de26u6c7f3f1992549c9c@mail.gmail.com>
2009-10-05 13:56 ` erik quanstrom
     [not found] <<f7c633ef2aae073a6ed65cf21142b5b2@quintile.net>
2009-10-04 17:25 ` erik quanstrom
2009-10-04  6:08 ron minnich

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=13426df10910042339j2e1889em728f6f103a535529@mail.gmail.com \
    --to=rminnich@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).