diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/oprofile/oprofilefs.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/oprofile/oprofilefs.c')
-rw-r--r-- | drivers/oprofile/oprofilefs.c | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c index 2766a6d3c2e9..e9ff6f7770be 100644 --- a/drivers/oprofile/oprofilefs.c +++ b/drivers/oprofile/oprofilefs.c | |||
@@ -28,6 +28,7 @@ static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode) | |||
28 | struct inode *inode = new_inode(sb); | 28 | struct inode *inode = new_inode(sb); |
29 | 29 | ||
30 | if (inode) { | 30 | if (inode) { |
31 | inode->i_ino = get_next_ino(); | ||
31 | inode->i_mode = mode; | 32 | inode->i_mode = mode; |
32 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 33 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
33 | } | 34 | } |
@@ -91,16 +92,20 @@ static ssize_t ulong_read_file(struct file *file, char __user *buf, size_t count | |||
91 | 92 | ||
92 | static ssize_t ulong_write_file(struct file *file, char const __user *buf, size_t count, loff_t *offset) | 93 | static ssize_t ulong_write_file(struct file *file, char const __user *buf, size_t count, loff_t *offset) |
93 | { | 94 | { |
94 | unsigned long *value = file->private_data; | 95 | unsigned long value; |
95 | int retval; | 96 | int retval; |
96 | 97 | ||
97 | if (*offset) | 98 | if (*offset) |
98 | return -EINVAL; | 99 | return -EINVAL; |
99 | 100 | ||
100 | retval = oprofilefs_ulong_from_user(value, buf, count); | 101 | retval = oprofilefs_ulong_from_user(&value, buf, count); |
102 | if (retval) | ||
103 | return retval; | ||
101 | 104 | ||
105 | retval = oprofile_set_ulong(file->private_data, value); | ||
102 | if (retval) | 106 | if (retval) |
103 | return retval; | 107 | return retval; |
108 | |||
104 | return count; | 109 | return count; |
105 | } | 110 | } |
106 | 111 | ||
@@ -117,59 +122,52 @@ static const struct file_operations ulong_fops = { | |||
117 | .read = ulong_read_file, | 122 | .read = ulong_read_file, |
118 | .write = ulong_write_file, | 123 | .write = ulong_write_file, |
119 | .open = default_open, | 124 | .open = default_open, |
125 | .llseek = default_llseek, | ||
120 | }; | 126 | }; |
121 | 127 | ||
122 | 128 | ||
123 | static const struct file_operations ulong_ro_fops = { | 129 | static const struct file_operations ulong_ro_fops = { |
124 | .read = ulong_read_file, | 130 | .read = ulong_read_file, |
125 | .open = default_open, | 131 | .open = default_open, |
132 | .llseek = default_llseek, | ||
126 | }; | 133 | }; |
127 | 134 | ||
128 | 135 | ||
129 | static struct dentry *__oprofilefs_create_file(struct super_block *sb, | 136 | static int __oprofilefs_create_file(struct super_block *sb, |
130 | struct dentry *root, char const *name, const struct file_operations *fops, | 137 | struct dentry *root, char const *name, const struct file_operations *fops, |
131 | int perm) | 138 | int perm, void *priv) |
132 | { | 139 | { |
133 | struct dentry *dentry; | 140 | struct dentry *dentry; |
134 | struct inode *inode; | 141 | struct inode *inode; |
135 | 142 | ||
136 | dentry = d_alloc_name(root, name); | 143 | dentry = d_alloc_name(root, name); |
137 | if (!dentry) | 144 | if (!dentry) |
138 | return NULL; | 145 | return -ENOMEM; |
139 | inode = oprofilefs_get_inode(sb, S_IFREG | perm); | 146 | inode = oprofilefs_get_inode(sb, S_IFREG | perm); |
140 | if (!inode) { | 147 | if (!inode) { |
141 | dput(dentry); | 148 | dput(dentry); |
142 | return NULL; | 149 | return -ENOMEM; |
143 | } | 150 | } |
144 | inode->i_fop = fops; | 151 | inode->i_fop = fops; |
145 | d_add(dentry, inode); | 152 | d_add(dentry, inode); |
146 | return dentry; | 153 | dentry->d_inode->i_private = priv; |
154 | return 0; | ||
147 | } | 155 | } |
148 | 156 | ||
149 | 157 | ||
150 | int oprofilefs_create_ulong(struct super_block *sb, struct dentry *root, | 158 | int oprofilefs_create_ulong(struct super_block *sb, struct dentry *root, |
151 | char const *name, unsigned long *val) | 159 | char const *name, unsigned long *val) |
152 | { | 160 | { |
153 | struct dentry *d = __oprofilefs_create_file(sb, root, name, | 161 | return __oprofilefs_create_file(sb, root, name, |
154 | &ulong_fops, 0644); | 162 | &ulong_fops, 0644, val); |
155 | if (!d) | ||
156 | return -EFAULT; | ||
157 | |||
158 | d->d_inode->i_private = val; | ||
159 | return 0; | ||
160 | } | 163 | } |
161 | 164 | ||
162 | 165 | ||
163 | int oprofilefs_create_ro_ulong(struct super_block *sb, struct dentry *root, | 166 | int oprofilefs_create_ro_ulong(struct super_block *sb, struct dentry *root, |
164 | char const *name, unsigned long *val) | 167 | char const *name, unsigned long *val) |
165 | { | 168 | { |
166 | struct dentry *d = __oprofilefs_create_file(sb, root, name, | 169 | return __oprofilefs_create_file(sb, root, name, |
167 | &ulong_ro_fops, 0444); | 170 | &ulong_ro_fops, 0444, val); |
168 | if (!d) | ||
169 | return -EFAULT; | ||
170 | |||
171 | d->d_inode->i_private = val; | ||
172 | return 0; | ||
173 | } | 171 | } |
174 | 172 | ||
175 | 173 | ||
@@ -183,37 +181,29 @@ static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t coun | |||
183 | static const struct file_operations atomic_ro_fops = { | 181 | static const struct file_operations atomic_ro_fops = { |
184 | .read = atomic_read_file, | 182 | .read = atomic_read_file, |
185 | .open = default_open, | 183 | .open = default_open, |
184 | .llseek = default_llseek, | ||
186 | }; | 185 | }; |
187 | 186 | ||
188 | 187 | ||
189 | int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root, | 188 | int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root, |
190 | char const *name, atomic_t *val) | 189 | char const *name, atomic_t *val) |
191 | { | 190 | { |
192 | struct dentry *d = __oprofilefs_create_file(sb, root, name, | 191 | return __oprofilefs_create_file(sb, root, name, |
193 | &atomic_ro_fops, 0444); | 192 | &atomic_ro_fops, 0444, val); |
194 | if (!d) | ||
195 | return -EFAULT; | ||
196 | |||
197 | d->d_inode->i_private = val; | ||
198 | return 0; | ||
199 | } | 193 | } |
200 | 194 | ||
201 | 195 | ||
202 | int oprofilefs_create_file(struct super_block *sb, struct dentry *root, | 196 | int oprofilefs_create_file(struct super_block *sb, struct dentry *root, |
203 | char const *name, const struct file_operations *fops) | 197 | char const *name, const struct file_operations *fops) |
204 | { | 198 | { |
205 | if (!__oprofilefs_create_file(sb, root, name, fops, 0644)) | 199 | return __oprofilefs_create_file(sb, root, name, fops, 0644, NULL); |
206 | return -EFAULT; | ||
207 | return 0; | ||
208 | } | 200 | } |
209 | 201 | ||
210 | 202 | ||
211 | int oprofilefs_create_file_perm(struct super_block *sb, struct dentry *root, | 203 | int oprofilefs_create_file_perm(struct super_block *sb, struct dentry *root, |
212 | char const *name, const struct file_operations *fops, int perm) | 204 | char const *name, const struct file_operations *fops, int perm) |
213 | { | 205 | { |
214 | if (!__oprofilefs_create_file(sb, root, name, fops, perm)) | 206 | return __oprofilefs_create_file(sb, root, name, fops, perm, NULL); |
215 | return -EFAULT; | ||
216 | return 0; | ||
217 | } | 207 | } |
218 | 208 | ||
219 | 209 | ||
@@ -269,17 +259,17 @@ static int oprofilefs_fill_super(struct super_block *sb, void *data, int silent) | |||
269 | } | 259 | } |
270 | 260 | ||
271 | 261 | ||
272 | static int oprofilefs_get_sb(struct file_system_type *fs_type, | 262 | static struct dentry *oprofilefs_mount(struct file_system_type *fs_type, |
273 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) | 263 | int flags, const char *dev_name, void *data) |
274 | { | 264 | { |
275 | return get_sb_single(fs_type, flags, data, oprofilefs_fill_super, mnt); | 265 | return mount_single(fs_type, flags, data, oprofilefs_fill_super); |
276 | } | 266 | } |
277 | 267 | ||
278 | 268 | ||
279 | static struct file_system_type oprofilefs_type = { | 269 | static struct file_system_type oprofilefs_type = { |
280 | .owner = THIS_MODULE, | 270 | .owner = THIS_MODULE, |
281 | .name = "oprofilefs", | 271 | .name = "oprofilefs", |
282 | .get_sb = oprofilefs_get_sb, | 272 | .mount = oprofilefs_mount, |
283 | .kill_sb = kill_litter_super, | 273 | .kill_sb = kill_litter_super, |
284 | }; | 274 | }; |
285 | 275 | ||