xref: /openbmc/linux/fs/xfs/xfs_itable.h (revision b8d312aa)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
4  */
5 #ifndef __XFS_ITABLE_H__
6 #define	__XFS_ITABLE_H__
7 
8 /* In-memory representation of a userspace request for batch inode data. */
9 struct xfs_ibulk {
10 	struct xfs_mount	*mp;
11 	void __user		*ubuffer; /* user output buffer */
12 	xfs_ino_t		startino; /* start with this inode */
13 	unsigned int		icount;   /* number of elements in ubuffer */
14 	unsigned int		ocount;   /* number of records returned */
15 	unsigned int		flags;    /* see XFS_IBULK_FLAG_* */
16 };
17 
18 /* Only iterate within the same AG as startino */
19 #define XFS_IBULK_SAME_AG	(XFS_IWALK_SAME_AG)
20 
21 /* Return value that means we want to abort the walk. */
22 #define XFS_IBULK_ABORT		(XFS_IWALK_ABORT)
23 
24 /*
25  * Advance the user buffer pointer by one record of the given size.  If the
26  * buffer is now full, return the appropriate error code.
27  */
28 static inline int
29 xfs_ibulk_advance(
30 	struct xfs_ibulk	*breq,
31 	size_t			bytes)
32 {
33 	char __user		*b = breq->ubuffer;
34 
35 	breq->ubuffer = b + bytes;
36 	breq->ocount++;
37 	return breq->ocount == breq->icount ? XFS_IBULK_ABORT : 0;
38 }
39 
40 /*
41  * Return stat information in bulk (by-inode) for the filesystem.
42  */
43 
44 typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq,
45 		const struct xfs_bulkstat *bstat);
46 
47 int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
48 int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
49 void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1,
50 		const struct xfs_bulkstat *bstat);
51 
52 typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq,
53 		const struct xfs_inumbers *igrp);
54 
55 int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter);
56 void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1,
57 		const struct xfs_inumbers *ig);
58 
59 #endif	/* __XFS_ITABLE_H__ */
60