[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fstatat + AT_NO_AUTOMOUNT

From: Bernhard Voelker
Subject: Re: fstatat + AT_NO_AUTOMOUNT
Date: Wed, 9 Mar 2022 00:53:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1

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 

  $ 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,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]