Re: How to get vfsmount from inode?

From: Chris Wright (chrisat_private)
Date: Wed Jul 30 2003 - 15:15:26 PDT

  • Next message: Omen Wild: "Re: How to get vfsmount from inode?"

    * Omen Wild (Omen.Wildat_private) wrote:
    > 
    > Something like this?
    
    No, cycle the whole namespace looking for mountpoint roots that match
    the root of the superblock that the dentry (that you start with) is on.
    
    More like:
    > ...
    > struct vfsmount *mnt = find_vfsmount(inode->i_sb->s_root);
    > ...
    > 
    > static struct vfsmount *find_vfsmount(struct dentry *d) {
    	struct dentry *root = dget(dentry->d_sb->s_root);
    	struct namespace *namespace = current->namespace;
    	struct list_head *head;
    	struct vfsmount *mnt = NULL;
    
    	down_read(&namespace->sem);
    	list_for_each(head, &namespace->list) {
    		mnt = list_entry(head, struct vfsmount, mnt_list);
    		if (mnt->mnt_root == sb_root) {
    			mntget(mnt);
    			break;	/* this is the problem spot */
    		}
    	}
    	up_read(&namespace->sem);
    	dput(sb_root);
    	return mnt;
    }
    
    It's pretty fugly, but will find the matches (well, with the 'break' only
    the first match.  which is not necessarily the path the user used to get
    to the dentry!).
    
    thanks,
    -chris
    -- 
    Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net
    _______________________________________________
    linux-security-module mailing list
    linux-security-moduleat_private
    http://mail.wirex.com/mailman/listinfo/linux-security-module
    



    This archive was generated by hypermail 2b30 : Wed Jul 30 2003 - 15:20:19 PDT