-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmfs_file.c
More file actions
45 lines (36 loc) · 917 Bytes
/
mfs_file.c
File metadata and controls
45 lines (36 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <linux/fs.h>
#include "mfs_file.h"
#include "mfs_client.h"
/**
* -------------------------------------
* File operations handling
* -------------------------------------
*/
static int mfs_file_open(struct inode *inode, struct file *f)
{
f->private_data = inode->i_sb->s_fs_info;
return 0;
}
static ssize_t mfs_file_read(struct file *f, char __user *buf, size_t size,
loff_t *off)
{
size_t l;
struct mfs_client *clt = (struct mfs_client *)f->private_data;
l = mfs_client_read(clt, f, buf, size, *off);
if(l < 0)
goto out;
*off += l;
out:
return l;
}
static ssize_t mfs_file_write(struct file *f, const char __user *buf,
size_t size, loff_t *off)
{
struct mfs_client *clt = (struct mfs_client *)f->private_data;
return mfs_client_write(clt, f, buf, size);
}
struct file_operations const mfs_file_ops = {
.open = mfs_file_open,
.read = mfs_file_read,
.write = mfs_file_write,
};