#include <linux/file.h>
#include <linux/sched.h>
#include <linux/user_namespace.h>
+#include <linux/capability.h>
#include <linux/uidgid.h>
#include <linux/falloc.h>
#include <linux/ktime.h>
if (is_root_inode(child_inode))
GOTO(out_iput, rc = -EINVAL);
+ /*
+ * setxattr() used for finishing the dir migration, has the same
+ * capability check for updating attributes in "trusted" namespace.
+ */
+ if (!capable(CAP_SYS_ADMIN))
+ GOTO(out_iput, rc = -EPERM);
+
op_data = ll_prep_md_op_data(NULL, parent, NULL, name, namelen,
child_inode->i_mode, LUSTRE_OPC_ANY, NULL);
if (IS_ERR(op_data))
}
ret = setxattr(path, XATTR_NAME_LMV, lmu, lmulen, 0);
- if (ret == -EALREADY)
- ret = 0;
+ if (ret == -1) {
+ if (errno == EALREADY) {
+ ret = 0;
+ } else {
+ llapi_error(LLAPI_MSG_ERROR, errno,
+ "%s: error completing migration of %s",
+ __func__, path);
+ ret = -errno;
+ }
+ }
+
out:
cb_common_fini(path, p, dp, data, de);
return ret;