ma->ma_attr.la_mtime, ma->ma_attr.la_ctime);
*la_copy = ma->ma_attr;
- mdd_write_lock(env, mdd_obj);
+ mdd_read_lock(env, mdd_obj);
rc = mdd_fix_attr(env, mdd_obj, la_copy);
- mdd_write_unlock(env, mdd_obj);
+ mdd_read_unlock(env, mdd_obj);
if (rc)
GOTO(cleanup, rc);
int rc;
ENTRY;
- rc = mdd_oc_sanity_check(env, mdd_obj, ma);
- if (rc)
- RETURN(rc);
-
mdd_txn_param_build(env, mdd, MDD_TXN_OBJECT_CREATE_OP);
handle = mdd_trans_start(env, mdd);
if (IS_ERR(handle))
RETURN(PTR_ERR(handle));
mdd_write_lock(env, mdd_obj);
+ rc = mdd_oc_sanity_check(env, mdd_obj, ma);
+ if (rc)
+ GOTO(unlock, rc);
+
rc = mdd_object_create_internal(env, mdd_obj, ma, handle);
if (rc)
GOTO(unlock, rc);
RETURN(rc);
}
- /*
- * FIFO's, sockets and device files are special: they don't
- * actually live on the filesystem itself, and as such you
- * can write to them even if the filesystem is read-only.
- */
- if (S_ISFIFO(tmp_la->la_mode) || S_ISSOCK(tmp_la->la_mode))
- flag &= ~O_TRUNC;
+ if (S_ISFIFO(tmp_la->la_mode) || S_ISSOCK(tmp_la->la_mode) ||
+ S_ISBLK(tmp_la->la_mode) || S_ISCHR(tmp_la->la_mode))
+ flag &= ~MDS_OPEN_TRUNC;
/*
- * An append-only file must be opened in append mode for writing.
+ * For writing append-only file must open it with append mode.
*/
if (mdd_is_append(obj)) {
- if ((mode & FMODE_WRITE) && !(flag & O_APPEND))
+ if ((flag & FMODE_WRITE) && !(flag & MDS_OPEN_APPEND))
RETURN(-EPERM);
- if (flag & O_TRUNC)
+ if (flag & MDS_OPEN_TRUNC)
RETURN(-EPERM);
}
- /* O_NOATIME can only be set by the owner or superuser */
+#if 0
+ /*
+ * Now, flag -- O_NOATIME does not be packed by client.
+ */
if (flag & O_NOATIME) {
struct md_ucred *uc = md_ucred(env);
!mdd_capable(uc, CAP_FOWNER))
RETURN(-EPERM);
}
+#endif
RETURN(0);
}
p->e_id = cpu_to_le32(p->e_id);
}
+/*
+ * Check permission based on POSIX ACL.
+ */
static int mdd_posix_acl_permission(struct md_ucred *uc, struct lu_attr *la,
int want, posix_acl_xattr_entry *entry,
int count)
/*
* Modify acl when creating a new obj.
- *
- * mode_p initially must contain the mode parameter to the open() / creat()
- * system calls. All permissions that are not granted by the acl are removed.
- * The permissions in the acl are changed to reflect the mode_p parameter.
*/
static int mdd_posix_acl_create_masq(posix_acl_xattr_entry *entry,
__u32 *mode_p, int count)
mode >>= 3;
}
- /*
- * If the DACs are ok we don't need any capability check.
- */
if (((mode & mask & S_IRWXO) == mask))
RETURN(0);
check_capabilities:
-
- /*
- * Read/write DACs are always overridable.
- * Executable DACs are overridable if at least one exec bit is set.
- * Dir's DACs are always overridable.
- */
if (!(mask & MAY_EXEC) ||
(la->la_mode & S_IXUGO) || S_ISDIR(la->la_mode))
if (mdd_capable(uc, CAP_DAC_OVERRIDE))
RETURN(0);
- /*
- * Searching includes executable on directories, else just read.
- */
if ((mask == MAY_READ) ||
(S_ISDIR(la->la_mode) && !(mask & MAY_WRITE)))
if (mdd_capable(uc, CAP_DAC_READ_SEARCH))
}
inline int mdd_permission_internal_locked(const struct lu_env *env,
- struct mdd_object *obj,
- int mask)
+ struct mdd_object *obj, int mask)
{
int rc;