From: Darrick J. Wong Date: Fri, 17 Feb 2012 14:56:33 +0000 (-0500) Subject: libext2fs: Add ext2fs_file_get_inode_num call (for fuse2fs) X-Git-Tag: v1.42.1~10 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=3ae682bb0a5e025963b25ff5ac5d53e2115483f2;p=tools%2Fe2fsprogs.git libext2fs: Add ext2fs_file_get_inode_num call (for fuse2fs) Add a function to return the inode number of an open file. Signed-off-by: Darrick J. Wong Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 7343090..68afdff 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -1103,6 +1103,7 @@ extern errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino, int flags, ext2_file_t *ret); extern ext2_filsys ext2fs_file_get_fs(ext2_file_t file); struct ext2_inode *ext2fs_file_get_inode(ext2_file_t file); +extern ext2_ino_t ext2fs_file_get_inode_num(ext2_file_t file); extern errcode_t ext2fs_file_close(ext2_file_t file); extern errcode_t ext2fs_file_flush(ext2_file_t file); extern errcode_t ext2fs_file_read(ext2_file_t file, void *buf, diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c index 8751635..1f7002c 100644 --- a/lib/ext2fs/fileio.c +++ b/lib/ext2fs/fileio.c @@ -106,6 +106,14 @@ struct ext2_inode *ext2fs_file_get_inode(ext2_file_t file) return &file->inode; } +/* This function returns the inode number from the structure */ +ext2_ino_t ext2fs_file_get_inode_num(ext2_file_t file) +{ + if (file->magic != EXT2_ET_MAGIC_EXT2_FILE) + return 0; + return file->ino; +} + /* * This function flushes the dirty block buffer out to disk if * necessary.