Getting the inode from the file descriptor - Unix

This is a discussion on Getting the inode from the file descriptor - Unix ; Hi I'm interested in find out the various inodes that make up the bits of file I'm reading from. How can I get the current inode that the file descriptor is on/using? From my tests fstat() only seems to give ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Getting the inode from the file descriptor

  1. Getting the inode from the file descriptor

    Hi

    I'm interested in find out the various inodes that make up the bits of
    file I'm reading from. How can I get the current inode that the file
    descriptor is on/using? From my tests fstat() only seems to give the
    initial inode.

    Thanks for any help

    B2003


  2. Re: Getting the inode from the file descriptor

    2007-10-22, 06:10(-07), Boltar:
    > Hi
    >
    > I'm interested in find out the various inodes that make up the bits of
    > file I'm reading from. How can I get the current inode that the file
    > descriptor is on/using? From my tests fstat() only seems to give the
    > initial inode.

    [...]

    There's only one inode per file. There may be several data
    blocks, That may be what you were thinking of but that's
    something different.

    How the file system is physically organised is something that is
    lower level and that the user shouldn't have access to. If you
    want to know the block addresses in FSs that organise files in
    blocks, you'll have to use an API specific to your filesystem
    (if any is provided). For instance for an ext2/3 FS, you can use
    the libe2fs API. The debugfs command for instance allows you do
    get the list of blocks for a given inode.

    --
    Stéphane

+ Reply to Thread