From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Blunck Subject: Re: [RFC PATCH] mountinfo: show only reachable mounts Date: Fri, 14 Mar 2008 16:17:53 +0100 Message-ID: <20080314151753.GB27730@T61> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org To: Miklos Szeredi Return-path: Received: from charybdis-ext.suse.de ([195.135.221.2]:55637 "EHLO emea5-mh.id5.novell.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752116AbYCNPSH (ORCPT ); Fri, 14 Mar 2008 11:18:07 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Mar 13, Miklos Szeredi wrote: > But I'm an idiot. This is a much simpler and faster implementation > that uses is_subdir(), which essentially does what you suggested: > > /* > * Return true if 'path' is reachable from 'root' > */ > static bool is_path_reachable(const struct path *path, const struct path *root) > { > struct dentry *dentry = path->dentry; > struct vfsmount *mnt = path->mnt; > bool res = false; > > spin_lock(&vfsmount_lock); > while (mnt != root->mnt && mnt->mnt_parent != mnt) { > dentry = mnt->mnt_mountpoint; > mnt = mnt->mnt_parent; > } > if (mnt == root->mnt && is_subdir(dentry, root->dentry)) > res = true; > spin_unlock(&vfsmount_lock); > > return res; > } Very well. BTW, I have a patch rotting in my quilt stack to remove lives_below_in_same_fs() since is_subdir() provides the same functionality. Cheers, Jan