How to get device name with device id?

ashish mahamuni ashitpro at yahoo.co.in
Thu Mar 20 11:13:09 UTC 2008



Can you suggest any other method(in user space) for this?

--- On Thu, 20/3/08, liuyue <liuyue at ncic.ac.cn> wrote:

> From: liuyue <liuyue at ncic.ac.cn>
> Subject: Re: How to get device name with device id?
> To: "ashitpro at yahoo.co.in" <ashitpro at yahoo.co.in>, "ext3-users at redhat.com" <ext3-users at redhat.com>
> Date: Thursday, 20 March, 2008, 4:34 PM
> ashish mahamuni,
> 
> I guess maybe the following function does what you want.
> But it is a kernel function, sorry :(
> 
> int __file_to_disk (char * file_name,  char *disk_name) {
>         int err = 0;
>         struct nameidata        nd;
>         struct super_block      * sb;
>         struct vfsmount *mnt;
>         err = path_lookup(file_name, LOOKUP_FOLLOW,
> &nd);
>         if(err){
>                 DCFS3_ERROR("error to parse the file
> name, %s\n", file_name);
>                 goto exit;
>         }
>         mnt = nd.mnt;
>         sb = mnt->mnt_sb;
>         strcpy (disk_name,
> sb->s_bdev->bd_disk->disk_name);
>         path_release(&nd);
> exit:
>         return err;
> }
> 
> ======= 2008-03-20 19:21:04
> 您在来信中写道:=======
> 
> >Hi all,
> >
> >I want to open a device(/dev/sda1, /dev/hda2 etc) in
> which my file exists.
> >I've used 'stat' system call to get the
> device id.
> >
> >But now I want the device name from this id(st_dev).
> >How to get that one?
> >Or 
> >Do you have any other method to know the device name
> where my file resides?
> >
> >Thanks 
> >
> >
> >      Bollywood, fun, friendship, sports and more. You
> name it, we have it on http://in.promos.yahoo.com/groups  
> >
> >
> >_______________________________________________
> >Ext3-users mailing list
> >Ext3-users at redhat.com
> >https://www.redhat.com/mailman/listinfo/ext3-users
> >
> >
> 
> = = = = = = = = = = = = = = = = = = = =
> 			
> 
>         致
> 礼!
>  
> 				 
>         liuyue
>         liuyue at ncic.ac.cn
>           2008-03-20


      Chat on a cool, new interface. No download required. Go to http://in.messenger.yahoo.com/webmessengerpromo.php





More information about the Ext3-users mailing list