return(rc);
}
+static int mdd_xattr_del(const struct lu_env *env, struct md_object *obj,
+ const char *name);
+
/**
* The caller should guarantee to update the object ctime
* after xattr_set if needed.
if (rc)
RETURN(rc);
+ if (strcmp(name, XATTR_NAME_ACL_ACCESS) == 0 ||
+ strcmp(name, XATTR_NAME_ACL_DEFAULT) == 0) {
+ struct posix_acl *acl;
+
+ /* user may set empty ACL, which should be treated as removing
+ * ACL. */
+ acl = posix_acl_from_xattr(&init_user_ns, buf->lb_buf,
+ buf->lb_len);
+ if (acl == NULL) {
+ rc = mdd_xattr_del(env, obj, name);
+ RETURN(rc);
+ }
+ posix_acl_release(acl);
+ }
+
if (!strcmp(name, XATTR_NAME_ACL_ACCESS)) {
rc = mdd_acl_set(env, mdd_obj, attr, buf, fl);
RETURN(rc);
LASSERT(dt_object_exists(dt));
if (!osd_obj2dev(obj)->od_posix_acl &&
- (!strcmp(name, POSIX_ACL_XATTR_ACCESS) ||
- !strcmp(name, POSIX_ACL_XATTR_DEFAULT)))
+ (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0 ||
+ strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0))
RETURN(-EOPNOTSUPP);
down(&obj->oo_guard);
LASSERT(obj->oo_db);
if (!osd_obj2dev(obj)->od_posix_acl &&
- (!strcmp(name, POSIX_ACL_XATTR_ACCESS) ||
- !strcmp(name, POSIX_ACL_XATTR_DEFAULT)))
+ (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0 ||
+ strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0))
RETURN(-EOPNOTSUPP);
oh = container_of0(handle, struct osd_thandle, ot_super);
LASSERT(oh->ot_tx != NULL);
if (!osd_obj2dev(obj)->od_posix_acl &&
- (!strcmp(name, POSIX_ACL_XATTR_ACCESS) ||
- !strcmp(name, POSIX_ACL_XATTR_DEFAULT)))
+ (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0 ||
+ strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0))
RETURN(-EOPNOTSUPP);
down(&obj->oo_guard);
const char *name = nvpair_name(nvp);
if (!osd_obj2dev(obj)->od_posix_acl &&
- (!strcmp(name, POSIX_ACL_XATTR_ACCESS) ||
- !strcmp(name, POSIX_ACL_XATTR_DEFAULT)))
+ (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0 ||
+ strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0))
continue;
len = strlen(nvpair_name(nvp));
while ((rc = -udmu_zap_cursor_retrieve_key(env, zc, oti->oti_key,
MAXNAMELEN)) == 0) {
if (!osd_obj2dev(obj)->od_posix_acl &&
- (!strcmp(oti->oti_key, POSIX_ACL_XATTR_ACCESS) ||
- !strcmp(oti->oti_key, POSIX_ACL_XATTR_DEFAULT))) {
+ (strcmp(oti->oti_key, POSIX_ACL_XATTR_ACCESS) == 0 ||
+ strcmp(oti->oti_key, POSIX_ACL_XATTR_DEFAULT) == 0)) {
zap_cursor_advance(zc);
continue;
}
error "failed to start MDT."
fi
- rm -f $DIR/$tfile
+ true
+}
+run_test 103b "MDS mount option 'noacl'"
+
+test_103c() {
+ mkdir -p $DIR/$tdir
+ cp -rp $DIR/$tdir $DIR/$tdir.bak
+
+ [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
+ error "$DIR/$tdir shouldn't contain default ACL"
+ [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
+ error "$DIR/$tdir.bak shouldn't contain default ACL"
+ true
}
-run_test 103b "MDS mount option \"noacl\" ======================="
+run_test 103c "'cp -rp' won't set empty acl"
test_104a() {
[ $PARALLEL == "yes" ] && skip "skip parallel run" && return