linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Are "," and ".." in directory required?
@ 2003-07-10  8:16 "Andrey Borzenkov" 
  2003-07-10 10:01 ` Nikita Danilov
  0 siblings, 1 reply; 7+ messages in thread
From: "Andrey Borzenkov"  @ 2003-07-10  8:16 UTC (permalink / raw)
  To: linux-kernel


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

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

* Re: Are "," and ".." in directory required?
  2003-07-10  8:16 Are "," and ".." in directory required? "Andrey Borzenkov" 
@ 2003-07-10 10:01 ` Nikita Danilov
  2003-07-10 10:19   ` Re[2]: " "Andrey Borzenkov" 
  0 siblings, 1 reply; 7+ messages in thread
From: Nikita Danilov @ 2003-07-10 10:01 UTC (permalink / raw)
  To: "Andrey Borzenkov" ; +Cc: linux-kernel

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

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

* Re[2]: Are "," and ".." in directory required?
  2003-07-10 10:01 ` Nikita Danilov
@ 2003-07-10 10:19   ` "Andrey Borzenkov" 
  2003-07-10 10:37     ` Nikita Danilov
  2003-07-10 10:41     ` Oleg Drokin
  0 siblings, 2 replies; 7+ messages in thread
From: "Andrey Borzenkov"  @ 2003-07-10 10:19 UTC (permalink / raw)
  To: "Nikita Danilov" ; +Cc: linux-kernel



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

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

* Re: Are "," and ".." in directory required?
  2003-07-10 10:19   ` Re[2]: " "Andrey Borzenkov" 
@ 2003-07-10 10:37     ` Nikita Danilov
  2003-07-10 11:47       ` "Andrey Borzenkov" 
  2003-07-10 10:41     ` Oleg Drokin
  1 sibling, 1 reply; 7+ messages in thread
From: Nikita Danilov @ 2003-07-10 10:37 UTC (permalink / raw)
  To: "Andrey Borzenkov" ; +Cc: "Nikita Danilov" , linux-kernel

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

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

* Re: Are "," and ".." in directory required?
  2003-07-10 10:19   ` Re[2]: " "Andrey Borzenkov" 
  2003-07-10 10:37     ` Nikita Danilov
@ 2003-07-10 10:41     ` Oleg Drokin
  2003-07-10 12:01       ` Andreas Schwab
  1 sibling, 1 reply; 7+ messages in thread
From: Oleg Drokin @ 2003-07-10 10:41 UTC (permalink / raw)
  To: Andrey Borzenkov; +Cc: "Nikita Danilov" , linux-kernel

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

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

* Re: Are "," and ".." in directory required?
  2003-07-10 10:37     ` Nikita Danilov
@ 2003-07-10 11:47       ` "Andrey Borzenkov" 
  0 siblings, 0 replies; 7+ messages in thread
From: "Andrey Borzenkov"  @ 2003-07-10 11:47 UTC (permalink / raw)
  To: "Nikita Danilov" ; +Cc: linux-kernel



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



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

* Re: Are "," and ".." in directory required?
  2003-07-10 10:41     ` Oleg Drokin
@ 2003-07-10 12:01       ` Andreas Schwab
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2003-07-10 12:01 UTC (permalink / raw)
  To: Oleg Drokin; +Cc: Andrey Borzenkov, "Nikita Danilov" , linux-kernel

Oleg Drokin <green@namesys.com> 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, schwab@suse.de
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."

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

end of thread, other threads:[~2003-07-10 11:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-10  8:16 Are "," and ".." in directory required? "Andrey Borzenkov" 
2003-07-10 10:01 ` Nikita Danilov
2003-07-10 10:19   ` Re[2]: " "Andrey Borzenkov" 
2003-07-10 10:37     ` Nikita Danilov
2003-07-10 11:47       ` "Andrey Borzenkov" 
2003-07-10 10:41     ` Oleg Drokin
2003-07-10 12:01       ` Andreas Schwab

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