Skip to contentSkip to conversation

FileSystem, "." and "..", rmdir

DISCUSSION unDEFER 1 participant 3 messages Nov 6, 2005 – Nov 7, 2005

lore
Share & tools
lore

unDEFER

author
#0 lore raw

Hello,

I'm newbie in kernel programming and try to write filesystem, and have two problems.

1) There are not "<mount-point>/.", "<mount-point>/..", and "<mount-point>/<any_dir>/.." entries, for example:

# ls -a
dir  link  text_file
# ls -a dir/
.  level_2
# ls -a dir/level_2/
.  ..

I make

      filldir(dirent, ".", 1, i, ino, DT_DIR) and
      filldir(dirent, "..", 2, i, parent_ino(filp->f_dentry))

in readdir() for all directories.

2) Problem with removing not empty directories:

# ls -l
total 135
drwxr-xr-x  3 root root      0 Nov  6 17:48 dir
lr-xr-xr-x  1 root root   1024 Nov  2 11:13 link -> /home/undefer
-r-xr-xr-x  1 root root 274944 Nov  2 11:13 text_file
# rmdir dir
rmdir: `dir': Directory not empty
# ls -l
total 135
?---------  0 root root      0 Jan  1  1970 dir
lr-xr-xr-x  1 root root   1024 Nov  2 11:13 link -> /home/undefer
-r-xr-xr-x  1 root root 274944 Nov  2 11:13 text_file

So anything call "delete_inode" for directory and it's entries but it is not empty! What is? Why? What I could made not so?

Thanks,
Sorry for bad english.

Signature · 2 lines
registered Linux user #360474
Don't worry, I can read OpenOffice.org
author
#1 lore raw

В письме от Sun, 06 Nov 2005 18:05:03 +0300, unDEFER <[email protected]> сообщал:

Quoted 1 line

So anything call "delete_inode" for directory and it's entries but it is not empty! What is? Why? What I could made not so?

Oh! I found my big error! It is here (in struct super_operations):
.drop_inode = generic_delete_inode,

So, second problem is solved.

Signature · 3 lines
Nikolaj Krivchenkov aka unDEFER
registered Linux user #360474
Don't worry, I can read OpenOffice.org
author
#2 lore raw
In reply to unDEFER

В письме от Sun, 06 Nov 2005 18:05:03 +0300, unDEFER <[email protected]> сообщал:

Quoted 1 line

1) There are not "<mount-point>/.", "<mount-point>/..", and "<mount-point>/<any_dir>/.." entries,

And the first problem was solved when I change root inode to #1 and reserve inode #0 as not allocatable.

Signature · 2 lines
registered Linux user #360474
Don't worry, I can read OpenOffice.org