Hello, OKUJI!
> > Well, I've rewritten it.
>
> Thank you very much! You are a very nice guy. :)
You have renamed debug_fs_func to disk_read_func
I think it's not necessary to have two function for the same purpose.
What is needed is a function (disk_read_hook) and a variable (I've named
it disk_read_file) indicating that the sectors being read belong to the
file in question, not to other filesystem objects.
The patch is attached.
ChangeLog:
* stage2/disk_io.c, stage2/shared.h: rename disk_read_func to
debug_read_file
Use it as as a flag that disk_read_hook should be called.
* stage2/fsys_ext2fs.c: set debug_read_file to 1 when reading
files.
* stage2/fsys_ffs.c: Likewise
* stage2/fsys_minix.c: Likewise
* docs/grub.texi: document it
You may want to rename disk_read_file to something more meaningful, e.g.
file_access_flag
By the way, it's quite strange that fsys_fat.c doesn't set this flag.
Pavel Roskin
Index: docs/grub.texi
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/docs/grub.texi,v
retrieving revision 1.29
diff -u -r1.29 grub.texi
--- grub.texi 1999/09/23 01:02:24 1.29
+++ grub.texi 1999/09/23 06:41:26
@@ -2859,11 +2859,11 @@
@item filemax
Should be the length of the file.
-@item disk_read_func
-Should be set to the value of @samp{disk_read_hook} @emph{only} during
+@item disk_read_file
+Should be set to a @code{1} value @emph{only} during
reading of data for the file, not any other fs data, inodes, FAT tables,
-whatever, then set to @code{NULL} at all other times (it will be
-@code{NULL} by default). If this isn't done corrently, then the
+whatever, then set to @code{0} at all other times (it will be
+@code{0} by default). If this isn't done corrently, then the
@command{testload} and @command{install} commands won't work
correctly.
@end vtable
Index: stage2/disk_io.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/disk_io.c,v
retrieving revision 1.13
diff -u -r1.13 disk_io.c
--- disk_io.c 1999/09/23 01:02:27 1.13
+++ disk_io.c 1999/09/23 06:41:27
@@ -25,9 +25,10 @@
#include "filesys.h"
#ifndef STAGE1_5
-/* instrumentation variables */
+/* function called for every sector of the file read by grub_read */
void (*disk_read_hook) (int) = NULL;
-void (*disk_read_func) (int) = NULL;
+/* set this to 1 when the sectors being read belong to the file */
+int disk_read_file = 0;
int print_possibilities;
@@ -176,13 +177,13 @@
/*
* Instrumentation to tell which sectors were read and used.
*/
- if (disk_read_hook && disk_read_func)
+ if (disk_read_hook && disk_read_file)
{
int sector_end = sector + ((num_sect < slen) ? num_sect : slen);
int sector_num = sector;
while (sector_num < sector_end)
- (*disk_read_func) (sector_num++);
+ (*disk_read_hook) (sector_num++);
}
#endif /* STAGE1_5 */
@@ -1360,7 +1361,7 @@
size = len;
#ifndef STAGE1_5
- disk_read_func = disk_read_hook;
+ disk_read_file = 1;
#endif /* STAGE1_5 */
/* read current block and put it in the right place in memory */
@@ -1368,7 +1369,7 @@
off, size, buf);
#ifndef STAGE1_5
- disk_read_func = NULL;
+ disk_read_file = 0;
#endif /* STAGE1_5 */
len -= size;
Index: stage2/fsys_ext2fs.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/fsys_ext2fs.c,v
retrieving revision 1.4
diff -u -r1.4 fsys_ext2fs.c
--- fsys_ext2fs.c 1999/09/23 01:02:28 1.4
+++ fsys_ext2fs.c 1999/09/23 06:41:28
@@ -431,14 +431,14 @@
size = len;
#ifndef STAGE1_5
- disk_read_func = disk_read_hook;
+ disk_read_file = 1;
#endif /* STAGE1_5 */
devread (map * (EXT2_BLOCK_SIZE (SUPERBLOCK) / DEV_BSIZE),
offset, size, buf);
#ifndef STAGE1_5
- disk_read_func = NULL;
+ disk_read_file = 0;
#endif /* STAGE1_5 */
buf += size;
Index: stage2/fsys_ffs.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/fsys_ffs.c,v
retrieving revision 1.6
diff -u -r1.6 fsys_ffs.c
--- fsys_ffs.c 1999/09/23 01:02:29 1.6
+++ fsys_ffs.c 1999/09/23 06:41:28
@@ -161,13 +161,13 @@
size = len;
#ifndef STAGE1_5
- disk_read_func = disk_read_hook;
+ disk_read_file = 1;
#endif /* STAGE1_5 */
devread (fsbtodb (SUPERBLOCK, map), off, size, buf);
#ifndef STAGE1_5
- disk_read_func = NULL;
+ disk_read_file = 0;
#endif /* STAGE1_5 */
buf += size;
Index: stage2/fsys_minix.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/fsys_minix.c,v
retrieving revision 1.3
diff -u -r1.3 fsys_minix.c
--- fsys_minix.c 1999/09/23 01:02:30 1.3
+++ fsys_minix.c 1999/09/23 06:41:28
@@ -269,14 +269,14 @@
size = len;
#ifndef STAGE1_5
- disk_read_func = disk_read_hook;
+ disk_read_file = 1;
#endif /* STAGE1_5 */
devread (map * (BLOCK_SIZE / DEV_BSIZE),
offset, size, buf);
#ifndef STAGE1_5
- disk_read_func = NULL;
+ disk_read_file = 0;
#endif /* STAGE1_5 */
buf += size;
Index: stage2/shared.h
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/shared.h,v
retrieving revision 1.20
diff -u -r1.20 shared.h
--- shared.h 1999/09/23 01:02:31 1.20
+++ shared.h 1999/09/23 06:41:28
@@ -402,7 +402,7 @@
#ifndef STAGE1_5
/* instrumentation variables */
extern void (*disk_read_hook) (int);
-extern void (*disk_read_func) (int);
+extern int disk_read_file;
/* The flag for debug mode. */
extern int debug;
/* Color settings */