Re: Deleting the current directory, V2.1.54

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Sat, 13 Sep 1997 09:34:33 +0200 (MET DST)


Richard B. Johnson wrote:
>
> Observation:
>
> If a directory is empty, it is now possible to remove the default
> directory.
>
> 'pwd' shows that the default directory is still the directory that
> was removed.
>
> Attempts to write into the directory that was removed, will fail with
> "Operation not permitted".

That is correct behaviour. You already could remove the current
directory from under someone, but now you can also do "rm ."

> If the entire path-name is used, it is possible to make a new directory
> with the same name as the one just removed.

That is correct.

> Attempts to write into the newly created directory, will fail with
> "Operation not permitted".

You mean you're still in that deleted directory and try to create
files inside that deleted directory? That's supposed to fail
with operation not permitted.

The confusing thing here is that there now are TWO DIFFERENT directories
which just happen to have the same name.

consider
something < tempfile > tempfile
This program simply uses its stdin/out file descriptors to access one
single tempfile.

Now consider
something < tempfile > tempfile
rm temfile
something < tempfile > tempfile
Now there are also two copies of "tempfile", both with the same name.
This will work on any Unix.

> However, if the entire path name is used, it is possible to write into
> the new directory. The file exists and can be manipulated if its entire
> path-name is used. It does not seem to exist if accessed from the default
> directory.

Correct.

> If the default directory is changed, then changed back to the newly created
> one, the subsequent file operations are normal.

Correct.

> If the default directory is not changed, but instead is reset, i.e.,
> 'cd /complete/path/name', file operations are again normal.

Correct.

> I have looked in the old AT&T Unix reference manual and cannot find
> any prohibition against removing the default directory, however my
> Sun doesn't allow such an operation. Sun's rmdir responds with
> "Can't remove . or ..".

Right. This is an implementation problem that used to be valid for
ALL unices, but this restriction has been removed for Linux last
month.

> If this new behavior is okay, it could result in some problems for
> new-bee Linux users. They could get "lost" as programs running in
> certain default directories could have their file operations fail
> for no apparent reason as some other task removed that directory
> and then recreated it.

New bees (:-) won't likely hit this. If they do it is a nice
way to introduce them to the real semantics of Unix.

> Richard B. Johnson

Telling random people they don't know how to write code, and don't
even know yourself how Unix is supposed to work. Jee.

By the way, it is bad practise to Email as "root". For one, it shows
you're a newby. (newby's like to brag "look, look, I'm root on my own
machine!") If you resent being called "newby", I'll quote you:

> If this new behavior is okay, it could result in some problems for
> new-bee Linux users. They could get "lost" as programs running in
> certain default directories could have their file operations fail
> for no apparent reason as some other task removed that directory
> and then recreated it.

Yes, the behaviour is OK, and yes you got "lost". You qualify as
a newby.

Roger.

-- 
** R.E.Wolff@BitWizard.nl ** +31-15-2137555 ** http://www.BitWizard.nl/ **
Florida -- A 39 year old construction worker woke up this morning when a
109-car freigt train drove over him. According to the police the man was 
drunk. The man himself claims he slipped while walking the dog. 080897