diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-12-28 17:38:48 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-12-28 17:38:48 -0800 |
commit | 22d83c14f4d916e65ffee040468a7f944fdd30d7 (patch) | |
tree | 0396b906e78c6f21a55b20b932df95b36caa148f /core/include/fs.h | |
parent | 078bd1b56a512c1dac52020d23382c1bdb37056d (diff) | |
parent | b5839067e5fa11af7e76a6f6f87ef914ba9913d1 (diff) | |
download | syslinux-22d83c14f4d916e65ffee040468a7f944fdd30d7.tar.gz |
Merge commit 'liu/master' into fsc
Resolved Conflicts:
core/fs.c
core/fs/ext2/ext2.c
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'core/include/fs.h')
-rw-r--r-- | core/include/fs.h | 89 |
1 files changed, 79 insertions, 10 deletions
diff --git a/core/include/fs.h b/core/include/fs.h index df103023..f0fe5347 100644 --- a/core/include/fs.h +++ b/core/include/fs.h @@ -5,6 +5,7 @@ #include <stdbool.h> #include <string.h> #include <com32.h> +#include <stdio.h> #include "core.h" #include "disk.h" @@ -20,22 +21,30 @@ #define FILENAME_MAX_LG2 8 #define FILENAME_MAX (1 << FILENAME_MAX_LG2) +#define BLOCK_SIZE(fs) (1 << fs->block_shift) +#define SECTOR_SIZE(fs) (1 << fs->sector_shift) + struct fs_info { const struct fs_ops *fs_ops; struct device *fs_dev; + void *fs_info; /* The fs-specific information */ + int sector_shift; + int block_shift; }; -struct open_file_t; /* Filesystem private structure */ -struct dirent; /* Directory entry structure */ - -struct file { - struct open_file_t *open_file; /* Filesystem private data */ - struct fs_info *fs; - uint32_t file_len; -}; +extern struct fs_info *this_fs; +struct dirent; /* Directory entry structure */ +struct file; enum fs_flags { - FS_NODEV = 1, + FS_NODEV = 1 << 0, + FS_USEMEM = 1 << 1, /* If we need a malloc routine, set it */ + + /* + * Update the this_inode pointer at each part of path searching. This + * flag is just used for FAT and ISO fs for now. + */ + FS_THISIND = 1 << 2, }; struct fs_ops { @@ -51,11 +60,56 @@ struct fs_ops { char * (*unmangle_name)(char *, const char *); int (*load_config)(); + struct inode * (*iget_root)(void); + struct inode * (*iget_current)(void); + struct inode * (*iget)(char *, struct inode *); + char * (*follow_symlink)(struct inode *, const char *); + /* the _dir_ stuff */ - void (*opendir)(com32sys_t *); struct dirent * (*readdir)(struct file *); }; +enum inode_mode {I_FILE, I_DIR, I_SYMLINK}; + +/* + * The inode structure, including the detail file information + */ +struct inode { + int mode; /* FILE , DIR or SYMLINK */ + uint32_t size; + uint32_t ino; /* Inode number */ + uint32_t atime; /* Access time */ + uint32_t mtime; /* Modify time */ + uint32_t ctime; /* Create time */ + uint32_t dtime; /* Delete time */ + int blocks; /* How many blocks the file take */ + uint32_t * data; /* The block address array where the file stored */ + uint32_t flags; + uint32_t file_acl; +}; + +extern struct inode *this_inode; + +struct open_file_t; + +struct file { + struct fs_info *fs; + union { + /* For the new universal-path_lookup */ + struct { + struct inode *inode; /* The file-specific information */ + uint32_t offset; /* for next read */ + }; + + /* For the old searhdir method */ + struct { + struct open_file_t *open_file;/* The fs-specific open file struct */ + uint32_t file_len; + }; + }; +}; + + enum dev_type {CHS, EDD}; /* @@ -88,6 +142,21 @@ static inline bool not_whitespace(char c) return (unsigned char)c > ' '; } +static inline void free_inode(struct inode * inode) +{ + if (inode) { + if (inode->data) + free(inode->data); + free(inode); + } +} + +static inline void malloc_error(char *obj) +{ + printf("Out of memory: can't allocate memory for %s\n", obj); + kaboom(); +} + /* * functions */ |