summaryrefslogtreecommitdiff
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
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.
-rw-r--r--fatfs/ChangeLog22
-rw-r--r--fatfs/fat.c15
-rw-r--r--fatfs/fatfs.h10
-rw-r--r--fatfs/inode.c4
-rw-r--r--fatfs/pager.c23
5 files changed, 51 insertions, 23 deletions
diff --git a/fatfs/ChangeLog b/fatfs/ChangeLog
index 180ff9b3..3528d25d 100644
--- a/fatfs/ChangeLog
+++ b/fatfs/ChangeLog
@@ -1,3 +1,25 @@
+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.
+
2003-04-26 Marco Gerards <metgerards@student.han.nl>
* dir.c (diskfs_get_directs): Consider ENTRY when adding
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;
diff --git a/fatfs/fatfs.h b/fatfs/fatfs.h
index f46695ba..a741d875 100644
--- a/fatfs/fatfs.h
+++ b/fatfs/fatfs.h
@@ -1,5 +1,5 @@
/* fatfs.h - Interface for fatfs.
- Copyright (C) 1997, 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1999, 2002, 2003 Free Software Foundation, Inc.
Written by Thomas Bushnell, n/BSG and Marcus Brinkmann.
This file is part of the GNU Hurd.
@@ -95,12 +95,16 @@ extern vm_address_t zerocluster;
extern struct dirrect dr_root_node;
+#define LOG2_BLOCKS_PER_CLUSTER
+ (log2_bytes_per_cluster - store->logs2_block_size)
+
#define round_cluster(offs) \
((((offs) + bytes_per_cluster - 1) \
>> log2_bytes_per_cluster) << log2_bytes_per_cluster)
-#define fat_first_cluster_byte(cluster) \
- (first_data_byte + ((cluster - 2) << log2_bytes_per_cluster))
+#define FAT_FIRST_CLUSTER_BLOCK(cluster) \
+ (((cluster - 2) << LOG2_BLOCKS_PER_CLUSTER) +
+ (first_data_byte >> store->log2_block_size))
void drop_pager_softrefs (struct node *);
void allow_pager_softrefs (struct node *);
diff --git a/fatfs/inode.c b/fatfs/inode.c
index 50f8662b..b341f188 100644
--- a/fatfs/inode.c
+++ b/fatfs/inode.c
@@ -329,8 +329,8 @@ read_node (struct node *np, vm_address_t buf)
st->st_mode = S_IFDIR | 0777;
/* When we read in the node the first time, diskfs_root_node is
zero. */
- if (diskfs_root_node == 0 ||
- (np == diskfs_root_node && (fat_type == FAT12 || fat_type == FAT16)))
+ if ((diskfs_root_node == 0 || np == diskfs_root_node) &&
+ (fat_type = FAT12 || fat_type == FAT16))
{
st->st_size = read_dword (dr->file_size);
np->allocsize = nr_of_root_dir_sectors << log2_bytes_per_sector;
diff --git a/fatfs/pager.c b/fatfs/pager.c
index 606dc4d8..61cf7cf7 100644
--- a/fatfs/pager.c
+++ b/fatfs/pager.c
@@ -1,5 +1,5 @@
/* pager.c - Pager for fatfs.
- Copyright (C) 1997, 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1999, 2002, 2003 Free Software Foundation, Inc.
Written by Thomas Bushnell, n/BSG and Marcus Brinkmann.
This file is part of the GNU Hurd.
@@ -36,7 +36,7 @@ spin_lock_t node_to_page_lock = SPIN_LOCK_INITIALIZER;
#define MAY_CACHE 1
#endif
-#define STAT_INC(field) /* nop */0
+#define STAT_INC(field) (void) 0
#define MAX_FREE_PAGE_BUFS 32
@@ -178,9 +178,11 @@ file_pager_read_small_page (struct node *node, vm_offset_t page,
if (!err)
{
err = store_read (store,
- (fat_first_cluster_byte(cluster) +
- (page % bytes_per_cluster)) >> store->log2_block_size,
+ FAT_FIRST_CLUSTER_BLOCK(cluster)
+ + ((page % bytes_per_cluster)
+ >> store->log2_block_size),
vm_page_size, (void **) buf, &read);
+
if (read != vm_page_size)
err = EIO;
}
@@ -215,7 +217,7 @@ file_pager_read_huge_page (struct node *node, vm_offset_t page,
{
if (num_pending_clusters > 0)
{
- size_t dev_block = fat_first_cluster_byte(pending_clusters) >> store->log2_block_size;
+ size_t dev_block = FAT_FIRST_CLUSTER_BLOCK(pending_clusters);
size_t amount = num_pending_clusters << log2_bytes_per_cluster;
/* The buffer we try to read into; on the first read, we pass in a
size of zero, so that the read is guaranteed to allocate a new
@@ -317,7 +319,8 @@ pending_clusters_write (struct pending_clusters *pc)
if (pc->num > 0)
{
error_t err;
- size_t dev_block = fat_first_cluster_byte(pc->cluster) >> store->log2_block_size;
+ size_t dev_block = FAT_FIRST_CLUSTER_BLOCK(pc->cluster);
+
size_t length = pc->num << log2_bytes_per_cluster, amount;
if (pc->offs > 0)
@@ -477,10 +480,10 @@ file_pager_write_small_page (struct node *node, vm_offset_t offset, void *buf)
if (!err)
{
- err = store_write (store,
- (fat_first_cluster_byte(cluster) +
- (offset % bytes_per_cluster)) >> store->log2_block_size,
- (void **) buf, vm_page_size, &write);
+ err = store_write (store, FAT_FIRST_CLUSTER_BLOCK(cluster)
+ + ((offset % bytes_per_cluster)
+ >> store->log2_block_size),
+ (void **) buf, vm_page_size, &write);
if (write != vm_page_size)
err = EIO;
}