linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* get vfsmount from dentry
@ 2006-03-12 13:44 Ashish Khurange
  2006-03-12 13:55 ` Al Viro
  2006-03-12 19:10 ` Jamie Lokier
  0 siblings, 2 replies; 13+ messages in thread
From: Ashish Khurange @ 2006-03-12 13:44 UTC (permalink / raw)
  To: linux-fsdevel

Hi,
I'm trying to develop a fmon (file monitor) patch. For that I'm trying 
to find complete pathname of the file/directory being changed.  If you 
have dentry of a file and a corresponding vfsmount struct, I can find 
out its entire pathname using following code. Which works exactly the 
way I want.

static char * mirror_path (struct dentry *dentry, struct vfsmount 
*vfsmnt, char *buffer, int buflen)
{
        char * end = buffer+buflen;
        char * retval;
        int namelen;

        *--end = '\0';
        buflen--;

        if (buflen < 1)
                goto Elong;
        /* Get '/' right */
        retval = end-1;
        *retval = '/';

        for (;;) {
                struct dentry * parent;

                if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
                        /* Global root? */
                        spin_lock(&vfsmount_lock);
                        if (vfsmnt->mnt_parent == vfsmnt) {
                                spin_unlock(&vfsmount_lock);
                                break;
                        }
                        dentry = vfsmnt->mnt_mountpoint;
                        vfsmnt = vfsmnt->mnt_parent;
                        spin_unlock(&vfsmount_lock);
                        continue;
                }
                parent = dentry->d_parent;
                prefetch(parent);
                namelen = dentry->d_name.len;
                buflen -= namelen + 1;
                if (buflen < 0)
                        goto Elong;
                end -= namelen;
                memcpy(end, dentry->d_name.name, namelen);
                *--end = '/';
                retval = end;
                dentry = parent;
        }
        namelen = dentry->d_name.len;
        buflen -= namelen;
        if (buflen < 0)
                goto Elong;
        retval -= namelen-1;    /* hit the slash */
        memcpy(retval, dentry->d_name.name, namelen);
        return retval;
Elong:
        return NULL;
}


Now the only problem is in many functions in the filesystem code, I have 
access only to the dentry and not to its vfsmount. I can do one thing I 
can change the function definition and pass corresponding vfsmount as a 
parameter to the function, but this will lead to lot of changes.

Is there any way by which I can found the vfsmount structure of a file 
represented by dentry structure?

Regards,
- Ashish

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-03-13  7:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-12 13:44 get vfsmount from dentry Ashish Khurange
2006-03-12 13:55 ` Al Viro
2006-03-12 17:20   ` Ashish Khurange
2006-03-12 17:41     ` Al Viro
2006-03-12 18:00       ` Ashish Khurange
2006-03-12 18:23         ` Shaya Potter
2006-03-12 18:54           ` Ashish Khurange
2006-03-12 19:13             ` Al Viro
2006-03-12 20:34               ` Ashish Khurange
2006-03-12 20:45                 ` Shaya Potter
2006-03-13  7:24                 ` Jan Hudec
2006-03-12 18:24         ` Al Viro
2006-03-12 19:10 ` Jamie Lokier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).