core: VFS cleanups: add a persistent generic struct file
[profile/ivi/syslinux.git] / core / include / fs.h
1 #ifndef FS_H
2 #define FS_H
3
4 #include <stddef.h>
5 #include <stdbool.h>
6 #include <com32.h>
7 #include "core.h"
8 #include "disk.h"
9
10 /*
11  * Maximum number of open files.  This is *currently* constrained by the
12  * fact that PXE needs to be able to fit all its packet buffers into a
13  * 64K segment; this should be fixed by moving the packet buffers to high
14  * memory.
15  */
16 #define MAX_OPEN_LG2    5
17 #define MAX_OPEN        (1 << MAX_OPEN_LG2)
18
19 struct fs_info {
20     const struct fs_ops *fs_ops;
21     struct device *fs_dev;
22 };
23
24 struct open_file_t;             /* Filesystem private structure */
25
26 struct file {
27     struct open_file_t *open_file; /* Filesystem private data */
28     struct fs_info *fs;
29     uint32_t file_len;
30 };
31
32 enum fs_flags {
33     FS_NODEV = 1,
34 };
35
36 struct fs_ops {
37     /* in fact, we use fs_ops structure to find the right fs */
38     const char *fs_name;
39     enum fs_flags fs_flags;
40     
41     int      (*fs_init)(struct fs_info *);
42     void     (*searchdir)(char *, struct file *);
43     uint32_t (*getfssec)(struct file *, char *, int, bool *);
44     void     (*close_file)(struct file *);
45     void     (*mangle_name)(char *, char *);
46     int      (*unmangle_name)(char *, char *);
47     void     (*load_config)(com32sys_t *);
48 };
49
50 enum dev_type {CHS, EDD};
51     
52 /*
53  * Struct device contains:
54  *     the pointer points to the disk structure,
55  *     the cache stuff.
56  */
57 struct device {
58     struct disk *disk;
59
60     /* the cache stuff */
61     char* cache_data;
62     void* cache_head;
63     uint16_t cache_block_size;
64     uint16_t cache_entries;
65     uint32_t cache_size;
66 };
67
68 #endif /* FS_H */