}
/*
- * Look up the inode number and filetype for an exact name in a directory.
+ * Given a parent directory @dp and a metadata inode path component @xname,
+ * Look up the inode number in the directory, returning it in @ino.
+ * @xname.type must match the directory entry's ftype.
+ *
* Caller must hold ILOCK_EXCL.
*/
static inline int
-xfs_imeta_dir_lookup(
+xfs_imeta_lookup_component(
struct xfs_trans *tp,
struct xfs_inode *dp,
struct xfs_name *xname,
xfs_ino_t *ino)
{
+ struct xfs_mount *mp = dp->i_mount;
struct xfs_da_args args = {
.trans = tp,
.dp = dp,
- .geo = dp->i_mount->m_dir_geo,
+ .geo = mp->m_dir_geo,
.name = xname->name,
.namelen = xname->len,
- .hashval = xfs_dir2_hashname(dp->i_mount, xname),
+ .hashval = xfs_dir2_hashname(mp, xname),
.whichfork = XFS_DATA_FORK,
.op_flags = XFS_DA_OP_OKNOENT,
.owner = dp->i_ino,
};
int error;
- if (xfs_is_shutdown(dp->i_mount))
+ if (!S_ISDIR(VFS_I(dp)->i_mode))
+ goto corrupt;
+ if (xfs_is_shutdown(mp))
return -EIO;
error = xfs_dir_lookup_args(&args);
if (error)
return error;
- *ino = args.inumber;
- xname->type = args.filetype;
- return 0;
-}
+ if (!xfs_verify_ino(mp, args.inumber))
+ goto corrupt;
+ if (xname->type != XFS_DIR3_FT_UNKNOWN && xname->type != args.filetype)
+ goto corrupt;
-/*
- * Given a parent directory @dp and a metadata inode path component @xname,
- * Look up the inode number in the directory, returning it in @ino.
- * @xname.type must match the directory entry's ftype.
- *
- * Caller must hold ILOCK_EXCL.
- */
-static inline int
-xfs_imeta_lookup_component(
- struct xfs_trans *tp,
- struct xfs_inode *dp,
- struct xfs_name *xname,
- xfs_ino_t *ino)
-{
- int type_wanted = xname->type;
- int error;
-
- if (!S_ISDIR(VFS_I(dp)->i_mode)) {
- xfs_fs_mark_sick(dp->i_mount, XFS_SICK_FS_METADIR);
- return -EFSCORRUPTED;
- }
-
- error = xfs_imeta_dir_lookup(tp, dp, xname, ino);
- if (error)
- return error;
- if (!xfs_verify_ino(dp->i_mount, *ino)) {
- xfs_fs_mark_sick(dp->i_mount, XFS_SICK_FS_METADIR);
- return -EFSCORRUPTED;
- }
- if (type_wanted != XFS_DIR3_FT_UNKNOWN && xname->type != type_wanted) {
- xfs_fs_mark_sick(dp->i_mount, XFS_SICK_FS_METADIR);
- return -EFSCORRUPTED;
- }
-
- trace_xfs_imeta_lookup_component(dp, xname, *ino);
+ trace_xfs_imeta_lookup_component(dp, xname, args.inumber);
+ *ino = args.inumber;
return 0;
+corrupt:
+ xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR);
+ return -EFSCORRUPTED;
}
/*