ls 从哪里获取已删除目录中的 inode 信息

ls 从哪里获取已删除目录中的 inode 信息

我无法理解以下情况下的行为:创建ls目录cda/b/c

$ mkdir a/b/c -p
$ ls -lhRai
.:
total 324K
24512531 drwxrwxr-x  3 mayank mayank 312K May 22 16:23 .
24380771 drwxr-xr-x 34 mayank mayank 4.0K May 22 15:14 ..
25690305 drwxrwxr-x  3 mayank mayank 4.0K May 22 16:23 a

./a:
total 324K
25690305 drwxrwxr-x 3 mayank mayank 4.0K May 22 16:23 .
24512531 drwxrwxr-x 3 mayank mayank 312K May 22 16:23 ..
25690306 drwxrwxr-x 3 mayank mayank 4.0K May 22 16:23 b

./a/b:
total 12K
25690306 drwxrwxr-x 3 mayank mayank 4.0K May 22 16:23 .
25690305 drwxrwxr-x 3 mayank mayank 4.0K May 22 16:23 ..
25690307 drwxrwxr-x 2 mayank mayank 4.0K May 22 16:23 c

./a/b/c:
total 8.0K
25690307 drwxrwxr-x 2 mayank mayank 4.0K May 22 16:23 .
25690306 drwxrwxr-x 3 mayank mayank 4.0K May 22 16:23 ..

cd到最里面的目录c

$ cd a/b/c

从另一个终端,删除目录a,即

$ rm -rf a

ls仍然得到索引节点信息

$ pwd
/home/mayank/Tmp/a/b/c
$ ls -lai .
total 0
$ ls -laid .
25690307 drwxrwxr-x 0 mayank mayank 0 May 22 16:23 .
$ ls -laid 
25690307 drwxrwxr-x 0 mayank mayank 0 May 22 16:23 .
$ ls -laid ../
25690306 drwxrwxr-x 0 mayank mayank 0 May 22 16:24 ../
$ ls -laid ../..
25690305 drwxrwxr-x 0 mayank mayank 0 May 22 16:24 ../..
$ ls -laid ../../..
24512531 drwxrwxr-x 2 mayank mayank 319488 May 22 16:24 ../../..

bash 中的offcoursecwd文件/proc指向已删除的目录

$ ls -l /proc/$$/cwd
lrwxrwxrwx 1 mayank mayank 0 May 22 16:32 /proc/13125/cwd -> /home/mayank/Tmp/a/b/c (deleted)

另外,无法理解cd行为

$ cd ..
cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory    
$ ls -li
total 0
$ ls -lid
25690306 drwxrwxr-x 0 mayank mayank 0 May 22 16:24 .
$ pwd
/home/mayank/Tmp/a/b/c/..
$ cd ..
cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
$ pwd
/home/mayank/Tmp/a/b/c/../..
$ ls -lhid
25690305 drwxrwxr-x 0 mayank mayank 0 May 22 16:24 .
$ cd ..    
Tmp:$ ls -lhtrai
total 320K
24380771 drwxr-xr-x 34 mayank mayank 4.0K May 22 15:14 ..
24512531 drwxrwxr-x  2 mayank mayank 312K May 22 16:24 .
Tmp:$ cd -
bash: cd: /home/mayank/Tmp/a/b/c/../..: No such file or directory

cd无法获取父目录信息c b,但是a

相关内容