]> code.delx.au - refind/commitdiff
Use stderr for user message output (allows to save readed fils using
authorStefan Agner <stefan@agner.ch>
Sat, 15 Dec 2012 14:12:43 +0000 (15:12 +0100)
committerStefan Agner <stefan@agner.ch>
Sat, 15 Dec 2012 14:12:43 +0000 (15:12 +0100)
redirect in order to check integrity), fixed lsroot and Makefile

filesystems/test/Makefile
filesystems/test/fsw_posix_base.h
filesystems/test/lslr.c
filesystems/test/lsroot.c

index 224c363a71e41e00ca3590ee4a4dbeffcc5d4ee0..d1ed07a889a1d93acf1eee585519e9836ab9296c 100644 (file)
@@ -8,7 +8,7 @@ FSW_NAMES       = ../fsw_core ../fsw_lib
 FSW_OBJS       = $(FSW_NAMES:=.o)
 LSLR_OBJS      = $(FSW_OBJS) ../fsw_$(DRIVERNAME).o fsw_posix.o lslr.o
 LSLR_BIN       = lslr
-LSROOT_OBJS    = $(FSW_OBJS) ../fsw_ext2.o fsw_posix.o lsroot.o
+LSROOT_OBJS    = $(FSW_OBJS) ../fsw_ext2.o ../fsw_ext4.o ../fsw_hfs.o ../fsw_iso9660.o ../fsw_reiserfs.o fsw_posix.o lsroot.o
 LSROOT_BIN     = lsroot
 
 
@@ -19,5 +19,8 @@ $(LSLR_BIN):  $(LSLR_OBJS)
 $(LSROOT_BIN): $(LSROOT_OBJS) 
                $(CC) $(CFLAGS) -o $(LSROOT_BIN) $(LSROOT_OBJS) $(LDFLAGS)
 
-all:           $(LSLR_BIN)
-               $(LSROOT_BIN)
+all:           $(LSLR_BIN) $(LSROOT_BIN)
+
+clean:         
+               @rm -f *.o ../*.o lslr lsroot
+
index 70c70525d7fade3104bfa0a703f302c902bb7b7c..0b7334b7cf26e80bfc7803e3d92da0143695f0c0 100644 (file)
@@ -76,7 +76,7 @@ typedef uint64_t            fsw_u64;
 // message printing
 
 #define FSW_MSGSTR(s) s
-#define FSW_MSGFUNC printf
+#define FSW_MSGFUNC(str, ...) (fprintf(stderr, str, ##__VA_ARGS__))
 
 // 64-bit hooks
 
index 6b8e3a2fb20c5ff9ded721242b9371a64bb88a30..bca4277d4bf8514853adb0c4b1171152209d7fe0 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 /*-
+ * Copyright (c) 2012 Stefan Agner
  * Copyright (c) 2006 Christoph Pfisterer
  *
  * Redistribution and use in source and binary forms, with or without
@@ -60,19 +61,20 @@ static int listdir(struct fsw_posix_volume *vol, char *path, int level)
 
     dir = fsw_posix_opendir(vol, path);
     if (dir == NULL) {
-        printf("opendir(%s) call failed.\n", path);
+        fprintf(stderr, "opendir(%s) call failed.\n", path);
         return 1;
     }
     while ((dent = fsw_posix_readdir(dir)) != NULL) {
         for (i = 0; i < level*2; i++)
-            fputc(' ', stdout);
-        printf("%d  %s\n", dent->d_type, dent->d_name);
+            fputc(' ', stderr);
+        fprintf(stderr, "%d  %s\n", dent->d_type, dent->d_name);
 
         if (dent->d_type == DT_DIR) {
             snprintf(subpath, 4095, "%s%s/", path, dent->d_name);
             listdir(vol, subpath, level + 1);
         }
     }
+
     fsw_posix_closedir(dir);
 
     return 0;
@@ -86,9 +88,10 @@ static int catfile(struct fsw_posix_volume *vol, char *path)
 
     file = fsw_posix_open(vol, path, 0, 0);
     if (file == NULL) {
-        printf("open(%s) call failed.\n", path);
+        fprintf(stderr, "open(%s) call failed.\n", path);
         return 1;
     }
+
     while ((r=fsw_posix_read(file, buf, sizeof(buf))) > 0)
     {
         int i;
@@ -108,24 +111,24 @@ int main(int argc, char **argv)
     int i;
 
     if (argc != 2) {
-        printf("Usage: lslr <file/device>\n");
+        fprintf(stderr, "Usage: lslr <file/device>\n");
         return 1;
     }
 
     for (i = 0; fstypes[i]; i++) {
         vol = fsw_posix_mount(argv[1], fstypes[i]);
         if (vol != NULL) {
-            printf("Mounted as '%s'.\n", fstypes[i]->name.data);
+            fprintf(stderr, "Mounted as '%s'.\n", fstypes[i]->name.data);
             break;
         }
     }
     if (vol == NULL) {
-        printf("Mounting failed.\n");
+        fprintf(stderr, "Mounting failed.\n");
         return 1;
     }
 
-    listdir(vol, "/", 0);
-    catfile(vol, "/gaga/test");
+    listdir(vol, "/boot/", 0);
+    catfile(vol, "/boot/vmlinuz-3.5.0-19-generic");
 
     fsw_posix_unmount(vol);
 
index bb2cba09c2b682a5d5d510957bdd342d0d2bef0d..abbebff2aa0cf527f975c0c66fe7ff116dc6bd28 100644 (file)
 #include "fsw_posix.h"
 
 
-extern struct fsw_fstype_table FSW_FSTYPE_TABLE_NAME(ext2);
 extern struct fsw_fstype_table FSW_FSTYPE_TABLE_NAME(reiserfs);
 extern struct fsw_fstype_table FSW_FSTYPE_TABLE_NAME(iso9660);
 extern struct fsw_fstype_table FSW_FSTYPE_TABLE_NAME(hfs);
+extern struct fsw_fstype_table FSW_FSTYPE_TABLE_NAME(ext2);
+extern struct fsw_fstype_table FSW_FSTYPE_TABLE_NAME(ext4);
 
 int main(int argc, char **argv)
 {
@@ -50,7 +51,7 @@ int main(int argc, char **argv)
     struct dirent *dent;
 
     if (argc != 2) {
-        printf("Usage: lsroot <file/device>\n");
+        fprintf(stderr, "Usage: lsroot <file/device>\n");
         return 1;
     }
 
@@ -58,17 +59,17 @@ int main(int argc, char **argv)
     //vol = fsw_posix_mount(argv[1], &FSW_FSTYPE_TABLE_NAME(reiserfs));
     vol = fsw_posix_mount(argv[1], &FSW_FSTYPE_TABLE_NAME(FSTYPE));
     if (vol == NULL) {
-        printf("Mounting failed.\n");
+        fprintf(stderr, "Mounting failed.\n");
         return 1;
     }
     //dir = fsw_posix_opendir(vol, "/drivers/net/");
     dir = fsw_posix_opendir(vol, "/");
     if (dir == NULL) {
-        printf("opendir call failed.\n");
+        fprintf(stderr, "opendir call failed.\n");
         return 1;
     }
     while ((dent = fsw_posix_readdir(dir)) != NULL) {
-        printf("- %s\n", dent->d_name);
+        fprintf(stderr, "- %s\n", dent->d_name);
     }
     fsw_posix_closedir(dir);
     fsw_posix_unmount(vol);