Linux-Fsdevel Archive on lore.kernel.org
 help / color / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Tavian Barnes <tavianator@tavianator.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: d_type and bind mounts
Date: Tue, 12 Feb 2019 07:59:38 +1100
Message-ID: <20190211205938.GE20493@dastard> (raw)
In-Reply-To: <CABg4E-mbCk-jeRjETEtXk+ZHVub00_G5QaOnxbf5fgKd5MpD+A@mail.gmail.com>

On Mon, Feb 11, 2019 at 02:59:29PM -0500, Tavian Barnes wrote:
> It seems that readdir()/getdents() fill d_type from the underlying
> filesystem, not respecting bind mounts of non-directories:
> 
> $ touch mount_point
> $ sudo mount --bind /dev/null mount_point
> $ find -name mount_point -type c
> $ find -name mount_point -type f
> ./mount_point
> 
> (Requires a fairly recent GNU findutils to reproduce, older ones
> always call stat().)  I've seen similar discussions about d_ino being
> for the underlying file, not the mount point, which people have said

Find is using readdir to look up the directory entry, so what it
finds is the underlying filesystem dirent that is completely unaware
that the dentry cache has an overlayed mountpoint above the
filesystem.  d_type is stored in the underlying directory, so it is
reported from the on-disk information in the underlying filesystem,
not the dentry cache that is aware of the mount point at that
location.

> is technically a POSIX violation but also unlikely to be fixed.  Is
> the same true of d_type?  And is there some workaround a program could
> use to get the actual type without the overhead of a whole stat()
> call? For example, a way to tell whether a directory entry is a mount
> point?

Not that I know of, but that doesn't mean there isn't one. In
general, though, if you are looking for something overlaid on the
underlying dirent (like a mount point) then you have to trigger a
path walk to find whatever is overlaid on that location.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-11 19:59 Tavian Barnes
2019-02-11 20:59 ` Dave Chinner [this message]

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190211205938.GE20493@dastard \
    --to=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tavianator@tavianator.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Fsdevel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-fsdevel/0 linux-fsdevel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fsdevel linux-fsdevel/ https://lore.kernel.org/linux-fsdevel \
		linux-fsdevel@vger.kernel.org linux-fsdevel@archiver.kernel.org
	public-inbox-index linux-fsdevel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-fsdevel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox