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
18 #define MAX_OPEN_LG2 5
19 #define MAX_OPEN (1 << MAX_OPEN_LG2)
21 #define FILENAME_MAX_LG2 8
22 #define FILENAME_MAX (1 << FILENAME_MAX_LG2)
24 #define BLOCK_SIZE(fs) (1 << fs->block_shift)
25 #define SECTOR_SIZE(fs) (1 << fs->sector_shift)
28 const struct fs_ops *fs_ops;
29 struct device *fs_dev;
30 void *fs_info; /* The fs-specific information */
35 extern struct fs_info *this_fs;
37 struct dirent; /* Directory entry structure */
41 FS_USEMEM = 1 << 1, /* If we need a malloc routine, set it */
44 * Update the this_inode pointer at each part of path searching. This
45 * flag is just used for FAT and ISO fs for now.
51 /* in fact, we use fs_ops structure to find the right fs */
53 enum fs_flags fs_flags;
55 int (*fs_init)(struct fs_info *);
56 void (*searchdir)(char *, struct file *);
57 uint32_t (*getfssec)(struct file *, char *, int, bool *);
58 void (*close_file)(struct file *);
59 void (*mangle_name)(char *, const char *);
60 char * (*unmangle_name)(char *, const char *);
63 struct inode * (*iget_root)(void);
64 struct inode * (*iget_current)(void);
65 struct inode * (*iget)(char *, struct inode *);
66 char * (*follow_symlink)(struct inode *, const char *);
69 struct dirent * (*readdir)(struct file *);
72 enum inode_mode {I_FILE, I_DIR, I_SYMLINK};
75 * The inode structure, including the detail file information
78 int mode; /* FILE , DIR or SYMLINK */
80 uint32_t ino; /* Inode number */
81 uint32_t atime; /* Access time */
82 uint32_t mtime; /* Modify time */
83 uint32_t ctime; /* Create time */
84 uint32_t dtime; /* Delete time */
85 int blocks; /* How many blocks the file take */
86 uint32_t * data; /* The block address array where the file stored */
91 extern struct inode *this_inode;
98 /* For the new universal-path_lookup */
100 struct inode *inode; /* The file-specific information */
101 uint32_t offset; /* for next read */
104 /* For the old searhdir method */
106 struct open_file_t *open_file;/* The fs-specific open file struct */
113 enum dev_type {CHS, EDD};
116 * Generic functions that filesystem drivers may choose to use
118 void generic_mangle_name(char *, const char *);
119 #define generic_unmangle_name stpcpy
122 * Struct device contains:
123 * the pointer points to the disk structure,
129 /* the cache stuff */
132 uint16_t cache_block_size;
133 uint16_t cache_entries;
138 * Our definition of "not whitespace"
140 static inline bool not_whitespace(char c)
142 return (unsigned char)c > ' ';
145 static inline void free_inode(struct inode * inode)
154 static inline void malloc_error(char *obj)
156 printf("Out of memory: can't allocate memory for %s\n", obj);
163 void mangle_name(com32sys_t *);
164 void searchdir(com32sys_t *);
165 void _close_file(struct file *);
166 inline uint16_t file_to_handle(struct file *);
167 inline struct file *handle_to_file(uint16_t);