fs/xfs/scrub/listxattr.c

Source file repositories/reference/linux-study-clean/fs/xfs/scrub/listxattr.c

File Facts

System
Linux kernel
Corpus path
fs/xfs/scrub/listxattr.c
Extension
.c
Size
7538 bytes
Lines
321
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

if (entry->flags & XFS_ATTR_LOCAL) {
			struct xfs_attr_leaf_name_local		*name_loc;

			name_loc = xfs_attr3_leaf_name_local(leaf, i);
			name = name_loc->nameval;
			namelen = name_loc->namelen;
			value = &name_loc->nameval[name_loc->namelen];
			valuelen = be16_to_cpu(name_loc->valuelen);
		} else {
			struct xfs_attr_leaf_name_remote	*name_rmt;

			name_rmt = xfs_attr3_leaf_name_remote(leaf, i);
			name = name_rmt->name;
			namelen = name_rmt->namelen;
			value = NULL;
			valuelen = be32_to_cpu(name_rmt->valuelen);
		}

		error = attr_fn(sc, ip, entry->flags, name, namelen, value,
				valuelen, priv);
		if (error)
			return error;

	}

	return 0;
}

/*
 * Call a function for every entry in a leaf-format xattr structure.  Avoid
 * memory allocations for the loop detector since there's only one block.
 */
STATIC int
xchk_xattr_walk_leaf(
	struct xfs_scrub		*sc,
	struct xfs_inode		*ip,
	xchk_xattr_fn			attr_fn,
	void				*priv)
{
	struct xfs_buf			*leaf_bp;
	int				error;

	error = xfs_attr3_leaf_read(sc->tp, ip, I_INO(ip), 0, &leaf_bp);
	if (error)
		return error;

	error = xchk_xattr_walk_leaf_entries(sc, ip, attr_fn, leaf_bp, priv);
	xfs_trans_brelse(sc->tp, leaf_bp);
	return error;
}

/* Find the leftmost leaf in the xattr dabtree. */
STATIC int
xchk_xattr_find_leftmost_leaf(
	struct xfs_scrub		*sc,
	struct xfs_inode		*ip,
	struct xdab_bitmap		*seen_dablks,
	struct xfs_buf			**leaf_bpp)
{
	struct xfs_da3_icnode_hdr	nodehdr;
	struct xfs_mount		*mp = sc->mp;
	struct xfs_trans		*tp = sc->tp;
	struct xfs_da_intnode		*node;
	struct xfs_da_node_entry	*btree;
	struct xfs_buf			*bp;
	xfs_failaddr_t			fa;
	xfs_dablk_t			blkno = 0;
	unsigned int			expected_level = 0;
	int				error;

	for (;;) {
		xfs_extlen_t		len = 1;
		uint16_t		magic;

		/* Make sure we haven't seen this new block already. */
		if (xdab_bitmap_test(seen_dablks, blkno, &len))
			return -EFSCORRUPTED;

		error = xfs_da3_node_read(tp, ip, blkno, &bp, XFS_ATTR_FORK);
		if (error)
			return error;

		node = bp->b_addr;
		magic = be16_to_cpu(node->hdr.info.magic);
		if (magic == XFS_ATTR_LEAF_MAGIC ||
		    magic == XFS_ATTR3_LEAF_MAGIC)
			break;

		error = -EFSCORRUPTED;
		if (magic != XFS_DA_NODE_MAGIC &&

Annotation

Implementation Notes