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 CURRENTDIR_MAX FILENAME_MAX
26 #define BLOCK_SIZE(fs) ((fs)->block_size)
27 #define BLOCK_SHIFT(fs) ((fs)->block_shift)
28 #define SECTOR_SIZE(fs) ((fs)->sector_size)
29 #define SECTOR_SHIFT(fs) ((fs)->sector_shift)
32 const struct fs_ops *fs_ops;
33 struct device *fs_dev;
34 void *fs_info; /* The fs-specific information */
35 int sector_shift, sector_size;
36 int block_shift, block_size;
37 struct inode *cwd; /* Current directory */
38 char cwd_name[CURRENTDIR_MAX]; /* Current directory by name */
41 extern struct fs_info *this_fs;
43 struct dirent; /* Directory entry structure */
47 FS_USEMEM = 1 << 1, /* If we need a malloc routine, set it */
48 FS_THISIND = 1 << 2, /* Set cwd based on config file location */
52 /* in fact, we use fs_ops structure to find the right fs */
54 enum fs_flags fs_flags;
56 int (*fs_init)(struct fs_info *);
57 void (*searchdir)(const char *, struct file *);
58 uint32_t (*getfssec)(struct file *, char *, int, bool *);
59 void (*close_file)(struct file *);
60 void (*mangle_name)(char *, const char *);
61 char * (*unmangle_name)(char *, const char *);
62 size_t (*realpath)(struct fs_info *, char *, const char *, size_t);
63 int (*chdir)(struct fs_info *, const char *);
64 int (*load_config)(void);
66 struct inode * (*iget_root)(struct fs_info *);
67 struct inode * (*iget)(char *, struct inode *);
68 char * (*follow_symlink)(struct inode *, const char *);
71 struct dirent * (*readdir)(struct file *);
74 enum inode_mode {I_FILE, I_DIR, I_SYMLINK};
77 * The inode structure, including the detail file information
80 struct fs_info *fs; /* The filesystem this inode is associated with */
81 int mode; /* FILE , DIR or SYMLINK */
83 uint32_t ino; /* Inode number */
84 uint32_t atime; /* Access time */
85 uint32_t mtime; /* Modify time */
86 uint32_t ctime; /* Create time */
87 uint32_t dtime; /* Delete time */
88 int blocks; /* How many blocks the file take */
91 char pvt[0]; /* Private filesystem data */
100 /* For the new universal-path_lookup */
102 struct inode *inode; /* The file-specific information */
103 uint32_t offset; /* for next read */
106 /* For the old searhdir method */
108 struct open_file_t *open_file;/* The fs-specific open file struct */
114 enum dev_type {CHS, EDD};
117 * Struct device contains:
118 * the pointer points to the disk structure,
124 /* the cache stuff */
127 uint16_t cache_block_size;
128 uint16_t cache_entries;
133 * Our definition of "not whitespace"
135 static inline bool not_whitespace(char c)
137 return (unsigned char)c > ' ';
141 * Inode allocator/deallocator
143 struct inode *alloc_inode(struct fs_info *fs, uint32_t ino, size_t data);
144 static inline void free_inode(struct inode * inode)
149 static inline void malloc_error(char *obj)
151 printf("Out of memory: can't allocate memory for %s\n", obj);
156 * File handle conversion functions
158 extern struct file files[];
159 static inline uint16_t file_to_handle(struct file *file)
161 return file ? (file - files)+1 : 0;
163 static inline struct file *handle_to_file(uint16_t handle)
165 return handle ? &files[handle-1] : NULL;
169 void pm_mangle_name(com32sys_t *);
170 void pm_unmangle_name(com32sys_t *);
171 void pm_searchdir(com32sys_t *);
172 void mangle_name(char *, const char *);
173 char *unmangle_name(char *, const char *);
174 int searchdir(const char *name);
175 void _close_file(struct file *);
178 void pm_realpath(com32sys_t *regs);
179 size_t realpath(char *dst, const char *src, size_t bufsize);
180 int chdir(const char *src);
183 * Generic functions that filesystem drivers may choose to use
187 void generic_mangle_name(char *, const char *);
188 #define generic_unmangle_name stpcpy
191 int generic_load_config(void);