Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | */ |
| 5 | #ifndef __XFS_ITABLE_H__ |
| 6 | #define __XFS_ITABLE_H__ |
| 7 | |
Darrick J. Wong | 2810bd6 | 2019-07-02 09:39:40 -0700 | [diff] [blame] | 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 | }; |
| 16 | |
| 17 | /* Return value that means we want to abort the walk. */ |
| 18 | #define XFS_IBULK_ABORT (XFS_IWALK_ABORT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | /* |
Darrick J. Wong | 2810bd6 | 2019-07-02 09:39:40 -0700 | [diff] [blame] | 21 | * 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | */ |
Darrick J. Wong | 2810bd6 | 2019-07-02 09:39:40 -0700 | [diff] [blame] | 24 | static inline int |
| 25 | xfs_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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
| 36 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | * Return stat information in bulk (by-inode) for the filesystem. |
| 38 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
Darrick J. Wong | 2810bd6 | 2019-07-02 09:39:40 -0700 | [diff] [blame] | 40 | typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq, |
Darrick J. Wong | 7035f97 | 2019-07-03 20:36:26 -0700 | [diff] [blame^] | 41 | const struct xfs_bulkstat *bstat); |
Michal Marek | faa63e9 | 2007-07-11 11:10:19 +1000 | [diff] [blame] | 42 | |
Darrick J. Wong | 2810bd6 | 2019-07-02 09:39:40 -0700 | [diff] [blame] | 43 | int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter); |
| 44 | int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter); |
Darrick J. Wong | 7035f97 | 2019-07-03 20:36:26 -0700 | [diff] [blame^] | 45 | void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1, |
| 46 | const struct xfs_bulkstat *bstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Darrick J. Wong | 677717f | 2019-07-02 09:39:43 -0700 | [diff] [blame] | 48 | typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq, |
| 49 | const struct xfs_inogrp *igrp); |
Michal Marek | faa63e9 | 2007-07-11 11:10:19 +1000 | [diff] [blame] | 50 | |
Darrick J. Wong | 677717f | 2019-07-02 09:39:43 -0700 | [diff] [blame] | 51 | int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | #endif /* __XFS_ITABLE_H__ */ |