12 * Maximum number of open files. This is *currently* constrained by the
13 * fact that PXE needs to be able to fit all its packet buffers into a
14 * 64K segment; this should be fixed by moving the packet buffers to high
17 #define MAX_OPEN_LG2 5
18 #define MAX_OPEN (1 << MAX_OPEN_LG2)
20 #define FILENAME_MAX_LG2 8
21 #define FILENAME_MAX (1 << FILENAME_MAX_LG2)
23 #define BLOCK_SIZE(fs) (1 << fs->block_shift)
24 #define SECTOR_SIZE(fs) (1 << fs->sector_shift)
27 const struct fs_ops *fs_ops;
28 struct device *fs_dev;
29 void *fs_info; /* The fs-specific information */
34 extern struct fs_info *this_fs;
36 struct dirent; /* Directory entry structure */
40 FS_USEMEM = 1 << 1, /* If we need a malloc routine, set it */
43 * Update the this_inode pointer at each part of path searching. This
44 * flag is just used for FAT and ISO fs for now.
50 /* in fact, we use fs_ops structure to find the right fs */
52 enum fs_flags fs_flags;
54 int (*fs_init)(struct fs_info *);
55 void (*searchdir)(char *, struct file *);
56 uint32_t (*getfssec)(struct file *, char *, int, bool *);
57 void (*close_file)(struct file *);
58 void (*mangle_name)(char *, const char *);
59 char * (*unmangle_name)(char *, const char *);
62 struct inode * (*iget_root)(void);
63 struct inode * (*iget_current)(void);
64 struct inode * (*iget)(char *, struct inode *);
65 char * (*follow_symlink)(struct inode *, const char *);
68 struct dirent * (*readdir)(struct file *);
71 enum inode_mode {I_FILE, I_DIR, I_SYMLINK};
74 * The inode structure, including the detail file information
77 int mode; /* FILE , DIR or SYMLINK */
79 uint32_t ino; /* Inode number */
80 uint32_t atime; /* Access time */
81 uint32_t mtime; /* Modify time */
82 uint32_t ctime; /* Create time */
83 uint32_t dtime; /* Delete time */
84 int blocks; /* How many blocks the file take */
85 uint32_t * data; /* The block address array where the file stored */
90 extern struct inode *this_inode;
97 /* For the new universal-path_lookup */
99 struct inode *inode; /* The file-specific information */
100 uint32_t offset; /* for next read */
103 /* For the old searhdir method */
105 struct open_file_t *open_file;/* The fs-specific open file struct */
112 enum dev_type {CHS, EDD};
115 * Generic functions that filesystem drivers may choose to use
117 void generic_mangle_name(char *, const char *);
118 #define generic_unmangle_name stpcpy
121 * Struct device contains:
122 * the pointer points to the disk structure,
128 /* the cache stuff */
131 uint16_t cache_block_size;
132 uint16_t cache_entries;
137 * Our definition of "not whitespace"
139 static inline bool not_whitespace(char c)
141 return (unsigned char)c > ' ';
144 static inline void free_inode(struct inode * inode)
153 static inline void malloc_error(char *obj)
155 printf("Out of memory: can't allocate memory for %s\n", obj);
161 void mangle_name(com32sys_t *);
162 void searchdir(com32sys_t *);
163 void _close_file(struct file *);
164 inline uint16_t file_to_handle(struct file *);
165 inline struct file *handle_to_file(uint16_t);