nckernel  0.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vfs.h
Go to the documentation of this file.
1 
19 struct nctx {
21  void *priv;
22 };
23 
25 enum ntype {
30 };
31 
32 struct ninfo;
33 
37 struct entry {
38  struct object object;
39  int mode;
40  struct ninfo *ninfo;
41  struct nctx nctx;
42 };
43 
45 #define MAJOR(id) ((id) >> 8)
46 
48 #define MINOR(id) ((id) & 0xFF)
49 
53 struct ninfo_dev {
55 };
56 
60 struct ninfo_ops {
61  int (*open)(struct ninfo *, struct nctx *);
62  int (*close)(struct ninfo *, struct nctx *);
63  int (*read)(struct ninfo *, struct nctx *, void *, size_t);
64  int (*write)(struct ninfo *, struct nctx *, const void *, size_t);
65  off_t (*lseek)(struct ninfo *, struct nctx *, off_t, int);
66  int (*ioctl)(struct ninfo *, struct nctx *, int, va_list);
67 };
68 
70 struct ninfo {
71  char *name;
72  enum ntype type;
73  int refcnt;
74  int deleted;
76 
77  struct sinfo *si;
78  void *priv;
80  unsigned long size;
83  struct list_head sibling;
85  struct list_head child;
86  struct list_head sinfo;
88  struct ninfo_ops nops;
89 };
90 
91 #define ROOT_NINFO 0
92 
93 struct sinfo {
94  struct list_head head;
95  void *priv;
96  int refcnt;
97 
98  struct ninfo *(*get_ninfo)(struct sinfo *this, unsigned long id);
99  int (*fill_ninfo)(struct sinfo *this, struct ninfo *parent,
100  struct ninfo *ninfo, void *info);
101  int (*del_ninfo)(struct sinfo *this, struct ninfo *ninfo);
102  void (*refresh_children)(struct sinfo *this, struct ninfo *ninfo);
103 };
104 
105 static inline void vfs_ninfo_ref(struct ninfo *node)
106 {
107  node->refcnt++;
108 }
109 
110 static inline void vfs_ninfo_unref(struct ninfo *node)
111 {
112  node->refcnt--;
113 }
114 
115 static inline void vfs_sinfo_ref(struct sinfo *sinfo)
116 {
117  sinfo->refcnt++;
118 }
119 
120 static inline void vfs_sinfo_unref(struct sinfo *sinfo)
121 {
122  sinfo->refcnt--;
123 }
124 
130 extern struct ninfo *vfs_get_ninfo_child(struct ninfo *node);
131 
137 extern struct ninfo *vfs_get_ninfo_parent(struct ninfo *node);
138 
145 extern struct ninfo *vfs_get_ninfo_next_sibling(struct ninfo *node);
146 
153 extern struct ninfo *vfs_get_ninfo_prev_sibling(struct ninfo *node);
154 
160 extern struct sinfo *vfs_get_last_sinfo(struct ninfo *node);
161 
166 extern int vfs_init(void);
167 
174 extern int vfs_attach_storage(struct ninfo *node, struct sinfo *sb);
175 
181 extern int vfs_deatch_storage(struct ninfo *node);
182 
190 extern struct ninfo *vfs_get_ninfo(struct sinfo *sinfo, struct ninfo *node,
191  const char *path);
192 
201 extern struct ninfo *vfs_new_ninfo(struct sinfo *si,
202  struct ninfo *parent, const char *name, void *info);
203 
209 extern int vfs_del_ninfo(struct ninfo *ninfo);
210 
211 extern struct ninfo *vfs_new_dev_ninfo(struct sinfo *si, struct ninfo *parent,
212  const char *name, dev_t device, struct ninfo_ops *nops);
213