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) ((fs)->block_size)
25 #define BLOCK_SHIFT(fs) ((fs)->block_shift)
26 #define SECTOR_SIZE(fs) ((fs)->sector_size)
27 #define SECTOR_SHIFT(fs) ((fs)->sector_shift)
30 const struct fs_ops *fs_ops;
31 struct device *fs_dev;
32 void *fs_info; /* The fs-specific information */
33 int sector_shift, sector_size;
34 int block_shift, block_size;
37 extern struct fs_info *this_fs;
39 struct dirent; /* Directory entry structure */
43 FS_USEMEM = 1 << 1, /* If we need a malloc routine, set it */
44 FS_THISIND = 1 << 2, /* Set cwd based on config file location */
48 /* in fact, we use fs_ops structure to find the right fs */
50 enum fs_flags fs_flags;
52 int (*fs_init)(struct fs_info *);
53 void (*searchdir)(char *, struct file *);
54 uint32_t (*getfssec)(struct file *, char *, int, bool *);
55 void (*close_file)(struct file *);
56 void (*mangle_name)(char *, const char *);
57 char * (*unmangle_name)(char *, const char *);
58 int (*load_config)(void);
60 struct inode * (*iget_root)(struct fs_info *);
61 struct inode * (*iget_current)(struct fs_info *);
62 struct inode * (*iget)(char *, struct inode *);
63 char * (*follow_symlink)(struct inode *, const char *);
66 struct dirent * (*readdir)(struct file *);
69 enum inode_mode {I_FILE, I_DIR, I_SYMLINK};
72 * The inode structure, including the detail file information
75 struct fs_info *fs; /* The filesystem this inode is associated with */
76 int mode; /* FILE , DIR or SYMLINK */
78 uint32_t ino; /* Inode number */
79 uint32_t atime; /* Access time */
80 uint32_t mtime; /* Modify time */
81 uint32_t ctime; /* Create time */
82 uint32_t dtime; /* Delete time */
83 int blocks; /* How many blocks the file take */
86 char pvt[0]; /* Private filesystem data */
94 /* For the new universal-path_lookup */
96 struct inode *inode; /* The file-specific information */
97 uint32_t offset; /* for next read */
100 /* For the old searhdir method */
102 struct open_file_t *open_file;/* The fs-specific open file struct */
109 enum dev_type {CHS, EDD};
112 * Generic functions that filesystem drivers may choose to use
114 void generic_mangle_name(char *, const char *);
115 #define generic_unmangle_name stpcpy
118 * Struct device contains:
119 * the pointer points to the disk structure,
125 /* the cache stuff */
128 uint16_t cache_block_size;
129 uint16_t cache_entries;
134 * Our definition of "not whitespace"
136 static inline bool not_whitespace(char c)
138 return (unsigned char)c > ' ';
142 * Inode allocator/deallocator
144 struct inode *alloc_inode(struct fs_info *fs, uint32_t ino, size_t data);
145 static inline void free_inode(struct inode * inode)
150 static inline void malloc_error(char *obj)
152 printf("Out of memory: can't allocate memory for %s\n", obj);
159 void mangle_name(com32sys_t *);
160 void searchdir(com32sys_t *);
161 void _close_file(struct file *);
162 inline uint16_t file_to_handle(struct file *);
163 inline struct file *handle_to_file(uint16_t);