summaryrefslogtreecommitdiff
path: root/fatfs/fat.c
diff options
context:
space:
mode:
authorJeff Bailey <jbailey@gnu.org>2003-07-28 01:48:26 +0000
committerJeff Bailey <jbailey@gnu.org>2003-07-28 01:48:26 +0000
commit211ee30f24c0abf5fcd5df17451b738e32c2c2c5 (patch)
treee2281b39ab091d290441f038de849494e99a76ea /fatfs/fat.c
parent3099f96171c69d65a1b7add77e9a7356b073d92b (diff)
2003-07-14 Marco Gerards <metgerards@student.han.nl>
* fat.c (fat_read_sblock): Don't test if the root dir size is a multiple of sectors_per_cluster. Reported by Barry deFreese (bddebian@cox.net). * fatfs.h (LOG2_BLOCKS_PER_CLUSTER): New macro. (FAT_FIRST_CLUSTER_BLOCK): Likewise. (fat_first_cluster_byte): Macro removed. * inode.c (read_node): Correctly setup diskfs_root_node for FAT32 filesystems. * pager.c (fat_getcluster): Check for reading beyond allocsize correctly for file systems with a clustersize > vm_page_size. (file_pager_read_small_page): Don't use byte offsets when calculating the block. (file_pager_read_huge_page): Likewise. (pending_clusters_write): Likewise. (file_pager_write_small_page): Likewise. (STAT_INC): Cast to void to suppress warning.
Diffstat (limited to 'fatfs/fat.c')
-rw-r--r--fatfs/fat.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/fatfs/fat.c b/fatfs/fat.c
index 4d3ba3da..4eb4b063 100644
--- a/fatfs/fat.c
+++ b/fatfs/fat.c
@@ -1,5 +1,5 @@
/* fat.c - Support for FAT filesystems.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
This file is part of the GNU Hurd.
@@ -151,8 +151,8 @@ fat_read_sblock (void)
error (1, 0, "Number of total sectors is zero");
if (bytes_per_sector & (store->block_size - 1))
- error (1, 0, "Block size of filesystem is not a multiple of the block size "
- "of the store");
+ error (1, 0, "Block size of filesystem is not
+ " a multiple of the block size of the store");
if (read_word (sblock->reserved_sectors) == 0)
error (1, 0, "Number of reserved sectors is zero");
@@ -164,14 +164,13 @@ fat_read_sblock (void)
if (sectors_per_fat == 0)
error (1, 0, "Number of sectors per fat is zero");
- nr_of_root_dir_sectors = ((read_word (sblock->nr_of_root_dirents) * FAT_DIR_REC_LEN)
- - 1) / bytes_per_sector + 1;
- if (nr_of_root_dir_sectors & (sectors_per_cluster - 1))
- error (1, 0, "Number of root dir sectors is not a multiple of sectors_per_cluster");
+ nr_of_root_dir_sectors = ((read_word (sblock->nr_of_root_dirents) *
+ FAT_DIR_REC_LEN) - 1) / bytes_per_sector + 1;
first_root_dir_byte = (read_word (sblock->reserved_sectors)
+ (sblock->nr_of_fat_tables * sectors_per_fat)) << log2_bytes_per_sector;
- first_data_sector = (first_root_dir_byte >> log2_bytes_per_sector) + nr_of_root_dir_sectors;
+ first_data_sector = (first_root_dir_byte >> log2_bytes_per_sector)
+ + nr_of_root_dir_sectors;
first_data_byte = first_data_sector << log2_bytes_per_sector;
nr_of_clusters = (total_sectors - first_data_sector) / sectors_per_cluster;