Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
0004  */
0005 #ifndef __XFS_ITABLE_H__
0006 #define __XFS_ITABLE_H__
0007 
0008 /* In-memory representation of a userspace request for batch inode data. */
0009 struct xfs_ibulk {
0010     struct xfs_mount    *mp;
0011     struct user_namespace   *mnt_userns;
0012     void __user     *ubuffer; /* user output buffer */
0013     xfs_ino_t       startino; /* start with this inode */
0014     unsigned int        icount;   /* number of elements in ubuffer */
0015     unsigned int        ocount;   /* number of records returned */
0016     unsigned int        flags;    /* see XFS_IBULK_FLAG_* */
0017 };
0018 
0019 /* Only iterate within the same AG as startino */
0020 #define XFS_IBULK_SAME_AG   (1U << 0)
0021 
0022 /* Fill out the bs_extents64 field if set. */
0023 #define XFS_IBULK_NREXT64   (1U << 1)
0024 
0025 /*
0026  * Advance the user buffer pointer by one record of the given size.  If the
0027  * buffer is now full, return the appropriate error code.
0028  */
0029 static inline int
0030 xfs_ibulk_advance(
0031     struct xfs_ibulk    *breq,
0032     size_t          bytes)
0033 {
0034     char __user     *b = breq->ubuffer;
0035 
0036     breq->ubuffer = b + bytes;
0037     breq->ocount++;
0038     return breq->ocount == breq->icount ? -ECANCELED : 0;
0039 }
0040 
0041 /*
0042  * Return stat information in bulk (by-inode) for the filesystem.
0043  */
0044 
0045 /*
0046  * Return codes for the formatter function are 0 to continue iterating, and
0047  * non-zero to stop iterating.  Any non-zero value will be passed up to the
0048  * bulkstat/inumbers caller.  The special value -ECANCELED can be used to stop
0049  * iteration, as neither bulkstat nor inumbers will ever generate that error
0050  * code on their own.
0051  */
0052 
0053 typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq,
0054         const struct xfs_bulkstat *bstat);
0055 
0056 int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
0057 int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
0058 void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1,
0059         const struct xfs_bulkstat *bstat);
0060 
0061 typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq,
0062         const struct xfs_inumbers *igrp);
0063 
0064 int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter);
0065 void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1,
0066         const struct xfs_inumbers *ig);
0067 
0068 #endif  /* __XFS_ITABLE_H__ */