View previous topic :: View next topic |
Author |
Message |
SableEA n00b
Joined: 23 Aug 2024 Posts: 4 Location: Belarus
|
Posted: Sun Aug 25, 2024 8:39 am Post subject: Strange behaviour with . directory |
|
|
I turned off computer with gentoo installation on the stage Installing the Gentoo installation files (I unpacked archive.). After turning on I mounted needed partitions of disk Code: | cd /mnt/gentoo; mnt /dev/sda3 . |
Then there where strange behaviour: output of showed me all files, but output of just was nothing
I understood that this is problem with . directory, because working with direct path /mnt/gentoo was normal, but with . directory not (I retried ls, find and file commands).
I decided to make something with . directory, so I just wrote
And there is surprise: after that ls command and another commands with . worked normal
Why did it happened? |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 31280 Location: here
|
Posted: Sun Aug 25, 2024 10:35 am Post subject: |
|
|
Moved from Other Things Gentoo to Installing Gentoo. _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
kimchi_sg Advocate
Joined: 26 Nov 2004 Posts: 3038
|
Posted: Mon Aug 26, 2024 1:08 am Post subject: Re: Strange behaviour with . directory |
|
|
SableEA wrote: | output of showed me all files, but output of just was nothing |
This is expected, the latter command shows current directory just after you booted the Gentoo live USB; this is empty by default. |
|
Back to top |
|
|
Banana Moderator
Joined: 21 May 2004 Posts: 1748 Location: Germany
|
|
Back to top |
|
|
Chiitoo Administrator
Joined: 28 Feb 2010 Posts: 2733 Location: Here and Away Again
|
Posted: Mon Aug 26, 2024 1:42 pm Post subject: |
|
|
I'm not entirely sure how to explain it at this time, but the current work directory doesn't seem to get "updated" for the mount.
I see the same behaviour if I 'cd /to/some/dir' and 'bind' mount anything to it: the 'ls' command will not show anything until I 'cd' to that directory again. _________________ Kindest of regardses. |
|
Back to top |
|
|
sublogic Apprentice
Joined: 21 Mar 2022 Posts: 273 Location: Pennsylvania, USA
|
Posted: Mon Aug 26, 2024 10:49 pm Post subject: |
|
|
Interesting. Mounting to the current working directory is different. Here's a test: (/dev/sda2 is my boot partition.) Code: | # ls -a toto
. ..
# cd toto
# touch HI_THERE
# ls -a
. .. HI_THERE
# mount -o ro /dev/sda2 .
# ls -a
. .. HI_THERE
# cd ..
# cd toto
# ls -a
. grub
.. initramfs-5.15.19
.keep initramfs-generic
System.map-6.6.38-gentoo-x86_64 intel-uc.img
System.map-6.6.47-gentoo-x86_64 lost+found
amd-uc.img vmlinuz-6.6.38-gentoo-x86_64
config-6.6.38-gentoo-x86_64 vmlinuz-6.6.47-gentoo-x86_64
config-6.6.47-gentoo-x86_64
# |
Mounting a filesystem hides whatever was under the mount point. BUT if a process had the mount point as its working directory, the old content remains visible to that process. (In the above test, changing out of toto lost the pointer to the old content.)
Might be interesting to follow this in the kernel sources.
Question: can the process can give the old content to another process by open(".") and passing the descriptor through an AF_UNIX socket ? |
|
Back to top |
|
|
|