public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Vorfeed Canal <vorfeed.canal@gmail.com>
To: Thomas Wolff <towo@towo.net>
Cc: cygwin@cygwin.com
Subject: Re: Please test latest developer snapshot
Date: Sun, 27 Feb 2011 10:21:00 -0000	[thread overview]
Message-ID: <AANLkTikLU-VgjdqHszoH8VXm86kSPTO0nTvUAYu9oNtv@mail.gmail.com> (raw)
Message-ID: <20110227102100.VASRA915yScPqI7HOj_gA85GF4T-dHpieJhgIq-gHy4@z> (raw)
In-Reply-To: <4D685151.5020602@towo.net>

On Sat, Feb 26, 2011 at 4:03 AM, Thomas Wolff <towo@towo.net> wrote:
> No, what used to work (and didn't work in cygwin for a while) is that the
> current directory of some process is removed, not mentioning how it could be
> removed.

Sure, this is pre-requisite of rmdir("."). I was specifically talking about
rmdir(".") and rmdir("..").

> It cannot be removed by "rmdir ." for the reasons I mentioned.

Well, may be it can not be done in CygWin for some internal reasons but it
was possible to do that in Linux for a long time - till it was explicitly
forbidden.

> It can only be removed by using its full path, or relative path from its parent
> directory. The parent directory must be referred explicitly, otherwise it
> cannot work - because, as I tried to explain, the semantics of removing a
> directory entry (whether file or subdirectory) could not be established.
>

It can be established and it was established in Linux 15 years ago.

> Actually, in traditional Unix terminology, directories were also special
> files; moreever, there could even be hard links of directories - but that
> doesn't contribute to the issue.
>

Oh, but it does. Sure, long time ago directories were just "files+" and you had
no need for getdents(2) and Co. But as long as directories are just a special
files and you are allowed to make hardlinks you can corrupt filesystem from
userspace using standard Unix API. Not good(tm). Thus small alteration was made:
".." entity. It was introduced to make sure you are not introducing loops (you
can traverse back to the root using chains of ".." and see that you are not
corrupting the tree).

But the introduction of ".." and special functions needed to manipulate the tree
made it perfectly fine to do rmdir(".") - there are not ambguity from this point
on!

> This conclusion is not correct. The code you seem to refer to is just a way
> of handling an error that would otherwise go unhandled and produce problems.

No, it'll not produce problems. It'll just work(tm). Well, may be it'll produce
problems today (it's possible there are some other places in kernel which depend
on these checks today), but it certainly worked in Linux for a long, long time
without any ill effects (except for some brain-dead scripts). Long enough to
paper over the problem in rmdir(1)...

> Error handling is not a limitation.

It's the only limitation.

> Further down in the code, where the actual removal is invoked, the code needs
> the parent directory which it would not have in the case guarded by the error
> checking.

Why do you think so? Parent directory is ALWAYS available via ".."
entity. In some
case it's not available (for example if it's the root of the filesystem) - well,
in this case rmdir(".") obviously can not work.

Sure, in original Unix design where ".." was convenience, not a requirement it's
not possible to make rmdir(".") work, but these Unix system were extinct for so
long that we may happily forget about them.

P.S. Actually in modern Unix systems (including Linux) ".." entity does not
exist on disk - but it's strictly enforced in VFS layer so it does not change
anything conceptually: rmdir(".") makes perfect sense in Unix filesystem
and the ONLY reason it does not work on modern Unix systems is explicit
prohibition in POSIX.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  reply	other threads:[~2011-02-27  7:36 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-17 12:04 Corinna Vinschen
2011-02-17 18:06 ` Ken Brown
2011-02-17 18:15 ` marco atzeri
2011-02-18 12:36   ` Corinna Vinschen
2011-02-18 13:34     ` marco atzeri
2011-02-17 19:33 ` Aaron Peromsik
2011-02-17 20:15 ` Yaakov (Cygwin/X)
2011-02-19 18:29 ` Warren Young
2011-02-19 18:35   ` Warren Young
2011-02-19 20:35     ` Warren Young
2011-02-20 12:16       ` Corinna Vinschen
2011-02-21 14:16   ` Eric Blake
2011-02-21 15:21     ` Thomas Wolff
2011-02-26  0:25       ` Vorfeed Canal
2011-02-26  0:45         ` Eric Blake
2011-02-26  1:03         ` Thomas Wolff
2011-02-27  7:35           ` Vorfeed Canal [this message]
2011-02-27 10:21             ` Vorfeed Canal
2011-02-27 11:21             ` Vorfeed Canal
2011-02-24 14:57 ` Chris Sutcliffe
2011-02-24 15:16   ` Corinna Vinschen
2011-02-24 19:34     ` Karl M
2011-02-24 20:56       ` Reini Urban
2011-02-24 21:52 ` Kai Tietz
2011-02-25  9:47   ` Corinna Vinschen
2011-02-25 23:25 ` David Rothenberger
2011-02-26  0:09   ` David Rothenberger
2011-02-26  9:51     ` marco atzeri
2011-02-26 10:36     ` Corinna Vinschen
2011-02-27 14:15       ` Corinna Vinschen
2011-02-27 18:45         ` David Rothenberger
2011-03-01  7:06     ` Christopher Faylor
2011-03-01 15:51       ` David Rothenberger
2011-02-18 15:34 Angelo Graziosi
2011-02-19 16:05 ` jdzstz - gmail dot com
2011-02-27 15:03 Angelo Graziosi
     [not found] <AANLkTim4xT_LL=CGFXhgKmO0gLd5P_rXctaMpHwT2pxn@mail.gmail.com>
2011-03-03 12:22 ` Oleg Marchuk
2011-03-03 12:53   ` Oleg Marchuk
2011-03-03 16:41     ` Christopher Faylor

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=AANLkTikLU-VgjdqHszoH8VXm86kSPTO0nTvUAYu9oNtv@mail.gmail.com \
    --to=vorfeed.canal@gmail.com \
    --cc=cygwin@cygwin.com \
    --cc=towo@towo.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 read-only IMAP folder(s) and NNTP newsgroup(s).