* vfsmount @ 2008-09-22 16:57 Rohit Sharma 2008-09-25 6:43 ` vfsmount Manish Katiyar 0 siblings, 1 reply; 3+ messages in thread From: Rohit Sharma @ 2008-09-22 16:57 UTC (permalink / raw) To: Kernelnewbies; +Cc: ext4 I am interested in getting the vfsmount structure of the mounted file system from my module. I used filp = get_empty_filp() (filp is file pointer) function to create an empty file object (as this contains pointer to vfsmount structure) file object has a field f_vfsmnt which points to the vfsmount structure i am storing this in my own my_vfsmnt structure of type vfsmount. my_vfsmnt = filp->f_vfsmnt but i am getting my_vfsmnt as NULL ?? is there any other way of getting the vfsmount structure ?? ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: vfsmount 2008-09-22 16:57 vfsmount Rohit Sharma @ 2008-09-25 6:43 ` Manish Katiyar 2008-09-25 11:53 ` vfsmount Srikanth Srinivasan 0 siblings, 1 reply; 3+ messages in thread From: Manish Katiyar @ 2008-09-25 6:43 UTC (permalink / raw) To: Rohit Sharma; +Cc: Kernelnewbies, ext4 On Mon, Sep 22, 2008 at 10:27 PM, Rohit Sharma <imreckless@gmail.com> wrote: > I am interested in getting the vfsmount structure of the mounted file > system from my module. > I used filp = get_empty_filp() (filp is file pointer) > function to create an empty file object (as this contains pointer to > vfsmount structure) > file object has a field f_vfsmnt which points to the vfsmount structure > i am storing this in my own my_vfsmnt structure of type vfsmount. > my_vfsmnt = filp->f_vfsmnt > but i am getting my_vfsmnt as NULL ?? > > is there any other way of getting the vfsmount structure ?? Will this help ?? [root@localhost test]# insmod katiyar.ko err=0, Path = / [root@localhost test]# cat nngfs.c #include <linux/module.h> #include <linux/fs.h> #include <linux/mount.h> #include <linux/namei.h> #define MOD_AUTHOR "Manish Katiyar" #define MODULE_DESC "A Simple test module " static int nngfs_fs_init(void){ int err; struct vfsmount *tmp; struct nameidata nd; err = path_lookup(".",LOOKUP_FOLLOW | LOOKUP_DIRECTORY,&nd); tmp = nd.path.mnt; printk(KERN_CRIT "err=%d, Path = %s\n",err,tmp->mnt_root->d_name.name); return err; } static void nngfs_fs_exit(void){ printk(KERN_INFO "Unregistering \n"); return ; } module_init(nngfs_fs_init); module_exit(nngfs_fs_exit); MODULE_AUTHOR(MOD_AUTHOR); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION(MODULE_DESC); Thanks - Manish > -- > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: vfsmount 2008-09-25 6:43 ` vfsmount Manish Katiyar @ 2008-09-25 11:53 ` Srikanth Srinivasan 0 siblings, 0 replies; 3+ messages in thread From: Srikanth Srinivasan @ 2008-09-25 11:53 UTC (permalink / raw) To: mkatiyar, imreckless; +Cc: kernelnewbies, linux-ext4 On Thu, Sep 25, 2008 at 12:13 PM, Manish Katiyar <mkatiyar@gmail.com> wrote: > > On Mon, Sep 22, 2008 at 10:27 PM, Rohit Sharma <imreckless@gmail.com> wrote: > > I am interested in getting the vfsmount structure of the mounted file > > system from my module. > > I used filp = get_empty_filp() (filp is file pointer) > > function to create an empty file object (as this contains pointer to > > vfsmount structure) > > file object has a field f_vfsmnt which points to the vfsmount structure > > i am storing this in my own my_vfsmnt structure of type vfsmount. > > my_vfsmnt = filp->f_vfsmnt > > but i am getting my_vfsmnt as NULL ?? > > > > is there any other way of getting the vfsmount structure ?? > > Will this help ?? > > [root@localhost test]# insmod katiyar.ko > err=0, Path = / > [root@localhost test]# cat nngfs.c > #include <linux/module.h> > #include <linux/fs.h> > #include <linux/mount.h> > #include <linux/namei.h> > > #define MOD_AUTHOR "Manish Katiyar" > #define MODULE_DESC "A Simple test module " > > static int nngfs_fs_init(void){ > int err; > struct vfsmount *tmp; > struct nameidata nd; > err = path_lookup(".",LOOKUP_FOLLOW | LOOKUP_DIRECTORY,&nd); > tmp = nd.path.mnt; > printk(KERN_CRIT "err=%d, Path = %s\n",err,tmp->mnt_root->d_name.name); > return err; > } > > static void nngfs_fs_exit(void){ > printk(KERN_INFO "Unregistering \n"); > return ; > } > > module_init(nngfs_fs_init); > module_exit(nngfs_fs_exit); > > MODULE_AUTHOR(MOD_AUTHOR); > MODULE_LICENSE("GPL"); > MODULE_DESCRIPTION(MODULE_DESC); > > > Thanks - > Manish > > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > >From kernel version 2.6.25 on you could directly use the "current->fs->altroot.mnt" to retrieve the vfsmount structure. Thanks - Srikanth ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-25 11:53 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-09-22 16:57 vfsmount Rohit Sharma 2008-09-25 6:43 ` vfsmount Manish Katiyar 2008-09-25 11:53 ` vfsmount Srikanth Srinivasan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox