]> code.delx.au - refind/blobdiff - filesystems/test/lslr.c
Ext4fs support; enable override of initrd in refind_linux.conf
[refind] / filesystems / test / lslr.c
index d3e4e3cdd9727134b98995277d5f6e815c17e622..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
@@ -35,6 +36,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define FSW_DEBUG_LEVEL 3
+
 #include "fsw_posix.h"
 
 
@@ -58,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;
@@ -84,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;
@@ -106,27 +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, "/System/Library/Extensions/udf.kext/", 0);
-    //listdir(vol, "/System/Library/Extensions/AppleACPIPlatform.kext/", 0);
-    //listdir(vol, "/System/Library/Extensions/", 0);
-    catfile(vol, "/System/Library/Extensions/AppleHPET.kext/Contents/Info.plist");
-    //listdir(vol, "/", 0);
+    listdir(vol, "/boot/", 0);
+    catfile(vol, "/boot/vmlinuz-3.5.0-19-generic");
 
     fsw_posix_unmount(vol);