Is it possible to delete . and ..?
I read somewhere there are some patches for the linux kernel which let you do that. I have no idea where I read it and I don't know how to search for it because google and duckduckgo ignore the .s.
Is it possible to delete . and ..?
I read somewhere there are some patches for the linux kernel which let you do that. I have no idea where I read it and I don't know how to search for it because google and duckduckgo ignore the .s.
Technically, it is possible; for example, on an ext4 file system in e2test.img:
$ sudo mount e2test.img /mnt/temp
$ sudo mkdir /mnt/temp/dir{1,2}
$ sudo umount /mnt/temp
$ debugfs -w e2test.img
debugfs 1.45.6 (20-Mar-2020)
debugfs: unlink dir1/..
debugfs: unlink dir1/.
debugfs: quit
$ sudo mount e2test.img /mnt/temp
$ ls -a /mnt/temp/dir{1,2}
/mnt/temp/dir1:
/mnt/temp/dir2:
. ..
The shell isn’t particularly confused:
$ cd /mnt/temp/dir1
$ pwd
/mnt/temp/dir1
$ cd ..
$ pwd
/mnt/temp
As might be expected, e2fsck isn’t happy about this:
$ e2fsck e2test.img
e2fsck 1.45.6 (20-Mar-2020)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Missing '.' in directory inode 113793.
Fix<y>? yes
Setting filetype for entry '.' in ... (113793) to 2.
Missing '..' in directory inode 113793.
Fix<y>? yes
Setting filetype for entry '..' in ... (113793) to 2.
Pass 3: Checking directory connectivity
'..' in /dir1 (113793) is <The NULL inode> (0), should be / (2).
Fix<y>? yes
Pass 4: Checking reference counts
Pass 5: Checking group summary information
e2test.img: ***** FILE SYSTEM WAS MODIFIED *****
e2test.img: 14/128016 files (0.0% non-contiguous), 18478/512000 blocks
The exact behaviour will depend on the specific file system being used. Some don’t even store . and .. entries, but emulate them instead (POSIX requires . and .. to be understood and resolve to the appropriate directories, but doesn’t require them to be physically present).