aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiu Aleaxander <Aleaxander@gmail.com>2009-05-18 16:08:46 +0800
committerLiu Aleaxander <Aleaxander@gmail.com>2009-05-18 16:08:46 +0800
commit15bbff8d71dadc14b606a4731e6f2ca283cb8061 (patch)
treeb12a8e6fd19c45e457c2c3ed7261c0f3291b1ef6
parent8cfa4e68e2d62fd86b4603b27c71e3eaf54b6f68 (diff)
downloaddevel-15bbff8d71dadc14b606a4731e6f2ca283cb8061.tar.gz
devel-15bbff8d71dadc14b606a4731e6f2ca283cb8061.tar.xz
devel-15bbff8d71dadc14b606a4731e6f2ca283cb8061.zip
fix some bug and make the progrom more universal
-rw-r--r--extlinux.c15
-rw-r--r--main.c4
2 files changed, 9 insertions, 10 deletions
diff --git a/extlinux.c b/extlinux.c
index ed5e413..d411794 100644
--- a/extlinux.c
+++ b/extlinux.c
@@ -579,12 +579,11 @@ int getfssec(char *buf, struct open_file_t *file, int sectors, int *have_more)
bytes_read = file->file_bytesleft;
close_file(file);
*have_more = 0;
- return bytes_read;
+ } else {
+ file->file_bytesleft -= bytes_read;
+ *have_more = 1;
}
- file->file_bytesleft -= bytes_read;
- *have_more = 1;
-
return bytes_read;
}
@@ -814,7 +813,7 @@ struct open_file_t* searchdir(char * filename, __u32 *file_len)
* @return: return 1 one successful, or 0
*
*/
-struct open_file_t* ext2_open(char *filename)
+struct open_file_t* open_file(char *filename)
{
struct open_file_t *file;
struct getc_file *gc_file;
@@ -843,11 +842,11 @@ struct open_file_t* ext2_open(char *filename)
* read function:
* return the bytes read
*/
-int ext2_read(struct open_file_t *file, char *buf, int size, int *have_more)
+int read_file(struct open_file_t *file, char *buf, int size, int *have_more)
{
- int sector = (size + SECTOR_SIZE - 1) >> SECTOR_SHIFT;
- return getfssec(buf, file, sector, have_more);
+ int sectors = (size + SECTOR_SIZE - 1) >> SECTOR_SHIFT;
+ return getfssec(buf, file, sectors, have_more);
}
diff --git a/main.c b/main.c
index 372c324..e11ceed 100644
--- a/main.c
+++ b/main.c
@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
init_fs();
- file = (struct open_file_t *)ext2_open(filename);
+ file = (struct open_file_t *)open_file(filename);
if ( ! file ) {
printf("open file error: file %s not found ....\n", filename);
close(fd);
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
* going well.
*/
do {
- bytes_read = ext2_read(file, buf, 1024, &have_more);
+ bytes_read = read_file(file, buf, 1024, &have_more);
printf("--------read %d bytes-------\n", bytes_read);
printf("----------------\n");
print_hex(buf, bytes_read);