blob: 60e2591920568ac8a6eb5662ffbf5f2228470066 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 */
5#ifndef __XFS_ITABLE_H__
6#define __XFS_ITABLE_H__
7
Darrick J. Wong2810bd62019-07-02 09:39:40 -07008/* In-memory representation of a userspace request for batch inode data. */
9struct 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};
16
17/* Return value that means we want to abort the walk. */
18#define XFS_IBULK_ABORT (XFS_IWALK_ABORT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20/*
Darrick J. Wong2810bd62019-07-02 09:39:40 -070021 * Advance the user buffer pointer by one record of the given size. If the
22 * buffer is now full, return the appropriate error code.
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 */
Darrick J. Wong2810bd62019-07-02 09:39:40 -070024static inline int
25xfs_ibulk_advance(
26 struct xfs_ibulk *breq,
27 size_t bytes)
28{
29 char __user *b = breq->ubuffer;
30
31 breq->ubuffer = b + bytes;
32 breq->ocount++;
33 return breq->ocount == breq->icount ? XFS_IBULK_ABORT : 0;
34}
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 * Return stat information in bulk (by-inode) for the filesystem.
38 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Darrick J. Wong2810bd62019-07-02 09:39:40 -070040typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq,
Darrick J. Wong7035f972019-07-03 20:36:26 -070041 const struct xfs_bulkstat *bstat);
Michal Marekfaa63e92007-07-11 11:10:19 +100042
Darrick J. Wong2810bd62019-07-02 09:39:40 -070043int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
44int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
Darrick J. Wong7035f972019-07-03 20:36:26 -070045void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1,
46 const struct xfs_bulkstat *bstat);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Darrick J. Wong677717f2019-07-02 09:39:43 -070048typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq,
49 const struct xfs_inogrp *igrp);
Michal Marekfaa63e92007-07-11 11:10:19 +100050
Darrick J. Wong677717f2019-07-02 09:39:43 -070051int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter);
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#endif /* __XFS_ITABLE_H__ */