Core: opendir/readdir/closedir stuff added
[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 <string.h>
7 #include <com32.h>
8 #include "core.h"
9 #include "disk.h"
10 #include "dir.h"
11
12 /*
13  * Maximum number of open files.  This is *currently* constrained by the
14  * fact that PXE needs to be able to fit all its packet buffers into a
15  * 64K segment; this should be fixed by moving the packet buffers to high
16  * memory.
17  */
18 #define MAX_OPEN_LG2    5
19 #define MAX_OPEN        (1 << MAX_OPEN_LG2)
20
21 #define FILENAME_MAX_LG2 8
22 #define FILENAME_MAX     (1 << FILENAME_MAX_LG2)
23
24 struct fs_info {
25     const struct fs_ops *fs_ops;
26     struct device *fs_dev;
27 };
28
29 struct open_file_t;             /* Filesystem private structure */
30
31 struct file {
32     struct open_file_t *open_file; /* Filesystem private data */
33     struct fs_info *fs;
34     uint32_t file_len;
35 };
36
37 enum fs_flags {
38     FS_NODEV = 1,
39 };
40
41 struct fs_ops {
42     /* in fact, we use fs_ops structure to find the right fs */
43     const char *fs_name;
44     enum fs_flags fs_flags;
45     
46     int      (*fs_init)(struct fs_info *);
47     void     (*searchdir)(char *, struct file *);
48     uint32_t (*getfssec)(struct file *, char *, int, bool *);
49     void     (*close_file)(struct file *);
50     void     (*mangle_name)(char *, const char *);
51     char *   (*unmangle_name)(char *, const char *);
52     void     (*load_config)(com32sys_t *);
53
54         /* the _dir_ stuff */
55         void     (*readdir)(struct fs_info *, DIR *);
56 };
57
58 enum dev_type {CHS, EDD};
59
60 /*
61  * Generic functions that filesystem drivers may choose to use
62  */
63 void generic_mangle_name(char *, const char *);
64 #define generic_unmangle_name stpcpy
65
66 /*
67  * Struct device contains:
68  *     the pointer points to the disk structure,
69  *     the cache stuff.
70  */
71 struct device {
72     struct disk *disk;
73
74     /* the cache stuff */
75     char* cache_data;
76     void* cache_head;
77     uint16_t cache_block_size;
78     uint16_t cache_entries;
79     uint32_t cache_size;
80 };
81
82 /*
83  * Our definition of "not whitespace"
84  */
85 static inline bool not_whitespace(char c)
86 {
87   return (unsigned char)c > ' ';
88 }
89
90 /* 
91  * functions
92  */
93 void mangle_name(com32sys_t *);
94 void searchdir(com32sys_t *);
95
96
97
98 #endif /* FS_H */