inode を取得しようとしてみた

とある必要にかられて書いてみた。

#include <stdio.h>
#include <io.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <memory.h>

int main(int argc, char* argv[])
{
    if ( argc < 2 ) {
        return -1;
    }

    struct _stat stat;
    memset( &stat, 0, sizeof(struct _stat) );

    int fd = _open( argv[1], _O_RDONLY | _O_TEXT );
    if ( fd > 0 ) {
        _fstat( fd, &stat );
        printf( "ino = %d\n", stat.st_ino );
    } else {
        fprintf( stderr, "ファイルを開けませんでした。\n" );
    }
    _close( fd );
}

まあ、結果は:

ino = 0

なんだけどね…