diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-02-16 12:22:12 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-02-16 12:22:12 -0800 |
commit | 362daa623200248b789ec6d4703070cb001cc929 (patch) | |
tree | 61b709be540b96bd91eb1e2c343beeda4cce876f | |
parent | 508bcfcf3999e06730338a68f012cbb1023975de (diff) | |
download | syslinux-362daa623200248b789ec6d4703070cb001cc929.tar.gz |
fs: move cache_init() into fs_init, to handle special needs
Move cache_init() into the fs_init methods, to accommodate special
handling, e.g. the all-zero zero block for ext2.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | core/fs/btrfs/btrfs.c | 13 | ||||
-rw-r--r-- | core/fs/ext2/ext2.c | 7 | ||||
-rw-r--r-- | core/fs/fat/fat.c | 6 | ||||
-rw-r--r-- | core/fs/iso9660/iso9660.c | 3 |
4 files changed, 26 insertions, 3 deletions
diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c index 5557c871..4389302f 100644 --- a/core/fs/btrfs/btrfs.c +++ b/core/fs/btrfs/btrfs.c @@ -691,8 +691,15 @@ static void btrfs_get_fs_tree(void) /* init. the fs meta data, return the block size shift bits. */ static int btrfs_fs_init(struct fs_info *_fs) { + struct disk *disk = fs->fs_dev->disk; + btrfs_init_crc32c(); + fs->sector_shift = disk->sector_shift; + fs->sector_size = 1 << fs->sector_shift; + fs->block_shift = BTRFS_BLOCK_SHIFT; + fs->block_size = 1 << fs->block_shift; + fs = _fs; btrfs_read_super_block(); if (strncmp((char *)(&sb.magic), BTRFS_MAGIC, sizeof(sb.magic))) @@ -702,7 +709,11 @@ static int btrfs_fs_init(struct fs_info *_fs) btrfs_get_fs_tree(); btrfs_set_cwd(); cache_ready = 1; - return BTRFS_BLOCK_SHIFT;/* to determine cache size */ + + /* Initialize the block cache */ + cache_init(fs->fs_dev, fs->block_size); + + return fs->block_size; } const struct fs_ops btrfs_fs_ops = { diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c index 020cefee..fcf5cb95 100644 --- a/core/fs/ext2/ext2.c +++ b/core/fs/ext2/ext2.c @@ -358,6 +358,7 @@ static int ext2_fs_init(struct fs_info *fs) struct disk *disk = fs->fs_dev->disk; struct ext2_sb_info *sbi; struct ext2_super_block sb; + struct cache *cs; /* read the super block */ disk->rdwr_sectors(disk, &sb, 2, 2, 0); @@ -395,6 +396,12 @@ static int ext2_fs_init(struct fs_info *fs) sbi->s_first_data_block = sb.s_first_data_block; sbi->s_inode_size = sb.s_inode_size; + /* Initialize the cache, and force block zero to all zero */ + cache_init(fs->fs_dev, fs->block_shift); + cs = _get_cache_block(fs->fs_dev, 0); + memset(cs->data, 0, fs->block_size); + cache_lock_block(cs); + return fs->block_shift; } diff --git a/core/fs/fat/fat.c b/core/fs/fat/fat.c index bea6a89e..ba4ae1a1 100644 --- a/core/fs/fat/fat.c +++ b/core/fs/fat/fat.c @@ -824,8 +824,10 @@ static int vfat_fs_init(struct fs_info *fs) } sbi->clusters = clusters; - /* for SYSLINUX, the cache is based on sector size */ - return fs->sector_shift; + /* Initialize the cache */ + cache_init(fs->fs_dev, fs->block_shift); + + return fs->block_shift; } const struct fs_ops vfat_fs_ops = { diff --git a/core/fs/iso9660/iso9660.c b/core/fs/iso9660/iso9660.c index a7c70a3f..61860419 100644 --- a/core/fs/iso9660/iso9660.c +++ b/core/fs/iso9660/iso9660.c @@ -423,6 +423,9 @@ static int iso_fs_init(struct fs_info *fs) fs->sector_size = 1 << fs->sector_shift; fs->block_size = 1 << fs->block_shift; + /* Initialize the cache */ + cache_init(fs->fs_dev, fs->block_shift); + return fs->block_shift; } |