# HG changeset patch # User Paul Boddie # Date 1646348356 -3600 # Node ID 65f27efbb208271529415991cb00e8d2959fa53c # Parent a7c302c50e9008b8f5eaa858bb867157e24f706f Added another file lookup function. diff -r a7c302c50e90 -r 65f27efbb208 libe2access/include/e2access/image.h --- a/libe2access/include/e2access/image.h Thu Mar 03 23:40:20 2022 +0100 +++ b/libe2access/include/e2access/image.h Thu Mar 03 23:59:16 2022 +0100 @@ -60,6 +60,9 @@ errcode_t image_find_file(ext2_filsys fs, const char *dirname, const char *basename, ext2_ino_t *ino); +errcode_t image_find_file_by_inode(ext2_filsys fs, ext2_ino_t ino_parent, + const char *basename, ext2_ino_t *ino); + errcode_t image_inode(ext2_filsys fs, const char *path, struct ext2_inode *inode); diff -r a7c302c50e90 -r 65f27efbb208 libe2access/lib/src/image.c --- a/libe2access/lib/src/image.c Thu Mar 03 23:40:20 2022 +0100 +++ b/libe2access/lib/src/image.c Thu Mar 03 23:59:16 2022 +0100 @@ -318,6 +318,24 @@ return image_find_by_path(fs, path, ino); } +/* Find an object in the given directory with the given inode. */ + +errcode_t image_find_file_by_inode(ext2_filsys fs, ext2_ino_t ino_parent, + const char *basename, ext2_ino_t *ino) +{ + char *buf; + errcode_t retval = ext2fs_get_mem(fs->blocksize, &buf); + + if (retval) + return retval; + + retval = ext2fs_lookup(fs, ino_parent, basename, strlen(basename), buf, ino); + + ext2fs_free_mem(&buf); + + return retval; +} + /* Obtain the inode for the object with the given path. */ errcode_t image_inode(ext2_filsys fs, const char *path,