@@ -69,6 +69,7 @@ attr_set_f(
{
struct xfs_da_args args = { };
char *sp;
+ enum xfs_attr_update op = XFS_ATTRUPDATE_UPSERTR;
int c;
if (cur_typ == NULL) {
@@ -98,12 +99,10 @@ attr_set_f(
/* 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':
@@ -162,7 +161,7 @@ attr_set_f(
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;
@@ -248,7 +247,7 @@ attr_remove_f(
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);
@@ -920,7 +920,8 @@ xfs_attr_defer_add(
*/
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;
@@ -1006,7 +1007,7 @@ xfs_attr_set(
}
/* 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;
@@ -1016,7 +1017,7 @@ xfs_attr_set(
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;
@@ -544,7 +544,14 @@ int xfs_inode_hasattr(struct xfs_inode *ip);
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);
@@ -60,7 +60,6 @@ typedef struct xfs_da_args {
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 */