1 |
/* pager.c - Pager for fatfs. |
/* pager.c - Pager for fatfs. |
2 |
Copyright (C) 1997, 1999, 2002 Free Software Foundation, Inc. |
Copyright (C) 1997, 1999, 2002, 2003 Free Software Foundation, Inc. |
3 |
Written by Thomas Bushnell, n/BSG and Marcus Brinkmann. |
Written by Thomas Bushnell, n/BSG and Marcus Brinkmann. |
4 |
|
|
5 |
This file is part of the GNU Hurd. |
This file is part of the GNU Hurd. |
36 |
#define MAY_CACHE 1 |
#define MAY_CACHE 1 |
37 |
#endif |
#endif |
38 |
|
|
39 |
#define STAT_INC(field) /* nop */0 |
#define STAT_INC(field) (void) 0 |
40 |
|
|
41 |
#define MAX_FREE_PAGE_BUFS 32 |
#define MAX_FREE_PAGE_BUFS 32 |
42 |
|
|
178 |
if (!err) |
if (!err) |
179 |
{ |
{ |
180 |
err = store_read (store, |
err = store_read (store, |
181 |
(fat_first_cluster_byte(cluster) + |
FAT_FIRST_CLUSTER_BLOCK(cluster) |
182 |
(page % bytes_per_cluster)) >> store->log2_block_size, |
+ ((page % bytes_per_cluster) |
183 |
|
>> store->log2_block_size), |
184 |
vm_page_size, (void **) buf, &read); |
vm_page_size, (void **) buf, &read); |
185 |
|
|
186 |
if (read != vm_page_size) |
if (read != vm_page_size) |
187 |
err = EIO; |
err = EIO; |
188 |
} |
} |
217 |
{ |
{ |
218 |
if (num_pending_clusters > 0) |
if (num_pending_clusters > 0) |
219 |
{ |
{ |
220 |
size_t dev_block = fat_first_cluster_byte(pending_clusters) >> store->log2_block_size; |
size_t dev_block = FAT_FIRST_CLUSTER_BLOCK(pending_clusters); |
221 |
size_t amount = num_pending_clusters << log2_bytes_per_cluster; |
size_t amount = num_pending_clusters << log2_bytes_per_cluster; |
222 |
/* The buffer we try to read into; on the first read, we pass in a |
/* The buffer we try to read into; on the first read, we pass in a |
223 |
size of zero, so that the read is guaranteed to allocate a new |
size of zero, so that the read is guaranteed to allocate a new |
319 |
if (pc->num > 0) |
if (pc->num > 0) |
320 |
{ |
{ |
321 |
error_t err; |
error_t err; |
322 |
size_t dev_block = fat_first_cluster_byte(pc->cluster) >> store->log2_block_size; |
size_t dev_block = FAT_FIRST_CLUSTER_BLOCK(pc->cluster); |
323 |
|
|
324 |
size_t length = pc->num << log2_bytes_per_cluster, amount; |
size_t length = pc->num << log2_bytes_per_cluster, amount; |
325 |
|
|
326 |
if (pc->offs > 0) |
if (pc->offs > 0) |
480 |
|
|
481 |
if (!err) |
if (!err) |
482 |
{ |
{ |
483 |
err = store_write (store, |
err = store_write (store, FAT_FIRST_CLUSTER_BLOCK(cluster) |
484 |
(fat_first_cluster_byte(cluster) + |
+ ((offset % bytes_per_cluster) |
485 |
(offset % bytes_per_cluster)) >> store->log2_block_size, |
>> store->log2_block_size), |
486 |
(void **) buf, vm_page_size, &write); |
(void **) buf, vm_page_size, &write); |
487 |
if (write != vm_page_size) |
if (write != vm_page_size) |
488 |
err = EIO; |
err = EIO; |
489 |
} |
} |