9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] union directories
@ 2003-03-03 20:00 Keith Nash
  2003-03-03 20:05 ` Russ Cox
  0 siblings, 1 reply; 31+ messages in thread
From: Keith Nash @ 2003-03-03 20:00 UTC (permalink / raw)
  To: 9fans

> Ls tells the truth!  I see no value in causing it to lie.

It tells the truth and nothing but the truth, but does it tell the whole truth?

I might believe from running ls -ld on a directory that I can create a new file in it; but I can't, if the directory is a union mount, and none of the elements was bound with -c.

Is there any way to test the writability of a directory, other than by attempting to create a file there, or by combining ls -ld with an examination of the output of ns?


Keith.



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] union directories
@ 2003-03-03 20:45 Keith Nash
  2003-03-03 20:51 ` Russ Cox
  0 siblings, 1 reply; 31+ messages in thread
From: Keith Nash @ 2003-03-03 20:45 UTC (permalink / raw)
  To: 9fans

>> Is there any way to test the writability
>> of a directory, other than by attempting
>> to create a file there, or by combining
>> ls -ld with an examination of the output of ns?

>No.

>I'm not even sure how ls -ld would help you.
Just to check user/group/world w flags.

>ns would give you a first approximation.



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] union directories
@ 2003-03-03 18:58 rog
  2003-03-03 23:17 ` anyrhine
  0 siblings, 1 reply; 31+ messages in thread
From: rog @ 2003-03-03 18:58 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1728 bytes --]

> Ls tells the truth!  I see no value in causing it to lie.

i'd like to be able to think of "ls" as showing me the files available
to me in a given directory.

files obscured within a union mount are not accessible to me; in fact,
apart from telling me that the directory probably contains a union
mount, information on those files is of no use at all.

there's a good implementation reason for having the duplicates show up
in raw reads (it only requires constant space in the kernel), but why
not get rid of the duplicates given that we're sorting the entries
anyway.

this isn't lying: it's showing a simplified version of the truth which
is not misleading (unlike the example in the lexnames paper).

> And then once ls lies, why doesn't ls *?  Why doesn't acme?

in fact, i think it's more important that * removes duplicates than ls.
i think it's a bug that:

	for (i in *) do something

can end up processing a single file multiple times.

acme the same - what's the point of showing me two of the same names
next to each other?  it just causes clutter. clicking on either
one performs exactly the same action.

> There might be good arguments that directory reads should
> reflect the information in the mount table, perhaps eliding
> duplicates and perhaps showing you the real stat info for 
> bound-over files (what you'd get with stat(2)).  Then again
> there are also good arguments for the way things are now.

mk was bitten by this at one stage.
it's a pity that
	ls -l | grep foo
doesn't necessarily give the same results as
	ls -ld foo

now that's a genuine case of ls (or at least unionread()) lying...
i agree about the arguments for the current behaviour though.

[-- Attachment #2: Type: message/rfc822, Size: 2798 bytes --]

From: "Russ Cox" <rsc@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] union directories
Date: Mon, 3 Mar 2003 13:05:41 -0500
Message-ID: <0a304f2dd88c5bdb8eb1ce403c53e037@plan9.bell-labs.com>

> Actually I have had more Unix-oriented folks ask me if in a union ls 
> there could be an option, per-file, to display the binding for that file 
> when there is more than one. 

Per-file options are a bad idea not even worth talking about.

> I got real complaints from people about seeing multiple files with the 
> same name on an ls. 

Ls tells the truth!  I see no value in causing it to lie.
And then once ls lies, why doesn't ls *?  Why doesn't acme?
Ls does one thing.  It does it well.  It's consistent with the
rest of the system.  If you want sort -u, you know where to
find it.

There might be good arguments that directory reads should
reflect the information in the mount table, perhaps eliding
duplicates and perhaps showing you the real stat info for 
bound-over files (what you'd get with stat(2)).  Then again
there are also good arguments for the way things are now.

Read the ksh example in the lexnames paper.  The last thing we
need is user-space programs that ``patch'' kernel behaviors.
Arguing that the kernel needs fixing might be reasonable.
Changing ls to hack around perceived kernel deficiencies
is the path to madness (or to Linux, take your pick).

Russ

^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] union directories
@ 2003-03-03 13:18 rog
  2003-03-03 17:40 ` Ronald G. Minnich
  0 siblings, 1 reply; 31+ messages in thread
From: rog @ 2003-03-03 13:18 UTC (permalink / raw)
  To: 9fans

> (Bind -bc 9 9 is like:
> 
> 	bind 9 9 
> 	bind -bc 9 9
> 
> hence everything appears twice.)

is there a good reason why ls doesn't eliminate duplicates when
showing union directories?

occasionally it might be useful, but as the default behaviour?

come to that, it would be nice if ls -l used a stable sorting
algorithm so that it was possible to tell which file attributes were
likely to correspond to the file that would be opened under a
particular name.

i did both of these things in inferno, with no obvious adverse
consequences.



^ permalink raw reply	[flat|nested] 31+ messages in thread
* [9fans] union directories
@ 2003-02-28 18:52 Joel Salomon
  2003-02-28 18:56 ` Russ Cox
  0 siblings, 1 reply; 31+ messages in thread
From: Joel Salomon @ 2003-02-28 18:52 UTC (permalink / raw)
  To: 9fans

Jack Johnson wrote:

> mkdir 9
> bind -bc 9 9
> bind -ac /sys/src/9 9
> cd 9
> mk

What is the significance of bind -bc 9 9 ?
I've seen this bind foo foo elsewhere - what does it do?
--Joel



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] presentation preparation
@ 2003-02-15 19:37 Scott Schwartz
  2003-02-15 19:48 ` andrey mirtchovski
  0 siblings, 1 reply; 31+ messages in thread
From: Scott Schwartz @ 2003-02-15 19:37 UTC (permalink / raw)
  To: 9fans

| I could use the extant doc prep
| tools I'm becoming increasingly familiar
| with.

Not a Plan 9 specific answer, but...  I rather like latex with the
prosper package.  Ideally it is used to make pdf, and can take advantage
of acroread's features, but straight ps output should be usable.



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] union directories
@ 2001-03-23 13:30 G. David Butler
  0 siblings, 0 replies; 31+ messages in thread
From: G. David Butler @ 2001-03-23 13:30 UTC (permalink / raw)
  To: 9fans

No, I did NOT pay him to say this! :)


"Douglas A. Gwyn" <DAGwyn@null.net> wrote:
__________
>rob pike wrote:
>> This is all a legacy of Unix's model that create means two different
>> things in the two situations.
>
>Well, there you go -- an attempt to create an existing file should
>fail.  That is a simpler and more useful property.
>




^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] union directories
@ 2001-03-23 13:08 rog
  2001-03-26  8:44 ` Douglas A. Gwyn
  0 siblings, 1 reply; 31+ messages in thread
From: rog @ 2001-03-23 13:08 UTC (permalink / raw)
  To: 9fans

> > This is all a legacy of Unix's model that create means two different
> > things in the two situations.
>
> Well, there you go -- an attempt to create an existing file should
> fail.  That is a simpler and more useful property.

it's not just a problem with the semantics of the create() system call,
but with the shell too.

if i type:

	echo hello > /usr/rog/file

i expect /usr/rog/file to be created if it isn't already there, but
overwritten if it is.

if create didn't overwrite an existing file, the shell would have to do
exactly as the kernel does currently, and for most intents and purposes
you'd still get the same "dual meaning".

i think under 9p2000 it's possible to call create() with an OEXCL
option and get the semantics you suggest.

  cheers,
    rog.



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] union directories
@ 2001-03-22  3:28 rob pike
  2001-03-23 10:06 ` Douglas A. Gwyn
  0 siblings, 1 reply; 31+ messages in thread
From: rob pike @ 2001-03-22  3:28 UTC (permalink / raw)
  To: 9fans

	The manual says "creation goes to the first element of the union that 
	permits creation". Doesn't that means that it shoud jump non_writable?.

Actually, the manual page bind(1) says,

	[-c] can be used in addition to any of the above to permit
	creation in a union directory.
	When a new file is created in a union directory,
	it is placed in the first element of the union that permits creation.

In this context, I don't feel it's ambiguous.

Bind(2) says,

	When a create system call (see open (2)) attempts to create in a union
	directory, and the file does not exist, the elements of the union are
	searched in order until one is found with MCREATE set.  The file is
	created in that directory; if that attempt fails, the create fails.

which is even clearer.

As to what it *should* do, this topic was one of the most discussed
in the early days of the system.  The current behavior obviously
reflects an easy implementation.  It's worked well in practice but
better designs may exist.

	Lookup should win whenever creation wins.

I'm not sure what this means.  There's no "winning" going on, and
lookup cannot work the same as creation if the file does not exist,
since there's nothing to look up.  If there is an existing file with that
name, in any element of the union, it is the one to which creation
will always apply.

This is all a legacy of Unix's model that create means two different
things in the two situations.

-rob



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] union directories
@ 2001-03-22  2:57 Gorka Guardiola Muzquiz
  0 siblings, 0 replies; 31+ messages in thread
From: Gorka Guardiola Muzquiz @ 2001-03-22  2:57 UTC (permalink / raw)
  To: 9fans

Russ> Actually that's the way it's supposed to work.
The manual says "creation goes to the first element of the union that 
permits creation". Doesn't that means that it should jump over non_writeble?
Even taking that in account, I can't see the logic behind this behaviour.
Lookup should win whenever creation wins. That would be symmetrical and
clean. with bind -ac n1 n2, bind -bc n1 n2, bind -ac n2 n1, bind -bc n2 n1
you would cover all the logical possibilities, and you save doing
bind -c n1 n2


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] union directories
@ 2001-03-22  2:46 Gorka Guardiola Muzquiz
  0 siblings, 0 replies; 31+ messages in thread
From: Gorka Guardiola Muzquiz @ 2001-03-22  2:46 UTC (permalink / raw)
  To: 9fans

>Actually that's the way it's supposed to work.
The manual says "creation goes to the first element of the union that 
permits creation". Doesn't that means that it shoud jump non_writable?.


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] union directories
@ 2001-03-22  2:42 Gorka Guardiola Muzquiz
  0 siblings, 0 replies; 31+ messages in thread
From: Gorka Guardiola Muzquiz @ 2001-03-22  2:42 UTC (permalink / raw)
  To: 9fans



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] union directories
@ 2001-03-22  2:37 Russ Cox
  0 siblings, 0 replies; 31+ messages in thread
From: Russ Cox @ 2001-03-22  2:37 UTC (permalink / raw)
  To: 9fans

That's an unfortunate choice of words (in the manual).
"Permits creation" in that context means "was bound
into the union with -c" not "creates would succeed there
if tried".

Russ


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] union directories
@ 2001-03-22  2:02 Russ Cox
  0 siblings, 0 replies; 31+ messages in thread
From: Russ Cox @ 2001-03-22  2:02 UTC (permalink / raw)
  To: 9fans

Actually that's the way it's supposed to work.

    Say you have two directories free_space and non_writable.
    If you write:

    bind -bc free_space non_writable 

    You add space to non_writable. Everything works fine. free_space is before
    non_writable in non_writable. If you create a file in non_writable you
    are actually creating int in free_space.

The union looks like

 * free_space
   non_writable

where the * means the directory was bound with -c.
Creates go to the topmost starred directory.

    bind -ac non_writable2 free_space2

    non_writable2 is after free_space2 in free_space2. You should be able to
    write in free_space. *you can't*. Even stranger:

Now you have

   free_space2
 * non_writable2

Creates go to non_writable2, but the directory
isn't writable.

    bind -ac fspace1 fspace2

    Any file in fspace2 supersedes any file in fspace1 with the same name,
    but if you create a file in fspace2 it is actually created *in fspace1*!!!???.
    fspace1 is *after* fspace2 for already existing files,
    but it is *before* when you create new ones.

Now you have

   fspace2
 * fspace1

Creates go to fspace1 but fspace2 wins for lookups.

It's just the way it's defined.  Note that if you did

bind -c fspace2 fspace2
bind -ac fspace1 fspace2

you'd have

 * fspace2
 * fspace1

so creates would go to fspace2 (the fact that fspace1
is starred is ignored), and fspace2 would win for lookups.

Russ


^ permalink raw reply	[flat|nested] 31+ messages in thread
* [9fans] union directories
@ 2001-03-22  1:56 Gorka Guardiola Muzquiz
  0 siblings, 0 replies; 31+ messages in thread
From: Gorka Guardiola Muzquiz @ 2001-03-22  1:56 UTC (permalink / raw)
  To: 9fans

I have encountered a behaviour in bind (well, actually in the fs) which
I find inconsistent. I may not be a bug, but it is counter intuitive.
Say you have two directories free_space and non_writable.
If you write:
bind -bc free_space non_writable 

You add space to non_writable. Everything works fine. free_space is before
non_writable in non_writable. If you create a file in non_writable you
are actually creating int in free_space.

bind -ac non_writable2 free_space2

non_writable2 is after free_space2 in free_space2. You should be able to
write in free_space. *you can't*. Even stranger:

bind -ac fspace1 fspace2

Any file in fspace2 supersedes any file in fspace1 with the same name,
but if you create a file in fspace2 it is actually created *in fspace1*!!!???.
fspace1 is *after* fspace2 for already existing files,
but it is *before* when you create new ones.

I find this weird and counter intuitive. It also seems to contradict
the manual page.  Is there any reason for this?. Is there something
I am not getting?.
-- 
                 Saludos,
                         Gorka

"Curiosity sKilled the cat"
-- 
    /"\
    \ /    ascii ribbon campaign - against html mail 
     X                           - against ms attachments
    / \


^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2003-03-04  9:44 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-03 20:00 [9fans] union directories Keith Nash
2003-03-03 20:05 ` Russ Cox
  -- strict thread matches above, loose matches on Subject: below --
2003-03-03 20:45 Keith Nash
2003-03-03 20:51 ` Russ Cox
2003-03-03 18:58 rog
2003-03-03 23:17 ` anyrhine
2003-03-03 13:18 rog
2003-03-03 17:40 ` Ronald G. Minnich
2003-03-03 18:05   ` Russ Cox
2003-03-03 18:09     ` Ronald G. Minnich
2003-03-03 18:16       ` Russ Cox
2003-02-28 18:52 Joel Salomon
2003-02-28 18:56 ` Russ Cox
2003-02-28 21:16   ` Jack Johnson
2003-02-28 22:58   ` Geoff Collyer
2003-02-28 23:19     ` Jack Johnson
2003-02-28 23:59       ` Geoff Collyer
2003-02-15 19:37 [9fans] presentation preparation Scott Schwartz
2003-02-15 19:48 ` andrey mirtchovski
2003-02-27  9:35   ` Ralph Corderoy
2003-02-28 18:44     ` [9fans] union directories Jack Johnson
2003-02-28 18:53       ` Russ Cox
2003-03-04  9:44       ` Adrian Tritschler
2001-03-23 13:30 G. David Butler
2001-03-23 13:08 rog
2001-03-26  8:44 ` Douglas A. Gwyn
2001-03-22  3:28 rob pike
2001-03-23 10:06 ` Douglas A. Gwyn
2001-03-22  2:57 Gorka Guardiola Muzquiz
2001-03-22  2:46 Gorka Guardiola Muzquiz
2001-03-22  2:42 Gorka Guardiola Muzquiz
2001-03-22  2:37 Russ Cox
2001-03-22  2:02 Russ Cox
2001-03-22  1:56 Gorka Guardiola Muzquiz

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).