in fs/extfs/extfs.cpp [1442:1489]
ext2_ino_t get_inode(const char *str, int follow, bool release) {
ext2_ino_t ino = 0;
DEFER(LOG_DEBUG("get_inode ", VALUE(str), VALUE(follow), VALUE(release), VALUE(ino)));
auto func = [&]() -> ext2_ino_t * {
ext2_ino_t *i = new ext2_ino_t;
errcode_t ret = 0;
if (follow) {
ret = ext2fs_namei_follow(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, str, i);
} else {
auto parent = get_parent_dir_ino(fs, str);
if (parent) {
auto filename = get_filename(str);
if (filename)
ret = ext2fs_namei(fs, EXT2_ROOT_INO, parent, filename, i);
else
ret = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, str, i);
} else {
ret = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, str, i);
}
}
if (ret) {
LOG_DEBUG("ext2fs_namei not found ", VALUE(str), VALUE(follow));
errno = -parse_extfs_error(fs, 0, ret);
delete i;
return nullptr;
}
LOG_DEBUG("ext2fs_namei ", VALUE(str), VALUE(follow), VALUE(*i));
return i;
};
if (follow) {
auto b = func();
if (b) ino = *b;
} else {
auto b = ino_cache.borrow(str, func);
if (b) ino = *b;
}
if (release) {
LOG_DEBUG("release ino_cache ", VALUE(str), VALUE(release));
auto b = ino_cache.borrow(str);
b.recycle(true);
}
return ino;
}