aboutsummaryrefslogtreecommitdiffstats
path: root/fs/relayfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/relayfs/inode.c')
-rw-r--r--fs/relayfs/inode.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/fs/relayfs/inode.c b/fs/relayfs/inode.c
index 0f7f88d067ad..379e07cd2b34 100644
--- a/fs/relayfs/inode.c
+++ b/fs/relayfs/inode.c
@@ -34,23 +34,13 @@ static struct backing_dev_info relayfs_backing_dev_info = {
34}; 34};
35 35
36static struct inode *relayfs_get_inode(struct super_block *sb, int mode, 36static struct inode *relayfs_get_inode(struct super_block *sb, int mode,
37 struct rchan *chan) 37 void *data)
38{ 38{
39 struct rchan_buf *buf = NULL;
40 struct inode *inode; 39 struct inode *inode;
41 40
42 if (S_ISREG(mode)) {
43 BUG_ON(!chan);
44 buf = relay_create_buf(chan);
45 if (!buf)
46 return NULL;
47 }
48
49 inode = new_inode(sb); 41 inode = new_inode(sb);
50 if (!inode) { 42 if (!inode)
51 relay_destroy_buf(buf);
52 return NULL; 43 return NULL;
53 }
54 44
55 inode->i_mode = mode; 45 inode->i_mode = mode;
56 inode->i_uid = 0; 46 inode->i_uid = 0;
@@ -62,7 +52,7 @@ static struct inode *relayfs_get_inode(struct super_block *sb, int mode,
62 switch (mode & S_IFMT) { 52 switch (mode & S_IFMT) {
63 case S_IFREG: 53 case S_IFREG:
64 inode->i_fop = &relayfs_file_operations; 54 inode->i_fop = &relayfs_file_operations;
65 RELAYFS_I(inode)->buf = buf; 55 RELAYFS_I(inode)->buf = data;
66 break; 56 break;
67 case S_IFDIR: 57 case S_IFDIR:
68 inode->i_op = &simple_dir_inode_operations; 58 inode->i_op = &simple_dir_inode_operations;
@@ -83,7 +73,7 @@ static struct inode *relayfs_get_inode(struct super_block *sb, int mode,
83 * @name: the name of the file to create 73 * @name: the name of the file to create
84 * @parent: parent directory 74 * @parent: parent directory
85 * @mode: mode 75 * @mode: mode
86 * @chan: relay channel associated with the file 76 * @data: user-associated data for this file
87 * 77 *
88 * Returns the new dentry, NULL on failure 78 * Returns the new dentry, NULL on failure
89 * 79 *
@@ -92,7 +82,7 @@ static struct inode *relayfs_get_inode(struct super_block *sb, int mode,
92static struct dentry *relayfs_create_entry(const char *name, 82static struct dentry *relayfs_create_entry(const char *name,
93 struct dentry *parent, 83 struct dentry *parent,
94 int mode, 84 int mode,
95 struct rchan *chan) 85 void *data)
96{ 86{
97 struct dentry *d; 87 struct dentry *d;
98 struct inode *inode; 88 struct inode *inode;
@@ -127,7 +117,7 @@ static struct dentry *relayfs_create_entry(const char *name,
127 goto release_mount; 117 goto release_mount;
128 } 118 }
129 119
130 inode = relayfs_get_inode(parent->d_inode->i_sb, mode, chan); 120 inode = relayfs_get_inode(parent->d_inode->i_sb, mode, data);
131 if (!inode) { 121 if (!inode) {
132 d = NULL; 122 d = NULL;
133 goto release_mount; 123 goto release_mount;
@@ -155,20 +145,20 @@ exit:
155 * @name: the name of the file to create 145 * @name: the name of the file to create
156 * @parent: parent directory 146 * @parent: parent directory
157 * @mode: mode, if not specied the default perms are used 147 * @mode: mode, if not specied the default perms are used
158 * @chan: channel associated with the file 148 * @data: user-associated data for this file
159 * 149 *
160 * Returns file dentry if successful, NULL otherwise. 150 * Returns file dentry if successful, NULL otherwise.
161 * 151 *
162 * The file will be created user r on behalf of current user. 152 * The file will be created user r on behalf of current user.
163 */ 153 */
164struct dentry *relayfs_create_file(const char *name, struct dentry *parent, 154struct dentry *relayfs_create_file(const char *name, struct dentry *parent,
165 int mode, struct rchan *chan) 155 int mode, void *data)
166{ 156{
167 if (!mode) 157 if (!mode)
168 mode = S_IRUSR; 158 mode = S_IRUSR;
169 mode = (mode & S_IALLUGO) | S_IFREG; 159 mode = (mode & S_IALLUGO) | S_IFREG;
170 160
171 return relayfs_create_entry(name, parent, mode, chan); 161 return relayfs_create_entry(name, parent, mode, data);
172} 162}
173 163
174/** 164/**
@@ -505,9 +495,6 @@ static struct inode *relayfs_alloc_inode(struct super_block *sb)
505 */ 495 */
506static void relayfs_destroy_inode(struct inode *inode) 496static void relayfs_destroy_inode(struct inode *inode)
507{ 497{
508 if (RELAYFS_I(inode)->buf)
509 relay_destroy_buf(RELAYFS_I(inode)->buf);
510
511 kmem_cache_free(relayfs_inode_cachep, RELAYFS_I(inode)); 498 kmem_cache_free(relayfs_inode_cachep, RELAYFS_I(inode));
512} 499}
513 500