Commit 482e0cd3 authored by Al Viro's avatar Al Viro

devcgroup_inode_permission: take "is it a device node" checks to inlined wrapper

inode_permission() calls devcgroup_inode_permission() and almost all such
calls are _not_ for device nodes; let's at least keep the common path
straight...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 8e833fd2
...@@ -2,8 +2,16 @@ ...@@ -2,8 +2,16 @@
#include <linux/fs.h> #include <linux/fs.h>
#ifdef CONFIG_CGROUP_DEVICE #ifdef CONFIG_CGROUP_DEVICE
extern int devcgroup_inode_permission(struct inode *inode, int mask); extern int __devcgroup_inode_permission(struct inode *inode, int mask);
extern int devcgroup_inode_mknod(int mode, dev_t dev); extern int devcgroup_inode_mknod(int mode, dev_t dev);
static inline int devcgroup_inode_permission(struct inode *inode, int mask)
{
if (likely(!inode->i_rdev))
return 0;
if (!S_ISBLK(inode->i_mode) && !S_ISCHR(inode->i_mode))
return 0;
return __devcgroup_inode_permission(inode, mask);
}
#else #else
static inline int devcgroup_inode_permission(struct inode *inode, int mask) static inline int devcgroup_inode_permission(struct inode *inode, int mask)
{ return 0; } { return 0; }
......
...@@ -474,17 +474,11 @@ struct cgroup_subsys devices_subsys = { ...@@ -474,17 +474,11 @@ struct cgroup_subsys devices_subsys = {
.subsys_id = devices_subsys_id, .subsys_id = devices_subsys_id,
}; };
int devcgroup_inode_permission(struct inode *inode, int mask) int __devcgroup_inode_permission(struct inode *inode, int mask)
{ {
struct dev_cgroup *dev_cgroup; struct dev_cgroup *dev_cgroup;
struct dev_whitelist_item *wh; struct dev_whitelist_item *wh;
dev_t device = inode->i_rdev;
if (!device)
return 0;
if (!S_ISBLK(inode->i_mode) && !S_ISCHR(inode->i_mode))
return 0;
rcu_read_lock(); rcu_read_lock();
dev_cgroup = task_devcgroup(current); dev_cgroup = task_devcgroup(current);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment