@@ -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"
@@ -369,6 +369,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,
@@ -378,7 +412,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;
@@ -410,21 +443,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)
@@ -35,6 +35,8 @@ int xfs_ioc_attrmulti_one(struct file *parfilp, struct inode *inode,
int xfs_ioc_attr_list(struct xfs_inode *dp, void __user *ubuf,
size_t 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(