xfs: add a new ioctl to describe allocation group geometry

Add a new ioctl to describe an allocation group's geometry.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
This commit is contained in:
Darrick J. Wong
2019-04-12 07:41:17 -07:00
parent 1b6d968de2
commit 7cd5006bdb
5 changed files with 93 additions and 0 deletions

View File

@@ -33,6 +33,7 @@
#include "xfs_fsmap.h"
#include "scrub/xfs_scrub.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include <linux/capability.h>
#include <linux/cred.h>
@@ -804,6 +805,26 @@ xfs_ioc_fsgeometry(
return 0;
}
STATIC int
xfs_ioc_ag_geometry(
struct xfs_mount *mp,
void __user *arg)
{
struct xfs_ag_geometry ageo;
int error;
if (copy_from_user(&ageo, arg, sizeof(ageo)))
return -EFAULT;
error = xfs_ag_get_geometry(mp, ageo.ag_number, &ageo);
if (error)
return error;
if (copy_to_user(arg, &ageo, sizeof(ageo)))
return -EFAULT;
return 0;
}
/*
* Linux extended inode flags interface.
*/
@@ -1930,6 +1951,9 @@ xfs_file_ioctl(
case XFS_IOC_FSGEOMETRY:
return xfs_ioc_fsgeometry(mp, arg, 5);
case XFS_IOC_AG_GEOMETRY:
return xfs_ioc_ag_geometry(mp, arg);
case XFS_IOC_GETVERSION:
return put_user(inode->i_generation, (int __user *)arg);