From 211ee30f24c0abf5fcd5df17451b738e32c2c2c5 Mon Sep 17 00:00:00 2001 From: Jeff Bailey Date: Mon, 28 Jul 2003 01:48:26 +0000 Subject: 2003-07-14 Marco Gerards * 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. --- fatfs/pager.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'fatfs/pager.c') 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; } -- cgit v1.2.3