#include "xfs_btree_mem.h"
#include "xfs_parent.h"
#include "xfs_ag_resv.h"
+#include "xfs_metafile.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
return now;
}
+static inline bool inode_wrong_type(const struct inode *inode, umode_t mode)
+{
+ return (inode->i_mode ^ mode) & S_IFMT;
+}
+
typedef struct xfs_inode {
struct cache_node i_node;
struct xfs_mount *i_mount; /* fs mount struct ptr */
xfs_inode_buf.h \
xfs_inode_fork.h \
xfs_inode_util.h \
+ xfs_metafile.h \
xfs_parent.h \
xfs_quota_defs.h \
xfs_refcount.h \
return error;
}
+/*
+ * Get a metadata inode. The file type part of @mode must match the inode
+ * exactly. Caller must supply a transaction (even if empty) to avoid
+ * livelocking if the inobt has a cycle.
+ */
+int
+libxfs_metafile_iget(
+ struct xfs_trans *tp,
+ xfs_ino_t ino,
+ umode_t mode,
+ struct xfs_inode **ipp)
+{
+ struct xfs_mount *mp = tp->t_mountp;
+ struct xfs_inode *ip;
+ int error;
+
+ error = libxfs_iget(mp, tp, ino, XFS_IGET_UNTRUSTED, &ip);
+ if (error)
+ return error;
+
+ if (inode_wrong_type(VFS_I(ip), mode))
+ goto bad_rele;
+
+ *ipp = ip;
+ return 0;
+bad_rele:
+ libxfs_irele(ip);
+ return -EFSCORRUPTED;
+}
+
static void
libxfs_idestroy(
struct xfs_inode *ip)
#define xfs_iext_next libxfs_iext_next
#define xfs_ifork_zap_attr libxfs_ifork_zap_attr
#define xfs_imap_to_bp libxfs_imap_to_bp
+
#define xfs_initialize_perag libxfs_initialize_perag
#define xfs_initialize_perag_data libxfs_initialize_perag_data
#define xfs_init_local_fork libxfs_init_local_fork
#define xfs_log_calc_minimum_size libxfs_log_calc_minimum_size
#define xfs_log_get_max_trans_res libxfs_log_get_max_trans_res
#define xfs_log_sb libxfs_log_sb
+
+#define xfs_metafile_iget libxfs_metafile_iget
#define xfs_mode_to_ftype libxfs_mode_to_ftype
#define xfs_mkdir_space_res libxfs_mkdir_space_res
+
#define xfs_parent_addname libxfs_parent_addname
#define xfs_parent_finish libxfs_parent_finish
#define xfs_parent_hashval libxfs_parent_hashval
--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2018-2024 Oracle. All Rights Reserved.
+ * Author: Darrick J. Wong <djwong@kernel.org>
+ */
+#ifndef __XFS_METAFILE_H__
+#define __XFS_METAFILE_H__
+
+/* Code specific to kernel/userspace; must be provided externally. */
+
+int xfs_metafile_iget(struct xfs_trans *tp, xfs_ino_t ino, umode_t mode,
+ struct xfs_inode **ipp);
+
+#endif /* __XFS_METAFILE_H__ */