sysprog21 / simplefs

A simple native file system for Linux kernel
Other
369 stars 91 forks source link

Symbolic link creation fails after file deletion #58

Closed cbkadal closed 1 month ago

cbkadal commented 3 months ago
$ echo "FILE" > file1
$ ln -s file1 symlink
$ cat file1
FILE
$ cat symlink 
cat: symlink: Too many levels of symbolic links
$ rm -f symlink 
$ touch symlink
touch: cannot touch 'symlink': No space left on device
$ 
HotMercury commented 3 months ago

$ echo "FILE" > file1 $ ln -s file1 symlink $ cat file1 FILE $ cat symlink FILE $ rm -f symlink $ ls file1 $ touch symlink touch: cannot touch 'symlink': No space left on device $ ls file1 $ touch symlink $ ls file1 symlink

I only find the porblem of "No space left on device"

cbkadal commented 3 months ago

The symlink problem will happen after running "test.txt" (modified). test.txt

PS: The failed tests are commented "FAILED" in the script.

$ ls -al
ls: cannot read symbolic link 'symlink': Invalid argument
total 6
drwxrwxr-x 2 cbkadal cbkadal 4096 Jun 20 20:48 .
drwxr-xr-x 7 cbkadal cbkadal 4096 Jun 20 20:48 ..
-rw-r--r-- 1 cbkadal cbkadal    5 Jun 20 20:48 file
lrwxrwxrwx 1 cbkadal cbkadal    4 Jun 20 20:49 symlink
HotMercury commented 3 months ago

This is indeed a bug. After we remove a file, the first soft link creation fails, but subsequent ones succeed.

$ touch a $ ln -s a b $ ln -s a c $ touch nothing $ rm nothing $ ln -s a d $ ln -s a e $ ls -l output: d is error

a
b -> a
c -> a
e -> a 
d

I need some time to resolve the issue, or you can submit a PR.