Source kernel commit:
54275d8496f3e4764302cebc0e9517d950ba6589
This field only ever contains XATTR_{CREATE,REPLACE}, and it only goes
as deep as xfs_attr_set. Remove the field from the structure and
replace it with an enum specifying exactly what kind of change we want
to make to the xattr structure. Upsert is the name that we'll give to
the flags==0 operation, because we're either updating an existing value
or inserting it, and the caller doesn't care.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
{
struct xfs_da_args args = { };
char *sp;
+ enum xfs_attr_update op = XFS_ATTRUPDATE_UPSERTR;
int c;
if (cur_typ == NULL) {
/* modifiers */
case 'C':
- args.attr_flags |= XATTR_CREATE;
- args.attr_flags &= ~XATTR_REPLACE;
+ op = XFS_ATTRUPDATE_CREATE;
break;
case 'R':
- args.attr_flags |= XATTR_REPLACE;
- args.attr_flags &= ~XATTR_CREATE;
+ op = XFS_ATTRUPDATE_REPLACE;
break;
case 'n':
goto out;
}
- if (libxfs_attr_set(&args)) {
+ if (libxfs_attr_set(&args, op)) {
dbprintf(_("failed to set attr %s on inode %llu\n"),
args.name, (unsigned long long)iocur_top->ino);
goto out;
goto out;
}
- if (libxfs_attr_set(&args)) {
+ if (libxfs_attr_set(&args, XFS_ATTRUPDATE_UPSERTR)) {
dbprintf(_("failed to remove attr %s from inode %llu\n"),
(unsigned char *)args.name,
(unsigned long long)iocur_top->ino);
*/
int
xfs_attr_set(
- struct xfs_da_args *args)
+ struct xfs_da_args *args,
+ enum xfs_attr_update op)
{
struct xfs_inode *dp = args->dp;
struct xfs_mount *mp = dp->i_mount;
}
/* Pure create fails if the attr already exists */
- if (args->attr_flags & XATTR_CREATE)
+ if (op == XFS_ATTRUPDATE_CREATE)
goto out_trans_cancel;
xfs_attr_defer_add(args, XFS_ATTRI_OP_FLAGS_REPLACE);
break;
goto out_trans_cancel;
/* Pure replace fails if no existing attr to replace. */
- if (args->attr_flags & XATTR_REPLACE)
+ if (op == XFS_ATTRUPDATE_REPLACE)
goto out_trans_cancel;
xfs_attr_defer_add(args, XFS_ATTRI_OP_FLAGS_SET);
break;
bool xfs_attr_is_leaf(struct xfs_inode *ip);
int xfs_attr_get_ilocked(struct xfs_da_args *args);
int xfs_attr_get(struct xfs_da_args *args);
-int xfs_attr_set(struct xfs_da_args *args);
+
+enum xfs_attr_update {
+ XFS_ATTRUPDATE_UPSERTR, /* set/remove value, replace any existing attr */
+ XFS_ATTRUPDATE_CREATE, /* set value, fail if attr already exists */
+ XFS_ATTRUPDATE_REPLACE, /* set value, fail if attr does not exist */
+};
+
+int xfs_attr_set(struct xfs_da_args *args, enum xfs_attr_update op);
int xfs_attr_set_iter(struct xfs_attr_intent *attr);
int xfs_attr_remove_iter(struct xfs_attr_intent *attr);
bool xfs_attr_namecheck(const void *name, size_t length);
void *value; /* set of bytes (maybe contain NULLs) */
int valuelen; /* length of value */
unsigned int attr_filter; /* XFS_ATTR_{ROOT,SECURE,INCOMPLETE} */
- unsigned int attr_flags; /* XATTR_{CREATE,REPLACE} */
xfs_dahash_t hashval; /* hash value of name */
xfs_ino_t inumber; /* input/output inode number */
struct xfs_inode *dp; /* directory inode to manipulate */