ubifs: Add generic fs support
authorHans de Goede <hdegoede@redhat.com>
Thu, 17 Sep 2015 22:46:58 +0000 (18:46 -0400)
committerTom Rini <trini@konsulko.com>
Sat, 24 Oct 2015 17:50:32 +0000 (13:50 -0400)
Add generic fs support, so that commands like ls, load and test -e can be
used on ubifs.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
disk/part.c
fs/fs.c
include/fs.h

index 8c65cdb60dda51181c305b8e6db70fae9e29d93b..e57a252d948dfb4fc3f6c69533c44241673afb01 100644 (file)
@@ -10,6 +10,7 @@
 #include <ide.h>
 #include <malloc.h>
 #include <part.h>
+#include <ubifs_uboot.h>
 
 #undef PART_DEBUG
 
@@ -511,6 +512,10 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str,
        int part;
        disk_partition_t tmpinfo;
 
+#if defined CONFIG_SANDBOX && defined CONFIG_CMD_UBIFS
+#error Only one of CONFIG_SANDBOX and CONFIG_CMD_UBIFS may be selected
+#endif
+
 #ifdef CONFIG_SANDBOX
        /*
         * Special-case a pseudo block device "hostfs", to allow access to the
@@ -532,6 +537,28 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str,
        }
 #endif
 
+#ifdef CONFIG_CMD_UBIFS
+       /*
+        * Special-case ubi, ubi goes through a mtd, rathen then through
+        * a regular block device.
+        */
+       if (0 == strcmp(ifname, "ubi")) {
+               if (!ubifs_is_mounted()) {
+                       printf("UBIFS not mounted, use ubifsmount to mount volume first!\n");
+                       return -1;
+               }
+
+               *dev_desc = NULL;
+               memset(info, 0, sizeof(*info));
+               strcpy((char *)info->type, BOOT_PART_TYPE);
+               strcpy((char *)info->name, "UBI");
+#ifdef CONFIG_PARTITION_UUIDS
+               info->uuid[0] = 0;
+#endif
+               return 0;
+       }
+#endif
+
        /* If no dev_part_str, use bootdevice environment variable */
        if (!dev_part_str || !strlen(dev_part_str) ||
            !strcmp(dev_part_str, "-"))
diff --git a/fs/fs.c b/fs/fs.c
index 827b143e85e5538f9a250565ce2a54b0455fdab8..b2d6a532330cb2cc14d77a5490971b6bcebd1d0b 100644 (file)
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -23,6 +23,7 @@
 #include <fat.h>
 #include <fs.h>
 #include <sandboxfs.h>
+#include <ubifs_uboot.h>
 #include <asm/io.h>
 #include <div64.h>
 #include <linux/math64.h>
@@ -156,6 +157,21 @@ static struct fstype_info fstypes[] = {
                .write = fs_write_sandbox,
                .uuid = fs_uuid_unsupported,
        },
+#endif
+#ifdef CONFIG_CMD_UBIFS
+       {
+               .fstype = FS_TYPE_UBIFS,
+               .name = "ubifs",
+               .null_dev_desc_ok = true,
+               .probe = ubifs_set_blk_dev,
+               .close = ubifs_close,
+               .ls = ubifs_ls,
+               .exists = ubifs_exists,
+               .size = ubifs_size,
+               .read = ubifs_read,
+               .write = fs_write_unsupported,
+               .uuid = fs_uuid_unsupported,
+       },
 #endif
        {
                .fstype = FS_TYPE_ANY,
index fd1e4ab1c0f3880e0a4a9fdfd8e2be5df42fd4ca..059a39505d43abb30dcbf66820c60a328e67069f 100644 (file)
@@ -22,6 +22,7 @@
 #define FS_TYPE_FAT    1
 #define FS_TYPE_EXT    2
 #define FS_TYPE_SANDBOX        3
+#define FS_TYPE_UBIFS  4
 
 /*
  * Tell the fs layer which block device an partition to use for future