chore: fix almost *ALL* warnings.
[lunaix-os.git] / lunaix-os / kernel / fs / defaults.c
1 #include <lunaix/fs.h>
2
3 int
4 default_file_close(struct v_file* file)
5 {
6     return 0;
7 }
8
9 int
10 default_file_seek(struct v_inode* inode, size_t offset)
11 {
12     return 0;
13 }
14
15 int
16 default_inode_open(struct v_inode* this, struct v_file* file)
17 {
18     return 0;
19 }
20
21 int
22 default_file_read(struct v_inode* inode, void* buffer, size_t len, size_t fpos)
23 {
24     return ENOTSUP;
25 }
26
27 int
28 default_file_write(struct v_inode* inode, void* buffer, size_t len, size_t fpos)
29 {
30     return ENOTSUP;
31 }
32
33 int
34 default_file_readdir(struct v_file* file, struct dir_context* dctx)
35 {
36     int i = 0;
37     struct v_dnode *pos, *n;
38     llist_for_each(pos, n, &file->dnode->children, siblings)
39     {
40         if (i < dctx->index) {
41             i++;
42             continue;
43         }
44         dctx->read_complete_callback(dctx, pos->name.value, pos->name.len, 0);
45         break;
46     }
47
48     return i;
49 }
50
51 int
52 default_inode_dirlookup(struct v_inode* this, struct v_dnode* dnode)
53 {
54     return ENOENT;
55 }
56
57 int
58 default_inode_rename(struct v_inode* from_inode,
59                      struct v_dnode* from_dnode,
60                      struct v_dnode* to_dnode)
61 {
62     return 0;
63 }
64
65 int
66 default_inode_sync(struct v_inode* this)
67 {
68     return 0;
69 }
70
71 int
72 default_inode_rmdir(struct v_inode* this, struct v_dnode* dir)
73 {
74     return ENOTSUP;
75 }
76
77 int
78 default_inode_mkdir(struct v_inode* this, struct v_dnode* dir)
79 {
80     return ENOTSUP;
81 }
82
83 struct v_file_ops default_file_ops = { .close = default_file_close,
84                                        .read = default_file_read,
85                                        .seek = default_file_seek,
86                                        .readdir = default_file_readdir };
87
88 struct v_inode_ops default_inode_ops = { .dir_lookup = default_inode_dirlookup,
89                                          .sync = default_inode_sync,
90                                          .open = default_inode_open,
91                                          .rename = default_inode_rename,
92                                          .rmdir = default_inode_rmdir };