lkml.org 
[lkml]   [2000]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: how can i get hold of a file inode ?
    Malcolm Beattie wrote:

    > BenHanokh Gabriel writes:
    > > i need to find what physical blocks a file occuiped on disk.
    > > so i have to find the file's inode and pass it as an argument to the vfs method
    > > - bmap.
    >
    > No you don't, you can persuade the kernel to do it for you.

    >
    > #include <linux/fs.h>
    > ...
    > int block;
    > ...
    > fd = open(.....);
    >
    > block = get_logical_blocknum();
    > if (ioctl(fd, FIBMAP, &block) == 0) {
    > /* block now holds "physical" block number */
    > }
    >

    sound good, is this ioctl simply calling bmap for me ?
    where can i find documantion about this ioctl( e.g. sparse-files

    >
    > You need CAP_SYS_RAWIO to do this. Note the

    sorry, i don't understand what you mean with CAP_SYS_RAWIO


    >
    > #include <linux/fs.h>
    > which shouts "I'm not portable" to the entire world.

    i'm aware to this, but something like this can never be done in a portable way.


    > Note also that
    > knowing the "physical" block number is often not what you want (even
    > if you think you do) and that I've been putting scare quotes around
    > "physical" because the device might actually be a logical device (e.g.
    > LVM or RAID md where the physical block number isn't really physical)

    i'm aware to this as well

    > or it may be a real disk but the block has been transparently remapped
    > elsewhere by the firmware or probably various other gotchas.
    >

    do you mean that a special-purpose hardware is being used as a proxy to the disk, or
    that this is a feature available in a "normal" hard drives?

    >
    > --Malcolm
    >
    > --
    > Malcolm Beattie <mbeattie@sable.ox.ac.uk>
    > Unix Systems Programmer
    > Oxford University Computing Services

    THX ALOTTTT you have been of a great help

    /gabriel


    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:57    [W:8.343 / U:0.064 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site