summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'driver/gator_fs.c')
-rw-r--r--driver/gator_fs.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/driver/gator_fs.c b/driver/gator_fs.c
index 81b0d5b..9ff118b 100644
--- a/driver/gator_fs.c
+++ b/driver/gator_fs.c
@@ -35,8 +35,8 @@ static struct inode *gatorfs_get_inode(struct super_block *sb, int mode)
35} 35}
36 36
37static const struct super_operations s_ops = { 37static const struct super_operations s_ops = {
38 .statfs = simple_statfs, 38 .statfs = simple_statfs,
39 .drop_inode = generic_delete_inode, 39 .drop_inode = generic_delete_inode,
40}; 40};
41 41
42ssize_t gatorfs_str_to_user(char const *str, char __user *buf, size_t count, loff_t *offset) 42ssize_t gatorfs_str_to_user(char const *str, char __user *buf, size_t count, loff_t *offset)
@@ -104,19 +104,21 @@ static int default_open(struct inode *inode, struct file *filp)
104} 104}
105 105
106static const struct file_operations ulong_fops = { 106static const struct file_operations ulong_fops = {
107 .read = ulong_read_file, 107 .read = ulong_read_file,
108 .write = ulong_write_file, 108 .write = ulong_write_file,
109 .open = default_open, 109 .open = default_open,
110}; 110};
111 111
112static const struct file_operations ulong_ro_fops = { 112static const struct file_operations ulong_ro_fops = {
113 .read = ulong_read_file, 113 .read = ulong_read_file,
114 .open = default_open, 114 .open = default_open,
115}; 115};
116 116
117static struct dentry *__gatorfs_create_file(struct super_block *sb, 117static struct dentry *__gatorfs_create_file(struct super_block *sb,
118 struct dentry *root, char const *name, const struct file_operations *fops, 118 struct dentry *root,
119 int perm) 119 char const *name,
120 const struct file_operations *fops,
121 int perm)
120{ 122{
121 struct dentry *dentry; 123 struct dentry *dentry;
122 struct inode *inode; 124 struct inode *inode;
@@ -135,10 +137,10 @@ static struct dentry *__gatorfs_create_file(struct super_block *sb,
135} 137}
136 138
137int gatorfs_create_ulong(struct super_block *sb, struct dentry *root, 139int gatorfs_create_ulong(struct super_block *sb, struct dentry *root,
138 char const *name, unsigned long *val) 140 char const *name, unsigned long *val)
139{ 141{
140 struct dentry *d = __gatorfs_create_file(sb, root, name, 142 struct dentry *d = __gatorfs_create_file(sb, root, name,
141 &ulong_fops, 0644); 143 &ulong_fops, 0644);
142 if (!d) 144 if (!d)
143 return -EFAULT; 145 return -EFAULT;
144 146
@@ -147,10 +149,10 @@ int gatorfs_create_ulong(struct super_block *sb, struct dentry *root,
147} 149}
148 150
149int gatorfs_create_ro_ulong(struct super_block *sb, struct dentry *root, 151int gatorfs_create_ro_ulong(struct super_block *sb, struct dentry *root,
150 char const *name, unsigned long *val) 152 char const *name, unsigned long *val)
151{ 153{
152 struct dentry *d = __gatorfs_create_file(sb, root, name, 154 struct dentry *d = __gatorfs_create_file(sb, root, name,
153 &ulong_ro_fops, 0444); 155 &ulong_ro_fops, 0444);
154 if (!d) 156 if (!d)
155 return -EFAULT; 157 return -EFAULT;
156 158
@@ -165,15 +167,15 @@ static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t coun
165} 167}
166 168
167static const struct file_operations atomic_ro_fops = { 169static const struct file_operations atomic_ro_fops = {
168 .read = atomic_read_file, 170 .read = atomic_read_file,
169 .open = default_open, 171 .open = default_open,
170}; 172};
171 173
172int gatorfs_create_ro_atomic(struct super_block *sb, struct dentry *root, 174int gatorfs_create_ro_atomic(struct super_block *sb, struct dentry *root,
173 char const *name, atomic_t *val) 175 char const *name, atomic_t *val)
174{ 176{
175 struct dentry *d = __gatorfs_create_file(sb, root, name, 177 struct dentry *d = __gatorfs_create_file(sb, root, name,
176 &atomic_ro_fops, 0444); 178 &atomic_ro_fops, 0444);
177 if (!d) 179 if (!d)
178 return -EFAULT; 180 return -EFAULT;
179 181
@@ -182,7 +184,7 @@ int gatorfs_create_ro_atomic(struct super_block *sb, struct dentry *root,
182} 184}
183 185
184int gatorfs_create_file(struct super_block *sb, struct dentry *root, 186int gatorfs_create_file(struct super_block *sb, struct dentry *root,
185 char const *name, const struct file_operations *fops) 187 char const *name, const struct file_operations *fops)
186{ 188{
187 if (!__gatorfs_create_file(sb, root, name, fops, 0644)) 189 if (!__gatorfs_create_file(sb, root, name, fops, 0644))
188 return -EFAULT; 190 return -EFAULT;
@@ -190,7 +192,8 @@ int gatorfs_create_file(struct super_block *sb, struct dentry *root,
190} 192}
191 193
192int gatorfs_create_file_perm(struct super_block *sb, struct dentry *root, 194int gatorfs_create_file_perm(struct super_block *sb, struct dentry *root,
193 char const *name, const struct file_operations *fops, int perm) 195 char const *name,
196 const struct file_operations *fops, int perm)
194{ 197{
195 if (!__gatorfs_create_file(sb, root, name, fops, perm)) 198 if (!__gatorfs_create_file(sb, root, name, fops, perm))
196 return -EFAULT; 199 return -EFAULT;
@@ -198,7 +201,7 @@ int gatorfs_create_file_perm(struct super_block *sb, struct dentry *root,
198} 201}
199 202
200struct dentry *gatorfs_mkdir(struct super_block *sb, 203struct dentry *gatorfs_mkdir(struct super_block *sb,
201 struct dentry *root, char const *name) 204 struct dentry *root, char const *name)
202{ 205{
203 struct dentry *dentry; 206 struct dentry *dentry;
204 struct inode *inode; 207 struct inode *inode;
@@ -256,28 +259,29 @@ static int gatorfs_fill_super(struct super_block *sb, void *data, int silent)
256 259
257#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) 260#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
258static int gatorfs_get_sb(struct file_system_type *fs_type, 261static int gatorfs_get_sb(struct file_system_type *fs_type,
259 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 262 int flags, const char *dev_name, void *data,
263 struct vfsmount *mnt)
260{ 264{
261 return get_sb_single(fs_type, flags, data, gatorfs_fill_super, mnt); 265 return get_sb_single(fs_type, flags, data, gatorfs_fill_super, mnt);
262} 266}
263#else 267#else
264static struct dentry *gatorfs_mount(struct file_system_type *fs_type, 268static struct dentry *gatorfs_mount(struct file_system_type *fs_type,
265 int flags, const char *dev_name, void *data) 269 int flags, const char *dev_name, void *data)
266{ 270{
267 return mount_nodev(fs_type, flags, data, gatorfs_fill_super); 271 return mount_nodev(fs_type, flags, data, gatorfs_fill_super);
268} 272}
269#endif 273#endif
270 274
271static struct file_system_type gatorfs_type = { 275static struct file_system_type gatorfs_type = {
272 .owner = THIS_MODULE, 276 .owner = THIS_MODULE,
273 .name = "gatorfs", 277 .name = "gatorfs",
274#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) 278#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
275 .get_sb = gatorfs_get_sb, 279 .get_sb = gatorfs_get_sb,
276#else 280#else
277 .mount = gatorfs_mount, 281 .mount = gatorfs_mount,
278#endif 282#endif
279 283
280 .kill_sb = kill_litter_super, 284 .kill_sb = kill_litter_super,
281}; 285};
282 286
283int __init gatorfs_register(void) 287int __init gatorfs_register(void)