aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiu Aleaxander <Aleaxander@gmail.com>2009-05-31 10:07:29 +0800
committerLiu Aleaxander <Aleaxander@gmail.com>2009-05-31 10:07:29 +0800
commitb40e3a85f314e5b365bf0534cf896df02611257d (patch)
treea8d44f2713ffa831360f6807225228b91bf696a8
parent7725b222acc764ef02b454728a0ff0194df815c3 (diff)
downloaddevel-b40e3a85f314e5b365bf0534cf896df02611257d.tar.gz
devel-b40e3a85f314e5b365bf0534cf896df02611257d.tar.xz
devel-b40e3a85f314e5b365bf0534cf896df02611257d.zip
make the test out more understandable
it will output a file with name in fs_filename(fs is the second parameter, and filename is the third parameter which is also the file name we want open) format instead of hex dump like before.
-rw-r--r--iso_main.c38
-rw-r--r--isolinux.c2
-rw-r--r--main.c33
3 files changed, 66 insertions, 7 deletions
diff --git a/iso_main.c b/iso_main.c
index efd753b..c5b44f4 100644
--- a/iso_main.c
+++ b/iso_main.c
@@ -16,6 +16,7 @@
*
*/
#include <stdio.h>
+#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
@@ -80,7 +81,10 @@ int main(int argc, char *argv[])
char buf[2048];
struct cache_struct *cs;
struct open_file_t *file = NULL;
-
+
+ int fd2;
+ char save_file[256];
+ char *p = NULL;
if (argc != 3 ) {
usage();
@@ -94,6 +98,28 @@ int main(int argc, char *argv[])
return 0;
}
+
+ strcpy(save_file, "test_out/");
+ if ( p = strchr(fs, '.') )
+ strncat(save_file, fs, p - fs);
+ else
+ strcat(save_file, fs);
+
+ if ( p = strrchr(filename, '/') )
+ p ++;
+ else
+ p = filename;
+
+ strcat(save_file, "_");
+ strcat(save_file, p);
+ fd2 = open(save_file, O_RDWR | O_CREAT, 0644);
+ if ( fd < 0 ) {
+ printf("create file %s error....\n", save_file);
+ return 0;
+ }
+
+
+
init_fs();
file = (struct open_file_t *)open_file(filename);
@@ -108,13 +134,17 @@ int main(int argc, char *argv[])
* going well.
*/
do {
- bytes_read = read_file(file, buf, 2048, &have_more);
+ bytes_read = read_file(file, buf, 1024, &have_more);
+ total_bytes += bytes_read;
+ write(fd2, buf, bytes_read);
+
+#if 0
printf("--------read %d bytes-------\n", bytes_read);
printf("----------------\n");
print_hex(buf, bytes_read);
-
- total_bytes += bytes_read;
+#endif
}while(have_more);
+
printf("-------------total read %d bytes------\n", total_bytes);
diff --git a/isolinux.c b/isolinux.c
index 236168c..7228645 100644
--- a/isolinux.c
+++ b/isolinux.c
@@ -144,7 +144,7 @@ void getlinsec(char *buf, int sector, int sector_cnt)
{
int bytes_read;
-#if 1 /* Debug message */
+#if 0 /* Debug message */
printf("/**************************************************\n");
printf("You are reading stores at sector --0x%x--0x%x\n",
sector, sector + sector_cnt -1);
diff --git a/main.c b/main.c
index 130476d..9705049 100644
--- a/main.c
+++ b/main.c
@@ -7,6 +7,7 @@
*
*/
#include <stdio.h>
+#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
@@ -75,6 +76,9 @@ int main(int argc, char *argv[])
struct cache_struct *cs;
struct open_file_t *file = NULL;
+ int fd2;
+ char save_file[256];
+ char *p;
if (argc != 3 ) {
usage();
@@ -89,6 +93,27 @@ int main(int argc, char *argv[])
return 0;
}
+ strcpy(save_file, "test_out/");
+ if ( p = strchr(fs, '.') )
+ strncat(save_file, fs, p - fs);
+ else
+ strcat(save_file, fs);
+
+ if ( p = strrchr(filename, '/') )
+ p ++;
+ else
+ p = filename;
+
+ strcat(save_file, "_");
+ strcat(save_file, p);
+ fd2 = open(save_file, O_RDWR | O_CREAT, 0644);
+ if ( fd < 0 ) {
+ printf("create file %s error....\n", save_file);
+ return 0;
+ }
+
+
+
block_size = init_fs();
cache_init(block_size);
@@ -106,15 +131,19 @@ int main(int argc, char *argv[])
*/
do {
bytes_read = read_file(file, buf, 1024, &have_more);
+ total_bytes += bytes_read;
+ write(fd2, buf, bytes_read);
+
+#if 0
printf("--------read %d bytes-------\n", bytes_read);
printf("----------------\n");
print_hex(buf, bytes_read);
-
- total_bytes += bytes_read;
+#endif
}while(have_more);
printf("-------------total read %d bytes------\n", total_bytes);
+ close(fd2);
close(fd);
return 0;