From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: get vfsmount from dentry Date: Sun, 12 Mar 2006 17:41:49 +0000 Message-ID: <20060312174149.GC27946@ftp.linux.org.uk> References: <441425BB.6030604@it.iitb.ac.in> <20060312135543.GB27946@ftp.linux.org.uk> <44145873.6010802@it.iitb.ac.in> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:18155 "EHLO ZenIV.linux.org.uk") by vger.kernel.org with ESMTP id S1751651AbWCLRlu (ORCPT ); Sun, 12 Mar 2006 12:41:50 -0500 To: Ashish Khurange Content-Disposition: inline In-Reply-To: <44145873.6010802@it.iitb.ac.in> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Sun, Mar 12, 2006 at 10:50:51PM +0530, Ashish Khurange wrote: > Yes thats it, the pathname that is used by a process to access a file, I > want to that pathname. Which process? > >So what are you really trying to achieve? > > To get that pathname along with dentry of the file I need the vfsmount > of that file also. > Is there any way to get vfsmount of a file, when you have its dentry > with you. No. Simply because there may be many pathnames giving the same dentry. mkdir /tmp/1 mkdir /tmp/2 mkdir /tmp/3 mount -t ramfs none /tmp/1 mount --bind /tmp/1 /tmp/2 mount --bind /tmp/1 /tmp/3 touch /tmp/1/foo umount /tmp/1 Now /tmp/2/foo and /tmp/3/foo have exact same dentry. They do have different vfsmounts. In other words, dentry alone is simply not enough to find the pathname. Moreover, if you do mkdir /tmp/1 mount -t ramfs none /tmp/1 exec >/tmp/1/foo umount -l /tmp/1 echo a you will have a written into file that has no pathname. I.e. there is no such pathname that opening it at that point would result in that file. At all. It's the same situation as with getting pathname by inode - there may be many (hardlinks), there may be none (unlinked but still open). In other words, the answer to your question above is "no, there is no way to find vfsmount by dentry and that is in principle impossible". So unless you can give higher-level description of what you want to get, you are out of luck.