Skip to content

Commit

Permalink
xfs: Add helper function xfs_attr_list_context_init
Browse files Browse the repository at this point in the history
This patch adds a helper function xfs_attr_list_context_init used by
xfs_attr_list. This function initializes the xfs_attr_list_context
structure passed to xfs_attr_list_int. We will need this later to call
xfs_attr_list_int_ilocked when the node is already locked.

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
  • Loading branch information
allisonhenderson committed Oct 13, 2021
1 parent 909c23b commit 72e3522
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 16 deletions.
1 change: 1 addition & 0 deletions fs/xfs/xfs_file.c
Expand Up @@ -17,6 +17,7 @@
#include "xfs_bmap_util.h"
#include "xfs_dir2.h"
#include "xfs_dir2_priv.h"
#include "xfs_attr.h"
#include "xfs_ioctl.h"
#include "xfs_trace.h"
#include "xfs_log.h"
Expand Down
54 changes: 38 additions & 16 deletions fs/xfs/xfs_ioctl.c
Expand Up @@ -368,6 +368,40 @@ xfs_attr_flags(
return 0;
}

/*
* Initializes an xfs_attr_list_context suitable for
* use by xfs_attr_list
*/
int
xfs_ioc_attr_list_context_init(
struct xfs_inode *dp,
char *buffer,
int bufsize,
int flags,
struct xfs_attr_list_context *context)
{
struct xfs_attrlist *alist;

/*
* Initialize the output buffer.
*/
context->dp = dp;
context->resynch = 1;
context->attr_filter = xfs_attr_filter(flags);
context->buffer = buffer;
context->bufsize = round_down(bufsize, sizeof(uint32_t));
context->firstu = context->bufsize;
context->put_listent = xfs_ioc_attr_put_listent;

alist = context->buffer;
alist->al_count = 0;
alist->al_more = 0;
alist->al_offset[0] = context->bufsize;

return 0;
}


int
xfs_ioc_attr_list(
struct xfs_inode *dp,
Expand All @@ -377,7 +411,6 @@ xfs_ioc_attr_list(
struct xfs_attrlist_cursor __user *ucursor)
{
struct xfs_attr_list_context context = { };
struct xfs_attrlist *alist;
void *buffer;
int error;

Expand Down Expand Up @@ -409,21 +442,10 @@ xfs_ioc_attr_list(
if (!buffer)
return -ENOMEM;

/*
* Initialize the output buffer.
*/
context.dp = dp;
context.resynch = 1;
context.attr_filter = xfs_attr_filter(flags);
context.buffer = buffer;
context.bufsize = round_down(bufsize, sizeof(uint32_t));
context.firstu = context.bufsize;
context.put_listent = xfs_ioc_attr_put_listent;

alist = context.buffer;
alist->al_count = 0;
alist->al_more = 0;
alist->al_offset[0] = context.bufsize;
error = xfs_ioc_attr_list_context_init(dp, buffer, bufsize, flags,
&context);
if (error)
return error;

error = xfs_attr_list(&context);
if (error)
Expand Down
2 changes: 2 additions & 0 deletions fs/xfs/xfs_ioctl.h
Expand Up @@ -40,6 +40,8 @@ int xfs_ioc_attrmulti_one(struct file *parfilp, struct inode *inode,
uint32_t *len, uint32_t flags);
int xfs_ioc_attr_list(struct xfs_inode *dp, void __user *ubuf, int bufsize,
int flags, struct xfs_attrlist_cursor __user *ucursor);
int xfs_ioc_attr_list_context_init(struct xfs_inode *dp, char *buffer,
int bufsize, int flags, struct xfs_attr_list_context *context);

extern struct dentry *
xfs_handle_to_dentry(
Expand Down

0 comments on commit 72e3522

Please sign in to comment.