common: Drop log.h from common header
[oweals/u-boot.git] / fs / fs.c
diff --git a/fs/fs.c b/fs/fs.c
index 48d8f1f6dab88ada6d4debf1cd51d299300c783d..ad4caaeb1ec9c1f7f502df20d0dce92df6471b1a 100644 (file)
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -3,9 +3,13 @@
  * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
  */
 
+#include <command.h>
 #include <config.h>
 #include <errno.h>
 #include <common.h>
+#include <env.h>
+#include <lmb.h>
+#include <log.h>
 #include <mapmem.h>
 #include <part.h>
 #include <ext4fs.h>
@@ -23,11 +27,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static struct blk_desc *fs_dev_desc;
 static int fs_dev_part;
-static disk_partition_t fs_partition;
+static struct disk_partition fs_partition;
 static int fs_type = FS_TYPE_ANY;
 
 static inline int fs_probe_unsupported(struct blk_desc *fs_dev_desc,
-                                     disk_partition_t *fs_partition)
+                                     struct disk_partition *fs_partition)
 {
        printf("** Unrecognized filesystem type **\n");
        return -1;
@@ -134,7 +138,7 @@ struct fstype_info {
         */
        bool null_dev_desc_ok;
        int (*probe)(struct blk_desc *fs_dev_desc,
-                    disk_partition_t *fs_partition);
+                    struct disk_partition *fs_partition);
        int (*ls)(const char *dirname);
        int (*exists)(const char *filename);
        int (*size)(const char *filename, loff_t *size);
@@ -306,6 +310,19 @@ static struct fstype_info *fs_get_info(int fstype)
        return info;
 }
 
+/**
+ * fs_get_type() - Get type of current filesystem
+ *
+ * Return: filesystem type
+ *
+ * Returns filesystem type representing the current filesystem, or
+ * FS_TYPE_ANY for any unrecognised filesystem.
+ */
+int fs_get_type(void)
+{
+       return fs_type;
+}
+
 /**
  * fs_get_type_name() - Get type of current filesystem
  *
@@ -388,7 +405,7 @@ int fs_set_blk_dev_with_part(struct blk_desc *desc, int part)
        return -1;
 }
 
-static void fs_close(void)
+void fs_close(void)
 {
        struct fstype_info *info = fs_get_info(fs_type);
 
@@ -412,7 +429,6 @@ int fs_ls(const char *dirname)
 
        ret = info->ls(dirname);
 
-       fs_type = FS_TYPE_ANY;
        fs_close();
 
        return ret;
@@ -596,7 +612,6 @@ int fs_unlink(const char *filename)
 
        ret = info->unlink(filename);
 
-       fs_type = FS_TYPE_ANY;
        fs_close();
 
        return ret;
@@ -610,7 +625,6 @@ int fs_mkdir(const char *dirname)
 
        ret = info->mkdir(dirname);
 
-       fs_type = FS_TYPE_ANY;
        fs_close();
 
        return ret;
@@ -632,8 +646,8 @@ int fs_ln(const char *fname, const char *target)
        return ret;
 }
 
-int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
-               int fstype)
+int do_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
+           int fstype)
 {
        loff_t size;
 
@@ -651,8 +665,8 @@ int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
        return 0;
 }
 
-int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
-               int fstype)
+int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
+           int fstype)
 {
        unsigned long addr;
        const char *addr_str;
@@ -725,8 +739,8 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
        return 0;
 }
 
-int do_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
-       int fstype)
+int do_ls(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
+         int fstype)
 {
        if (argc < 2)
                return CMD_RET_USAGE;
@@ -751,8 +765,8 @@ int file_exists(const char *dev_type, const char *dev_part, const char *file,
        return fs_exists(file);
 }
 
-int do_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
-               int fstype)
+int do_save(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
+           int fstype)
 {
        unsigned long addr;
        const char *filename;
@@ -793,8 +807,8 @@ int do_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
        return 0;
 }
 
-int do_fs_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
-               int fstype)
+int do_fs_uuid(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
+              int fstype)
 {
        int ret;
        char uuid[37];
@@ -818,7 +832,7 @@ int do_fs_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
        return CMD_RET_SUCCESS;
 }
 
-int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_fs_type(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
        struct fstype_info *info;
 
@@ -840,7 +854,7 @@ int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return CMD_RET_SUCCESS;
 }
 
-int do_rm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
+int do_rm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
          int fstype)
 {
        if (argc != 4)
@@ -855,7 +869,7 @@ int do_rm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
        return 0;
 }
 
-int do_mkdir(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
+int do_mkdir(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
             int fstype)
 {
        int ret;
@@ -875,7 +889,7 @@ int do_mkdir(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
        return 0;
 }
 
-int do_ln(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
+int do_ln(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
          int fstype)
 {
        if (argc != 5)