2003-07-10 08:03:22

by Andrey Borzenkov

[permalink] [raw]
Subject: Are "," and ".." in directory required?


Is it possible for readdir to return really empty directory - without
and entry, even "." and ".."?

The reason is, to enable full FAM/dnotify support for supermount I
have to allow open of non-mounted root and - if possible - readdir
in this case. Any attepmpt to simulate "." and ".." in this case
will result in races between kernel/user space, so the best case
would be just return nothing (meaning empty directory).

TIA

-andrey


2003-07-10 09:47:07

by Nikita Danilov

[permalink] [raw]
Subject: Re: Are "," and ".." in directory required?

"Andrey Borzenkov" writes:
>
> Is it possible for readdir to return really empty directory - without
> and entry, even "." and ".."?

Enter empty directory. Remove it by rmdir() by another process. Now you
have a directory without dot and dotdot.

>
> TIA
>
> -andrey

Nikita.

2003-07-10 10:04:44

by Andrey Borzenkov

[permalink] [raw]
Subject: Re[2]: Are "," and ".." in directory required?



-----Original Message-----

>
> "Andrey Borzenkov" writes:
> >
> > Is it possible for readdir to return really empty directory - without
> > and entry, even "." and ".."?
>
> Enter empty directory. Remove it by rmdir() by another process. Now you
> have a directory without dot and dotdot.
>

It is not quite the same.

bor@itsrm2% cd foo
bor@itsrm2% sudo rmdir /tmp/foo
bor@itsrm2% ls -la .
.: No such file or directory

how do I access this? OK I could have opendir on it ... but then,
directory contents is (mur be) still there just like with any
open unlinked file.

OK, not "possible to return" - it was wrong. Is it allowed? :)

-andrey

2003-07-10 10:23:25

by Nikita Danilov

[permalink] [raw]
Subject: Re: Are "," and ".." in directory required?

"Andrey Borzenkov" writes:
>
>
> -----Original Message-----
>
> >
> > "Andrey Borzenkov" writes:
> > >
> > > Is it possible for readdir to return really empty directory - without
> > > and entry, even "." and ".."?
> >
> > Enter empty directory. Remove it by rmdir() by another process. Now you
> > have a directory without dot and dotdot.
> >
>
> It is not quite the same.
>
> bor@itsrm2% cd foo
> bor@itsrm2% sudo rmdir /tmp/foo
> bor@itsrm2% ls -la .
> .: No such file or directory
>
> how do I access this? OK I could have opendir on it ... but then,

You should access it through getcwd(2). Try 'ls -al'. readdir has
special case for such directories (IS_DEADDIR), so it will come up as
empty without dot and dotdot.

> directory contents is (mur be) still there just like with any
> open unlinked file.

What actually remains in the directory is completely up to the file
system. File system may decide to remove dot and dotdot during rmdir, or
remove some of them, of leave everything to the final iput().

>
> OK, not "possible to return" - it was wrong. Is it allowed? :)
>
> -andrey

Nikita.

2003-07-10 10:27:09

by Oleg Drokin

[permalink] [raw]
Subject: Re: Are "," and ".." in directory required?

Hello!

On Thu, Jul 10, 2003 at 02:19:21PM +0400, "Andrey Borzenkov" wrote:
> > Enter empty directory. Remove it by rmdir() by another process. Now you
> > have a directory without dot and dotdot.
> It is not quite the same.
> bor@itsrm2% cd foo
> bor@itsrm2% sudo rmdir /tmp/foo
> bor@itsrm2% ls -la .
> .: No such file or directory

Well, this sequence of events is wrong.
You need to open it first, then remove it, and then do readdir (you still have filehandle to it).

Bye,
Oleg

2003-07-10 11:32:25

by Andrey Borzenkov

[permalink] [raw]
Subject: Re: Are "," and ".." in directory required?



> > bor@itsrm2% cd foo
> > bor@itsrm2% sudo rmdir /tmp/foo
> > bor@itsrm2% ls -la .
> > .: No such file or directory
> >
> > how do I access this? OK I could have opendir on it ... but then,
>
> You should access it through getcwd(2). Try 'ls -al'. readdir has
> special case for such directories (IS_DEADDIR), so it will come up as
> empty without dot and dotdot.
>

OK I tried it not under Linux the first time.

Tnx

-andrey


2003-07-10 11:47:22

by Andreas Schwab

[permalink] [raw]
Subject: Re: Are "," and ".." in directory required?

Oleg Drokin <[email protected]> writes:

|> Hello!
|>
|> On Thu, Jul 10, 2003 at 02:19:21PM +0400, "Andrey Borzenkov" wrote:
|> > > Enter empty directory. Remove it by rmdir() by another process. Now you
|> > > have a directory without dot and dotdot.
|> > It is not quite the same.
|> > bor@itsrm2% cd foo
|> > bor@itsrm2% sudo rmdir /tmp/foo

No need for sudo.

|> > bor@itsrm2% ls -la .
|> > .: No such file or directory
|>
|> Well, this sequence of events is wrong.
|> You need to open it first, then remove it, and then do readdir (you still have filehandle to it).

The filehandle is implicit (by being a cwd).

Andreas.

--
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N?rnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."