On 3/8/22 18:44, Paul Eggert wrote: > On 3/8/22 04:29, Bernhard Voelker wrote: >> I'm not so sure about that: at least in container environment it seems to be >> common practice to mount regular files somewhere into the container, e.g.: > > Oh, I wasn't aware of that. However, don't they mount a regular file > atop an already-existing regular file? In that case, the optimization > would still be valid.
Indeed, the GNU/Linux kernel does not allow to bind-mount a file atop of a directory: $ strace -ve mount mount --bind /etc/hosts dir mount("/etc/hosts", "/root/dir", 0x557e7ed77570, MS_BIND, NULL) = -1 ENOTDIR (Not a directory) mount: /root/dir: mount(2) system call failed: Not a directory. +++ exited with 32 +++ The kernel doesn't seem so picky about other target file types; e.g. it allows to bind-mount atop of a character device: $ mknod char c 1 3 $ ls -log x crw-r--r-- 1 1, 3 Mar 9 00:51 char $ mount --bind /etc/hosts char $ ls -log char -rw-r--r-- 1 1515 Jan 16 14:55 char Have a nice day, Berny