From 459d5c9adf1312827b2882d54d29d396a032d62b Mon Sep 17 00:00:00 2001 From: fanyong Date: Tue, 31 Oct 2006 07:25:29 +0000 Subject: [PATCH] (1) drop some comment. (2) small fix for lock using. (3) replace kernel flag with LUSTRE flag. --- lustre/mdd/mdd_object.c | 34 +++++++++++++++++----------------- lustre/mdd/mdd_permission.c | 22 ++++------------------ 2 files changed, 21 insertions(+), 35 deletions(-) diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index a762ea3..b419783 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -733,9 +733,9 @@ static int mdd_attr_set(const struct lu_env *env, struct md_object *obj, 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); @@ -957,16 +957,16 @@ static int mdd_object_create(const struct lu_env *env, 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); @@ -1098,25 +1098,24 @@ static int mdd_open_sanity_check(const struct lu_env *env, 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); @@ -1124,6 +1123,7 @@ static int mdd_open_sanity_check(const struct lu_env *env, !mdd_capable(uc, CAP_FOWNER)) RETURN(-EPERM); } +#endif RETURN(0); } diff --git a/lustre/mdd/mdd_permission.c b/lustre/mdd/mdd_permission.c index 0a0ee95..ffa7839 100644 --- a/lustre/mdd/mdd_permission.c +++ b/lustre/mdd/mdd_permission.c @@ -133,6 +133,9 @@ static inline void mdd_acl_cpu_to_le(posix_acl_xattr_entry *p) 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) @@ -316,10 +319,6 @@ int mdd_acl_chmod(const struct lu_env *env, struct mdd_object *o, __u32 mode, /* * 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) @@ -573,27 +572,15 @@ int __mdd_permission_internal(const struct lu_env *env, 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)) @@ -609,8 +596,7 @@ int mdd_permission_internal(const struct lu_env *env, struct mdd_object *obj, } 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; -- 1.8.3.1