Create core class (CKRM RCFS rewrite)
Core class creation/deletion which is triggered by directory creation/deletion.
Signed-off-by: Shailabh Nagar <[EMAIL PROTECTED]>
fs/rcfs/dir.c | 28 ----------------------------
fs/rcfs/inode.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/rcfs.h | 2 ++
3 files changed, 51 insertions(+), 28 deletions(-)
Index: linux-2.6.12/fs/rcfs/dir.c
===================================================================
--- linux-2.6.12.orig/fs/rcfs/dir.c 2005-08-09 15:30:37.220242384 -0400
+++ linux-2.6.12/fs/rcfs/dir.c 2005-08-09 15:30:37.293231288 -0400
@@ -33,34 +33,6 @@
/* Directory inode operations */
-int rcfs_create_coredir(struct inode *dir, struct dentry *dentry)
-{
-
- struct rcfs_inode_info *ripar, *ridir;
- int sz;
-
- ripar = rcfs_get_inode_info(dir);
- ridir = rcfs_get_inode_info(dentry->d_inode);
- /* Inform resource controllers - do Core operations */
- if (ckrm_is_core_valid(ripar->core)) {
- sz = strlen(ripar->name) + strlen(dentry->d_name.name) + 2;
- ridir->name = kmalloc(sz, GFP_KERNEL);
- if (!ridir->name) {
- return -ENOMEM;
- }
- snprintf(ridir->name, sz, "%s/%s", ripar->name,
- dentry->d_name.name);
- ridir->core = (*(ripar->core->classtype->alloc))
- (ripar->core, ridir->name);
- } else {
- printk(KERN_ERR "rcfs_mkdir: Invalid parent core %p\n",
- ripar->core);
- return -EINVAL;
- }
-
- return 0;
-}
-
int rcfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
{
Index: linux-2.6.12/fs/rcfs/inode.c
===================================================================
--- linux-2.6.12.orig/fs/rcfs/inode.c 2005-08-09 15:30:37.220242384 -0400
+++ linux-2.6.12/fs/rcfs/inode.c 2005-08-09 15:30:37.294231136 -0400
@@ -438,6 +438,55 @@ int rcfs_name(struct dentry *parent, str
return 0;
}
+int rcfs_create_core(struct inode *dir, struct dentry *dentry)
+{
+ struct rcfs_inode_info *ripar, *ri;
+ int sz;
+
+
+ ri = rcfs_get_inode_info(dentry->d_inode);
+ ripar = rcfs_get_inode_info(dir);
+ if (!ckrm_is_core_valid(ripar->core)) {
+ warn("parent core invalid\n");
+ return -EINVAL;
+ }
+
+ sz = strlen(ripar->name) + strlen(dentry->d_name.name) + 2;
+ ri->name = kmalloc(sz, GFP_KERNEL);
+ if (!ri->name)
+ return -ENOMEM;
+ snprintf(ri->name, sz, "%s/%s", ripar->name,
+ dentry->d_name.name);
+
+ ri->core = (*(ripar->core->classtype->alloc))(ripar->core, ri->name);
+ if (IS_ERR(ri->core)) {
+ kfree(ri->name);
+ return PTR_ERR(ri->core);
+ }
+ return 0;
+}
+
+
+int rcfs_destroy_core(struct dentry *dentry)
+{
+ struct rcfs_inode_info *ri;
+ int rc;
+
+ ri = rcfs_get_inode_info(dentry->d_inode);
+ if (!ckrm_is_core_valid(ri->core)) {
+ warn("Invalid core\n");
+ return -EINVAL;
+ }
+
+ rc = (*(ri->core->classtype->free))(ri->core) ;
+ if (rc) {
+ err("core class not freed\n");
+ return rc;
+ }
+
+ kfree(ri->name);
+ return 0;
+}
static struct file_system_type rcfs_fs_type = {
Index: linux-2.6.12/include/linux/rcfs.h
===================================================================
--- linux-2.6.12.orig/include/linux/rcfs.h 2005-08-09 15:30:37.220242384 -0400
+++ linux-2.6.12/include/linux/rcfs.h 2005-08-09 15:30:37.294231136 -0400
@@ -88,6 +88,8 @@ extern struct dentry *rcfs_create_file(c
extern int __rcfs_destroy_file(struct dentry *);
extern int rcfs_destroy_file(struct dentry *);
extern int rcfs_name(struct dentry *, struct inode *, char *);
+extern int rcfs_create_core(struct inode *, struct dentry *);
+extern int rcfs_destroy_core(struct dentry *);
extern int rcfs_create_noperm(struct inode *, struct dentry *, int , struct nameidata *);
extern int rcfs_symlink_noperm(struct inode *, struct dentry *, const char *);