fs/squashfs: add support for ZSTD decompression
[platform/kernel/u-boot.git] / fs / fs.c
diff --git a/fs/fs.c b/fs/fs.c
index ad4caae..17e4bc3 100644 (file)
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -22,6 +22,7 @@
 #include <div64.h>
 #include <linux/math64.h>
 #include <efi_loader.h>
+#include <squashfs.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -58,6 +59,9 @@ static int fs_ls_generic(const char *dirname)
                if (dent->type == FS_DT_DIR) {
                        printf("            %s/\n", dent->name);
                        ndirs++;
+               } else if (dent->type == FS_DT_LNK) {
+                       printf("    <SYM>   %s\n", dent->name);
+                       nfiles++;
                } else {
                        printf(" %8lld   %s\n", dent->size, dent->name);
                        nfiles++;
@@ -277,6 +281,20 @@ static struct fstype_info fstypes[] = {
                .ln = fs_ln_unsupported,
        },
 #endif
+#if IS_ENABLED(CONFIG_FS_SQUASHFS)
+       {
+               .fstype = FS_TYPE_SQUASHFS,
+               .name = "squashfs",
+               .probe = sqfs_probe,
+               .opendir = sqfs_opendir,
+               .readdir = sqfs_readdir,
+               .ls = fs_ls_generic,
+               .read = sqfs_read,
+               .size = sqfs_size,
+               .close = sqfs_close,
+               .closedir = sqfs_closedir,
+       },
+#endif
        {
                .fstype = FS_TYPE_ANY,
                .name = "unsupported",
@@ -715,15 +733,17 @@ int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
        else
                pos = 0;
 
-#ifdef CONFIG_CMD_BOOTEFI
-       efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "",
-                       (argc > 4) ? argv[4] : "");
-#endif
        time = get_timer(0);
        ret = _fs_read(filename, addr, pos, bytes, 1, &len_read);
        time = get_timer(time);
-       if (ret < 0)
+       if (ret < 0) {
+               printf("Failed to load '%s'\n", filename);
                return 1;
+       }
+
+       if (IS_ENABLED(CONFIG_CMD_BOOTEFI))
+               efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "",
+                               (argc > 4) ? argv[4] : "");
 
        printf("%llu bytes read in %lu ms", len_read, time);
        if (time > 0) {
@@ -903,3 +923,23 @@ int do_ln(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
 
        return 0;
 }
+
+int do_fs_types(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
+{
+       struct fstype_info *drv = fstypes;
+       const int n_ents = ARRAY_SIZE(fstypes);
+       struct fstype_info *entry;
+       int i = 0;
+
+       puts("Supported filesystems");
+       for (entry = drv; entry != drv + n_ents; entry++) {
+               if (entry->fstype != FS_TYPE_ANY) {
+                       printf("%c %s", i ? ',' : ':', entry->name);
+                       i++;
+               }
+       }
+       if (!i)
+               puts(": <none>");
+       puts("\n");
+       return CMD_RET_SUCCESS;
+}