Let me give a real answer to the original question and explain how to create this kind of state:
mkfile 100m ufs
lofiadm -a /path/to/ufs
newfs /dev/rlofi/1
newfs: Neues Dateisystem /dev/rlofi/1 erstellen: (y/n)? y
/dev/rlofi/1: 204600 Sektoren in 341 Zylindern von 1 Spuren, 600 Sektoren
99,9MB in 22 Zylindergruppen (16 c/g, 4,69MB/g, 2240 i/g)
Superblock Backups (für fsck -F ufs -o b=#) bei:
32, 9632, 19232, 28832, 38432, 48032, 57632, 67232, 76832, 86432,
115232, 124832, 134432, 144032, 153632, 163232, 172832, 182432, 192032, 201632
mount /dev/lofi/1 /mnt
cd /mnt
mkdir -p a/b/c d
ls -lid a/b/ a/b/c a/b/c/..
5 drwxr-xr-x 3 root root 512 Apr 20 17:05 a/b/
6 drwxr-xr-x 2 root root 512 Apr 20 17:05 a/b/c
5 drwxr-xr-x 3 root root 512 Apr 20 17:05 a/b/c/..
link a/b/c/ d/hlink
ls -lid a/b/ a/b/c a/b/c/.. d/ d/hlink/ d/hlink/..
5 drwxr-xr-x 3 root root 512 Apr 20 17:05 a/b/
6 drwxr-xr-x 3 root root 512 Apr 20 17:05 a/b/c
5 drwxr-xr-x 3 root root 512 Apr 20 17:05 a/b/c/..
7 drwxr-xr-x 2 root root 512 Apr 20 17:08 d/
6 drwxr-xr-x 3 root root 512 Apr 20 17:05 d/hlink/
5 drwxr-xr-x 3 root root 512 Apr 20 17:05 d/hlink/..
This is creating a test ufs filesystem in a file, which is then used as a block device via the lofi(7d)
"loopback file driver" (see fbk
note below) and mounted on the /mnt
directory. The ufs filesystem (unlike zfs) also supports creating hard links to directories, but only by root.
As you see, the inode number for a/b/
is 5 and the inode number of a/b/c/..
is 5 as well. You also see, that the link count for directory a/b/c increased by one from the link
call.
After creating the new hardlinked directory d/hlink
, you see that the inode number for d/hlink/..
is not 7 (the inode number of the directory above) but rather 5 (the inode number of the original directory above that directory).
BTW: the loopback
filesystem first appeared in 1987 with SunOS-4.0. It's purpose is to act as a VFS indirect layer that allows to mount a filesystem tree a second time in the same machine. I am not sure whether this Linux bind mount is a reimplementation of the loopback filesystem idea.
What is obvious is that the fbk
driver (file emulates block device) I invented in October 1988 has been reimplemented in the mid -1990s on linux under the improper name loopback
.
cd p/d/.. ; /bin/pwd
does it take you to p or x? – Mark Plotnick Apr 18 '20 at 22:12df -g p p/d p/d/..
), and how you determined thatd
is not a symbolic link. Make surels
is not an alias. – Apr 19 '20 at 10:25solaris "bind mount"
and saw several promising ones such as this and this, i.e., a "loopback" mount. What I supposed happened is that OP cd'd into a directory which was "really" under another directory, but bind-mounted into the directory where he began changing directories. Whether you call it "bind" or "loopback" is just terminology (not interesting). – Thomas Dickey Apr 19 '20 at 13:36