refactor: inode hashing and reusing
[lunaix-os.git] / lunaix-os / includes / lunaix / device.h
1 #ifndef __LUNAIX_DEVICE_H
2 #define __LUNAIX_DEVICE_H
3
4 #define DEVICE_NAME_SIZE 32
5
6 #include <lunaix/ds/hstr.h>
7 #include <lunaix/ds/llist.h>
8
9 typedef unsigned int dev_t;
10
11 struct device
12 {
13     struct llist_header dev_list;
14     struct device* parent;
15     struct hstr name;
16     dev_t dev_id;
17     char name_val[DEVICE_NAME_SIZE];
18     void* underlay;
19     void* fs_node;
20     int (*read)(struct device* dev, void* buf, size_t offset, size_t len);
21     int (*write)(struct device* dev, void* buf, size_t offset, size_t len);
22 };
23
24 void
25 device_init();
26
27 struct device*
28 device_addseq(struct device* parent, void* underlay, char* name_fmt, ...);
29
30 struct device*
31 device_addvol(struct device* parent, void* underlay, char* name_fmt, ...);
32
33 void
34 device_remove(struct device* dev);
35
36 #endif /* __LUNAIX_DEVICE_H */