Whamcloud - gitweb
LU-9859 libcfs: remove cfs_capable 83/41783/3
authorPeng Tao <bergwolf@gmail.com>
Mon, 11 Jan 2021 15:49:38 +0000 (10:49 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 13 Mar 2021 18:34:14 +0000 (18:34 +0000)
Use capable() directly.

Linux-commit: 2eb90a757e9d953c9e2a8fce530422189992fb1b

Change-Id: Iadaa3c743a350def37558b23d954f5dfd4e0844a
Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-on: https://review.whamcloud.com/41783
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/include/libcfs/curproc.h
libcfs/libcfs/linux/linux-curproc.c
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_lib.c
lustre/obdclass/class_obd.c
lustre/obdecho/echo_client.c
lustre/osc/osc_io.c

index ac947e8..8501041 100644 (file)
@@ -53,7 +53,6 @@ typedef __u32 cfs_cap_t;
 
 cfs_cap_t cfs_curproc_cap_pack(void);
 void cfs_curproc_cap_unpack(cfs_cap_t cap);
-int cfs_capable(cfs_cap_t cap);
 
 /* __LIBCFS_CURPROC_H__ */
 #endif
index e6cdb63..da2b107 100644 (file)
@@ -101,11 +101,6 @@ void cfs_curproc_cap_unpack(cfs_cap_t cap)
         }
 }
 
-int cfs_capable(cfs_cap_t cap)
-{
-        return capable(cfs_cap_unpack(cap));
-}
-
 static int cfs_access_process_vm(struct task_struct *tsk,
                                 struct mm_struct *mm,
                                 unsigned long addr,
@@ -268,7 +263,6 @@ out:
 EXPORT_SYMBOL(cfs_get_environ);
 
 EXPORT_SYMBOL(cfs_curproc_cap_pack);
-EXPORT_SYMBOL(cfs_capable);
 
 /*
  * Local variables:
index 6d083b6..2d631d9 100644 (file)
@@ -1138,14 +1138,14 @@ int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
        case LUSTRE_Q_SETDEFAULT:
        case LUSTRE_Q_SETQUOTAPOOL:
        case LUSTRE_Q_SETINFOPOOL:
-               if (!cfs_capable(CAP_SYS_ADMIN))
+               if (!capable(CAP_SYS_ADMIN))
                        RETURN(-EPERM);
                break;
        case Q_GETQUOTA:
        case LUSTRE_Q_GETDEFAULT:
        case LUSTRE_Q_GETQUOTAPOOL:
                if (check_owner(type, id) &&
-                   (!cfs_capable(CAP_SYS_ADMIN)))
+                   (!capable(CAP_SYS_ADMIN)))
                        RETURN(-EPERM);
                break;
        case Q_GETINFO:
@@ -1274,7 +1274,7 @@ int ll_rmfid(struct file *file, void __user *arg)
        int i, rc, *rcs = NULL;
        ENTRY;
 
-       if (!cfs_capable(CAP_DAC_READ_SEARCH) &&
+       if (!capable(CAP_DAC_READ_SEARCH) &&
            !(ll_i2sbi(file_inode(file))->ll_flags & LL_SBI_USER_FID2PATH))
                RETURN(-EPERM);
        /* Only need to get the buflen */
@@ -2040,7 +2040,7 @@ out_hur:
                RETURN(rc);
        }
        case LL_IOC_HSM_CT_START:
-               if (!cfs_capable(CAP_SYS_ADMIN))
+               if (!capable(CAP_SYS_ADMIN))
                        RETURN(-EPERM);
 
                rc = copy_and_ct_start(cmd, sbi->ll_md_exp,
index 449f895..975112b 100644 (file)
@@ -2243,7 +2243,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file,
        int                      rc;
        ENTRY;
 
-       if (!cfs_capable(CAP_SYS_ADMIN))
+       if (!capable(CAP_SYS_ADMIN))
                RETURN(-EPERM);
 
        OBD_ALLOC_LARGE(lump, lum_size);
@@ -2565,7 +2565,7 @@ int ll_fid2path(struct inode *inode, void __user *arg)
 
        ENTRY;
 
-       if (!cfs_capable(CAP_DAC_READ_SEARCH) &&
+       if (!capable(CAP_DAC_READ_SEARCH) &&
            !(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH))
                RETURN(-EPERM);
 
@@ -2853,7 +2853,7 @@ int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss)
        /* Non-root users are forbidden to set or clear flags which are
         * NOT defined in HSM_USER_MASK. */
        if (((hss->hss_setmask | hss->hss_clearmask) & ~HSM_USER_MASK) &&
-           !cfs_capable(CAP_SYS_ADMIN))
+           !capable(CAP_SYS_ADMIN))
                RETURN(-EPERM);
 
        if (!exp_connect_archive_id_array(exp)) {
index c6aff22..2783678 100644 (file)
@@ -2042,7 +2042,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr,
        /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
        if (attr->ia_valid & TIMES_SET_FLAGS) {
                if ((!uid_eq(current_fsuid(), inode->i_uid)) &&
-                   !cfs_capable(CAP_FOWNER))
+                   !capable(CAP_FOWNER))
                        RETURN(-EPERM);
        }
 
@@ -3382,7 +3382,7 @@ int ll_getparent(struct file *file, struct getparent __user *arg)
 
        ENTRY;
 
-       if (!cfs_capable(CAP_DAC_READ_SEARCH) &&
+       if (!capable(CAP_DAC_READ_SEARCH) &&
            !(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH))
                RETURN(-EPERM);
 
index 7fab38a..ac335ef 100644 (file)
@@ -482,7 +482,7 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd,
 
        ENTRY;
        /* Allow non-root access for some limited ioctls */
-       if (!cfs_capable(CAP_SYS_ADMIN))
+       if (!capable(CAP_SYS_ADMIN))
                RETURN(err = -EACCES);
 
        if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */
index 92c923d..1ef99a5 100644 (file)
@@ -2841,7 +2841,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 
        switch (cmd) {
        case OBD_IOC_CREATE:                    /* may create echo object */
-               if (!cfs_capable(CAP_SYS_ADMIN))
+               if (!capable(CAP_SYS_ADMIN))
                        GOTO(out, rc = -EPERM);
 
                rc = echo_create_object(env, ed, oa);
@@ -2855,7 +2855,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                int dirlen;
                __u64 id;
 
-               if (!cfs_capable(CAP_SYS_ADMIN))
+               if (!capable(CAP_SYS_ADMIN))
                        GOTO(out, rc = -EPERM);
 
                count = data->ioc_count;
@@ -2880,7 +2880,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                __u64            seq;
                int              max_count;
 
-               if (!cfs_capable(CAP_SYS_ADMIN))
+               if (!capable(CAP_SYS_ADMIN))
                        GOTO(out, rc = -EPERM);
 
                rc = seq_client_get_seq(env, ed->ed_cl_seq, &seq);
@@ -2901,7 +2901,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
        }
 #endif /* HAVE_SERVER_SUPPORT */
        case OBD_IOC_DESTROY:
-               if (!cfs_capable(CAP_SYS_ADMIN))
+               if (!capable(CAP_SYS_ADMIN))
                        GOTO(out, rc = -EPERM);
 
                rc = echo_get_object(&eco, ed, oa);
@@ -2922,7 +2922,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                GOTO(out, rc);
 
        case OBD_IOC_SETATTR:
-               if (!cfs_capable(CAP_SYS_ADMIN))
+               if (!capable(CAP_SYS_ADMIN))
                        GOTO(out, rc = -EPERM);
 
                rc = echo_get_object(&eco, ed, oa);
@@ -2933,7 +2933,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                GOTO(out, rc);
 
        case OBD_IOC_BRW_WRITE:
-               if (!cfs_capable(CAP_SYS_ADMIN))
+               if (!capable(CAP_SYS_ADMIN))
                        GOTO(out, rc = -EPERM);
 
                rw = OBD_BRW_WRITE;
index 0cdd2ea..062fbe4 100644 (file)
@@ -415,7 +415,7 @@ int osc_io_iter_init(const struct lu_env *env, const struct cl_io_slice *ios)
        }
        spin_unlock(&imp->imp_lock);
 
-       if (cfs_capable(CAP_SYS_RESOURCE))
+       if (capable(CAP_SYS_RESOURCE))
                oio->oi_cap_sys_resource = 1;
 
        RETURN(rc);