[Devel] [PATCH rh7 1/6] cgroup: add function to lookup a cgroup by pathname
Vladimir Davydov
vdavydov at parallels.com
Sun Jun 7 04:57:13 PDT 2015
Will be used later.
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
fs/internal.h | 2 --
include/linux/cgroup.h | 2 ++
include/linux/fs.h | 2 ++
kernel/cgroup.c | 23 +++++++++++++++++++++++
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/fs/internal.h b/fs/internal.h
index a592cd36971e..fc66b23c65db 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -47,8 +47,6 @@ extern void __init chrdev_init(void);
*/
extern int __inode_permission(struct inode *, int);
extern int user_path_mountpoint_at(int, const char __user *, unsigned int, struct path *);
-extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
- const char *, unsigned int, struct path *);
/*
* namespace.c
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 0108a98bb911..52fe02af71b5 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -50,6 +50,8 @@ enum cgroup_open_flags {
struct vfsmount *cgroup_kernel_mount(struct cgroup_sb_opts *opts);
struct cgroup *cgroup_get_root(struct vfsmount *mnt);
+struct cgroup *cgroup_kernel_lookup(struct vfsmount *mnt,
+ const char *pathname);
struct cgroup *cgroup_kernel_open(struct cgroup *parent,
enum cgroup_open_flags flags, const char *name);
int cgroup_kernel_remove(struct cgroup *parent, const char *name);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 9efd253c6da1..bc494a0d4616 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1596,6 +1596,8 @@ extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct ino
extern int vfs_rmdir(struct inode *, struct dentry *);
extern int vfs_unlink(struct inode *, struct dentry *, struct inode **);
extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **);
+extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
+ const char *, unsigned int, struct path *);
/*
* VFS dentry helper functions.
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 9b3d0e2ebbae..cca5b961ef37 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -5547,6 +5547,29 @@ struct cgroup *cgroup_get_root(struct vfsmount *mnt)
}
EXPORT_SYMBOL(cgroup_get_root);
+struct cgroup *cgroup_kernel_lookup(struct vfsmount *mnt,
+ const char *pathname)
+{
+ int err;
+ struct path path;
+ struct dentry *dentry;
+ struct cgroup *cgrp;
+
+ err = vfs_path_lookup(mnt->mnt_root, mnt, pathname,
+ LOOKUP_DIRECTORY, &path);
+ if (err)
+ return ERR_PTR(err);
+ dentry = path.dentry;
+ if (dentry->d_inode) {
+ cgrp = __d_cgrp(dentry);
+ atomic_inc(&cgrp->count);
+ } else
+ cgrp = ERR_PTR(-ENOENT);
+ path_put(&path);
+ return cgrp;
+}
+EXPORT_SYMBOL(cgroup_kernel_lookup);
+
struct cgroup *cgroup_kernel_open(struct cgroup *parent,
enum cgroup_open_flags flags, const char *name)
{
--
2.1.4
More information about the Devel
mailing list